Skip to content

sift_client.resources.data_imports

CLASS DESCRIPTION
DataImportAPIAsync

High-level API for importing data into Sift.

DataImportAPIAsync

DataImportAPIAsync(sift_client: SiftClient)

Bases: ResourceBase

High-level API for importing data into Sift.

Initialize the DataImportAPI.

PARAMETER DESCRIPTION
sift_client

The Sift client to use.

TYPE: SiftClient

METHOD DESCRIPTION
detect_config

Auto-detect import configuration from a file.

get_run

Get the run associated with a data import.

import_from_path

Import data from a local file.

ATTRIBUTE DESCRIPTION
client

TYPE: SiftClient

grpc_client

TYPE: GrpcClient

rest_client

TYPE: RestClient

client property

client: SiftClient

grpc_client property

grpc_client: GrpcClient

rest_client property

rest_client: RestClient

detect_config async

detect_config(
    file_path: str | Path,
    data_type: DataTypeKey | None = None,
) -> ImportConfig

Auto-detect import configuration from a file.

Reads a sample of the file, sends it to the server's DetectConfig endpoint, and returns the detected configuration. The file format is inferred from the file extension when data_type is not provided.

CSV, Parquet, HDF5, and TDMS files are supported for auto-detection.

For CSV files, the server scans the first two rows for an optional JSON metadata row. Row 1 is checked first; row 2 is checked only if row 1 is not valid metadata. A row qualifies as metadata when every cell contains valid JSON that describes either a time column or a data column. When present, first_data_row in the returned config is set to the row after the metadata row.

Each data column cell is a JSON ChannelConfig::

{"name": "speed", "units": "m/s", "dataType": "CHANNEL_DATA_TYPE_DOUBLE"}

The time column cell is a JSON CsvTimeColumn::

{"format": "TIME_FORMAT_ABSOLUTE_RFC3339"}

Enum type definitions and bit field elements can also be specified in the metadata row; they are applied server-side during import but are not included in the returned config.

For file types with multiple layouts (e.g. Parquet), data_type must be specified explicitly.

PARAMETER DESCRIPTION
file_path

Path to the file to analyze.

TYPE: str | Path

data_type

Explicit data type key. Required for formats like Parquet where the extension alone is ambiguous.

TYPE: DataTypeKey | None DEFAULT: None

RETURNS DESCRIPTION
ImportConfig

The detected import config.

RAISES DESCRIPTION
FileNotFoundError

If the file does not exist.

ValueError

If the file extension is unsupported or no supported configuration could be detected.

get_run async

get_run(data_import_id: str) -> Run

Get the run associated with a data import.

The data_import_id is available on the job returned by import_from_path via job.job_details.data_import_id. For a more ergonomic approach, use job.get_import_run() which calls this method internally.

PARAMETER DESCRIPTION
data_import_id

The ID of the data import.

TYPE: str

RETURNS DESCRIPTION
Run

The Run created by or associated with the import.

RAISES DESCRIPTION
ValueError

If the data import has no associated run.

import_from_path async

import_from_path(
    file_path: str | Path,
    *,
    asset: Asset | str | None = None,
    config: ImportConfig | None = None,
    data_type: DataTypeKey | None = None,
    run: Run | str | None = None,
    run_name: str | None = None,
    show_progress: bool | None = None,
) -> Job

Import data from a local file.

Creates a data import on the server, uploads the file, and returns a Job handle after uploading the file. The import processes server-side and typically completes shortly after upload. Use job.wait_until_complete() only if you need to confirm completion before proceeding.

When config is omitted the file format is auto-detected via detect_config (CSV, Parquet, HDF5, and TDMS). When asset is provided it overrides the config value; otherwise the config's asset_name is used. If neither run nor run_name is provided (and none is set on the config), run_name defaults to the filename.

PARAMETER DESCRIPTION
file_path

Path to the local file to import.

TYPE: str | Path

asset

Asset object or asset name to import data into. Optional when config already has asset_name set.

TYPE: Asset | str | None DEFAULT: None

config

Import configuration describing the file format and column mapping. When provided, data_type is ignored. If omitted, the config is auto-detected via detect_config. You can call detect_config yourself to inspect and modify the config before passing it here.

TYPE: ImportConfig | None DEFAULT: None

data_type

Explicit data type key. Required for formats like Parquet where the extension alone is ambiguous. Only used when config is not provided.

TYPE: DataTypeKey | None DEFAULT: None

run

Run object or run ID string to import into an existing run. Mutually exclusive with run_name.

TYPE: Run | str | None DEFAULT: None

run_name

Name for a new run. Defaults to the filename if neither run nor run_name is set.

TYPE: str | None DEFAULT: None

show_progress

If True, display a progress spinner during upload. Defaults to True for sync, False for async.

TYPE: bool | None DEFAULT: None

RETURNS DESCRIPTION
Job

A Job handle for the pending import.

RAISES DESCRIPTION
FileNotFoundError

If the file does not exist.