Skip to content

Commit

Permalink
Change get behavior and comment
Browse files Browse the repository at this point in the history
  • Loading branch information
vsamoilov committed Oct 27, 2023
1 parent 7f3b789 commit 57af9e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion databricks/sdk/dbutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,10 @@ class _TaskValuesUtil:

def get(self, taskKey: str, key: str, default: any = None, debugValue: any = None) -> None:
"""
Returns the latest task value that belongs to the current job run
Returns `debugValue` if present, throws an error otherwise as this implementation is always run outside of a job run
"""
if debugValue is None:
raise ValueError('No debug value set for task value, when outside of job run')
return debugValue

def set(self, key: str, value: any) -> None:
Expand Down
8 changes: 8 additions & 0 deletions tests/test_dbutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,11 @@ def test_jobs_task_values_get(dbutils):
dbutils.jobs.taskValues.set('key', 'value')

assert dbutils.jobs.taskValues.get('taskKey', 'key', debugValue='debug') == 'debug'


def test_jobs_task_values_get_throws(dbutils):
try:
dbutils.jobs.taskValues.get('taskKey', 'key')
assert False
except ValueError as e:
assert str(e) == 'No debug value set for task value, when outside of job run'

0 comments on commit 57af9e1

Please sign in to comment.