# Creating jobs in deployment spaces #

A job is a way of running a batch deployment, or a self\-contained asset like a script, notebook, code package, or flow in Watson Machine Learning\. You can select the input and output for your job and choose to run it manually or on a schedule\. From a deployment space, you can create, schedule, run, and manage jobs\.

## Creating a batch deployment job ##

Follow these steps when you are creating a batch deployment job:

Important: You must have an existing batch deployment to create a batch job\.

<!-- <ol> -->

1.  From the **Deployments** tab, select your deployment and click **New job**\. The *Create a job* dialog box opens\.
2.  In the *Define details* section, enter your job name, an optional description, and click **Next**\.
3.  In the *Configure* section, select a hardware specification\.  
    You can follow these steps to optionally configure environment variables and job run retention settings:
    
    <!-- <ul> -->
    
     *  Optional: If you are deploying a Python script, an R script, or a notebook, then you can enter environment variables to pass parameters to the job. Click **Environment variables** to enter the *key* - *value* pair.
     *  Optional: To avoid finishing resources by retaining all historical job metadata, follow one of these options:
        
        <!-- <ul> -->
        
         *  Click **By amount** to set thresholds for saving a set number of job runs and associated logs.
         *  Click **By duration (days)** to set thresholds for saving artifacts for a specified number of days.
        
        <!-- </ul> -->
        
    <!-- </ul> -->
    
4.  Optional: In the *Schedule* section, toggle the **Schedule off** button to schedule a run\. You can set a date and time for start of schedule and set a schedule for repetition\. Click **Next**\.
    
    Note: If you don't specify a schedule, the job runs immediately.
5.  Optional: In the *Notify* section, toggle the **Off** button to turn on notifications associated with this job\. Click **Next**\.
    
    Note: You can receive notifications for three types of events: success, warning, and failure.
6.  In the *Choose data* section, provide inline data that corresponds with your model schema\. You can provide input in JSON format\. Click **Next**\. See [Example JSON payload for inline data](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/create-jobs.html?context=cdpaas&locale=en#example-json)\.
7.  In the *Review and create* section, verify your job details, and click **Create and run**\.

<!-- </ol> -->

**Notes**:

<!-- <ul> -->

 *  Scheduled jobs display on the **Jobs** tab of the deployment space\.
 *  Results of job runs are written to the specified output file and saved as a space asset\.
 *  A data asset can be a data source file that you promoted to the space, a connected data source, or tables from databases and files from file\-based data sources\.
 *  If you exclude certain weekdays in your job schedule, the job might not run as you would expect\. The reason is due to a discrepancy between the time zone of the user who creates the schedule, and the time zone of the main node where the job runs\.
 *  When you create or modify a scheduled job, an API key is generated\. Future runs use this generated API key\.

<!-- </ul> -->

### Example JSON payload for inline data ###

    {
      "deployment": {
        "id": "<deployment id>"
      },
      "space_id": "<your space id>",
      "name": "test_v4_inline",
      "scoring": {
      "input_data": [{
        "fields": "AGE", "SEX", "BP", "CHOLESTEROL", "NA", "K"],
        "values": 47, "M", "LOW", "HIGH", 0.739, 0.056], 47, "M", "LOW", "HIGH", 0.739, 0.056]]
        }]
      }
    }

## Queuing and concurrent job executions ##

The maximum number of concurrent jobs for each deployment is handled internally by the deployment service\. For batch deployment, by default, two jobs can be run concurrently\. Any deployment job request for a batch deployment that already has two running jobs is placed in a queue for execution later\. When any of the running jobs is completed, the next job in the queue is run\. The queue has no size limit\.

## Limitation on using large inline payloads for batch deployments ##

Batch deployment jobs that use large inline payload might get stuck in `starting` or `running` state\.

Tip: If you provide huge payloads to batch deployments, use data references instead of inline\.

## Retention of deployment job metadata ##

Job\-related metadata is persisted and can be accessed until the job and its deployment are deleted\.

## Viewing deployment job details ##

When you create or view a batch job, the deployment ID and the job ID are displayed\.

![Job IDs](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/images/job-ids.png)

<!-- <ul> -->

 *  The deployment ID represents the deployment definition, including the hardware and software configurations and related assets\.
 *  The job ID represents the details for a job, including input data and an output location and a schedule for running the job\.

<!-- </ul> -->

Use these IDs to refer to the job in Watson Machine Learning [REST API](https://cloud.ibm.com/apidocs/machine-learning) requests or in notebooks that use the Watson Machine Learning [Python client library](https://ibm.github.io/watson-machine-learning-sdk/)\.

**Parent topic:**[Managing predictive deployments](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-deploy-general.html)

<!-- </article "role="article" "> -->