Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add git_source to DatabricksSubmitRunOperator #23620

Merged
merged 3 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions airflow/providers/databricks/operators/databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ def __init__(
idempotency_token: Optional[str] = None,
access_control_list: Optional[List[Dict[str, str]]] = None,
wait_for_termination: bool = True,
git_source: Optional[Dict[str, str]] = None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a docstring about it on L244

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, 0a264ad. Could you please have another look to see if that's descriptive enough?

**kwargs,
) -> None:
"""Creates a new ``DatabricksSubmitRunOperator``."""
Expand Down Expand Up @@ -312,6 +313,8 @@ def __init__(
self.json['idempotency_token'] = idempotency_token
if access_control_list is not None:
self.json['access_control_list'] = access_control_list
if git_source is not None:
self.json['git_source'] = git_source

self.json = _deep_string_coerce(self.json)
# This variable will be used in case our task gets killed.
Expand Down
18 changes: 18 additions & 0 deletions tests/providers/databricks/operators/test_databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,24 @@ def test_init_with_templating(self):
)
assert expected == op.json

def test_init_with_git_source(self):
json = {'new_cluster': NEW_CLUSTER, 'notebook_task': NOTEBOOK_TASK, 'run_name': RUN_NAME}
git_source = {
'git_url': 'https://github.com/apache/airflow',
'git_provider': 'github',
'git_branch': 'main',
}
op = DatabricksSubmitRunOperator(task_id=TASK_ID, git_source=git_source, json=json)
expected = databricks_operator._deep_string_coerce(
{
'new_cluster': NEW_CLUSTER,
'notebook_task': NOTEBOOK_TASK,
'run_name': RUN_NAME,
'git_source': git_source
eladkal marked this conversation as resolved.
Show resolved Hide resolved
}
)
assert expected == op.json

def test_init_with_bad_type(self):
json = {'test': datetime.now()}
# Looks a bit weird since we have to escape regex reserved symbols.
Expand Down