sift_client.sift_types.job
¶
Job types for the Sift API.
| CLASS | DESCRIPTION |
|---|---|
JobType |
Type of job. |
JobStatus |
Status of a job. |
DataImportStatusDetails |
Status details for a data import job. |
DataExportStatusDetails |
Status details for a data export job. |
RuleEvaluationStatusDetails |
Status details for a rule evaluation job. |
DataImportDetails |
Details for a data import job. |
DataExportDetails |
Details for a data export job. |
RuleEvaluationDetails |
Details for a rule evaluation job. |
Job |
A job in the Sift system. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
JobStatusDetails |
|
JobDetails |
|
JobStatusDetails
module-attribute
¶
JobStatusDetails = Union[
DataImportStatusDetails,
DataExportStatusDetails,
RuleEvaluationStatusDetails,
]
JobDetails
module-attribute
¶
JobDetails = Union[
DataImportDetails,
DataExportDetails,
RuleEvaluationDetails,
]
JobType
¶
Bases: str, Enum
Type of job.
| METHOD | DESCRIPTION |
|---|---|
to_filter_str |
Convert to string representation. |
to_proto |
Convert to proto enum value. |
from_proto |
Create from proto enum value. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
RULE_EVALUATION |
|
DATA_IMPORT |
|
DATA_EXPORT |
|
JobStatus
¶
Bases: str, Enum
Status of a job.
| METHOD | DESCRIPTION |
|---|---|
to_filter_str |
Convert to string representation. |
from_proto |
Create from proto enum value. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
CREATED |
|
RUNNING |
|
FINISHED |
|
FAILED |
|
CANCELLED |
|
CANCEL_REQUESTED |
|
DataImportStatusDetails
pydantic-model
¶
Bases: BaseModel
Status details for a data import job.
Fields:
-
points_processed(int) -
points_total(int)
DataExportStatusDetails
pydantic-model
¶
RuleEvaluationStatusDetails
pydantic-model
¶
Bases: BaseModel
Status details for a rule evaluation job.
DataImportDetails
pydantic-model
¶
DataExportDetails
pydantic-model
¶
RuleEvaluationDetails
pydantic-model
¶
Job
pydantic-model
¶
Bases: BaseType[Job, 'Job']
A job in the Sift system.
Jobs represent long-running operations like data imports, rule evaluations, and data exports.
Fields:
-
id_(str | None) -
proto(Any | None) -
_client(SiftClient | None) -
organization_id(str) -
created_by_user_id(str) -
modified_by_user_id(str) -
created_date(datetime) -
modified_date(datetime) -
job_type(JobType) -
job_status(JobStatus) -
started_date(datetime | None) -
completed_date(datetime | None) -
job_status_details(JobStatusDetails | None) -
job_details(JobDetails | None) -
_data_import_id(str | None)
is_in_progress
property
¶
Return True if the job is in progress, False otherwise.
A job is in progress if its status is RUNNING.
is_failed
property
¶
Return True if the job has failed, False otherwise.
A job has failed if its status is FAILED.
is_finished
property
¶
Return True if the job has finished, False otherwise.
A job has finished if its status is FINISHED.
is_cancelled
property
¶
Return True if the job has been cancelled, False otherwise.
A job has been cancelled if its status is CANCELLED.
refresh
¶
refresh() -> Job
Refresh this job with the latest data from the API.
| RETURNS | DESCRIPTION |
|---|---|
Job
|
The updated Job object. |
cancel
¶
Cancel this job.
If the job hasn't started yet, it will be cancelled immediately. Jobs that are already finished, failed, or cancelled are not affected.
retry
¶
retry() -> Job
Retry this job.
Jobs that are finished, in progress, or in the process of being cancelled are not affected.
| RETURNS | DESCRIPTION |
|---|---|
Job
|
The updated Job object. |
wait_until_complete
¶
wait_until_complete(
*,
polling_interval_secs: int = 5,
timeout_secs: int | None = None,
) -> Job
Wait until the job is complete or the timeout is reached.
Polls the job status at the given interval until the job is FINISHED, FAILED, or CANCELLED, returning the completed Job
| PARAMETER | DESCRIPTION |
|---|---|
job
|
The Job or job_id to wait for.
|
polling_interval_secs
|
Seconds between status polls. Defaults to 5s.
TYPE:
|
timeout_secs
|
Maximum seconds to wait. If None, polls indefinitely. Defaults to None (indefinite).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Job
|
The Job in the completed state. |
get_data_import
¶
get_data_import() -> DataImport
Get the data import this job ran.
The import's error message and warnings live there, not on the job.
| RETURNS | DESCRIPTION |
|---|---|
DataImport
|
The DataImport this job ran. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If this is not a data import job. |
get_import_run
¶
get_import_run() -> Run
Get the run created by this data import job.
| RETURNS | DESCRIPTION |
|---|---|
Run
|
The Run associated with this import. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If this is not a data import job or the import has no associated run. |
wait_and_download
¶
wait_and_download(
*,
polling_interval_secs: int = 5,
timeout_secs: int | None = None,
output_dir: str | Path | None = None,
extract: bool = True,
) -> list[Path]
Wait for a job to complete and download the result files.
Polls the job status at the given interval until the job is FINISHED, FAILED, or CANCELLED, then downloads the result files.
| PARAMETER | DESCRIPTION |
|---|---|
polling_interval_secs
|
Seconds between status polls. Defaults to 5.
TYPE:
|
timeout_secs
|
Maximum seconds to wait. If None, polls indefinitely.
TYPE:
|
output_dir
|
Directory to save the downloaded files. If omitted, a temporary directory is created automatically.
TYPE:
|
extract
|
If True (default) and the downloaded file is a zip, extract it and delete the archive, returning paths to the extracted files. Non-zip files are returned as-is regardless of this flag.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Path]
|
List of paths to the downloaded/extracted files. |
| RAISES | DESCRIPTION |
|---|---|
RuntimeError
|
If the job fails or is cancelled. |
TimeoutError
|
If the job does not complete within timeout_secs. |