# Python Job

This feature allows users to write their own Python script and run their script in the ***Jobs*** section of ***Data Pipeline*** module.&#x20;

Before creating the ***Python Job***, the user has to create a project in the ***Data Science Lab*** module under ***Python Environment***. Please refer the below image for reference:&#x20;

<figure><img src="https://content.gitbook.com/content/6ZP8JhQPMmuTgMyLMcCU/blobs/9bwg9HzKlzx3ufvVuC9X/image.png" alt=""><figcaption><p><em><strong>Creating a Data Science Lab Project under Python Environment</strong></em></p></figcaption></figure>

After creating the Data Science project, the users need to activate it and create a Notebook where they can write their own Python script. Once the script is written, the user must save it and export it to be able to use it in the Python Jobs.

## **Creating a Python Job**

* Navigate to the ***Data Pipeline*** module homepage.&#x20;
* Open the pipeline homepage and click on the **Create** option.

<figure><img src="https://content.gitbook.com/content/6ZP8JhQPMmuTgMyLMcCU/blobs/80mWDrIs4yrhpHc8rcic/image.png" alt=""><figcaption><p><em><strong>Accessing the Create Job option from the Pipeline Homepage</strong></em></p></figcaption></figure>

* The new panel opens from right hand side. Click on ***Create*** button in Job option. &#x20;
  * Enter a name for the new Job.&#x20;
  * Describe the Job (Optional).&#x20;
  * **Job Baseinfo:** Select ***Python Job*** from the drop-down.&#x20;
  * **Trigger By:** There are 2 options for triggering a job on success or failure of a job:&#x20;
    * **Success Job:** On successful execution of the selected job the current job will be triggered.
    * **Failure Job:** On failure of the selected job the current job will be triggered.&#x20;
  * **Is Scheduled?**&#x20;
    * A job can be scheduled for a particular timestamp. Every time at the same timestamp the job will be triggered.&#x20;
    * Job must be scheduled according to UTC.&#x20;
  * **On demand:** Check the ***"On demand"*** option to create an on-demand job. For more information on ***Python Job (On demand)***, check [***here***](https://docs.bdb.ai/data-pipeline-5/getting-started/homepage/create/creating-a-new-job/python-job).
  * **Docker Configuration:** Select a resource allocation option using the radio button. The given choices are:&#x20;
    * **Low**&#x20;
    * **Medium**&#x20;
    * **High**
  * Provide the resources required to run the python Job in the limit and Request section.
    * **Limit:** Enter max CPU and Memory required for the Python Job.&#x20;
    * **Request:** Enter the CPU and Memory required for the job at the start. &#x20;
    * **Instances:** Enter the number of instances for the Python Job. &#x20;
  * **Alert:** Please refer to the [***Job Alerts***](https://docs.bdb.ai/data-pipeline-5/getting-started/homepage/create/creating-a-new-job/job-alerts) page to configure alerts in job.
  * Click the ***Save*** option to save the Python Job.

<figure><img src="https://2386645923-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6ZP8JhQPMmuTgMyLMcCU%2Fuploads%2FFdk5y2Ilj5kN0kQlYI1S%2Fimage.png?alt=media&#x26;token=8310e083-3bbc-4139-80c5-e776c3c2f038" alt=""><figcaption><p><em>Creating a Python Job</em></p></figcaption></figure>

* The Python Job gets saved, and it will redirect the users to the ***Job Editor*** workspace.&#x20;

<figure><img src="https://content.gitbook.com/content/6ZP8JhQPMmuTgMyLMcCU/blobs/6YcNEQTQOUroeF0FM43V/image.png" alt=""><figcaption><p><em><strong>Python Job workspace</strong></em></p></figcaption></figure>

{% hint style="success" %}
*Check out the below given demonstration configure a Python Job.*
{% endhint %}

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fc39ZvXI46qjXzpN3rYAg%2Fuploads%2FCCni6J9d5JobCv9eds4W%2F2023-11-14-17-51-13%20(online-video-cutter.com).mp4?alt=media&token=9920f2c1-40bd-4e5b-b0d9-860e745957a3>" %}
***Configuring Python Job***
{% endembed %}

## **Configuring the Meta Information of Python Job**

Once the Python Job is created, follow the below given steps to configure the ***Meta Information*** tab of the Python Job.&#x20;

* **Project Name:** Select the same Project using the drop-down menu where the Notebook has been created.&#x20;
* **Script Name:** This field will list the exported Notebook names which are exported from the Data Science Lab module to Data Pipeline.&#x20;
* **External Library:** If any external libraries are used in the script the user can mention it here. The user can mention multiple libraries by giving comma (,) in between the names.&#x20;
* **Start Function:** Here, all the function names used in the script will be listed. Select the start function name to execute the python script.
* **Script:** The Exported script appears under this space.&#x20;
* **Input Data:** If any parameter has been given in the function, then the name of the parameter is provided as Key, and value of the parameters has to be provided as value in this field.

<figure><img src="https://2386645923-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6ZP8JhQPMmuTgMyLMcCU%2Fuploads%2F3K6w9TSlfiY6CNy7K17B%2Fimage%20(1).png?alt=media&#x26;token=20ca78b4-5489-4128-875a-a20b0da2a6c0" alt=""><figcaption><p><em><strong>Meta information tab</strong></em></p></figcaption></figure>
