Skip to main content

How to Upload Artifacts from a Job

Jobs typically generate logs and Labscale will always upload those, however there are times when something other than a log file is necessary. Labscale provides a mechanism where a job can upload object created during execution. To do this, in your job script do the following:

  1. Simply get the artifacts folder path from the LS_JOB_artifacts_path environment variable.
  2. Create the folder in that location.
  3. Copy or move your generated objects into that folder.

When the job completes, the objects will be automatically archived and uploaded to the LabScale service where it can be downloaded to your desktop from the job page. Example code of how to do this wintin a job may look like the following:

import os

# First create the artifacts folder
artifactsDir = os.environ["LS_JOB_artifacts_path"]
os.mkdir(artifactsDir)

# Write a file into the folder
artifactPath = os.path.join(artifactsDir, "test-artifact.txt")
with open(artifactPath, "w") as f:
f.write("example artifact")

# When the job completes, the agent will
# automatically archive and upload the
# artifacts to the backend. Once there
# they can be downloaded from the job page.

Where to Find the Artifacts

Once the Job has completed, if artifacts are placed in the correct location, the Job page will show an artifacts field that reveals a link to download the archived set of artifacts.

Artifacts location in Job page

Revealed Artifacts in Job page