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
import_from_path

Import data from a local file.

get

Get a data import by ID.

list_

List data imports with optional filtering.

find

Find a single data import matching the given query. Takes the same arguments as

get_run

Get the run associated with a data import.

detect_config

Auto-detect import configuration from a 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

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,
    time_format: TimeFormat | 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, TDMS, and ULog). 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 (for ULog the detected channel list is dropped so every channel in the file is imported). 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 with multiple supported layouts (Parquet, HDF5) where the file extension alone is ambiguous. Only used when config is not provided.

TYPE: DataTypeKey | None DEFAULT: None

time_format

Time format override for CSV, Parquet, HDF5, and TDMS. Ignored for ULog. When omitted, CSV, Parquet, and HDF5 use the detected format if available, otherwise TimeFormat.ABSOLUTE_UNIX_NANOSECONDS. TDMS keeps its detected/default time handling. Only used when config is not provided.

TYPE: TimeFormat | 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. Call

Job

job.get_data_import() on it for the import's status, error

Job

message, and warnings, which are not on the job.

RAISES DESCRIPTION
FileNotFoundError

If the file does not exist.

get async

get(data_import_id: str) -> DataImport

Get a data import by ID.

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_data_import() which calls this method internally.

PARAMETER DESCRIPTION
data_import_id

The ID of the data import.

TYPE: str

RETURNS DESCRIPTION
DataImport

The DataImport.

list_ async

list_(
    *,
    data_import_ids: list[str] | None = None,
    source_url: str | None = None,
    source_url_contains: str | None = None,
    status: DataImportStatus | None = None,
    runs: list[Run | str] | None = None,
    filter_query: str | None = None,
    order_by: str | None = None,
    limit: int | None = None,
    page_size: int | None = None,
) -> list[DataImport]

List data imports with optional filtering.

The server only supports filtering on data_import_id, source_url, status, and run_id, and only supports ordering by created_date and modified_date.

PARAMETER DESCRIPTION
data_import_ids

Filter to data imports with any of these IDs.

TYPE: list[str] | None DEFAULT: None

source_url

Filter to data imports with exactly this source url.

TYPE: str | None DEFAULT: None

source_url_contains

Filter to data imports whose source url contains this substring.

TYPE: str | None DEFAULT: None

status

Filter to data imports with this status.

TYPE: DataImportStatus | None DEFAULT: None

runs

Filter to data imports that ingested into any of these Runs or run IDs.

TYPE: list[Run | str] | None DEFAULT: None

filter_query

Explicit CEL query to filter data imports.

TYPE: str | None DEFAULT: None

order_by

Field and direction to order results by, e.g. "created_date desc". Defaults to oldest-first by created_date.

TYPE: str | None DEFAULT: None

limit

Maximum number of data imports to return. If None, returns all matches.

TYPE: int | None DEFAULT: None

page_size

Number of results to fetch per request. Lower this if you hit gRPC message size limits on responses. If None, uses the server default.

TYPE: int | None DEFAULT: None

RETURNS DESCRIPTION
list[DataImport]

A list of DataImport objects that match the filter criteria.

find async

find(**kwargs) -> DataImport | None

Find a single data import matching the given query. Takes the same arguments as list_. If more than one data import is found, raises an error.

PARAMETER DESCRIPTION
**kwargs

Keyword arguments to pass to list_.

DEFAULT: {}

RETURNS DESCRIPTION
DataImport | None

The DataImport found or None.

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, or job.get_data_import() followed by the import's run_id.

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.

detect_config async

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

Auto-detect import configuration from a file.

Returns the detected configuration, inferring the file format from the extension when data_type is not provided. CSV and Parquet are detected by sending a sample of the file to the server's DetectConfig endpoint; TDMS, HDF5, and ULog are detected locally on the client.

CSV, Parquet, HDF5, TDMS, and ULog 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 ULog files, data lists the channels pyulog decodes from the file. When imported, a non-empty data list restricts the import to exactly those channels; the import fails if a listed channel is not in the file. Clear data to import every channel.

For file types with multiple supported layouts (Parquet, HDF5), 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 with multiple supported layouts (Parquet, HDF5) where the file extension alone is ambiguous.

TYPE: DataTypeKey | None DEFAULT: None

time_format

Time format override for CSV, Parquet, HDF5, and TDMS. Ignored for ULog. When omitted, CSV, Parquet, and HDF5 use the detected format if available, otherwise TimeFormat.ABSOLUTE_UNIX_NANOSECONDS. TDMS keeps its detected/default time handling.

TYPE: TimeFormat | 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, no supported configuration could be detected, or data_type was omitted for a file format that requires a variant.