<?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 How to pass parameters to a &amp;quot;Job as Task&amp;quot; from code? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-pass-parameters-to-a-quot-job-as-task-quot-from-code/m-p/56949#M30691</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I would like to use the new "Job as Task" feature but Im having trouble to pass values.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Scenario&lt;/STRONG&gt;&lt;BR /&gt;I have a workflow job which contains 2 tasks.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;Task_A&lt;/STRONG&gt; (type "Notebook"): Read data from a table and based on the contents decide, whether the workflow in Task_B should be executed (or not).&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Task_B&lt;/STRONG&gt; (type "Run Job"): This references another Workflow that itself consists of multiple tasks, all of type "Notebook". The workflow takes several parameters. For the sake of brevity here, let's just assume a parameter "entity_ids".&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;The referenced workflow from Task_B runs totally fine on it's own when started manually.&lt;BR /&gt;For this scenario I would like to add some logic to automate execution of that workflow.&lt;/P&gt;&lt;P&gt;Based on what Task_A decides, I would like to start Task_B with the appropriate list of "entity_id" parameters values.&lt;/P&gt;&lt;P&gt;I had tried to set this with &lt;STRONG&gt;dbutils.jobs.taskValues.set("entity_id", "[1, 2]")&lt;/STRONG&gt;&amp;nbsp;in Task_A and read with&amp;nbsp;&lt;STRONG&gt;dbutils.jobs.taskValues.get("Task_A", "entity_ids", debugValue="[]" )&lt;/STRONG&gt;&amp;nbsp;in the first Notebook of Task_B, but this throws an error within the nested job:&lt;BR /&gt;&lt;STRONG&gt;Task key does not exist in run: Task_A.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I guess that the workflow that is referenced in Task_B is unaware of the parent workflow and might be run in a different context, and therefore cannot find the taskKey == "Task_A".&lt;/P&gt;&lt;P&gt;To verify my assumption, I tried changing the type of Task_B into a Notebook. Reading the value now works fine.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My question:&lt;BR /&gt;How do I pass (multiple) values into the job that is referenced in Task_B?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jan 2024 11:28:39 GMT</pubDate>
    <dc:creator>JensH</dc:creator>
    <dc:date>2024-01-11T11:28:39Z</dc:date>
    <item>
      <title>How to pass parameters to a "Job as Task" from code?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-pass-parameters-to-a-quot-job-as-task-quot-from-code/m-p/56949#M30691</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I would like to use the new "Job as Task" feature but Im having trouble to pass values.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Scenario&lt;/STRONG&gt;&lt;BR /&gt;I have a workflow job which contains 2 tasks.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;Task_A&lt;/STRONG&gt; (type "Notebook"): Read data from a table and based on the contents decide, whether the workflow in Task_B should be executed (or not).&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Task_B&lt;/STRONG&gt; (type "Run Job"): This references another Workflow that itself consists of multiple tasks, all of type "Notebook". The workflow takes several parameters. For the sake of brevity here, let's just assume a parameter "entity_ids".&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;The referenced workflow from Task_B runs totally fine on it's own when started manually.&lt;BR /&gt;For this scenario I would like to add some logic to automate execution of that workflow.&lt;/P&gt;&lt;P&gt;Based on what Task_A decides, I would like to start Task_B with the appropriate list of "entity_id" parameters values.&lt;/P&gt;&lt;P&gt;I had tried to set this with &lt;STRONG&gt;dbutils.jobs.taskValues.set("entity_id", "[1, 2]")&lt;/STRONG&gt;&amp;nbsp;in Task_A and read with&amp;nbsp;&lt;STRONG&gt;dbutils.jobs.taskValues.get("Task_A", "entity_ids", debugValue="[]" )&lt;/STRONG&gt;&amp;nbsp;in the first Notebook of Task_B, but this throws an error within the nested job:&lt;BR /&gt;&lt;STRONG&gt;Task key does not exist in run: Task_A.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I guess that the workflow that is referenced in Task_B is unaware of the parent workflow and might be run in a different context, and therefore cannot find the taskKey == "Task_A".&lt;/P&gt;&lt;P&gt;To verify my assumption, I tried changing the type of Task_B into a Notebook. Reading the value now works fine.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My question:&lt;BR /&gt;How do I pass (multiple) values into the job that is referenced in Task_B?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 11:28:39 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-pass-parameters-to-a-quot-job-as-task-quot-from-code/m-p/56949#M30691</guid>
      <dc:creator>JensH</dc:creator>
      <dc:date>2024-01-11T11:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass parameters to a "Job as Task" from code?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-pass-parameters-to-a-quot-job-as-task-quot-from-code/m-p/57961#M30970</link>
      <description>&lt;P&gt;&lt;SPAN&gt;To pass multiple values into the job that is referenced in Task_B, you can use dynamic value references. Dynamic value references allow you to reference task values set in upstream tasks. This is a recommended approach by Databricks as it can be used with multiple task types.&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;In your case, you can set the values in Task_A using&amp;nbsp;&lt;/SPAN&gt;&lt;CODE class="c-mrkdwn__code" data-stringify-type="code"&gt;dbutils.jobs.taskValues.set()&lt;/CODE&gt;&lt;SPAN&gt;. For example, if you want to set multiple entity_ids, you can do:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE class="c-mrkdwn__pre" data-stringify-type="pre"&gt;python&lt;BR /&gt;dbutils.jobs.taskValues.set(key = "entity_ids", value = [1, 2])&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Then, in Task_B, you can reference these values using dynamic value references. The syntax for this is&amp;nbsp;&lt;/SPAN&gt;&lt;CODE class="c-mrkdwn__code" data-stringify-type="code"&gt;{{tasks.Task_A.values.entity_ids}}&lt;/CODE&gt;&lt;SPAN&gt;.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Please note that the dynamic value references are used in the job settings, not in the notebook code.&lt;/SPAN&gt;&lt;SPAN&gt;This is how you would set it in the job settings:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE class="c-mrkdwn__pre" data-stringify-type="pre"&gt;json&lt;BR /&gt;"parameters": {&lt;BR /&gt; &amp;nbsp;&lt;WBR /&gt; &amp;nbsp;&lt;WBR /&gt;"entity_ids": "{{tasks.Task_A.values.entity_ids}}"&lt;BR /&gt;}&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;This way, the entity_ids set in Task_A will be passed to Task_B.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jan 2024 17:53:29 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-pass-parameters-to-a-quot-job-as-task-quot-from-code/m-p/57961#M30970</guid>
      <dc:creator>Walter_C</dc:creator>
      <dc:date>2024-01-20T17:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass parameters to a "Job as Task" from code?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-pass-parameters-to-a-quot-job-as-task-quot-from-code/m-p/58062#M31008</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/88823"&gt;@Walter_C&lt;/a&gt;&amp;nbsp;, this helped me a lot and seems to work.&lt;/P&gt;&lt;P&gt;However, I cannot seem find documentation about possible limitations about what I can put into the task values (types of data or how large data might be in volume). Do you know more?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 07:36:51 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-pass-parameters-to-a-quot-job-as-task-quot-from-code/m-p/58062#M31008</guid>
      <dc:creator>JensH</dc:creator>
      <dc:date>2024-01-22T07:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass parameters to a "Job as Task" from code?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-pass-parameters-to-a-quot-job-as-task-quot-from-code/m-p/58529#M31195</link>
      <description>&lt;P&gt;I found the following information:&lt;/P&gt;
&lt;UL class="simple"&gt;
&lt;LI&gt;
&lt;P&gt;&lt;CODE class="docutils literal notranslate"&gt;&lt;SPAN class="pre"&gt;value&lt;/SPAN&gt;&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is the value for this task value’s key. This command must be able to represent the value internally in JSON format. The size of the JSON representation of the value cannot exceed 48 KiB.&lt;BR /&gt;&lt;BR /&gt;You can refer to&amp;nbsp;&lt;A href="https://docs.databricks.com/en/workflows/jobs/share-task-context.html" target="_blank"&gt;https://docs.databricks.com/en/workflows/jobs/share-task-context.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Sat, 27 Jan 2024 14:31:33 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-pass-parameters-to-a-quot-job-as-task-quot-from-code/m-p/58529#M31195</guid>
      <dc:creator>Walter_C</dc:creator>
      <dc:date>2024-01-27T14:31:33Z</dc:date>
    </item>
  </channel>
</rss>

