Viewing Job Runs

πŸ‘

What you'll learn

  • Different ways of viewing job runs via servicefoundry

This is a guide to viewing Job Runs via servicefoundry. This guide assumes you have deployed a job and triggered it at least once. If not, then please read the following documentation to know more about Deploying a Job.

Prerequisites for Viewing Job Runs

To view job runs, you will need the Application FQN of the job, and the Run Name of any job run of your choice. To accomplish this, you may get these programmatically. The following snippet should give you an idea of how to get these programmatically:

from servicefoundry import list_applications, trigger_job

# All jobs
applications = list_applications(application_type="job")
for application in applications:
    print(f"Application fqn of {application.name}:", application.fqn)

# Runs a job (Replace application_fqn according to your needs)
trigger_job_result = trigger_job(
    application_fqn=applications[0].fqn,
)
job_run_name = trigger_job_result.jobRunName
print("Newly created job run name:", job_run_name)

Apart from the above method, you may also go to the TrueFoundry Dashboard, click on Deployments, and then go to the Jobs section. Select any job that you have deployed. Your jobs deployment dashboard will look similar to this:

From the above page, copy the Application FQN, and the Run Name of any job run of your choice. Also, make sure that the version of servicefoundry library is >= 0.9.4 (use servicefoundry --version to see version)

Viewing List of Job Runs

Given a Job, there are 2 ways of seeing its list of job runs via servicefoundry. One way is through CLI, and the other is through Python SDK

πŸ“˜

In the command and python code shown below, make sure to replace with the Application FQN you copied in Step 1

  • Command-Line Interface
servicefoundry list job-run --application-fqn <your-application-fqn>

You can also use servicefoundry list job-run --help to see what more arguments can be passed. When using the command, you will get an output similar to this:

  • Python Function Example
from servicefoundry import list_job_runs

application_fqn = "<your-application-fqn>"
job_runs = list_job_runs(application_fqn=application_fqn)

print("Number of Job Runs:", len(job_runs))
for run in job_runs:
    print(f"Job name: {run.name}, status: {run.status}, command: {run.command}\n")

Viewing a Specific Job Run

Just like viewing a list of job runs, there are 2 ways of extracting a specific job run via servicefoundry. One way is through CLI, and the other is through Python SDK. Apart from Application FQN, Run Name will be used to extract a unique job run.

πŸ“˜

In the command and python code shown below, make sure to replace and with the Application FQN and Run Name you copied in Step 1 respectively

  • Command-Line Interface
servicefoundry get job-run --application-fqn <your-application-fqn> --job-run-name <your-job-run-name>

When using the command, you will get an output similar to this:

  • Python Function Example
from servicefoundry import get_job_run

application_fqn = "<your-application-fqn>"
job_run_name = "<your-job-run-name>"
job_run = get_job_run(application_fqn=application_fqn, job_run_name=job_run_name)

print(f"Job name: {job_run.name}, status: {job_run.status}, command: {job_run.command}")