Jobs

class saagieapi.jobs.Jobs(saagie_api)

Bases: object

count_instances_by_status(job_id)

Count job instances by status

Parameters:

job_id (str) – UUID of your job (see README on how to find it)

Returns:

Dict of number of job instances by status

Return type:

dict

Examples

>>> saagie_api.jobs.count_instances_by_status(job_id=job_id)
{
    'countJobInstancesBySelector': [
        {'selector': 'ALL', 'count': 0},
        {'selector': 'SUCCEEDED', 'count': 0},
        {'selector': 'FAILED', 'count': 0},
        {'selector': 'STOPPED', 'count': 0},
        {'selector': 'UNKNOWN', 'count': 0}
    ]
}
create(job_name: str, project_id: str, file: str = None, description: str = '', category: str = 'Processing', technology: str = 'python', technology_catalog: str = 'Saagie', runtime_version: str = '3.10', command_line: str = 'python {file} arg1 arg2', release_note: str = '', extra_technology: str = None, extra_technology_version: str = None, cron_scheduling: str = None, schedule_timezone: str = 'UTC', resources: Dict = None, emails: List = None, status_list: List = None) Dict

Create job in given project

Note

  • Only work for gql>=3.0.0

Parameters:
  • job_name (str) – Name of the job. Must not already exist in the project

  • project_id (str) – UUID of your project (see README on how to find it)

  • file (str, optional) – Local path of the file to upload

  • description (str, optional) – Description of the job

  • category (str, optional) – Category to create the job into. Must be ‘Extraction’, ‘Processing’ or ‘Smart App’

  • technology (str, optional) – Technology label of the job to create.

  • technology_catalog (str, optional) – Technology catalog containing the technology to use for this job

  • runtime_version (str, optional) – Technology version of the job, the ID of the context

  • command_line (str, optional) – Command line of the job

  • release_note (str, optional) – Release note of the job

  • extra_technology (str, optional) – Extra technology when needed (spark jobs). If not needed, leave to empty string or the request will not work

  • extra_technology_version (str, optional) – Version of the extra technology. Leave to empty string when not needed

  • cron_scheduling (str, optional) – Scheduling CRON format Example: “0 0 * * *” (for every day At 00:00)

  • schedule_timezone (str, optional) – Timezone of the scheduling Example: “UTC”, “Pacific/Pago_Pago”

  • resources (dict, optional) – CPU, memory limit and requests Example: {“cpu”:{“request”:0.5, “limit”:2.6},”memory”:{“request”:1.0}}

  • emails (List[String], optional) – Emails to receive alerts for the job, each item should be a valid email

  • status_list (List[String], optional) – Receive an email when the job status change to a specific status Each item of the list should be one of these following values: “REQUESTED”, “QUEUED”, “RUNNING”, “FAILED”, “KILLED”, “KILLING”, “SUCCEEDED”, “UNKNOWN”, “AWAITING”, “SKIPPED”

Returns:

Dict of job information

Return type:

dict

Examples

>>> saagieapi.jobs.create(
...     job_name="my job",
...     project_id="860b8dc8-e634-4c98-b2e7-f9ec32ab4771",
...     file="/tmp/test.py",
...     description='My description',
...     category='Extraction',
...     technology='python',# technology id corresponding to your context.id in your technology catalog definition
...     technology_catalog='Saagie',
...     runtime_version='3.9',
...     command_line='python {file}',
...     release_note='First release',
...     extra_technology='',
...     extra_technology_version='',
...     cron_scheduling='0 0 * * *',
...     schedule_timezone='Europe/Paris',
...     resources={"cpu": {"request": 0.5, "limit": 2.6}, "memory": {"request": 1.0}},
...     emails=['email1@saagie.io', 'email2@saagie.io'],
...     status_list=["FAILED", "KILLED"]
... )
{
    "data":{
        "createJob":{
            "id":"60f46dce-c869-40c3-a2e5-1d7765a806db",
            "versions":[
                {
                    "number":1,
                    "__typename":"JobVersion"
                }
            ],
            "__typename":"Job"
        }
    }
}
create_or_upgrade(job_name: str, project_id: str, file: str = None, use_previous_artifact: bool = True, description: str = None, category: str = None, technology: str = None, technology_catalog: str = None, runtime_version: str = None, command_line: str = None, release_note: str = None, extra_technology: str = None, extra_technology_version: str = None, is_scheduled: bool = None, cron_scheduling: str = None, schedule_timezone: str = 'UTC', resources: Dict = None, emails: List = None, status_list: List = None) Dict

Create or upgrade a job

Parameters:
  • job_name (str) – Name of your job

  • project_id (str) – UUID of your project

  • file (str (optional)) – Path to your file

  • use_previous_artifact (bool (optional)) – Use previous artifact

  • description (str (optional)) – Description of your job

  • category (str (optional)) – Category of your job

  • technology (str (optional)) – Technology of your job

  • technology_catalog (str (optional)) – Technology catalog of your job

  • runtime_version (str (optional)) – Runtime version

  • command_line (str (optional)) – Command line

  • release_note (str (optional)) – Release note

  • extra_technology (str (optional)) – Extra technology when needed (spark jobs). If not needed, leave to None or the request will not work

  • extra_technology_version (str (optional)) – Version of the extra technology. Leave to None when not needed

  • is_scheduled (bool (optional)) – True if the job is scheduled, False to deactivate scheduling

  • cron_scheduling (str (optional)) – Cron scheduling

  • schedule_timezone (str (optional)) – Schedule timezone

  • resources (dict (optional)) – Resources

  • emails (list (optional)) – Emails

  • status_list (list (optional)) – Status list

Returns:

Either the same dict as create_job, or the one returned by concatenation of upgrade_job and edit_job

Return type:

dict

Examples

>>> saagieapi.jobs.create_or_upgrade(
...     job_name="my job",
...     project_id="860b8dc8-e634-4c98-b2e7-f9ec32ab4771",
...     file="/tmp/test.py",
...     use_previous_artifact=False,
...     description='My description',
...     category='Extraction',
...     technology='python',# technology id corresponding to your context.id in your technology catalog definition
...     technology_catalog='Saagie',
...     runtime_version='3.9',
...     command_line='python {file}',
...     release_note='First release',
...     extra_technology='',
...     extra_technology_version='',
...     cron_scheduling='0 0 * * *',
...     schedule_timezone='Europe/Paris',
...     resources={"cpu": {"request": 0.5, "limit": 2.6}, "memory": {"request": 1.0}},
...     emails=['email1@saagie.io', 'email2@saagie.io'],
...     status_list=["FAILED", "KILLED"]
... )
{
    "data":{
        "createJob":{
            "id":"60f46dce-c869-40c3-a2e5-1d7765a806db",
            "versions":[
                {
                    "number":1,
                    "__typename":"JobVersion"
                }
            ],
            "__typename":"Job"
        }
    }
}
delete(job_id: str) Dict

Delete a given job

Parameters:

job_id (str) – UUID of your job (see README on how to find it)

Returns:

Dict of deleted job

Return type:

dict

Examples

>>> saagieapi.jobs.delete(job_id="f5fce22d-2152-4a01-8c6a-4c2eb4808b6d")
{
    "deleteJob": True
}
delete_instances(job_id, job_instances_id)

Delete given job’s instances NB: You can only delete an instance not associated to a pipeline instance Also you can only delete instances if they aren’t processing by the orchestrator

Parameters:
  • job_id (str) – UUID of your job (see README on how to find it)

  • job_instances_id ([str]) – List of UUID of instances to delete (see README on how to find it)

Returns:

Dict of deleted instances

Return type:

dict

Examples

>>> saagie_api.jobs.delete_instances(
...     job_id=job_id,
...     job_instances_id=["c8f156bc-78ab-4dda-acff-bbe828237fd9", "7e5549cd-32aa-42c4-88b5-ddf5f3087502"]
... )
{
    'deleteJobInstances': [
        {'id': '7e5549cd-32aa-42c4-88b5-ddf5f3087502', 'success': True},
        {'id': 'c8f156bc-78ab-4dda-acff-bbe828237fd9', 'success': True}
    ]
}
delete_instances_by_selector(job_id, selector, exclude_instances_id: List = None, include_instances_id: List = None)

Delete given job’s instances by selector NB: You can only delete an instance not associated to a pipeline instance. Also you can only delete instances if they aren’t processing by the orchestrator

Parameters:
  • job_id (str) – UUID of your job (see README on how to find it)

  • selector (str) – Name of status to select in this list : ALL, SUCCEEDED, FAILED, STOPPED, UNKNOWN

  • exclude_instances_id ([str]) – List of UUID of instances of your job to exclude from the deletion

  • include_instances_id ([str]) – List of UUID of instances of your job to include from the deletion

Returns:

Return the number of instances deleted

Return type:

Dict

Examples

>>> saagie_api.jobs.delete_instances_by_selector(
...     job_id=job_id,
...     selector="FAILED",
...     exclude_instances_id=["478d48d4-1609-4bf0-883d-097d43709aa8"],
...     include_instances_id=["47d3df2c-5a38-4a5e-a49e-5405ad8f1699"]
... )
{
    'deleteJobInstancesBySelector': 1
}
delete_versions(job_id, versions)

Delete given job’s versions NB: You can only delete a version not associated to a pipeline instance

Parameters:
  • job_id (str) – UUID of your job (see README on how to find it)

  • versions ([str]) – List of version numbers to delete

Returns:

Dict of deleted versions with their number and success status

Return type:

dict

Examples

>>> saagie_api.jobs.delete_versions(
...     job_id=job_id,
...     versions=["1"]
... )
{
    'deleteJobVersions': [
        {'number': 1, 'success': True}
    ]
}
duplicate(job_id)

Duplicate a given job

Parameters:

job_id (str) – UUID of your job (see README on how to find it)

Returns:

Dict of duplicate job with its id and name

Return type:

dict

Examples

>>> saagie_api.jobs.duplicate(job_id=job_id)
{
    'duplicateJob': {
        'id': '29cf1b80-6b9c-47bc-a06c-c20897257097',
        'name': 'Copy of my_job 2'
    }
}
edit(job_id: str, job_name: str = None, description: str = None, is_scheduled: bool = None, cron_scheduling: str = None, schedule_timezone: str = 'UTC', resources: Dict = None, emails: List = None, status_list: List = None) Dict

Edit a job

Parameters:
  • job_id (str) – UUID of your job (see README on how to find it)

  • job_name (str, optional) – Job name If not filled, defaults to current value, else it will change the job’s name

  • description (str, optional) – Description of job if not filled, defaults to current value, else it will change the description of the pipeline

  • is_scheduled (bool, optional) – True if the job is scheduled, else False if not filled, defaults to current value

  • cron_scheduling (str, optional) – Scheduling CRON format When is_scheduled is set to True, it will be mandatory to fill this value if not filled, defaults to current value Example: “0 0 * * *” (for every day At 00:00)

  • schedule_timezone (str, optional) – Timezone of the scheduling Example: “UTC”, “Pacific/Pago_Pago”

  • resources (dict, optional) – CPU, memory limit and requests if not filled, defaults to current value Example: {“cpu”:{“request”:0.5, “limit”:2.6},”memory”:{“request”:1.0}}

  • emails (List[String], optional) – Emails to receive alerts for the job, each item should be a valid email, If you want to remove alerting, please set emails to [] or list() if not filled, defaults to current value

  • status_list (List[String], optional) – Receive an email when the job status change to a specific status Each item of the list should be one of these following values: “REQUESTED”, “QUEUED”, “RUNNING”, “FAILED”, “KILLED”, “KILLING”, “SUCCEEDED”, “UNKNOWN”, “AWAITING”, “SKIPPED”

Returns:

Dict of job information

Return type:

dict

Examples

>>> saagieapi.jobs.edit(
...     job_id="60f46dce-c869-40c3-a2e5-1d7765a806db",
...     job_name="newname",
...     description="new desc",
...     is_scheduled=True,
...     cron_scheduling='0 * * * *',
...     schedule_timezone='Europe/Paris',
...     resources={"cpu": {"request": 1.5, "limit": 2.2}, "memory": {"request": 2.0}},
...     emails=['email1@saagie.io'],
...     status_list=["FAILED", "QUEUED"]
... )
{
    "editJob": {
        "id": "60f46dce-c869-40c3-a2e5-1d7765a806db",
        "name": "newname",
        "alias": "newname",
        "description": "new desc",
        "isScheduled": True,
        "cronScheduling": "0 * * * *",
        "scheduleTimezone": "Europe/Paris",
        "resources": {
            "cpu": {
                "request": 1.5,
                "limit": 2.2
            },
            "memory": {
                "request": 2.0,
                "limit": None
            }
        },
        "alerting": {
            "emails": [
                "email1@saagie.io"
            ],
            "statusList": [
                "FAILED",
                "QUEUED"
            ]
        }
    }
}
export(job_id: str, output_folder: str, error_folder: str | None = '', versions_limit: int | None = None, versions_only_current: bool = False) bool

Export the job in a folder

Parameters:
  • job_id (str) – Job ID

  • output_folder (str) – Path to store the exported job

  • error_folder (str, optional) – Path to store the job ID in case of error. If not set, job ID is not write

  • versions_limit (int, optional) – Maximum limit of versions to fetch per job. Fetch from most recent to the oldest

  • versions_only_current (bool, optional) – Whether to only fetch the current version of each job

Returns:

True if job is exported False otherwise

Return type:

bool

Examples

>>> saagieapi.jobs.export(
...    job_id="f5fce22d-2152-4a01-8c6a-4c2eb4808b6d",
...    output_folder="./output/job/",
...    error_folder="./output/error/",
...    versions_only_current=True
... )
True
get_id(job_name: str, project_name: str) str

Get the job id with the job name and project name

Parameters:
  • job_name (str) – Name of your job

  • project_name (str) – Name of your project

Returns:

Job UUID

Return type:

str

Examples

>>> saagieapi.jobs.get_id(
...     project_name="Test project",
...     job_name="Python test job"
... )
"f5fce22d-2152-4a01-8c6a-4c2eb4808b6d"
get_info(job_id: str, instances_limit: int | None = None, versions_limit: int | None = None, versions_only_current: bool = False, pprint_result: bool | None = None) Dict

Get job’s info

Parameters:
  • job_id (str) – UUID of your job

  • instances_limit (int, optional) – Maximum limit of instances to fetch per job. Fetch from most recent to oldest

  • versions_limit (int, optional) – Maximum limit of versions to fetch per job. Fetch from most recent to oldest

  • versions_only_current (bool, optional) – Whether to only fetch the current version of each job

  • pprint_result (bool, optional) – Whether to pretty print the result of the query, default to saagie_api.pprint_global

Returns:

Dict of job’s info

Return type:

dict

Examples

>>> saagieapi.jobs.get_info(
...     job_id="f5fce22d-2152-4a01-8c6a-4c2eb4808b6d",
...     instances_limit=2
... )
{
    "job": {
        "id": "f5fce22d-2152-4a01-8c6a-4c2eb4808b6d",
        "name": "Python test job",
        "description": "Amazing python job",
        "alerting": None,
        "countJobInstance": 5,
        "instances": [
            {
                "id": "61f6175a-fd38-4fac-9fa9-a7b63554f14e",
                "status": "SUCCEEDED",
                "history": {
                    "currentStatus": {
                        "status": "SUCCEEDED",
                        "details": None,
                        "reason": None
                    }
                },
                "startTime": "2022-04-19T13:46:40.045Z",
                "endTime": "2022-04-19T13:46:47.708Z",
                "version": {
                    "number": 1,
                    "releaseNote": "",
                    "runtimeVersion": "3.7",
                    "commandLine": "python {file} arg1 arg2",
                    "isMajor": False,
                    "doesUseGPU": False
                }
            },
            {
                "id": "befe73b2-81ab-418f-bc2f-9d012102a895",
                "status": "SUCCEEDED",
                "history": {
                    "currentStatus": {
                        "status": "SUCCEEDED",
                        "details": None,
                        "reason": None
                    }
                },
                "startTime": "2022-04-19T13:45:49.783Z",
                "endTime": "2022-04-19T13:45:57.388Z",
                "version":{
                    "number": 1,
                    "releaseNote": "",
                    "runtimeVersion": "3.7",
                    "commandLine": "python {file} arg1 arg2",
                    "isMajor": False,
                    "doesUseGPU": False
                }
            }
        ],
        "versions": [
            {
                "number": 1,
                "creationDate": "2022-04-26T08:16:20.681Z",
                "releaseNote": "",
                "runtimeVersion": "3.7",
                "commandLine": "python {file} arg1 arg2",
                "packageInfo": {
                    "name": "test.py",
                    "downloadUrl": "/projects/api/platform/6/project/860b8dc8-e634-4c98-b2e7-f9ec32ab4771/job/f5fce22d-2152-4a01-8c6a-4c2eb4808b6d/version/1/artifact/test.py"
                },
                "dockerInfo": None,
                "extraTechnology": None,
                "isCurrent": True,
                "isMajor": False
            }
        ],
        "category": "Extraction",
        "technology": {
            "id": "0db6d0a7-ad4b-45cd-8082-913a192daa25"
        },
        "isScheduled": False,
        "cronScheduling": None,
        "scheduleStatus": None,
        "scheduleTimezone": "UTC",
        "isStreaming": False,
        "creationDate": "2022-04-26T08:16:20.681Z",
        "migrationStatus": None,
        "migrationProjectId": None,
        "isDeletable": True,
        "graphPipelines": [],
        "doesUseGPU": False,
        "resources": None
    }
}
get_instance(job_instance_id: str, pprint_result: bool | None = None) Dict

Get the given job instance

Parameters:
  • job_instance_id (str) – UUID of your job instance (see README on how to find it)

  • pprint_result (bool, optional) – Whether to pretty print the result of the query, default to saagie_api.pprint_global

Returns:

Dict of instance information

Return type:

dict

Examples

>>> saagieapi.jobs.get_instance(job_instance_id="befe73b2-81ab-418f-bc2f-9d012102a895")
{
    "jobInstance": {
        "id": "befe73b2-81ab-418f-bc2f-9d012102a895",
        "number": 1,
        "status": "SUCCEEDED",
        "history": {
            "currentStatus": {
                "status": "SUCCEEDED",
                "details": None,
                "reason": None
            }
        },
        "startTime": "2022-04-19T13:45:49.783Z",
        "endTime": "2022-04-19T13:45:57.388Z",
        "jobId": "f5fce22d-2152-4a01-8c6a-4c2eb4808b6d",
        "version":{
            "number": 1,
            "releaseNote": "",
            "runtimeVersion": "3.7",
            "commandLine": "python {file} arg1 arg2",
            "isMajor": False,
            "isCurrent": True
        }
        "executionGlobalVariablesInput": [
            {
                "key": "TEST_PASSWORD",
                "value": None,
                "isPassword": True
            },
            {
                "key": "TEST_PROJECT",
                "value": "TEST_PROJECT",
                "isPassword": False
            }
        ],
        "executionVariablesInput": [
            {
                "parentJobInstanceId": None,
                "parentJobId": None,
                "parentJobAlias": None,
                "isDirectParent": None,
                "executionVariables": [
                    {
                        "key": "TEST_PASSWORD",
                        "value": None,
                        "isPassword": True
                    },
                    {
                        "key": "TEST_PROJECT",
                        "value": "TEST_PROJECT",
                        "isPassword": False
                    }
                ],
                "isGlobalVariables": True
            }
        ],
        "executionVariablesOutput": None,
        "executionVariablesByKey": []
    }
}
import_from_json(project_id: str, path_to_folder: str) bool

Import a job from JSON format

Parameters:
  • project_id (str) – Project ID to import the job

  • path_to_folder (str) – Path to the folder of the job to import

Returns:

True if job is imported False otherwise

Return type:

bool

Examples

>>> saagieapi.jobs.import_from_json(
...     project_id="860b8dc8-e634-4c98-b2e7-f9ec32ab4771",
...     path_to_package="/path/to/the/package/of/the/job"
... )
True
list_for_project(project_id: str, instances_limit: int | None = None, versions_limit: int | None = None, versions_only_current: bool = False, pprint_result: bool | None = None) Dict

List jobs in the given project with their instances. NB: You can only list jobs if you have at least the viewer role on the project

Parameters:
  • project_id (str) – UUID of your project (see README on how to find it)

  • instances_limit (int, optional) – Maximum limit of instances to fetch per job. Fetch from most recent to oldest

  • versions_limit (int, optional) – Maximum limit of versions to fetch per job. Fetch from most recent to oldest

  • versions_only_current (bool, optional) – Whether to only fetch the current version of each job

  • pprint_result (bool, optional) – Whether to pretty print the result of the query, default to saagie_api.pprint_global

Returns:

Dict of jobs information

Return type:

dict

Examples

>>> saagieapi.jobs.list_for_project(
...     project_id="860b8dc8-e634-4c98-b2e7-f9ec32ab4771",
...     instances_limit=2
... )
{
    "jobs": [
        {
            "id": "fc7b6f52-5c3e-45bb-9a5f-a34bcea0fc10",
            "name": "Python test job 1",
            "description": "Amazing python job",
            "alerting": None,
            "countJobInstance": 0,
            "instances": [],
            "versions": [
                {
                    "number": 1,
                    "creationDate": "2022-04-26T12:08:15.286Z",
                    "releaseNote": "",
                    "runtimeVersion": "3.7",
                    "commandLine": "python {file} arg1 arg2",
                    "packageInfo": {
                        "name": "_tmp_test.py",
                        "downloadUrl": "/projects/api/platform/6/project/860b8dc8-e634-4c98-b2e7-f9ec32ab4771/job/fc7b6f52-5c3e-45bb-9a5f-a34bcea0fc10/version/1/artifact/_tmp_test.py"
                    },
                    "dockerInfo": None,
                    "extraTechnology": None,
                    "isCurrent": True,
                    "isMajor": False
                }
            ],
            "category": "Extraction",
            "technology": {
                "id": "0db6d0a7-ad4b-45cd-8082-913a192daa25"
            },
            "isScheduled": False,
            "cronScheduling": None,
            "scheduleTimezone": "UTC",
            "scheduleStatus": None,
            "isStreaming": False,
            "creationDate": "2022-04-26T12:08:15.286Z",
            "migrationStatus": None,
            "migrationProjectId": None,
            "isDeletable": True,
            "pipelines": [],
            "graphPipelines": [],
            "doesUseGPU": False,
            "resources": None
        }
    ]
}
list_for_project_minimal(project_id: str) Dict

List only job names and ids in the given project . NB: You can only list jobs if you have at least the viewer role on the project

Parameters:

project_id (str) – UUID of your project (see README on how to find it)

Returns:

Dict of jobs ids and names

Return type:

dict

Examples

>>> saagieapi.jobs.list_for_project_minimal(project_id="860b8dc8-e634-4c98-b2e7-f9ec32ab4771")
{
    "jobs": [
        {
            "id": "fc7b6f52-5c3e-45bb-9a5f-a34bcea0fc10",
            "name": "Python test job 1",
            "alias": "Python_test_job_1"
        },
        {
            "id": "e92ed170-50d6-4041-bba9-098a8e16f444",
            "name": "Python test job 2",
            "alias": "Python_test_job_2"
        }
    ]
}
rollback(job_id: str, version_number: str)

Rollback a given job to the given version

Parameters:
  • job_id (str) – UUID of your job (see README on how to find it)

  • version_number (str) – Number of the version to rollback

Returns:

Dict of rollback job

Return type:

dict

Examples

>>> saagie_api.jobs.rollback(
...     job_id="58870149-5f1c-45e9-93dc-04b2b30a732c",
...     version_number=3
... )
{
    "rollbackJobVersion": {
        "id": "58870149-5f1c-45e9-93dc-04b2b30a732c",
        "versions": [
            {
                "number": 4,
                "isCurrent": False
            },
            {
                "number": 3,
                "isCurrent": True
            },
            {
                "number": 2,
                "isCurrent": False
            },
            {
                "number": 1,
                "isCurrent": False
            }
        ]
    }
}
run(job_id: str) Dict

Run a given job

Parameters:

job_id (str) – UUID of your job (see README on how to find it)

Returns:

Dict of the given job information

Return type:

dict

Examples

>>> saagieapi.jobs.run(job_id="f5fce22d-2152-4a01-8c6a-4c2eb4808b6d")
{
    "runJob":{
        "id":"5b9fc971-1c4e-4e45-a978-5851caef0162",
        "status":"REQUESTED"
    }
}
run_with_callback(job_id: str, freq: int = 10, timeout: int = -1) Dict

Run a job and wait for the final status (KILLED, FAILED, UNKNOWN or SUCCESS). Regularly check (default to 10s) the job’s status.

Parameters:
  • job_id (str) – UUID of your job (see README on how to find it)

  • freq (int, optional) – Seconds to wait between two state checks

  • timeout (int, optional) – Seconds before timeout for a status check call

Returns:

(Final state of the job, job instance id)

Return type:

(str, str)

Raises:

TimeoutError – When the status check is not responding

Examples

>>> saagieapi.jobs.run_with_callback(
...        job_id="f5fce22d-2152-4a01-8c6a-4c2eb4808b6d",
...        freq=5,
...        timeout=60
... )
("SUCCEEDED", "5b9fc971-1c4e-4e45-a978-5851caef0162")
stop(job_instance_id: str) Dict

Stop a given job instance

Parameters:

job_instance_id (str) – UUID of your job instance (see README on how to find it)

Returns:

Job instance information

Return type:

dict

Examples

>>> saagieapi.jobs.stop(job_instance_id="8e9b9f16-4a5d-4188-a967-1a96b88e4358")
{
    "stopJobInstance":{
        "id":"8e9b9f16-4a5d-4188-a967-1a96b88e4358",
        "number":17,
        "status":"KILLING",
        "history": {
            "currentStatus": {
                "status": "SUCCEEDED",
                "details": None,
                "reason": None
            }
        },
        "startTime":"2022-04-29T08:38:49.344Z",
        "endTime":None,
        "jobId":"e92ed472-50d6-4041-bba9-098a8e16f444"
    }
}
upgrade(job_id: str, file: str = None, use_previous_artifact: bool = True, runtime_version: str = None, command_line: str = None, release_note: str = '', extra_technology: str = None, extra_technology_version: str = None) Dict

Upgrade a job

Parameters:
  • job_id (str) – UUID of your job

  • file (str (optional)) – Path to your file

  • use_previous_artifact (bool (optional)) – Use previous artifact

  • runtime_version (str (optional)) – Runtime version, the ID of the context Example: “3.10”

  • command_line (str (optional)) – Command line used to run the job Example: “python3 {file} arg1 arg2”

  • release_note (str (optional)) – Release note

  • extra_technology (str (optional)) – Extra technology when needed (spark jobs). If not needed, leave to None or the request will not work

  • extra_technology_version (str (optional)) – Version of the extra technology. Leave to None when not needed

Returns:

Dict with version number

Return type:

dict

Examples

>>> saagieapi.jobs.upgrade(
...     job_id="60f46dce-c869-40c3-a2e5-1d7765a806db",
...     use_previous_artifact=True,
...     runtime_version='3.8',
...     command_line='python {file} new_arg',
...     release_note="Second version"
... )
{
    "data":{
        "addJobVersion":{
            "number":2,
            "__typename":"JobVersion"
        }
    }
}
upgrade_by_name(job_name: str, project_name: str, file=None, use_previous_artifact: bool = True, runtime_version: str = None, command_line: str = None, release_note: str = None, extra_technology: str = None, extra_technology_version: str = None) Dict

Upgrade a job

Parameters:
  • job_name (str) – Name of your job

  • project_name (str) – Name of your project

  • file (str (optional)) – Path to your file

  • use_previous_artifact (bool (optional)) – Use previous artifact

  • runtime_version (str (optional)) – Runtime version

  • command_line (str (optional)) – Command line

  • release_note (str (optional)) – Release note

  • extra_technology (str (optional)) – Extra technology when needed (spark jobs). If not needed, leave to None or the request will not work

  • extra_technology_version (str (optional)) – Version of the extra technology. Leave to None when not needed

Returns:

Dict with version number

Return type:

dict

Examples

>>> saagieapi.jobs.upgrade_by_name(
...     job_name="my job",
...     project_name="My project",
...     use_previous_artifact=True,
...     runtime_version='3.8',
...     command_line='python {file} new_arg',
...     release_note="Second version"
... )
{
    "data":{
        "addJobVersion":{
            "number":3,
            "__typename":"JobVersion"
        }
    }
}