# Jobs

> Jobs - Learn how to manage and monitor jobs in DataRobot projects, including model creation jobs and
> queue management.

This Markdown file sits beside the HTML page at the same path (with a `.md` suffix). It summarizes the topic and lists links for tools and LLM context.

Companion generated at `2026-04-24T16:03:56.286013+00:00` (UTC).

## Primary page

- [Jobs](https://docs.datarobot.com/en/docs/api/dev-learning/python/modeling/job.html): Full documentation for this topic (HTML).

## Sections on this page

- [Check the contents of the queue](https://docs.datarobot.com/en/docs/api/dev-learning/python/modeling/job.html#check-the-contents-of-the-queue): In-page section heading.
- [Cancel a job](https://docs.datarobot.com/en/docs/api/dev-learning/python/modeling/job.html#cancel-a-job): In-page section heading.
- [Retrieve results from a job](https://docs.datarobot.com/en/docs/api/dev-learning/python/modeling/job.html#retrieve-results-from-a-job): In-page section heading.
- [Model jobs](https://docs.datarobot.com/en/docs/api/dev-learning/python/modeling/job.html#model-jobs): In-page section heading.
- [Get an existing model job](https://docs.datarobot.com/en/docs/api/dev-learning/python/modeling/job.html#get-an-existing-model-job): In-page section heading.
- [Get a created model](https://docs.datarobot.com/en/docs/api/dev-learning/python/modeling/job.html#get-a-created-model): In-page section heading.
- [Async model creation](https://docs.datarobot.com/en/docs/api/dev-learning/python/modeling/job.html#async-model-creation): In-page section heading.

## Related documentation

- [Developer documentation](https://docs.datarobot.com/en/docs/api/index.html): Linked from this page.
- [Developer learning](https://docs.datarobot.com/en/docs/api/dev-learning/index.html): Linked from this page.
- [Python API client user guide](https://docs.datarobot.com/en/docs/api/dev-learning/python/index.html): Linked from this page.
- [Modeling](https://docs.datarobot.com/en/docs/api/dev-learning/python/modeling/index.html): Linked from this page.
- [Job](https://docs.datarobot.com/en/docs/api/reference/sdk/jobs.html#jobs-api): Linked from this page.
- [wait_for_async_model_creation](https://docs.datarobot.com/en/docs/api/reference/sdk/datarobot-models.html#wait-for-async-model-creation-api-label): Linked from this page.

## Documentation content

# Jobs

The [Job](https://docs.datarobot.com/en/docs/api/reference/sdk/jobs.html#jobs-api) class is a generic representation of jobs running in a project's queue.
Many tasks for modeling, such as creating a new model or computing Feature Impact for a model, use a job to track the worker usage and progress of the associated task.

## Check the contents of the queue

To see what jobs running or waiting in the queue for a project, use the `Project.get_all_jobs` method.

```
from datarobot.enums import QUEUE_STATUS

jobs_list = project.get_all_jobs()  # gives all jobs queued or inprogress
jobs_by_type = {}
for job in jobs_list:
    if job.job_type not in jobs_by_type:
        jobs_by_type[job.job_type] = [0, 0]
    if job.status == QUEUE_STATUS.QUEUE:
        jobs_by_type[job.job_type][0] += 1
    else:
        jobs_by_type[job.job_type][1] += 1
for type in jobs_by_type:
    (num_queued, num_inprogress) = jobs_by_type[type]
    print('{} jobs: {} queued, {} inprogress'.format(type, num_queued, num_inprogress))
```

## Cancel a job

If a job is taking too long to run or no longer necessary, it can be cancelled from the `Job` object.

```
from datarobot.enums import QUEUE_STATUS

project.pause_autopilot()
bad_jobs = project.get_all_jobs(status=QUEUE_STATUS.QUEUE)
for job in bad_jobs:
    job.cancel()
project.unpause_autopilot()
```

## Retrieve results from a job

You can retrieve the results of a job once it is complete.
Note that the type of the returned object varies depending on the `job_type`.
All return types are documented in `Job.get_result`.

```
from datarobot.enums import JOB_TYPE

time_to_wait = 60 * 60  # how long to wait for the job to finish (in seconds) - i.e. an hour
assert my_job.job_type == JOB_TYPE.MODEL
my_model = my_job.get_result_when_complete(max_wait=time_to_wait)
```

### Model jobs

Model creation is an asynchronous process.
This means that when explicitly invoking new model creation (with `project.train` or `model.train` for example), all you get is the ID of the process responsible for model creation.
With this ID, you can get info about the model that is being created—or the model itself, once the creation process is finished—by using the `ModelJob` class.

## Get an existing model job

To retrieve existing model jobs, use the `ModelJob.get` method.
For this, you need the ID of the project from which the model was built and the ID of the model job.
The model job is useful if you want to know the parameters for a model’s creation (automatically chosen by the API backend) before the actual model was created.

If the model is already created, `ModelJob.get` will raise the `PendingJobFinished` exception.

```
import time

import datarobot as dr

blueprint_id = '5506fcd38bd88f5953219da0'
model_job_id = project.train(blueprint_id)
model_job = dr.ModelJob.get(project_id=project.id,
                            model_job_id=model_job_id)
model_job.sample_pct
>>> 64.0

# wait for model to be created (in a very inefficient way)
time.sleep(10 * 60)
model_job = dr.ModelJob.get(project_id=project.id,
                            model_job_id=model_job_id)
>>> datarobot.errors.PendingJobFinished

# get the job attached to the model
model_job.model
>>> Model('5d518cd3962d741512605e2b')
```

## Get a created model

After a model is created, you can use `ModelJob.get_model` to get the newly-created model.

```
import datarobot as dr

model = dr.ModelJob.get_model(project_id=project.id,
                              model_job_id=model_job_id)
```

## Async model creation

If you want to get the created model after getting the model job ID, you can use the [wait_for_async_model_creation](https://docs.datarobot.com/en/docs/api/reference/sdk/datarobot-models.html#wait-for-async-model-creation-api-label) function.
It will poll for the status of the model creation process until it’s finished, and then return the newly-created model.
Note the differences below between datetime partitioned projects and non-datetime partitioned projects.

```
from datarobot.models.modeljob import wait_for_async_model_creation

# Used during training based on blueprint
model_job_id = project.train(blueprint, sample_pct=33)
new_model = wait_for_async_model_creation(
    project_id=project.id,
    model_job_id=model_job_id,
)

# Used during training based on existing model
model_job_id = existing_model.train(sample_pct=33)
new_model = wait_for_async_model_creation(
    project_id=existing_model.project_id,
    model_job_id=model_job_id,
)

# For datetime-partitioned projects, use project.train_datetime. Note that train_datetime returns a model job instead
# of just an ID.
model_job = project.train_datetime(blueprint)
new_model = wait_for_async_model_creation(
    project_id=project.id,
    model_job_id=model_job.id
)
```
