Trigger a Job

πŸ‘

What you'll learn

  • Triggering Jobs via Python SDK and TrueFoundry Dashboard

This is a guide for triggering jobs via servicefoundry and TrueFoundry Dashboard. This guide assumes you have deployed a job previously. If not, then please refer to the Deploy a Job guide to know more about job deployment.

To trigger a job, you have two options:

Triggering a Job through TrueFoundry Dashboard

You can find the link to the Job Details from the Truefoundry dashboard on the Deployments page.

2668

Jobs list

You can trigger a job manually by Clicking the Trigger Job button from the Job Details UI.

2654

We can now visit our Applications page to check the Build status, Build Logs, Runs History and monitor the progress of runs. See Monitoring and Debugging guide for more details.

Triggering a Job Programmatically

Requires: servicefoundry library with version >= 0.8.0 (use servicefoundry --version to see version)

You can trigger your job programmatically by using the trigger_job function as shown below:

from servicefoundry import Job, trigger_job

# Configure a Job Deployment
job = Job(...)

# Deploy a Job
job_deployment = job.deploy(workspace_fqn="YOUR WORKSPACE FQN")

# Trigger/Run a Job
trigger_job(
  application_fqn=job_deployment.application_fqn, 
  command="YOUR COMMAND TO RUN JOB"
)

servicefoundry.trigger_job

Arguments:

  • application_fqn (str): Fully Qualified Name of the Deployed Job (without the version number)

  • command(Optional[Union[str, Sequence[str]]]): Command to run the job with, defaults to None. Can be a str or List[str]. When None, the job is triggered with configured command at the time of deployment. When passed as a list, the command will be joined using theshlex.join function.

  • params(Optional[Dict[str, str]]): Params to run the job with, defaults to None. Needs to be a Dict[str, str]. This is to be used when you have deployed a job with parameters. You can pass the param_name and param_value in a Dictionary and run the following:

    from servicefoundry import trigger_job
    
    trigger_job(
      application_fqn="tfy-ctl-euew1-devtest:tfy-demo:iris-train-job", 
      params={"kernel":"lin", "n_quantiles":"420"}
    )
    

Returns:

  • Deployment object

See Also