Skip to content

Commit c486234

Browse files
committed
Add task id to app id
1 parent 0a80f8f commit c486234

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import logging
2-
from sync.databricks.integrations._run_submit_runner import apply_sync_gradient_cluster_recommendation
2+
3+
from sync.databricks.integrations._run_submit_runner import (
4+
apply_sync_gradient_cluster_recommendation,
5+
)
36

47
logger = logging.getLogger(__name__)
58

@@ -9,21 +12,28 @@ def airflow_gradient_pre_execute_hook(context: dict):
912
logger.info("Running airflow gradient pre-execute hook!")
1013
logger.debug(f"Airflow operator context - context:{context}")
1114

15+
task_id = context["task"].task_id
1216
gradient_app_id = context["params"]["gradient_app_id"]
1317
auto_apply = context["params"]["gradient_auto_apply"]
1418
cluster_log_url = context["params"]["cluster_log_url"]
1519
workspace_id = context["params"]["databricks_workspace_id"]
16-
run_submit_task = context["task"].json.copy() # copy the run submit json from the task context
20+
run_submit_task = context[
21+
"task"
22+
].json.copy() # copy the run submit json from the task context
1723

1824
updated_task_configuration = apply_sync_gradient_cluster_recommendation(
1925
run_submit_task=run_submit_task,
20-
gradient_app_id=gradient_app_id,
26+
gradient_app_id=build_app_id(task_id, gradient_app_id),
2127
auto_apply=auto_apply,
2228
cluster_log_url=cluster_log_url,
23-
workspace_id=workspace_id
29+
workspace_id=workspace_id,
2430
)
2531

2632
context["task"].json = updated_task_configuration
2733
except Exception as e:
2834
logger.exception(e)
2935
logger.error("Unable to apply gradient configuration to Databricks run submit tasks")
36+
37+
38+
def build_app_id(task_id: str, app_id: str):
39+
return f"{task_id}-{app_id}"

0 commit comments

Comments
 (0)