-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy path__init__.pyi
More file actions
1460 lines (1214 loc) · 50.8 KB
/
Copy path__init__.pyi
File metadata and controls
1460 lines (1214 loc) · 50.8 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
import pandas as pd
import pyarrow as pa
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.report import Report, ReportUpdate
from sift_client.sift_types.rule import Rule, RuleCreate, RuleUpdate
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 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,
max_results: int | None = None,
page_size: int | None = None,
) -> 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.
max_results: The maximum number of data points to return.
page_size: The number of data points to return per page.
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,
max_results: int | None = None,
page_size: int | None = None,
) -> dict[str, pa.Table]:
"""Same as get_data but returns data 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,
include_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.
include_archived: If True, include archived channels in results.
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.
"""
...
class PingAPI:
"""Sync counterpart to `PingAPIAsync`.
High-level API for performing health checks.
"""
def __init__(self, sift_client: SiftClient):
"""Initialize the AssetsAPI.
Args:
sift_client: The Sift client to use.
"""
...
def _run(self, coro): ...
def ping(self) -> str:
"""Send a ping request to the server.
Returns:
The response from the server.
"""
...
class ReportsAPI:
"""Sync counterpart to `ReportsAPIAsync`.
High-level API for interacting with reports.
"""
def __init__(self, sift_client: SiftClient):
"""Initialize the ReportsAPI.
Args:
sift_client: The Sift client to use.
"""
...
def _run(self, coro): ...
def archive(self, *, report: str | Report) -> Report:
"""Archive a report."""
...
def cancel(self, *, report: str | Report) -> None:
"""Cancel a report.
Args:
report: The Report or report ID to cancel.
"""
...
def create_from_applicable_rules(
self,
*,
run: Run | str | None = None,
organization_id: str | None = None,
name: str | None = None,
start_time: datetime | None = None,
end_time: datetime | None = None,
) -> Report | None:
"""Create a new report from applicable rules based on a run.
If you want to evaluate against assets, use the rules client instead since no report is created in that case.
Args:
run: The run or run ID to associate with the report.
organization_id: The organization ID.
name: Optional name for the report.
start_time: Optional start time to evaluate rules against.
end_time: Optional end time to evaluate rules against.
Returns:
The created Report or None if no report was created.
"""
...
def create_from_rules(
self,
*,
name: str,
run: Run | str | None = None,
organization_id: str | None = None,
rules: list[Rule] | list[str],
) -> Report | None:
"""Create a new report from rules.
Args:
name: The name of the report.
run: The run or run ID to associate with the report.
organization_id: The organization ID.
rules: List of rules or rule IDs to include in the report.
Returns:
The created Report or None if no report was created.
"""
...
def create_from_template(
self,
*,
report_template_id: str,
run_id: str,
organization_id: str | None = None,
name: str | None = None,
) -> Report | None:
"""Create a new report from a report template.
Args:
report_template_id: The ID of the report template to use.
run_id: The run ID to associate with the report.
organization_id: The organization ID.
name: Optional name for the report.
Returns:
The created Report or None if no report was created.
"""
...
def find(self, **kwargs) -> Report | None:
"""Find a single report matching the given query. Takes the same arguments as `list`. If more than one report is found,
raises an error.
Args:
**kwargs: Keyword arguments to pass to `list`.
Returns:
The Report found or None.
"""
...
def get(self, *, report_id: str) -> Report:
"""Get a Report.
Args:
report_id: The ID of the report.
Returns:
The Report.
"""
...
def list_(
self,
*,
name: str | None = None,
name_contains: str | None = None,
name_regex: str | re.Pattern | None = None,
names: list[str] | None = None,
description_contains: str | None = None,
run: Run | str | None = None,
organization_id: str | None = None,
report_ids: list[str] | None = None,
report_template_id: str | None = None,
metadata: dict[str, str | float | bool] | None = None,
tag_names: list[str] | list[Tag] | None = None,
created_by: str | None = None,
modified_by: str | None = None,
order_by: str | None = None,
limit: int | None = None,
include_archived: bool = False,
filter_query: str | None = None,
created_after: datetime | None = None,
created_before: datetime | None = None,
modified_after: datetime | None = None,
modified_before: datetime | None = None,
) -> list[Report]:
"""List reports with optional filtering.
Args:
name: Exact name of the report.
name_contains: Partial name of the report.
name_regex: Regular expression string to filter reports by name.
names: List of report names to filter by.
description_contains: Partial description of the report.
run: Run/run ID to filter by.
organization_id: Organization ID to filter by.
report_ids: List of report IDs to filter by.
report_template_id: Report template ID to filter by.
metadata: Metadata to filter by.
tag_names: List of tags or tag names to filter by.
created_by: The user ID of the creator of the reports.
modified_by: The user ID of the last modifier of the reports.
order_by: How to order the retrieved reports.
limit: How many reports to retrieve. If None, retrieves all matches.
include_archived: Whether to include archived reports.
filter_query: Explicit CEL query to filter reports.
created_after: Filter reports created after this datetime.
created_before: Filter reports created before this datetime.
modified_after: Filter reports modified after this datetime.
modified_before: Filter reports modified before this datetime.
Returns:
A list of Reports that matches the filter.
"""
...
def rerun(self, *, report: str | Report) -> tuple[str, str]:
"""Rerun a report.
Args:
report: The Report or report ID to rerun.
Returns:
A tuple of (job_id, new_report_id).
"""
...
def unarchive(self, *, report: str | Report) -> Report:
"""Unarchive a report."""
...
def update(self, report: str | Report, update: ReportUpdate | dict) -> Report:
"""Update a report.
Args:
report: The Report or report ID to update.
update: The updates to apply.
"""
...
class RulesAPI:
"""Sync counterpart to `RulesAPIAsync`.
High-level API for interacting with rules.
This class provides a Pythonic, notebook-friendly interface for interacting with the RulesAPI.
It handles automatic handling of gRPC services, seamless type conversion, and clear error handling.
All methods in this class use the Rule class from the low-level wrapper, which is a user-friendly
representation of a rule using standard Python data structures and types.
"""
def __init__(self, sift_client: SiftClient):
"""Initialize the RulesAPI.
Args:
sift_client: The Sift client to use.
"""
...
def _run(self, coro): ...
def archive(self, rule: str | Rule) -> Rule:
"""Archive a rule.
Args:
rule: The id or Rule object of the rule to archive.
Returns:
The archived Rule.
"""
...
def create(self, create: RuleCreate | dict) -> Rule:
"""Create a new rule.
Args:
create: A RuleCreate object or dictionary with configuration for the new rule.
Returns:
The created Rule.
"""
...
def find(self, **kwargs) -> Rule | None:
"""Find a single rule matching the given query. Takes the same arguments as `list`. If more than one rule is found,
raises an error.
Args:
**kwargs: Keyword arguments to pass to `list`.
Returns:
The Rule found or None.
"""
...
def get(self, *, rule_id: str | None = None, client_key: str | None = None) -> Rule:
"""Get a Rule.
Args:
rule_id: The ID of the rule.
client_key: The client key of the rule.
Returns:
The Rule.
"""
...
def list_(
self,
*,
name: str | None = None,
names: list[str] | None = None,
name_contains: str | None = None,
name_regex: str | re.Pattern | None = None,
rule_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,
metadata: list[Any] | None = None,
assets: list[str] | list[Asset] | None = None,
asset_tags: list[str | Tag] | 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[Rule]:
"""List rules with optional filtering.
Args:
name: Exact name of the rule.
names: List of rule names to filter by.
name_contains: Partial name of the rule.
name_regex: Regular expression string to filter rules by name.
client_keys: Client keys of rules to filter to.
rule_ids: IDs of rules to filter to.
created_after: Rules created after this datetime.
created_before: Rules created before this datetime.
modified_after: Rules modified after this datetime.
modified_before: Rules modified before this datetime.
created_by: Filter rules created by this User or user ID.
modified_by: Filter rules last modified by this User or user ID.
metadata: Filter rules by metadata criteria.
assets: Filter rules associated with any of these Assets.
asset_tags: Filter rules associated with any Assets that have these Tag IDs.
description_contains: Partial description of the rule.
include_archived: If True, include archived rules in results.
filter_query: Explicit CEL query to filter rules.
order_by: Field and direction to order results by.
limit: Maximum number of rules to return. If None, returns all matches.
Returns:
A list of Rules that matches the filter.
"""
...
def unarchive(self, rule: str | Rule) -> Rule:
"""Unarchive a rule.
Args:
rule: The id or Rule object of the rule to unarchive.
Returns:
The unarchived Rule.
"""
...
def update(
self, rule: Rule | str, update: RuleUpdate | dict, *, version_notes: str | None = None
) -> Rule:
"""Update a Rule.
Args:
rule: The Rule or rule ID to update.
update: Updates to apply to the Rule.
version_notes: Notes to include in the rule version.
Returns:
The updated Rule.
"""
...
class RunsAPI:
"""Sync counterpart to `RunsAPIAsync`.
High-level API for interacting with runs.
This class provides a Pythonic, notebook-friendly interface for interacting with the RunsAPI.
It handles automatic handling of gRPC services, seamless type conversion, and clear error handling.
All methods in this class use the Run class from the low-level wrapper, which is a user-friendly
representation of a run using standard Python data structures and types.
"""
def __init__(self, sift_client: SiftClient):
"""Initialize the RunsAPI.
Args:
sift_client: The Sift client to use.
"""
...
def _run(self, coro): ...
def archive(self, run: str | Run) -> Run:
"""Archive a run.
Args:
run: The Run or run ID to archive.
"""
...
def create(
self,
create: RunCreate | dict,
assets: list[str | Asset] | None = None,
associate_new_data: bool = False,
) -> Run:
"""Create a new run.
Note on assets: You do not need to provide asset info when creating a run.
If you pass a Run to future ingestion configs associated with assets, the association will happen automatically then.
However, if you do pass assets and set associate_new_data=True, future ingested data that falls within the Run's time period will be associated with the Run. Even if that data's timestamp is in the past, if it has not been ingested yet and the Run's timestamp envelopes it, it will be associated with the Run. This may be useful if you want to capture a time range for a specific asset or won't know about this Run when ingesting to that asset.
If the data has already been ingested, leave associate_new_data=False.
Args:
create: The Run definition to create.
assets: List of assets to associate with the run. Note: if you are associating new data, you must provide assets/asset names.
associate_new_data: If True, future ingested data that falls within the Run's time period will be associated with the Run. Even if that data's timestamp is in the past, if it has not been ingested yet and the Run's timestamp envelopes it, it will be associated with the Run.
Returns:
The created Run.
"""
...
def find(self, **kwargs) -> Run | None:
"""Find a single run matching the given query. Takes the same arguments as `list_`. If more than one run is found,
raises an error.
Args:
**kwargs: Keyword arguments to pass to `list_`.
Returns:
The Run found or None.
"""
...
def get(self, *, run_id: str | None = None, client_key: str | None = None) -> Run:
"""Get a Run.
Args:
run_id: The ID of the run.
client_key: The client key of the run.
Returns:
The Run.
"""
...
def list_(
self,
*,
name: str | None = None,
names: list[str] | None = None,
name_contains: str | None = None,
name_regex: str | re.Pattern | None = None,
run_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[str | Tag] | None = None,
metadata: list[Any] | None = None,
assets: list[Asset] | list[str] | None = None,
asset_tags: list[str | Tag] | None = None,
duration_less_than: timedelta | None = None,
duration_greater_than: timedelta | None = None,
start_time_after: datetime | None = None,
start_time_before: datetime | None = None,
stop_time_after: datetime | None = None,
stop_time_before: datetime | None = None,
is_stopped: bool | 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[Run]:
"""List runs with optional filtering.
Args:
name: Exact name of the run.
names: List of run names to filter by.
name_contains: Partial name of the run.
name_regex: Regular expression to filter runs by name.
run_ids: Filter to runs with any of these IDs.
client_keys: Filter to runs with any of these client keys.
created_after: Filter runs created after this datetime.
created_before: Filter runs created before this datetime.
modified_after: Filter runs modified after this datetime.
modified_before: Filter runs modified before this datetime.
created_by: Filter runs created by this User or user ID.
modified_by: Filter runs last modified by this User or user ID.
tags: Filter runs with any of these Tags IDs.
metadata: Filter runs by metadata criteria.