メインコンテンツまでスキップ

Create a launch job

A job is a blueprint that contains contextual information about a W&B run it is created from; such as the run's source code, software dependencies, hyperparameters, artifact version, and so forth.

Once you have a launch job, you can add them to a pre-configured launch queue. The launch agent that was deployed by you or someone on your team, will poll that queue and send the job (as a Docker image) to the compute resource that was configured on launch queue.

There are three ways to create a launch job:

  • With a Python script
  • With a Docker image
  • With Git repository

The following sections show how to create a job based on each use case.

Before you get started

Before you create a launch job, find out the name of your queue and the entity it belongs to. Then, follow these instructions to find out the status of your queue and to check if an agent is polling that queue:

  1. Navigate to wandb.ai/launch.
  2. From the All entities dropdown, select the entity the launch queue belongs to. This will filter queues based on W&B entities.
  3. From the filtered results, check that the queue exists.
  4. Hover your mouse to the right of the launch queue and select View queue.
  5. Select the Agents tab. Within the Agents tab you sill see a list of Agent IDs and their statuses. Ensure that one of the agent IDs has a polling status.

Create a job with a W&B artifact

Create a launch job with with the W&B CLI.

Ensure the path with your Python script has a requirements.txt file with the Python dependencies required to run your code. A Python runtime is also required. The python runtime can either be specified manually with the runtime parameter or can be auto-detected from a runtime.txt or .python-version file.

Copy and paste the following code snippet. Replace the values within "<>" based on your use case:

wandb job create --project "<project-name>" -e "<your-entity>" \ 
--name "<name-for-job>" code "<path-to-script/code.py>"

For a full list of flags you can use, see the wandb job create command documentation.

注記

You do not need to use the run.log_code() function within your Python script when you create a launch job with the W&B CLI.

Create a job with a Docker image

Create a job with a Docker image with the W&B CLI or by creating a Docker container from the image. To create an image-based job, you must first create the Docker image. The Docker image should contain the source code (such as the Dockerfile, requirements.txt file, and so on) required to execute the W&B run.

As an example, suppose we have a directory called fashion_mnist_train with the following directory structure:

fashion_mnist_train
│ data_loader.py
│ Dockerfile
│ job.py
│ requirements.txt
└───configs
│ │ example.yml

We create a Docker image called fashion-mnist with the docker build command:

docker build . -t fashion-mnist 

For more information on how to build Docker images, see the Docker build reference documentation.

Create a launch job with the W&B CLI. Copy the following code snippet and replace the values within "<>" based on your use case:

wandb job create --project "<project-name>" --entity "<your-entity>" \ 
--name "<name-for-job>" image image-name:tag

For a full list of flags you can use, see the wandb job create command documentation.

Create a job with Git

Create a Git-based job with W&B Launch. Code and other assets are cloned from a certain commit, branch, or tag in a git repository.

wandb job create --project "<project-name>" --entity "<your-entity>" \ 
--name "<name-for-job>" git https://github.com/repo-name \
--entry-point "<path-to-script/code.py>"

Launch job names

By default, W&B automatically generates a job name for you. The name is generated depending on how the job is created (GitHub, code artifact, or Docker image). Alternatively, you can define a launch job's name with environment variables or with the W&B Python SDK.

Default launch job names

The following table describes the job naming convention used by default based on job source:

SourceNaming convention
GitHubjob-<git-remote-url>-<path-to-script>
Code artifactjob-<code-artifact-name>
Docker imagejob-<image-name>

Name your launch job

Name your job with a W&B environment variable or with the W&B Python SDK

Set the WANDB_JOB_NAME environment variable to your preferred job name. For example:

WANDB_JOB_NAME=awesome-job-name
注記

For docker image jobs, the version alias is automatically added as an alias to the job.

Was this page helpful?👍👎