Job¶
-
class
alpine.job.
Job
(base_url, session, token)¶ A class for interacting with jobs. The top-level methods deal with jobs. The subclass Task can be used to interact with individual tasks within a job.
-
class
ScheduleType
¶ Convenience strings for schedule types.
-
class
Task
(base_url, session, token)¶ A class for interacting with job tasks.
-
create
(workspace_id, job_id, workfile_id, task_type=None)¶ Add a new task to an existing job using an existing workfile.
Parameters: - workspace_id (int) – ID of the workspace.
- job_id (int) – ID of the job to which the task is to be added.
- workfile_id (int) – ID of the workfile to be added as a task.
- task_type (str) – Task type. Use the Workspace.Stage object for convenience. The default is “run_work_flow”.
Returns: Metadata of the new task.
Return type: dict
Example:
>>> session.job.task.create(workspace_id = 1672, job_id = 675, workfile_id = 823)
-
delete
(workspace_id, job_id, task_id)¶ Delete a task from a job.
Parameters: - workspace_id (int) – ID of the workspace.
- job_id (int) – ID of the job that has the task to be deleted.
- task_id (int) – ID of the task.
Returns: None
Return type: NoneType
Raises: - TaskNotFoundException – The job does not exist.
- InvalidResponseCodeException – The request got an unexpected HTTP status code in response (not 200 OK).
Example:
>>> session.job.task.delete(workspace_id = 1672, job_id = 675, task_id = 344)
-
get
(workspace_id, job_id, task_id)¶ Return metadata of one task.
Parameters: - workspace_id (int) – ID of the workspace.
- job_id (int) – ID of the job.
- task_id (int) – ID of the task.
Returns: Selected task’s metadata.
Return type: dict
Example:
>>> session.job.task.get(workspace_id = 1672, job_id = 675, task_id = 344)
-
get_id
(workspace_id, job_id, task_name)¶ Return the ID of a task.
Parameters: - workspace_id (int) – ID of the workspace.
- job_id (int) – ID of the job.
- task_name (str) – Name of the task.
Returns: ID of the task.
Return type: int
Example:
>>> session.job.task.get_id(workspace_id = 1672, job_id = 675, task_name = "Run test2") 344
-
get_list
(workspace_id, job_id)¶ Get a list of all tasks in a job.
Parameters: - workspace_id (int) – ID of the workspace.
- job_id (int) – ID of the job.
Returns: List of all tasks in the job.
Return type: list of dict
Example:
>>> session.job.task.get_list(workspace_id = 1672, job_id = 675);
-
-
class
TaskType
¶ Convenience strings for task types.
-
create
(workspace_id, job_name, schedule_type=None, interval_value=0, next_run=None, time_zone=None)¶ Create a new job in a workspace with specified configuration.
Parameters: - workspace_id (int) – ID of the workspace where the job is to be created.
- job_name (str) – Name of the job to be created.
- schedule_type (str) – Job run interval time unit. Use the Job.ScheduleType object for convenience. The default value is “on_demand”.
- interval_value (int) – Job run interval value. If you choose ‘Job.ScheduleType.Weekly’ for schedule_type and ‘2’ for interval_value, then it will run every 2 weeks.
- next_run (datetime) – When the next run should happen.
- time_zone (timezone) – Time zone info. If no time zone is provided, we use UTC.
Returns: Created job metadata.
Return type: dict
Example:
>>> session.job.create(workspace_id = 1672, job_name = "APICreatedJob", >>> schedule_type = Job.ScheduleType.Weekly, interval_value = 2, >>> next_run = datetime.today().now(pytz.timezone('US/Pacific')) + timedelta(hours=1), >>> time_zone =pytz.timezone('US/Pacific') >>> )
-
delete
(workspace_id, job_id)¶ Delete a job from a workspace.
Parameters: - workspace_id (int) – ID of the workspace that contains the job.
- job_id (str) – ID of the job to delete.
Returns: None.
Return type: NoneType
Raises: - JobNotFoundException – The job does not exist.
- InvalidResponseCodeException – The request got an unexpected HTTP status code in response (not 200 OK).
Example:
>>> session.job.delete(workspace_id = 1672, job_id = 675)
-
get
(workspace_id, job_id)¶ Get one job’s metadata.
Parameters: - workspace_id (int) – ID of the workspace that contains the job.
- job_id (str) – ID of the job.
Returns: Selected job’s metadata.
Return type: dict
Example:
>>> job_info = session.job.get(workspace_id = 1672, job_id = 675)
-
get_id
(workspace_id, job_name)¶ Gets the job ID.
Parameters: - workspace_id (int) – ID of the workspace the job is in.
- job_name (str) – Name of the job.
Returns: ID of the job.
Return type: int
Example:
>>> job_id = session.job.get_id(workspace_id = 1672, job_name = "DemoJob") >>> print(job_id) 675
-
get_list
(workspace_id, per_page=50)¶ Get a list of all jobs in a workspace.
Parameters: - workspace_id (int) – ID of the workspace.
- per_page (int) – Maximum number to fetch with each API call.
Returns: List of jobs’ metadata.
Return type: list of dict
Example:
>>> all_jobs = session.job.get_list(workspace_id = 1672)
-
run
(job_id)¶ Run a job.
Parameters: job_id (int) – ID of the job. Returns: HTTP response. Return type: response Example:
>>> session.job.run(job_id = 675)
-
class