alexott commented on code in PR #23712: URL: https://github.com/apache/airflow/pull/23712#discussion_r875215993
########## airflow/providers/databricks/sensors/databricks.py: ########## @@ -0,0 +1,103 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""Databricks sensors""" + +from typing import TYPE_CHECKING, Any, Dict, Optional, Sequence, Union + +from airflow.exceptions import AirflowException +from airflow.providers.databricks.hooks.databricks import DatabricksHook +from airflow.sensors.base import BaseSensorOperator +from airflow.utils.context import Context + +if TYPE_CHECKING: + from airflow.sensors.base import PokeReturnValue + + +class DatabricksJobRunSensor(BaseSensorOperator): + """ + Check for the state of a submitted Databricks job run or specific task of a job run. + + :param run_id: Id of the submitted Databricks job run or specific task of a job run. (templated) + :param databricks_conn_id: Reference to the :ref:`Databricks connection <howto/connection:databricks>`. + By default and in the common case this will be ``databricks_default``. To use + token based authentication, provide the key ``token`` in the extra field for the + connection and create the key ``host`` and leave the ``host`` field empty. + :param retry_limit: Amount of times retry if the Databricks backend is + unreachable. Its value must be greater than or equal to 1. + :param retry_delay_seconds: Number of seconds to wait between retries (it + might be a floating point number). + :param databricks_retry_args: An optional dictionary with arguments passed to ``tenacity.Retrying`` class. + """ + + template_fields: Sequence[str] = ('run_id',) Review Comment: Could it be really templatized? Run ID not an airflow variable… ########## airflow/providers/databricks/sensors/databricks.py: ########## @@ -0,0 +1,103 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""Databricks sensors""" + +from typing import TYPE_CHECKING, Any, Dict, Optional, Sequence, Union + +from airflow.exceptions import AirflowException +from airflow.providers.databricks.hooks.databricks import DatabricksHook +from airflow.sensors.base import BaseSensorOperator +from airflow.utils.context import Context + +if TYPE_CHECKING: + from airflow.sensors.base import PokeReturnValue + + +class DatabricksJobRunSensor(BaseSensorOperator): + """ + Check for the state of a submitted Databricks job run or specific task of a job run. + + :param run_id: Id of the submitted Databricks job run or specific task of a job run. (templated) Review Comment: It would make sense to refer to a job by name or ID, and a time frame… Run ID is very specific to a specific execution… it would make sense to list use cases for the sensor. For example, check for a specific job (by name or ID) executed today/yesterday/… -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
