-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy path__init__.pyi
More file actions
2211 lines (1834 loc) · 79.1 KB
/
__init__.pyi
File metadata and controls
2211 lines (1834 loc) · 79.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Auto-generated stub
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
import re
from datetime import datetime, timedelta
from pathlib import Path
from typing import TYPE_CHECKING, Any, Sequence
import pandas as pd
import pyarrow as pa
from sift_client._internal.low_level_wrappers.test_results import (
ReplayResult,
)
from sift_client.client import SiftClient
from sift_client.sift_types.asset import Asset, AssetUpdate
from sift_client.sift_types.calculated_channel import (
CalculatedChannel,
CalculatedChannelCreate,
CalculatedChannelUpdate,
)
from sift_client.sift_types.channel import Channel
from sift_client.sift_types.data_import import (
DataTypeKey,
ImportConfig,
)
from sift_client.sift_types.export import ExportOutputFormat
from sift_client.sift_types.file_attachment import (
FileAttachment,
FileAttachmentUpdate,
RemoteFileEntityType,
)
from sift_client.sift_types.job import (
Job,
JobStatus,
JobType,
)
from sift_client.sift_types.report import Report, ReportUpdate
from sift_client.sift_types.rule import Rule, RuleCreate, RuleUpdate, RuleVersion
from sift_client.sift_types.run import Run, RunCreate, RunUpdate
from sift_client.sift_types.tag import Tag, TagUpdate
from sift_client.sift_types.test_report import (
TestMeasurement,
TestMeasurementCreate,
TestMeasurementType,
TestMeasurementUpdate,
TestReport,
TestReportCreate,
TestReportUpdate,
TestStatus,
TestStep,
TestStepCreate,
TestStepType,
TestStepUpdate,
)
class AssetsAPI:
"""Sync counterpart to `AssetsAPIAsync`.
High-level API for interacting with assets.
This class provides a Pythonic, notebook-friendly interface for interacting with the AssetsAPI.
It handles automatic handling of gRPC services, seamless type conversion, and clear error handling.
All methods in this class use the Asset class from the low-level wrapper, which is a user-friendly
representation of an asset using standard Python data structures and types.
"""
def __init__(self, sift_client: SiftClient):
"""Initialize the AssetsAPI.
Args:
sift_client: The Sift client to use.
"""
...
def _run(self, coro): ...
def archive(self, asset: str | Asset, *, archive_runs: bool = False) -> Asset:
"""Archive an asset.
Args:
asset: The Asset or asset ID to archive.
archive_runs: If True, archive all Runs associated with the Asset.
Returns:
The archived Asset.
"""
...
def find(self, **kwargs) -> Asset | None:
"""Find a single asset matching the given query. Takes the same arguments as `list_`. If more than one asset is found,
raises an error.
Args:
**kwargs: Keyword arguments to pass to `list_`.
Returns:
The Asset found or None.
"""
...
def get(self, *, asset_id: str | None = None, name: str | None = None) -> Asset:
"""Get an Asset.
Args:
asset_id: The ID of the asset.
name: The name of the asset.
Returns:
The Asset.
"""
...
def list_(
self,
*,
name: str | None = None,
names: list[str] | None = None,
name_contains: str | None = None,
name_regex: str | re.Pattern | None = None,
asset_ids: list[str] | None = None,
created_after: datetime | None = None,
created_before: datetime | None = None,
modified_after: datetime | None = None,
modified_before: datetime | None = None,
created_by: Any | str | None = None,
modified_by: Any | str | None = None,
tags: list[Any] | list[str] | list[Tag] | None = None,
metadata: list[Any] | None = None,
description_contains: str | None = None,
include_archived: bool = False,
filter_query: str | None = None,
order_by: str | None = None,
limit: int | None = None,
) -> list[Asset]:
"""List assets with optional filtering.
Args:
name: Exact name of the asset.
names: List of asset names to filter by.
name_contains: Partial name of the asset.
name_regex: Regular expression to filter assets by name.
asset_ids: Filter to assets with any of these Ids.
created_after: Filter assets created after this datetime.
created_before: Filter assets created before this datetime.
modified_after: Filter assets modified after this datetime.
modified_before: Filter assets modified before this datetime.
created_by: Filter assets created by this User or user ID.
modified_by: Filter assets last modified by this User or user ID.
tags: Filter assets with any of these Tags or tag names.
metadata: Filter assets by metadata criteria.
description_contains: Partial description of the asset.
include_archived: If True, include archived assets in results.
filter_query: Explicit CEL query to filter assets.
order_by: Field and direction to order results by.
limit: Maximum number of assets to return. If None, returns all matches.
Returns:
A list of Asset objects that match the filter criteria.
"""
...
def unarchive(self, asset: str | Asset) -> Asset:
"""Unarchive an asset.
Args:
asset: The Asset or asset ID to unarchive.
Returns:
The unarchived Asset.
"""
...
def update(self, asset: str | Asset, update: AssetUpdate | dict) -> Asset:
"""Update an Asset.
Args:
asset: The Asset or asset ID to update.
update: Updates to apply to the Asset.
Returns:
The updated Asset.
"""
...
class CalculatedChannelsAPI:
"""Sync counterpart to `CalculatedChannelsAPIAsync`.
High-level API for interacting with calculated channels.
This class provides a Pythonic, notebook-friendly interface for interacting with the CalculatedChannelsAPI.
It handles automatic handling of gRPC services, seamless type conversion, and clear error handling.
All methods in this class use the CalculatedChannel class from the low-level wrapper, which is a user-friendly
representation of a calculated channel using standard Python data structures and types.
"""
def __init__(self, sift_client: SiftClient):
"""Initialize the CalculatedChannelsAPI.
Args:
sift_client: The Sift client to use.
"""
...
def _run(self, coro): ...
def archive(self, calculated_channel: str | CalculatedChannel) -> CalculatedChannel:
"""Archive a calculated channel.
Args:
calculated_channel: The id or CalculatedChannel object of the calculated channel to archive.
Returns:
The archived CalculatedChannel.
"""
...
def create(self, create: CalculatedChannelCreate | dict) -> CalculatedChannel:
"""Create a calculated channel.
Args:
create: A CalculatedChannelCreate object or dictionary with configuration for the new calculated channel.
This should include properties like name, expression, channel_references, etc.
Returns:
The created CalculatedChannel.
"""
...
def find(self, **kwargs) -> CalculatedChannel | None:
"""Find a single calculated channel matching the given query. Takes the same arguments as `list` but handles checking for multiple matches.
Will raise an error if multiple calculated channels are found.
Args:
**kwargs: Keyword arguments to pass to `list_`.
Returns:
The CalculatedChannel found or None.
"""
...
def get(
self, *, calculated_channel_id: str | None = None, client_key: str | None = None
) -> CalculatedChannel:
"""Get a Calculated Channel.
Args:
calculated_channel_id: The ID of the calculated channel.
client_key: The client key of the calculated channel.
Returns:
The CalculatedChannel.
Raises:
ValueError: If neither calculated_channel_id nor client_key is provided.
"""
...
def list_(
self,
*,
name: str | None = None,
names: list[str] | None = None,
name_contains: str | None = None,
name_regex: str | re.Pattern | None = None,
calculated_channel_ids: list[str] | None = None,
client_keys: list[str] | None = None,
created_after: datetime | None = None,
created_before: datetime | None = None,
modified_after: datetime | None = None,
modified_before: datetime | None = None,
created_by: Any | str | None = None,
modified_by: Any | str | None = None,
tags: list[Any] | list[str] | list[Tag] | None = None,
metadata: list[Any] | None = None,
asset: Asset | str | None = None,
run: Run | str | None = None,
version: int | None = None,
description_contains: str | None = None,
include_archived: bool = False,
filter_query: str | None = None,
order_by: str | None = None,
limit: int | None = None,
) -> list[CalculatedChannel]:
"""List calculated channels with optional filtering. This will return the latest version. To find all versions, use `list_versions`.
Args:
name: Exact name of the calculated channel.
names: List of calculated channel names to filter by.
name_contains: Partial name of the calculated channel.
name_regex: Regular expression string to filter calculated channels by name.
calculated_channel_ids: Filter to calculated channels with any of these IDs.
client_keys: Filter to calculated channels with any of these client keys.
created_after: Created after this date.
created_before: Created before this date.
modified_after: Modified after this date.
modified_before: Modified before this date.
created_by: Calculated channels created by this user.
modified_by: Calculated channels last modified by this user.
tags: Filter calculated channels with any of these Tags or tag names.
metadata: Filter calculated channels by metadata criteria.
asset: Filter calculated channels associated with this Asset or asset ID.
run: Filter calculated channels associated with this Run or run ID.
version: The version of the calculated channel.
description_contains: Partial description of the calculated channel.
include_archived: Include archived calculated channels.
filter_query: Explicit CEL query to filter calculated channels.
order_by: How to order the retrieved calculated channels.
limit: How many calculated channels to retrieve. If None, retrieves all matches.
Returns:
A list of CalculatedChannels that matches the filter.
"""
...
def list_versions(
self,
*,
calculated_channel: CalculatedChannel | str | None = None,
client_key: str | None = None,
name: str | None = None,
names: list[str] | None = None,
name_contains: str | None = None,
name_regex: str | re.Pattern | None = None,
created_after: datetime | None = None,
created_before: datetime | None = None,
modified_after: datetime | None = None,
modified_before: datetime | None = None,
created_by: Any | str | None = None,
modified_by: Any | str | None = None,
tags: list[Any] | list[str] | list[Tag] | None = None,
metadata: list[Any] | None = None,
description_contains: str | None = None,
include_archived: bool = False,
filter_query: str | None = None,
order_by: str | None = None,
limit: int | None = None,
) -> list[CalculatedChannel]:
"""List versions of a calculated channel.
Args:
calculated_channel: The CalculatedChannel or ID of the calculated channel to get versions for.
client_key: The client key of the calculated channel.
name: Exact name of the calculated channel.
names: List of calculated channel names to filter by.
name_contains: Partial name of the calculated channel.
name_regex: Regular expression string to filter calculated channels by name.
created_after: Filter versions created after this datetime.
created_before: Filter versions created before this datetime.
modified_after: Filter versions modified after this datetime.
modified_before: Filter versions modified before this datetime.
created_by: Filter versions created by this user or user ID.
modified_by: Filter versions modified by this user or user ID.
tags: Filter versions with any of these Tags or tag names.
metadata: Filter versions by metadata criteria.
description_contains: Partial description of the calculated channel.
include_archived: Include archived versions.
filter_query: Explicit CEL query to filter versions.
order_by: How to order the retrieved versions.
limit: Maximum number of versions to return. If None, returns all matches.
Returns:
A list of CalculatedChannel versions that match the filter criteria.
"""
...
def unarchive(self, calculated_channel: str | CalculatedChannel) -> CalculatedChannel:
"""Unarchive a calculated channel.
Args:
calculated_channel: The id or CalculatedChannel object of the calculated channel to unarchive.
Returns:
The unarchived CalculatedChannel.
"""
...
def update(
self,
calculated_channel: CalculatedChannel | str,
update: CalculatedChannelUpdate | dict,
*,
user_notes: str | None = None,
) -> CalculatedChannel:
"""Update a Calculated Channel.
Args:
calculated_channel: The CalculatedChannel or id of the CalculatedChannel to update.
update: Updates to apply to the CalculatedChannel.
user_notes: User notes for the update.
Returns:
The updated CalculatedChannel.
"""
...
class ChannelsAPI:
"""Sync counterpart to `ChannelsAPIAsync`.
High-level API for interacting with channels.
This class provides a Pythonic, notebook-friendly interface for interacting with the ChannelsAPI.
It handles automatic handling of gRPC services, seamless type conversion, and clear error handling.
All methods in this class use the Channel class from the low-level wrapper, which is a user-friendly
representation of a channel using standard Python data structures and types.
"""
def __init__(self, sift_client: SiftClient):
"""Initialize the ChannelsAPI.
Args:
sift_client: The Sift client to use.
"""
...
def _run(self, coro): ...
def archive(self, channels: list[str | Channel]) -> None:
"""Batch archive channels by setting active to false.
Args:
channels: List of channel IDs or Channel objects to archive. If a Channel
has no id set, raises ValueError.
"""
...
def find(self, **kwargs) -> Channel | None:
"""Find a single channel matching the given query. Takes the same arguments as `list`. If more than one channel is found,
raises an error.
Args:
**kwargs: Keyword arguments to pass to `list_`.
Returns:
The Channel found or None.
"""
...
def get(self, *, channel_id: str) -> Channel:
"""Get a Channel.
Args:
channel_id: The ID of the channel.
Returns:
The Channel.
"""
...
def get_data(
self,
*,
channels: list[Channel],
run: Run | str | None = None,
start_time: datetime | None = None,
end_time: datetime | None = None,
limit: int | None = None,
ignore_cache: bool = False,
) -> dict[str, pd.DataFrame]:
"""Get data for one or more channels.
Args:
channels: The channels to get data for.
run: The Run or run_id to get data for.
start_time: The start time to get data for.
end_time: The end time to get data for.
limit: The maximum number of data points to return. Will be in increments of page_size or default page size defined by the call if no page_size is provided.
ignore_cache: Whether to ignore cached data and fetch fresh data from the server.
Returns:
A dictionary mapping channel names to pandas DataFrames containing the channel data.
"""
...
def get_data_as_arrow(
self,
*,
channels: list[Channel],
run: Run | str | None = None,
start_time: datetime | None = None,
end_time: datetime | None = None,
limit: int | None = None,
ignore_cache: bool = False,
) -> dict[str, pa.Table]:
"""Get data for one or more channels as pyarrow tables."""
...
def list_(
self,
*,
name: str | None = None,
names: list[str] | None = None,
name_contains: str | None = None,
name_regex: str | re.Pattern | None = None,
channel_ids: list[str] | None = None,
created_after: datetime | None = None,
created_before: datetime | None = None,
modified_after: datetime | None = None,
modified_before: datetime | None = None,
asset: Asset | str | None = None,
assets: list[str | Asset] | None = None,
run: Run | str | None = None,
description_contains: str | None = None,
archived: bool | None = None,
filter_query: str | None = None,
order_by: str | None = None,
limit: int | None = None,
) -> list[Channel]:
"""List channels with optional filtering.
Args:
name: Exact name of the channel.
names: List of channel names to filter by.
name_contains: Partial name of the channel.
name_regex: Regular expression to filter channels by name.
channel_ids: Filter to channels with any of these IDs.
created_after: Filter channels created after this datetime. Note: This is related to the channel creation time, not the timestamp of the underlying data.
created_before: Filter channels created before this datetime. Note: This is related to the channel creation time, not the timestamp of the underlying data.
modified_after: Filter channels modified after this datetime.
modified_before: Filter channels modified before this datetime.
asset: Filter channels associated with this Asset or asset ID.
assets: Filter channels associated with these Assets or asset IDs.
run: Filter channels associated with this Run or run ID.
description_contains: Partial description of the channel.
archived: If True, searches for archived channels.
filter_query: Explicit CEL query to filter channels.
order_by: Field and direction to order results by.
limit: Maximum number of channels to return. If None, returns all matches.
Returns:
A list of Channels that matches the filter criteria.
"""
...
def unarchive(self, channels: list[str | Channel]) -> None:
"""Batch unarchive channels by setting active to true.
Args:
channels: List of channel IDs or Channel objects to unarchive. If a Channel
has no id set, raises ValueError.
"""
...
class DataExportAPI:
"""Sync counterpart to `DataExportAPIAsync`.
High-level API for exporting data from Sift.
"""
def __init__(self, sift_client: SiftClient):
"""Initialize the DataExportAPI.
Args:
sift_client: The Sift client to use.
"""
...
def _run(self, coro): ...
def export(
self,
*,
output_format: ExportOutputFormat,
runs: list[str | Run] | None = None,
assets: list[str | Asset] | None = None,
start_time: datetime | None = None,
stop_time: datetime | None = None,
channels: list[str | Channel] | None = None,
calculated_channels: list[CalculatedChannel | CalculatedChannelCreate | dict] | None = None,
simplify_channel_names: bool = False,
combine_runs: bool = False,
split_export_by_asset: bool = False,
split_export_by_run: bool = False,
) -> Job:
"""Export data from Sift.
Initiates an export on the server and returns a Job handle. Use
``job.wait_and_download()`` to poll for completion and download the files.
There are three ways to scope the export, determined by which arguments
are provided:
1. **By runs** — provide ``runs``. The ``start_time``/``stop_time`` are
optional (if omitted, the full time range of each run is used). If no
``channels`` or ``calculated_channels`` are provided, all channels
from the runs' assets are included.
2. **By assets** — provide ``assets``. Both ``start_time`` and
``stop_time`` are **required**. If no ``channels`` or
``calculated_channels`` are provided, all channels from the assets
are included.
3. **By time range only** — provide ``start_time`` and ``stop_time``
without ``runs`` or ``assets``. At least one of ``channels`` or
``calculated_channels`` **must** be provided to scope the data.
You cannot provide both ``runs`` and ``assets`` at the same time.
Args:
output_format: The file format for the export (CSV, Parquet, or Sun/WinPlot).
runs: One or more Run objects or run IDs to export data from.
assets: One or more Asset objects or asset IDs to export data from.
start_time: Start of the time range to export. Required when using
assets or time-range-only mode; optional when using runs.
stop_time: End of the time range to export. Required when using
assets or time-range-only mode; optional when using runs.
channels: Channel objects or channel IDs to include. If omitted and
runs or assets are provided, all channels are exported. Required
(along with ``calculated_channels``) in time-range-only mode.
calculated_channels: Calculated channels to include in the export.
Accepts existing CalculatedChannel objects,
CalculatedChannelCreate definitions, or dictionaries that
will be converted to CalculatedChannelCreate via model_validate.
simplify_channel_names: Remove text preceding last period in channel
names, only if the resulting simplified name is unique.
combine_runs: Identical channels within the same asset across
multiple runs will be combined into a single column.
split_export_by_asset: Split each asset into a separate file, with
asset name removed from channel name display.
split_export_by_run: Split each run into a separate file, with run
name removed from channel name display.
Returns:
A Job handle for the pending export.
"""
...
class DataImportAPI:
"""Sync counterpart to `DataImportAPIAsync`.
High-level API for importing data into Sift.
"""
def __init__(self, sift_client: SiftClient):
"""Initialize the DataImportAPI.
Args:
sift_client: The Sift client to use.
"""
...
def _run(self, coro): ...
def detect_config(
self, 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.
Args:
file_path: Path to the file to analyze.
data_type: Explicit data type key. Required for formats like
Parquet where the extension alone is ambiguous.
Returns:
The detected import config.
Raises:
FileNotFoundError: If the file does not exist.
ValueError: If the file extension is unsupported or no
supported configuration could be detected.
"""
...
def get_run(self, 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.
Args:
data_import_id: The ID of the data import.
Returns:
The Run created by or associated with the import.
Raises:
ValueError: If the data import has no associated run.
"""
...
def import_from_path(
self,
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.
Examples:
Import a CSV file with auto-detected config:
job = client.data_imports.import_from_path(
"data.csv",
asset=my_asset,
)
Auto-detect config, inspect and patch before importing:
config = client.data_imports.detect_config("data.csv")
# Fix a column data type
config["temperature"].data_type = ChannelDataType.FLOAT
# Remove an unwanted column
config.data_columns = [
dc for dc in config.data_columns if dc.name != "internal_id"
]
job = client.data_imports.import_from_path(
"data.csv",
asset=my_asset,
config=config,
)
Args:
file_path: Path to the local file to import.
asset: Asset object or asset name to import data into. Optional
when ``config`` already has ``asset_name`` set.
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.
data_type: Explicit data type key. Required for formats like
Parquet where the extension alone is ambiguous. Only used
when ``config`` is not provided.
run: ``Run`` object or run ID string to import into an existing
run. Mutually exclusive with ``run_name``.
run_name: Name for a new run. Defaults to the filename if
neither ``run`` nor ``run_name`` is set.
show_progress: If True, display a progress spinner during upload.
Defaults to True for sync, False for async.
Returns:
A ``Job`` handle for the pending import.
Raises:
FileNotFoundError: If the file does not exist.
"""
...
class FileAttachmentsAPI:
"""Sync counterpart to `FileAttachmentsAPIAsync`.
High-level API for interacting with file attachments (remote files).
This class provides a Pythonic interface for managing file attachments
on Sift entities like runs, assets, and test reports.
"""
def __init__(self, sift_client: SiftClient):
"""Initialize the FileAttachmentsAPIAsync.
Args:
sift_client: The Sift client to use.
"""
...
def _run(self, coro): ...
def delete(
self, *, file_attachments: list[FileAttachment | str] | FileAttachment | str
) -> None:
"""Batch delete multiple file attachments.
Args:
file_attachments: List of FileAttachments or the IDs of the file attachments to delete (up to 1000).
"""
...
def download(self, *, file_attachment: FileAttachment | str, output_path: str | Path) -> None:
"""Download a file attachment to a local path.
Args:
file_attachment: The FileAttachment or the ID of the file attachment to download.
output_path: The path to download the file attachment to.
"""
...
def get(self, *, file_attachment_id: str) -> FileAttachment:
"""Get a file attachment by ID.
Args:
file_attachment_id: The ID of the file attachment to retrieve.
Returns:
The FileAttachment.
"""
...
def get_download_url(self, *, file_attachment: FileAttachment | str) -> str:
"""Get a download URL for a file attachment.
Args:
file_attachment: The FileAttachment or the ID of the file attachment.
Returns:
The download URL for the file attachment.
"""
...
def list_(
self,
*,
name: str | None = None,
names: list[str] | None = None,
name_contains: str | None = None,
name_regex: str | re.Pattern | None = None,
remote_file_ids: list[str] | None = None,
entities: list[Run | Asset | TestReport | TestStep] | None = None,
entity_type: RemoteFileEntityType | None = None,
entity_ids: list[str] | None = None,
description_contains: str | None = None,
filter_query: str | None = None,
order_by: str | None = None,
limit: int | None = None,
) -> list[FileAttachment]:
"""List file attachments with optional filtering.
Args:
name: Exact name of the file attachment.
names: List of file attachment names to filter by.
name_contains: Partial name of the file attachment.
name_regex: Regular expression to filter file attachments by name.
remote_file_ids: Filter to file attachments with any of these IDs.
entities: Filter to file attachments associated with these entities.
entity_type: Filter to file attachments associated with this entity type.
entity_ids: Filter to file attachments associated with these entity IDs.
description_contains: Partial description of the file attachment.
filter_query: Explicit CEL query to filter file attachments.
order_by: Field and direction to order results by. Note: Not supported by the backend, but it is here for API consistency.
limit: Maximum number of file attachments to return. If None, returns all matches.
Returns:
A list of FileAttachment objects that match the filter criteria.
"""
...
def update(self, *, file_attachment: FileAttachmentUpdate | dict) -> FileAttachment:
"""Update a file attachment.
Args:
file_attachment: The FileAttachmentUpdate with fields to update.
Returns:
The updated FileAttachment.
"""
...
def upload(
self,
*,
path: str | Path,
entity: Asset | Run | TestReport | TestStep,
metadata: dict[str, Any] | None = None,
description: str | None = None,
organization_id: str | None = None,
) -> FileAttachment:
"""Upload a file attachment to a remote file.
Args:
path: The path to the file to upload.
entity: The entity that the file is attached to.
metadata: Optional metadata for the file (e.g., video/image metadata).
description: Optional description of the file.
organization_id: Optional organization ID.
Returns:
The uploaded FileAttachment.
"""
...
class JobsAPI:
"""Sync counterpart to `JobsAPIAsync`.
High-level API for interacting with jobs.
This class provides a Pythonic interface for managing jobs in Sift.
Jobs represent long-running operations like data imports, rule evaluations, and data exports.
"""
def __init__(self, sift_client: SiftClient):
"""Initialize the JobsAPI.
Args:
sift_client: The Sift client to use.
"""
...
def _run(self, coro): ...
def cancel(self, job: Job | str) -> None:
"""Cancel a job.
If the job hasn't started yet, it will be cancelled immediately.
Jobs that are already finished, failed, or cancelled are not affected.
Args:
job: The Job or ID of the job to cancel.
"""
...
def get(self, job_id: str) -> Job:
"""Get a job by ID.
Args:
job_id: The ID of the job to retrieve.
Returns:
The Job object.
"""
...
def list_(
self,
*,
job_ids: list[str] | None = None,
created_after: datetime | None = None,
created_before: datetime | None = None,
modified_after: datetime | None = None,
modified_before: datetime | None = None,
created_by_user_id: str | None = None,
modified_by_user_id: str | None = None,
job_type: JobType | None = None,
job_status: JobStatus | None = None,
started_date_after: datetime | None = None,
started_date_before: datetime | None = None,
completed_date_after: datetime | None = None,
completed_date_before: datetime | None = None,
organization_id: str | None = None,
filter_query: str | None = None,
order_by: str | None = None,
limit: int | None = None,
) -> list[Job]:
"""List jobs with optional filtering.
Args:
job_ids: Filter to jobs with any of these IDs.
created_after: Filter to jobs created after this datetime.
created_before: Filter to jobs created before this datetime.
modified_after: Filter to jobs modified after this datetime.
modified_before: Filter to jobs modified before this datetime.
created_by_user_id: Filter to jobs created by this user ID.
modified_by_user_id: Filter to jobs last modified by this user ID.
job_type: Filter to jobs with this type.
job_status: Filter to jobs with this status.
started_date_after: Filter to jobs started after this datetime.
started_date_before: Filter to jobs started before this datetime.
completed_date_after: Filter to jobs completed after this datetime.
completed_date_before: Filter to jobs completed before this datetime.