Hi @sharpbetty ,
One possible solution is to use task values to pass the parameters from Task 1 to Task 2 and then use a try-except block in Task 2 to handle the case where Task 1 fails. Here are the steps to implement this solution:
1. In Task 1, use the dbutils.jobs.taskValues.set()
command to set the parameters as task values. For example:
python
dbutils.jobs.taskValues.set(key="param1", value=42)
dbutils.jobs.taskValues.set(key="param2", value="foo")
2. In Task 2, use the dbutils.jobs.taskValues.get()
command to retrieve the parameters as task values. For example:
python
try:
param1 = dbutils.jobs.taskValues.get(taskKey="Task 1", key="param1")
param2 = dbutils.jobs.taskValues.get(taskKey="Task 1", key="param2")
except ValueError:
# Handle the case where Task 1 failed
param1 = None
param2 = None
3. Use the param1
and param2
variables in Task 2 to generate the report.4. If you want Task 2 to report "Failure" if Task 1 fails, you can add a check at the end of Task 2 to see if param1
and param2
are None
. If they are, then Task 1 failed, and Task 2 should report "Failure".
For example:
python
if param1 is None or param2 is None:
# Task 1 failed, report "Failure"
dbutils.notebook.exit("Failure")
else:
# Task 1 succeeded, generate the report
...
Task 2 can still run even if Task 1 fails by using task values to pass the parameters between functions. The try-except block in Task 2 allows you to handle the case where Task 1 fails and still generate the report if Task 1 succeeds. The check at the end of Task 2 will enable you to report "Failure" if Task 1 fails.