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 notification settings paramaters #39175

Merged
merged 5 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions airflow/providers/databricks/operators/databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,15 @@ class DatabricksCreateJobsOperator(BaseOperator):
.. seealso::
For more information about templating see :ref:`concepts:jinja-templating`.
:param name: An optional name for the job.
:param description: An optional description for the job.
:param tags: A map of tags associated with the job.
:param tasks: A list of task specifications to be executed by this job.
Array of objects (JobTaskSettings).
:param job_clusters: A list of job cluster specifications that can be shared and reused by
tasks of this job. Array of objects (JobCluster).
:param email_notifications: Object (JobEmailNotifications).
:param webhook_notifications: Object (WebhookNotifications).
:param notification_settings: Optional notification settings.
:param timeout_seconds: An optional timeout applied to each run of this job.
:param schedule: Object (CronSchedule).
:param max_concurrent_runs: An optional maximum allowed number of concurrent runs of the job.
Expand Down Expand Up @@ -249,11 +251,13 @@ def __init__(
*,
json: Any | None = None,
name: str | None = None,
description: str | None = None,
tags: dict[str, str] | None = None,
tasks: list[dict] | None = None,
job_clusters: list[dict] | None = None,
email_notifications: dict | None = None,
webhook_notifications: dict | None = None,
notification_settings: dict | None = None,
timeout_seconds: int | None = None,
schedule: dict | None = None,
max_concurrent_runs: int | None = None,
Expand All @@ -276,6 +280,8 @@ def __init__(
self.databricks_retry_args = databricks_retry_args
if name is not None:
self.json["name"] = name
if description is not None:
self.json["description"] = description
if tags is not None:
self.json["tags"] = tags
if tasks is not None:
Expand All @@ -286,6 +292,8 @@ def __init__(
self.json["email_notifications"] = email_notifications
if webhook_notifications is not None:
self.json["webhook_notifications"] = webhook_notifications
if notification_settings is not None:
self.json["notification_settings"] = notification_settings
if timeout_seconds is not None:
self.json["timeout_seconds"] = timeout_seconds
if schedule is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ override the top level ``json`` keys.

Currently the named parameters that ``DatabricksCreateJobsOperator`` supports are:
- ``name``
- ``description``
- ``tags``
- ``tasks``
- ``job_clusters``
- ``email_notifications``
- ``webhook_notifications``
- ``notification_settings``
- ``timeout_seconds``
- ``schedule``
- ``max_concurrent_runs``
Expand Down
10 changes: 10 additions & 0 deletions tests/providers/databricks/operators/test_databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
RUN_PAGE_URL = "run-page-url"
JOB_ID = "42"
JOB_NAME = "job-name"
JOB_DESCRIPTION = "job-description"
NOTEBOOK_PARAMS = {"dry-run": "true", "oldest-time-to-consider": "1457570074236"}
JAR_PARAMS = ["param1", "param2"]
RENDERED_TEMPLATED_JAR_PARAMS = [f"/test-{DATE}"]
Expand Down Expand Up @@ -202,6 +203,7 @@
}
],
}
NOTIFICATION_SETTINGS = {"no_alert_for_canceled_runs": True, "no_alert_for_skipped_runs": True}
TIMEOUT_SECONDS = 86400
SCHEDULE = {
"quartz_cron_expression": "20 30 * * * ?",
Expand Down Expand Up @@ -409,11 +411,13 @@ def test_exec_create(self, db_mock_class):
"""
json = {
"name": JOB_NAME,
"description": JOB_DESCRIPTION,
"tags": TAGS,
"tasks": TASKS,
"job_clusters": JOB_CLUSTERS,
"email_notifications": EMAIL_NOTIFICATIONS,
"webhook_notifications": WEBHOOK_NOTIFICATIONS,
"notification_settings": NOTIFICATION_SETTINGS,
"timeout_seconds": TIMEOUT_SECONDS,
"schedule": SCHEDULE,
"max_concurrent_runs": MAX_CONCURRENT_RUNS,
Expand All @@ -431,11 +435,13 @@ def test_exec_create(self, db_mock_class):
expected = utils.normalise_json_content(
{
"name": JOB_NAME,
"description": JOB_DESCRIPTION,
"tags": TAGS,
"tasks": TASKS,
"job_clusters": JOB_CLUSTERS,
"email_notifications": EMAIL_NOTIFICATIONS,
"webhook_notifications": WEBHOOK_NOTIFICATIONS,
"notification_settings": NOTIFICATION_SETTINGS,
"timeout_seconds": TIMEOUT_SECONDS,
"schedule": SCHEDULE,
"max_concurrent_runs": MAX_CONCURRENT_RUNS,
Expand All @@ -461,11 +467,13 @@ def test_exec_reset(self, db_mock_class):
"""
json = {
"name": JOB_NAME,
"description": JOB_DESCRIPTION,
"tags": TAGS,
"tasks": TASKS,
"job_clusters": JOB_CLUSTERS,
"email_notifications": EMAIL_NOTIFICATIONS,
"webhook_notifications": WEBHOOK_NOTIFICATIONS,
"notification_settings": NOTIFICATION_SETTINGS,
"timeout_seconds": TIMEOUT_SECONDS,
"schedule": SCHEDULE,
"max_concurrent_runs": MAX_CONCURRENT_RUNS,
Expand All @@ -481,11 +489,13 @@ def test_exec_reset(self, db_mock_class):
expected = utils.normalise_json_content(
{
"name": JOB_NAME,
"description": JOB_DESCRIPTION,
"tags": TAGS,
"tasks": TASKS,
"job_clusters": JOB_CLUSTERS,
"email_notifications": EMAIL_NOTIFICATIONS,
"webhook_notifications": WEBHOOK_NOTIFICATIONS,
"notification_settings": NOTIFICATION_SETTINGS,
"timeout_seconds": TIMEOUT_SECONDS,
"schedule": SCHEDULE,
"max_concurrent_runs": MAX_CONCURRENT_RUNS,
Expand Down