<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Databricks Tasks Python wheel : How access to JobID &amp; runID ? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/databricks-tasks-python-wheel-how-access-to-jobid-runid/m-p/5041#M1571</link>
    <description>&lt;P&gt;Hey Suteja, &lt;/P&gt;&lt;P&gt;Thank you for your response, but unfortunalty, it doesn't work with environment variables.&lt;/P&gt;&lt;P&gt;Got null value for both variable ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you have any idea which DBR should I use ? &lt;/P&gt;&lt;P&gt;Or any documentation about this environment variables ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
    <pubDate>Tue, 23 May 2023 13:32:38 GMT</pubDate>
    <dc:creator>GGG_P</dc:creator>
    <dc:date>2023-05-23T13:32:38Z</dc:date>
    <item>
      <title>Databricks Tasks Python wheel : How access to JobID &amp; runID ?</title>
      <link>https://community.databricks.com/t5/data-engineering/databricks-tasks-python-wheel-how-access-to-jobid-runid/m-p/5039#M1569</link>
      <description>&lt;P&gt;I'm using Python (as Python wheel application) on&amp;nbsp;&lt;B&gt;Databricks&lt;/B&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I deploy &amp;amp; run my jobs using&amp;nbsp;&lt;B&gt;dbx&lt;/B&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I defined some&amp;nbsp;&lt;B&gt;Databricks Workflow&lt;/B&gt;&amp;nbsp;using&amp;nbsp;&lt;B&gt;Python wheel tasks&lt;/B&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Everything is working fine, but I'm having issue to extract&amp;nbsp;&lt;B&gt;"databricks_job_id"&lt;/B&gt;&amp;nbsp;&amp;amp;&amp;nbsp;&lt;B&gt;"databricks_run_id"&lt;/B&gt;&amp;nbsp;for logging/monitoring purpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm used to defined&amp;nbsp;&lt;B&gt;{{job_id}}&lt;/B&gt;&amp;nbsp;&amp;amp;&amp;nbsp;&lt;B&gt;{{run_id}}&lt;/B&gt;&amp;nbsp;as parameter in "Notebook Task" or other task type, its works fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; But with Python wheel I'm not able to define theses :&lt;/P&gt;&lt;P&gt;With Python wheel task, parameters are basically an array of string :&lt;/P&gt;&lt;P&gt;["/dbfs/Shared/dbx/projects/myproject/66655665aac24e748d4e7b28c6f4d624/artifacts/myparameter.yml","/dbfs/Shared/dbx/projects/myproject/66655665aac24e748d4e7b28c6f4d624/artifacts/conf"]&lt;/P&gt;&lt;P&gt;Adding "&lt;B&gt;{{job_id}}&lt;/B&gt;" &amp;amp; "&lt;B&gt;{{run_id}}&lt;/B&gt;" in this array doesn't seems to work ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you have any ideas ? Don't want to use any REST API during my workload just to extract theses ids...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess that I cannot use dbutils / notebook context to got thoses IDs since I don't use any notebooks ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2023 18:45:13 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/databricks-tasks-python-wheel-how-access-to-jobid-runid/m-p/5039#M1569</guid>
      <dc:creator>GGG_P</dc:creator>
      <dc:date>2023-04-28T18:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: Databricks Tasks Python wheel : How access to JobID &amp; runID ?</title>
      <link>https://community.databricks.com/t5/data-engineering/databricks-tasks-python-wheel-how-access-to-jobid-runid/m-p/5040#M1570</link>
      <description>&lt;P&gt;@Grégoire PORTIER​&amp;nbsp;:&lt;/P&gt;&lt;P&gt;You can use the dbutils module to retrieve the job ID and run ID from within your Python wheel application. Here's an example of how you can do this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;from pyspark.sql import SparkSession
import requests
import json
import os
&amp;nbsp;
# Get the current SparkSession
spark = SparkSession.builder.getOrCreate()
&amp;nbsp;
# Get the Databricks job ID and run ID from the environment variables
job_id = os.environ.get("DATABRICKS_JOB_ID")
run_id = os.environ.get("DATABRICKS_RUN_ID")
&amp;nbsp;
# Print the job ID and run ID for logging/monitoring purposes
print(f"Databricks Job ID: {job_id}")
print(f"Databricks Run ID: {run_id}")&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You can then add this code to your Python wheel task to extract the job ID and run ID and use them for logging/monitoring purposes.&lt;/P&gt;&lt;P&gt;Note that the environment variables DATABRICKS_JOB_ID and DATABRICKS_RUN_ID are automatically set by Databricks when you run a job, so you don't need to pass them as parameters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 13 May 2023 16:53:14 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/databricks-tasks-python-wheel-how-access-to-jobid-runid/m-p/5040#M1570</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-05-13T16:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: Databricks Tasks Python wheel : How access to JobID &amp; runID ?</title>
      <link>https://community.databricks.com/t5/data-engineering/databricks-tasks-python-wheel-how-access-to-jobid-runid/m-p/5041#M1571</link>
      <description>&lt;P&gt;Hey Suteja, &lt;/P&gt;&lt;P&gt;Thank you for your response, but unfortunalty, it doesn't work with environment variables.&lt;/P&gt;&lt;P&gt;Got null value for both variable ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you have any idea which DBR should I use ? &lt;/P&gt;&lt;P&gt;Or any documentation about this environment variables ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 13:32:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/databricks-tasks-python-wheel-how-access-to-jobid-runid/m-p/5041#M1571</guid>
      <dc:creator>GGG_P</dc:creator>
      <dc:date>2023-05-23T13:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: Databricks Tasks Python wheel : How access to JobID &amp; runID ?</title>
      <link>https://community.databricks.com/t5/data-engineering/databricks-tasks-python-wheel-how-access-to-jobid-runid/m-p/62763#M32063</link>
      <description>&lt;P&gt;There you can see a complete template project with Databricks Asset Bundles and python wheel task. Please, follow the instructions for deployment.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/andre-salvati/databricks-template" rel="nofollow noreferrer" target="_blank"&gt;https://github.com/andre-salvati/databricks-template&lt;/A&gt;&lt;/P&gt;&lt;P&gt;In particular, take a look at the workflow definition &lt;A href="https://github.com/andre-salvati/databricks-template/blob/main/conf/wf_template.yml" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 16:54:17 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/databricks-tasks-python-wheel-how-access-to-jobid-runid/m-p/62763#M32063</guid>
      <dc:creator>AndréSalvati</dc:creator>
      <dc:date>2024-03-06T16:54:17Z</dc:date>
    </item>
  </channel>
</rss>

