Type: Package
Title: 'Palantir Foundry' Software Development Kit
Version: 0.13.0
Maintainer: Alexandre Guinaudeau <aguinaudeau@palantir.com>
Description: Interface to 'Palantir Foundry', including reading and writing structured or unstructured datasets, and more https://www.palantir.com/platforms/foundry/.
URL: https://github.com/palantir/palantir-r-sdk
BugReports: https://github.com/palantir/palantir-r-sdk/issues
Encoding: UTF-8
License: Apache License 2.0
RoxygenNote: 7.2.1
Depends: R (≥ 3.5.0)
Imports: arrow (≥ 0.14.0), jsonlite, httr, R6, yaml
Suggests: lintr, httptest, testthat (≥ 3.0.0), withr
Collate: 'config.R' 'api_client.R' 'utils.R' 'schema.R' 'datasets_api_client.R' 'datasets.R'
NeedsCompilation: no
Packaged: 2023-05-11 16:34:08 UTC; aguinaudeau
Author: Alexandre Guinaudeau [aut, cre], Palantir Technologies [aut, cph]
Repository: CRAN
Date/Publication: 2023-05-19 13:30:02 UTC

Download Foundry Files locally.

Description

Download Foundry Files locally.

Usage

datasets.download_files(alias, files)

Arguments

alias

The alias representing the Dataset.

files

The file paths or file properties.

Value

A list mapping Foundry Dataset files to the local file paths where files were downloaded.

Examples

## Not run: 
# Download a single file in a Dataset
downloaded_file <- datasets.download_files("my_alias", c("dir/my_file.csv"))
read.csv(downloaded_file$`dir/my_file.csv`)

# Extract text from all PDF files in a Dataset
pdf_files <- datasets.list_files("my_alias", regex = ".*\\.pdf")
downloaded_files <- datasets.download_files("my_alias", pdf_files)
contents <- lapply(downloaded_files, pdftools::pdf_text)

## End(Not run)


Lists the files stored in a Foundry Dataset.

Description

Lists the files stored in a Foundry Dataset.

Usage

datasets.list_files(alias, regex = ".*")

Arguments

alias

The alias representing the Dataset.

regex

A regex used to filter files by path.

Value

The lists of file properties.

Examples

## Not run: 
# List all PDF files in a Dataset
all_files <- datasets.list_files("my_dataset", regex=".*\\.pdf")

# Get all file names
file_names <- sapply(all_files, function(x) x$path)

## End(Not run)


Reads a tabular Foundry dataset as data.frame or an Apache Arrow Table.

Description

Reads a tabular Foundry dataset as data.frame or an Apache Arrow Table.

Usage

datasets.read_table(
  alias,
  columns = NULL,
  row_limit = NULL,
  format = "data.frame"
)

Arguments

alias

The alias representing the Dataset. The Dataset must be tabular, i.e. have a schema.

columns

The subset of columns to retrieve.

row_limit

The maximum number of rows to retrieve.

format

The output format, can be 'arrow' or 'data.frame'.

Value

A data.table or an Arrow Table

Column types

Note that types may not match exactly the Foundry column types. See https://arrow.apache.org/docs/r/articles/arrow.html for details on type conversions from an arrow Table to a data.frame.

Examples

## Not run: 
# Download a subset of a tabular Dataset
df <- datasets.read_table("my_input", columns = c("columnA", "columnB"), row_limit = 1000)

## End(Not run)


Upload a local file or folder to a Foundry Dataset.

Description

Upload a local file or folder to a Foundry Dataset.

Usage

datasets.upload_files(files, alias)

Arguments

files

The local files and folders to upload. If a folder is provided, all files found recursively in subfolders will be uploaded.

alias

The alias representing the Dataset.

Value

A list mapping local file paths to the corresponding Foundry Dataset file.

Examples

## Not run: 
# Upload RDS files to a Dataset
local_dir <- file.path(tempdir(), "to_upload")
dir.create(local_dir)
saveRDS(iris, file.path(local_dir, "iris.rds"))
saveRDS(Titanic, file.path(local_dir, "Titanic.rds"))

datasets.upload_files(local_dir, "my_output")

## End(Not run)


Writes a data.frame to a Foundry dataset.

Description

Writes a data.frame to a Foundry dataset.

Usage

datasets.write_table(data, alias)

Arguments

data

A data.frame or an arrow Table.

alias

The alias representing the Dataset.

Column types

Note that types may not be exactly preserved and all types are not supported. See https://arrow.apache.org/docs/r/articles/arrow.html for details on type conversions from a data.frame to an arrow Table. Use arrow::Table$create to use more granular types.

Row Names

Row names are silently removed.

Examples

## Not run: 
datasets.write_table(mtcars, "my_output")

## End(Not run)


Loads a config from an environment variable with format 'FOUNDRY_CONFIG_KEY' or from an option with format 'foundry.config.key'.

Description

Loads a config from an environment variable with format 'FOUNDRY_CONFIG_KEY' or from an option with format 'foundry.config.key'.

Usage

get_config(name, default = NULL)

mirror server hosted at Truenetwork, Russian Federation.