> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prophecy.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Jobs

> Schedule models in SQL projects with Databricks Jobs or Airflow

A job runs your project's models on a schedule using an external orchestrator: Databricks Jobs or Airflow. Use a job when you want to schedule models on their own, without a pipeline.

> [!NOTE]
>
> Jobs are available in the Enterprise Edition. See [Editions](https://docs.prophecy.ai/administration/platform/editions.md).

## Jobs and pipeline schedules

Jobs and [pipeline schedules](https://docs.prophecy.ai/data-analysis/production/scheduling/schedule-setup.md) both automate runs, but they run on different fabrics:

| | Pipeline schedules | Jobs |
| - | - | - |
| What runs | Pipelines | Models |
| Orchestrator | Prophecy's built-in scheduler | Databricks Jobs or Airflow |
| Fabric | Prophecy fabric | Databricks or Airflow fabric |
| Where you set it up | The pipeline's **Schedule** option | A job entity in the project |

## Create a job

To create a job:

1. In the left sidebar of the project, click **+ Add Entity** > **Job**.

2. In the **Create Job** dialog, fill in the following fields.

   | Field | Description |
   | - | - |
   | **Project** | The project that contains the job. When you create the job from inside a project, this field is filled in and can't be changed. |
   | **Branch** | The branch to create the job on. Appears only for projects that use the [Normal Git Storage Model](https://docs.prophecy.ai/data-analysis/development/versioning/git-storage-model.md). |
   | **Name** | The name of the job. |
   | **Scheduler** | The orchestrator that runs the job: **Databricks** or **Airflow**. See [Choose a scheduler](#choose-a-scheduler). |
   | **Fabric** | The Databricks or Airflow fabric that runs the job. The list shows fabrics for the scheduler you selected. |
   | **Job Size** | The cluster size for the job. Appears only for the Databricks scheduler when the fabric has job sizes. |
   | **Schedule Interval** | How often the job runs, as a cron expression. Databricks uses Quartz cron syntax. Airflow uses Unix cron syntax. |
   | **Description** | Optional. A description of the job. |
   | **Alerts on the full job** | Email alerts about the whole job run. Appears only for the Databricks scheduler. See [Job alerts](#job-alerts). |

3. Click **Create New**. The job opens on its own canvas.

### Choose a scheduler

* **Databricks**: Available only for Databricks SQL projects.
* **Airflow**: Available for SQL projects on any provider. Airflow appears only when it's enabled for your Prophecy deployment.

If your project doesn't use Databricks, Prophecy selects **Airflow** for you.

### Job alerts

For jobs that use the Databricks scheduler, you can send email alerts about the whole job run:

1. In **Alerts Email**, enter one or more email addresses, separated by commas.
2. Under **When should we send alerts**, turn on one or more of the following:
   * **on start**: When the job starts.
   * **on success**: When the job finishes successfully.
   * **on failure**: When the job fails.

## Build the job

Each gem on the job canvas is a task in the job. For Databricks jobs, the gem bar above the canvas has the following gems:

| Gem | Purpose |
| - | - |
| **Pipeline** | Runs a pipeline from the project. |
| **Script** | Runs a custom Python script. |
| **Notebook** | Runs a Databricks notebook. |
| **IfElse** | Branches the job based on a condition. |
| **RunJob** | Runs another job. |
| **Model** | Runs a model from the project. Appears only when [Show Models](https://docs.prophecy.ai/data-analysis/development/studio/development-settings.md#show-models) is on for the project. |

For details on configuring the **Script**, **Notebook**, **IfElse**, and **RunJob** gems, see [Databricks jobs](https://docs.prophecy.ai/data-engineering/orchestration/databricks-jobs.md#build-the-job).

### Add a model to a job

The **Model** gem runs either a single model or every model in a project. To add one:

1. If the gem bar doesn't show the **Model** gem, turn on [Show Models](https://docs.prophecy.ai/data-analysis/development/studio/development-settings.md#show-models) for the project.
2. Drag a **Model** gem to the job canvas.
3. Click the gem to open its properties.
4. Choose what to run and fill in the fields. See [Model gem settings](#model-gem-settings).
5. Click **Save**.

#### Model gem settings

The Model gem has two modes:

* **Run Entire Project**: Runs all models, tests, and seeds in the project.
* **Run a SQL model**: Runs one model from the project.

Both modes have the following fields:

| Field | Description |
| - | - |
| **Project** | The project to run, or the project that contains the model. |
| **SQL Model** | The model to run. Appears only in **Run a SQL model** mode. |
| **Fabric** | The fabric to run on. |
| **Git Target** | Whether to run from a branch or a tag. |
| **Reference Value** | The branch or tag to run from. |

The following options control which dbt commands run:

| Option | Description |
| - | - |
| **Pull most recent version of dependencies** | Runs `dbt deps` to refresh dependencies before the run. On by default. |
| **Run seeds** | Runs `dbt seed` before the run. On by default. |
| **Compile and execute against current target (run)** | Runs `dbt run` to compile and run the models. On by default. |
| **Run tests** | Runs `dbt test` after the models run. Off by default. See [Project tests](https://docs.prophecy.ai/data-analysis/development/tests/project-tests.md). |

## Deploy a job

A job runs on its schedule only after it's deployed to its fabric. Jobs deploy when you [publish the project](https://docs.prophecy.ai/data-analysis/production/publication/publish-project.md#publish-and-deploy-a-project) and select the job's Databricks or Airflow fabric. You can deploy jobs and pipelines in the same publish.

During publication, the schedule impact step lists the project's jobs:

* If **Selective job deployment** is on in the project settings, pick the jobs to deploy.
* If it's off, every job deploys.

If a job deployment fails, the publication logs open on the **Jobs** tab.

## Pause a job

To pause a job's schedule, turn off the **Job scheduling** toggle to the right of the gem bar on the job canvas. The change takes effect the next time you publish the project.

When you publish, Prophecy pauses the job's schedule on its fabric. If the job was never deployed to that fabric, Prophecy doesn't deploy it.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.