Skip to content

Commit fca8331

Browse files
committed
updated documentation around detect_config
1 parent 07007f9 commit fca8331

2 files changed

Lines changed: 60 additions & 2 deletions

File tree

python/lib/sift_client/resources/data_imports.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,41 @@ async def import_from_path(
7171
If neither ``run`` nor ``run_name`` is provided (and none is
7272
set on the config), ``run_name`` defaults to the filename.
7373
74+
Examples:
75+
Import a CSV file with auto-detected config:
76+
77+
job = client.data_imports.import_from_path(
78+
"data.csv",
79+
asset=my_asset,
80+
)
81+
82+
Auto-detect config, inspect and patch before importing:
83+
84+
config = client.data_imports.detect_config("data.csv")
85+
86+
# Fix a column data type
87+
config.get_column("temperature").data_type = ChannelDataType.FLOAT
88+
89+
# Remove an unwanted column
90+
config.data_columns = [
91+
dc for dc in config.data_columns if dc.name != "internal_id"
92+
]
93+
94+
job = client.data_imports.import_from_path(
95+
"data.csv",
96+
asset=my_asset,
97+
config=config,
98+
)
99+
74100
Args:
75101
file_path: Path to the local file to import.
76102
asset: Asset object or asset name to import data into. Optional
77103
when ``config`` already has ``asset_name`` set.
78104
config: Import configuration describing the file format and column
79-
mapping. When provided, ``data_type`` is ignored.
105+
mapping. When provided, ``data_type`` is ignored. If omitted,
106+
the config is auto-detected via ``detect_config``. You can
107+
call ``detect_config`` yourself to inspect and modify the
108+
config before passing it here.
80109
data_type: Explicit data type key. Required for formats like
81110
Parquet where the extension alone is ambiguous. Only used
82111
when ``config`` is not provided.

python/lib/sift_client/resources/sync_stubs/__init__.pyi

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,12 +708,41 @@ class DataImportAPI:
708708
If neither ``run`` nor ``run_name`` is provided (and none is
709709
set on the config), ``run_name`` defaults to the filename.
710710
711+
Examples:
712+
Import a CSV file with auto-detected config:
713+
714+
job = client.data_imports.import_from_path(
715+
"data.csv",
716+
asset=my_asset,
717+
)
718+
719+
Auto-detect config, inspect and patch before importing:
720+
721+
config = client.data_imports.detect_config("data.csv")
722+
723+
# Fix a column data type
724+
config.get_column("temperature").data_type = ChannelDataType.FLOAT
725+
726+
# Remove an unwanted column
727+
config.data_columns = [
728+
dc for dc in config.data_columns if dc.name != "internal_id"
729+
]
730+
731+
job = client.data_imports.import_from_path(
732+
"data.csv",
733+
asset=my_asset,
734+
config=config,
735+
)
736+
711737
Args:
712738
file_path: Path to the local file to import.
713739
asset: Asset object or asset name to import data into. Optional
714740
when ``config`` already has ``asset_name`` set.
715741
config: Import configuration describing the file format and column
716-
mapping. When provided, ``data_type`` is ignored.
742+
mapping. When provided, ``data_type`` is ignored. If omitted,
743+
the config is auto-detected via ``detect_config``. You can
744+
call ``detect_config`` yourself to inspect and modify the
745+
config before passing it here.
717746
data_type: Explicit data type key. Required for formats like
718747
Parquet where the extension alone is ambiguous. Only used
719748
when ``config`` is not provided.

0 commit comments

Comments
 (0)