partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
S3TaskHandler.s3_read
Returns the log found at the remote_log_location. Returns '' if no logs are found or there is an error. :param remote_log_location: the log's location in remote storage :type remote_log_location: str (path) :param return_error: if True, returns a string error message if an er...
airflow/utils/log/s3_task_handler.py
def s3_read(self, remote_log_location, return_error=False): """ Returns the log found at the remote_log_location. Returns '' if no logs are found or there is an error. :param remote_log_location: the log's location in remote storage :type remote_log_location: str (path) :...
def s3_read(self, remote_log_location, return_error=False): """ Returns the log found at the remote_log_location. Returns '' if no logs are found or there is an error. :param remote_log_location: the log's location in remote storage :type remote_log_location: str (path) :...
[ "Returns", "the", "log", "found", "at", "the", "remote_log_location", ".", "Returns", "if", "no", "logs", "are", "found", "or", "there", "is", "an", "error", ".", ":", "param", "remote_log_location", ":", "the", "log", "s", "location", "in", "remote", "sto...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/log/s3_task_handler.py#L127-L144
[ "def", "s3_read", "(", "self", ",", "remote_log_location", ",", "return_error", "=", "False", ")", ":", "try", ":", "return", "self", ".", "hook", ".", "read_key", "(", "remote_log_location", ")", "except", "Exception", ":", "msg", "=", "'Could not read logs f...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
S3TaskHandler.s3_write
Writes the log to the remote_log_location. Fails silently if no hook was created. :param log: the log to write to the remote_log_location :type log: str :param remote_log_location: the log's location in remote storage :type remote_log_location: str (path) :param append: i...
airflow/utils/log/s3_task_handler.py
def s3_write(self, log, remote_log_location, append=True): """ Writes the log to the remote_log_location. Fails silently if no hook was created. :param log: the log to write to the remote_log_location :type log: str :param remote_log_location: the log's location in remote...
def s3_write(self, log, remote_log_location, append=True): """ Writes the log to the remote_log_location. Fails silently if no hook was created. :param log: the log to write to the remote_log_location :type log: str :param remote_log_location: the log's location in remote...
[ "Writes", "the", "log", "to", "the", "remote_log_location", ".", "Fails", "silently", "if", "no", "hook", "was", "created", ".", ":", "param", "log", ":", "the", "log", "to", "write", "to", "the", "remote_log_location", ":", "type", "log", ":", "str", ":...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/log/s3_task_handler.py#L146-L170
[ "def", "s3_write", "(", "self", ",", "log", ",", "remote_log_location", ",", "append", "=", "True", ")", ":", "if", "append", "and", "self", ".", "s3_log_exists", "(", "remote_log_location", ")", ":", "old_log", "=", "self", ".", "s3_read", "(", "remote_lo...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
WorkerConfiguration._get_init_containers
When using git to retrieve the DAGs, use the GitSync Init Container
airflow/contrib/kubernetes/worker_configuration.py
def _get_init_containers(self): """When using git to retrieve the DAGs, use the GitSync Init Container""" # If we're using volume claims to mount the dags, no init container is needed if self.kube_config.dags_volume_claim or \ self.kube_config.dags_volume_host or self.kube_config.dags...
def _get_init_containers(self): """When using git to retrieve the DAGs, use the GitSync Init Container""" # If we're using volume claims to mount the dags, no init container is needed if self.kube_config.dags_volume_claim or \ self.kube_config.dags_volume_host or self.kube_config.dags...
[ "When", "using", "git", "to", "retrieve", "the", "DAGs", "use", "the", "GitSync", "Init", "Container" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/kubernetes/worker_configuration.py#L45-L131
[ "def", "_get_init_containers", "(", "self", ")", ":", "# If we're using volume claims to mount the dags, no init container is needed", "if", "self", ".", "kube_config", ".", "dags_volume_claim", "or", "self", ".", "kube_config", ".", "dags_volume_host", "or", "self", ".", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
WorkerConfiguration._get_environment
Defines any necessary environment variables for the pod executor
airflow/contrib/kubernetes/worker_configuration.py
def _get_environment(self): """Defines any necessary environment variables for the pod executor""" env = {} for env_var_name, env_var_val in six.iteritems(self.kube_config.kube_env_vars): env[env_var_name] = env_var_val env["AIRFLOW__CORE__EXECUTOR"] = "LocalExecutor" ...
def _get_environment(self): """Defines any necessary environment variables for the pod executor""" env = {} for env_var_name, env_var_val in six.iteritems(self.kube_config.kube_env_vars): env[env_var_name] = env_var_val env["AIRFLOW__CORE__EXECUTOR"] = "LocalExecutor" ...
[ "Defines", "any", "necessary", "environment", "variables", "for", "the", "pod", "executor" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/kubernetes/worker_configuration.py#L133-L156
[ "def", "_get_environment", "(", "self", ")", ":", "env", "=", "{", "}", "for", "env_var_name", ",", "env_var_val", "in", "six", ".", "iteritems", "(", "self", ".", "kube_config", ".", "kube_env_vars", ")", ":", "env", "[", "env_var_name", "]", "=", "env_...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
WorkerConfiguration._get_secrets
Defines any necessary secrets for the pod executor
airflow/contrib/kubernetes/worker_configuration.py
def _get_secrets(self): """Defines any necessary secrets for the pod executor""" worker_secrets = [] for env_var_name, obj_key_pair in six.iteritems(self.kube_config.kube_secrets): k8s_secret_obj, k8s_secret_key = obj_key_pair.split('=') worker_secrets.append( ...
def _get_secrets(self): """Defines any necessary secrets for the pod executor""" worker_secrets = [] for env_var_name, obj_key_pair in six.iteritems(self.kube_config.kube_secrets): k8s_secret_obj, k8s_secret_key = obj_key_pair.split('=') worker_secrets.append( ...
[ "Defines", "any", "necessary", "secrets", "for", "the", "pod", "executor" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/kubernetes/worker_configuration.py#L164-L180
[ "def", "_get_secrets", "(", "self", ")", ":", "worker_secrets", "=", "[", "]", "for", "env_var_name", ",", "obj_key_pair", "in", "six", ".", "iteritems", "(", "self", ".", "kube_config", ".", "kube_secrets", ")", ":", "k8s_secret_obj", ",", "k8s_secret_key", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
WorkerConfiguration._get_security_context
Defines the security context
airflow/contrib/kubernetes/worker_configuration.py
def _get_security_context(self): """Defines the security context""" security_context = {} if self.kube_config.worker_run_as_user: security_context['runAsUser'] = self.kube_config.worker_run_as_user if self.kube_config.worker_fs_group: security_context['fsGroup']...
def _get_security_context(self): """Defines the security context""" security_context = {} if self.kube_config.worker_run_as_user: security_context['runAsUser'] = self.kube_config.worker_run_as_user if self.kube_config.worker_fs_group: security_context['fsGroup']...
[ "Defines", "the", "security", "context" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/kubernetes/worker_configuration.py#L188-L202
[ "def", "_get_security_context", "(", "self", ")", ":", "security_context", "=", "{", "}", "if", "self", ".", "kube_config", ".", "worker_run_as_user", ":", "security_context", "[", "'runAsUser'", "]", "=", "self", ".", "kube_config", ".", "worker_run_as_user", "...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
QuboleHook.kill
Kill (cancel) a Qubole command :param ti: Task Instance of the dag, used to determine the Quboles command id :return: response from Qubole
airflow/contrib/hooks/qubole_hook.py
def kill(self, ti): """ Kill (cancel) a Qubole command :param ti: Task Instance of the dag, used to determine the Quboles command id :return: response from Qubole """ if self.cmd is None: if not ti and not self.task_instance: raise Exception("U...
def kill(self, ti): """ Kill (cancel) a Qubole command :param ti: Task Instance of the dag, used to determine the Quboles command id :return: response from Qubole """ if self.cmd is None: if not ti and not self.task_instance: raise Exception("U...
[ "Kill", "(", "cancel", ")", "a", "Qubole", "command", ":", "param", "ti", ":", "Task", "Instance", "of", "the", "dag", "used", "to", "determine", "the", "Quboles", "command", "id", ":", "return", ":", "response", "from", "Qubole" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/qubole_hook.py#L147-L162
[ "def", "kill", "(", "self", ",", "ti", ")", ":", "if", "self", ".", "cmd", "is", "None", ":", "if", "not", "ti", "and", "not", "self", ".", "task_instance", ":", "raise", "Exception", "(", "\"Unable to cancel Qubole Command, context is unavailable!\"", ")", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
QuboleHook.get_results
Get results (or just s3 locations) of a command from Qubole and save into a file :param ti: Task Instance of the dag, used to determine the Quboles command id :param fp: Optional file pointer, will create one and return if None passed :param inline: True to download actual results, False to get ...
airflow/contrib/hooks/qubole_hook.py
def get_results(self, ti=None, fp=None, inline=True, delim=None, fetch=True): """ Get results (or just s3 locations) of a command from Qubole and save into a file :param ti: Task Instance of the dag, used to determine the Quboles command id :param fp: Optional file pointer, will create o...
def get_results(self, ti=None, fp=None, inline=True, delim=None, fetch=True): """ Get results (or just s3 locations) of a command from Qubole and save into a file :param ti: Task Instance of the dag, used to determine the Quboles command id :param fp: Optional file pointer, will create o...
[ "Get", "results", "(", "or", "just", "s3", "locations", ")", "of", "a", "command", "from", "Qubole", "and", "save", "into", "a", "file", ":", "param", "ti", ":", "Task", "Instance", "of", "the", "dag", "used", "to", "determine", "the", "Quboles", "comm...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/qubole_hook.py#L164-L190
[ "def", "get_results", "(", "self", ",", "ti", "=", "None", ",", "fp", "=", "None", ",", "inline", "=", "True", ",", "delim", "=", "None", ",", "fetch", "=", "True", ")", ":", "if", "fp", "is", "None", ":", "iso", "=", "datetime", ".", "datetime",...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
QuboleHook.get_log
Get Logs of a command from Qubole :param ti: Task Instance of the dag, used to determine the Quboles command id :return: command log as text
airflow/contrib/hooks/qubole_hook.py
def get_log(self, ti): """ Get Logs of a command from Qubole :param ti: Task Instance of the dag, used to determine the Quboles command id :return: command log as text """ if self.cmd is None: cmd_id = ti.xcom_pull(key="qbol_cmd_id", task_ids=self.task_id) ...
def get_log(self, ti): """ Get Logs of a command from Qubole :param ti: Task Instance of the dag, used to determine the Quboles command id :return: command log as text """ if self.cmd is None: cmd_id = ti.xcom_pull(key="qbol_cmd_id", task_ids=self.task_id) ...
[ "Get", "Logs", "of", "a", "command", "from", "Qubole", ":", "param", "ti", ":", "Task", "Instance", "of", "the", "dag", "used", "to", "determine", "the", "Quboles", "command", "id", ":", "return", ":", "command", "log", "as", "text" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/qubole_hook.py#L192-L200
[ "def", "get_log", "(", "self", ",", "ti", ")", ":", "if", "self", ".", "cmd", "is", "None", ":", "cmd_id", "=", "ti", ".", "xcom_pull", "(", "key", "=", "\"qbol_cmd_id\"", ",", "task_ids", "=", "self", ".", "task_id", ")", "Command", ".", "get_log_id...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
QuboleHook.get_jobs_id
Get jobs associated with a Qubole commands :param ti: Task Instance of the dag, used to determine the Quboles command id :return: Job information associated with command
airflow/contrib/hooks/qubole_hook.py
def get_jobs_id(self, ti): """ Get jobs associated with a Qubole commands :param ti: Task Instance of the dag, used to determine the Quboles command id :return: Job information associated with command """ if self.cmd is None: cmd_id = ti.xcom_pull(key="qbol_cm...
def get_jobs_id(self, ti): """ Get jobs associated with a Qubole commands :param ti: Task Instance of the dag, used to determine the Quboles command id :return: Job information associated with command """ if self.cmd is None: cmd_id = ti.xcom_pull(key="qbol_cm...
[ "Get", "jobs", "associated", "with", "a", "Qubole", "commands", ":", "param", "ti", ":", "Task", "Instance", "of", "the", "dag", "used", "to", "determine", "the", "Quboles", "command", "id", ":", "return", ":", "Job", "information", "associated", "with", "...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/qubole_hook.py#L202-L210
[ "def", "get_jobs_id", "(", "self", ",", "ti", ")", ":", "if", "self", ".", "cmd", "is", "None", ":", "cmd_id", "=", "ti", ".", "xcom_pull", "(", "key", "=", "\"qbol_cmd_id\"", ",", "task_ids", "=", "self", ".", "task_id", ")", "Command", ".", "get_jo...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
QuboleHook.get_extra_links
Get link to qubole command result page. :param operator: operator :param dttm: datetime :return: url link
airflow/contrib/hooks/qubole_hook.py
def get_extra_links(self, operator, dttm): """ Get link to qubole command result page. :param operator: operator :param dttm: datetime :return: url link """ conn = BaseHook.get_connection(operator.kwargs['qubole_conn_id']) if conn and conn.host: ...
def get_extra_links(self, operator, dttm): """ Get link to qubole command result page. :param operator: operator :param dttm: datetime :return: url link """ conn = BaseHook.get_connection(operator.kwargs['qubole_conn_id']) if conn and conn.host: ...
[ "Get", "link", "to", "qubole", "command", "result", "page", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/qubole_hook.py#L212-L229
[ "def", "get_extra_links", "(", "self", ",", "operator", ",", "dttm", ")", ":", "conn", "=", "BaseHook", ".", "get_connection", "(", "operator", ".", "kwargs", "[", "'qubole_conn_id'", "]", ")", "if", "conn", "and", "conn", ".", "host", ":", "host", "=", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
BaseJob.heartbeat
Heartbeats update the job's entry in the database with a timestamp for the latest_heartbeat and allows for the job to be killed externally. This allows at the system level to monitor what is actually active. For instance, an old heartbeat for SchedulerJob would mean something is...
airflow/jobs.py
def heartbeat(self): """ Heartbeats update the job's entry in the database with a timestamp for the latest_heartbeat and allows for the job to be killed externally. This allows at the system level to monitor what is actually active. For instance, an old heartbeat for Sch...
def heartbeat(self): """ Heartbeats update the job's entry in the database with a timestamp for the latest_heartbeat and allows for the job to be killed externally. This allows at the system level to monitor what is actually active. For instance, an old heartbeat for Sch...
[ "Heartbeats", "update", "the", "job", "s", "entry", "in", "the", "database", "with", "a", "timestamp", "for", "the", "latest_heartbeat", "and", "allows", "for", "the", "job", "to", "be", "killed", "externally", ".", "This", "allows", "at", "the", "system", ...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L139-L189
[ "def", "heartbeat", "(", "self", ")", ":", "try", ":", "with", "create_session", "(", ")", "as", "session", ":", "job", "=", "session", ".", "query", "(", "BaseJob", ")", ".", "filter_by", "(", "id", "=", "self", ".", "id", ")", ".", "one", "(", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
BaseJob.reset_state_for_orphaned_tasks
This function checks if there are any tasks in the dagrun (or all) that have a scheduled state but are not known by the executor. If it finds those it will reset the state to None so they will get picked up again. The batch option is for performance reasons as the queries are made in ...
airflow/jobs.py
def reset_state_for_orphaned_tasks(self, filter_by_dag_run=None, session=None): """ This function checks if there are any tasks in the dagrun (or all) that have a scheduled state but are not known by the executor. If it finds those it will reset the state to None so they will get...
def reset_state_for_orphaned_tasks(self, filter_by_dag_run=None, session=None): """ This function checks if there are any tasks in the dagrun (or all) that have a scheduled state but are not known by the executor. If it finds those it will reset the state to None so they will get...
[ "This", "function", "checks", "if", "there", "are", "any", "tasks", "in", "the", "dagrun", "(", "or", "all", ")", "that", "have", "a", "scheduled", "state", "but", "are", "not", "known", "by", "the", "executor", ".", "If", "it", "finds", "those", "it",...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L223-L298
[ "def", "reset_state_for_orphaned_tasks", "(", "self", ",", "filter_by_dag_run", "=", "None", ",", "session", "=", "None", ")", ":", "queued_tis", "=", "self", ".", "executor", ".", "queued_tasks", "# also consider running as the state might not have changed in the db yet", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessor._launch_process
Launch a process to process the given file. :param result_queue: the queue to use for passing back the result :type result_queue: multiprocessing.Queue :param file_path: the file to process :type file_path: unicode :param pickle_dags: whether to pickle the DAGs found in the file...
airflow/jobs.py
def _launch_process(result_queue, file_path, pickle_dags, dag_id_white_list, thread_name, zombies): """ Launch a process to process the given file. :param result_queue: the qu...
def _launch_process(result_queue, file_path, pickle_dags, dag_id_white_list, thread_name, zombies): """ Launch a process to process the given file. :param result_queue: the qu...
[ "Launch", "a", "process", "to", "process", "the", "given", "file", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L342-L417
[ "def", "_launch_process", "(", "result_queue", ",", "file_path", ",", "pickle_dags", ",", "dag_id_white_list", ",", "thread_name", ",", "zombies", ")", ":", "def", "helper", "(", ")", ":", "# This helper runs in the newly created process", "log", "=", "logging", "."...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessor.start
Launch the process and start processing the DAG.
airflow/jobs.py
def start(self): """ Launch the process and start processing the DAG. """ self._process = DagFileProcessor._launch_process( self._result_queue, self.file_path, self._pickle_dags, self._dag_id_white_list, "DagFileProcessor{}".for...
def start(self): """ Launch the process and start processing the DAG. """ self._process = DagFileProcessor._launch_process( self._result_queue, self.file_path, self._pickle_dags, self._dag_id_white_list, "DagFileProcessor{}".for...
[ "Launch", "the", "process", "and", "start", "processing", "the", "DAG", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L419-L430
[ "def", "start", "(", "self", ")", ":", "self", ".", "_process", "=", "DagFileProcessor", ".", "_launch_process", "(", "self", ".", "_result_queue", ",", "self", ".", "file_path", ",", "self", ".", "_pickle_dags", ",", "self", ".", "_dag_id_white_list", ",", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessor.terminate
Terminate (and then kill) the process launched to process the file. :param sigkill: whether to issue a SIGKILL if SIGTERM doesn't work. :type sigkill: bool
airflow/jobs.py
def terminate(self, sigkill=False): """ Terminate (and then kill) the process launched to process the file. :param sigkill: whether to issue a SIGKILL if SIGTERM doesn't work. :type sigkill: bool """ if self._process is None: raise AirflowException("Tried to ...
def terminate(self, sigkill=False): """ Terminate (and then kill) the process launched to process the file. :param sigkill: whether to issue a SIGKILL if SIGTERM doesn't work. :type sigkill: bool """ if self._process is None: raise AirflowException("Tried to ...
[ "Terminate", "(", "and", "then", "kill", ")", "the", "process", "launched", "to", "process", "the", "file", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L432-L448
[ "def", "terminate", "(", "self", ",", "sigkill", "=", "False", ")", ":", "if", "self", ".", "_process", "is", "None", ":", "raise", "AirflowException", "(", "\"Tried to call stop before starting!\"", ")", "# The queue will likely get corrupted, so remove the reference", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessor.done
Check if the process launched to process this file is done. :return: whether the process is finished running :rtype: bool
airflow/jobs.py
def done(self): """ Check if the process launched to process this file is done. :return: whether the process is finished running :rtype: bool """ if self._process is None: raise AirflowException("Tried to see if it's done before starting!") if self._...
def done(self): """ Check if the process launched to process this file is done. :return: whether the process is finished running :rtype: bool """ if self._process is None: raise AirflowException("Tried to see if it's done before starting!") if self._...
[ "Check", "if", "the", "process", "launched", "to", "process", "this", "file", "is", "done", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L473-L504
[ "def", "done", "(", "self", ")", ":", "if", "self", ".", "_process", "is", "None", ":", "raise", "AirflowException", "(", "\"Tried to see if it's done before starting!\"", ")", "if", "self", ".", "_done", ":", "return", "True", "# In case result queue is corrupted."...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SchedulerJob._exit_gracefully
Helper method to clean up processor_agent to avoid leaving orphan processes.
airflow/jobs.py
def _exit_gracefully(self, signum, frame): """ Helper method to clean up processor_agent to avoid leaving orphan processes. """ self.log.info("Exiting gracefully upon receiving signal %s", signum) if self.processor_agent: self.processor_agent.end() sys.exit(os...
def _exit_gracefully(self, signum, frame): """ Helper method to clean up processor_agent to avoid leaving orphan processes. """ self.log.info("Exiting gracefully upon receiving signal %s", signum) if self.processor_agent: self.processor_agent.end() sys.exit(os...
[ "Helper", "method", "to", "clean", "up", "processor_agent", "to", "avoid", "leaving", "orphan", "processes", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L599-L606
[ "def", "_exit_gracefully", "(", "self", ",", "signum", ",", "frame", ")", ":", "self", ".", "log", ".", "info", "(", "\"Exiting gracefully upon receiving signal %s\"", ",", "signum", ")", "if", "self", ".", "processor_agent", ":", "self", ".", "processor_agent",...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SchedulerJob.manage_slas
Finding all tasks that have SLAs defined, and sending alert emails where needed. New SLA misses are also recorded in the database. Where assuming that the scheduler runs often, so we only check for tasks that should have succeeded in the past hour.
airflow/jobs.py
def manage_slas(self, dag, session=None): """ Finding all tasks that have SLAs defined, and sending alert emails where needed. New SLA misses are also recorded in the database. Where assuming that the scheduler runs often, so we only check for tasks that should have succeeded in...
def manage_slas(self, dag, session=None): """ Finding all tasks that have SLAs defined, and sending alert emails where needed. New SLA misses are also recorded in the database. Where assuming that the scheduler runs often, so we only check for tasks that should have succeeded in...
[ "Finding", "all", "tasks", "that", "have", "SLAs", "defined", "and", "sending", "alert", "emails", "where", "needed", ".", "New", "SLA", "misses", "are", "also", "recorded", "in", "the", "database", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L609-L738
[ "def", "manage_slas", "(", "self", ",", "dag", ",", "session", "=", "None", ")", ":", "if", "not", "any", "(", "[", "isinstance", "(", "ti", ".", "sla", ",", "timedelta", ")", "for", "ti", "in", "dag", ".", "tasks", "]", ")", ":", "self", ".", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SchedulerJob.update_import_errors
For the DAGs in the given DagBag, record any associated import errors and clears errors for files that no longer have them. These are usually displayed through the Airflow UI so that users know that there are issues parsing DAGs. :param session: session for ORM operations :type session:...
airflow/jobs.py
def update_import_errors(session, dagbag): """ For the DAGs in the given DagBag, record any associated import errors and clears errors for files that no longer have them. These are usually displayed through the Airflow UI so that users know that there are issues parsing DAGs. :p...
def update_import_errors(session, dagbag): """ For the DAGs in the given DagBag, record any associated import errors and clears errors for files that no longer have them. These are usually displayed through the Airflow UI so that users know that there are issues parsing DAGs. :p...
[ "For", "the", "DAGs", "in", "the", "given", "DagBag", "record", "any", "associated", "import", "errors", "and", "clears", "errors", "for", "files", "that", "no", "longer", "have", "them", ".", "These", "are", "usually", "displayed", "through", "the", "Airflo...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L741-L763
[ "def", "update_import_errors", "(", "session", ",", "dagbag", ")", ":", "# Clear the errors of the processed files", "for", "dagbag_file", "in", "dagbag", ".", "file_last_changed", ":", "session", ".", "query", "(", "errors", ".", "ImportError", ")", ".", "filter", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SchedulerJob.create_dag_run
This method checks whether a new DagRun needs to be created for a DAG based on scheduling interval. Returns DagRun if one is scheduled. Otherwise returns None.
airflow/jobs.py
def create_dag_run(self, dag, session=None): """ This method checks whether a new DagRun needs to be created for a DAG based on scheduling interval. Returns DagRun if one is scheduled. Otherwise returns None. """ if dag.schedule_interval and conf.getboolean('scheduler', '...
def create_dag_run(self, dag, session=None): """ This method checks whether a new DagRun needs to be created for a DAG based on scheduling interval. Returns DagRun if one is scheduled. Otherwise returns None. """ if dag.schedule_interval and conf.getboolean('scheduler', '...
[ "This", "method", "checks", "whether", "a", "new", "DagRun", "needs", "to", "be", "created", "for", "a", "DAG", "based", "on", "scheduling", "interval", ".", "Returns", "DagRun", "if", "one", "is", "scheduled", ".", "Otherwise", "returns", "None", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L766-L894
[ "def", "create_dag_run", "(", "self", ",", "dag", ",", "session", "=", "None", ")", ":", "if", "dag", ".", "schedule_interval", "and", "conf", ".", "getboolean", "(", "'scheduler'", ",", "'USE_JOB_SCHEDULE'", ")", ":", "active_runs", "=", "DagRun", ".", "f...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SchedulerJob._process_task_instances
This method schedules the tasks for a single DAG by looking at the active DAG runs and adding task instances that should run to the queue.
airflow/jobs.py
def _process_task_instances(self, dag, queue, session=None): """ This method schedules the tasks for a single DAG by looking at the active DAG runs and adding task instances that should run to the queue. """ # update the state of the previously active dag runs da...
def _process_task_instances(self, dag, queue, session=None): """ This method schedules the tasks for a single DAG by looking at the active DAG runs and adding task instances that should run to the queue. """ # update the state of the previously active dag runs da...
[ "This", "method", "schedules", "the", "tasks", "for", "a", "single", "DAG", "by", "looking", "at", "the", "active", "DAG", "runs", "and", "adding", "task", "instances", "that", "should", "run", "to", "the", "queue", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L897-L954
[ "def", "_process_task_instances", "(", "self", ",", "dag", ",", "queue", ",", "session", "=", "None", ")", ":", "# update the state of the previously active dag runs", "dag_runs", "=", "DagRun", ".", "find", "(", "dag_id", "=", "dag", ".", "dag_id", ",", "state"...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SchedulerJob._change_state_for_tis_without_dagrun
For all DAG IDs in the SimpleDagBag, look for task instances in the old_states and set them to new_state if the corresponding DagRun does not exist or exists but is not in the running state. This normally should not happen, but it can if the state of DagRuns are changed manually. ...
airflow/jobs.py
def _change_state_for_tis_without_dagrun(self, simple_dag_bag, old_states, new_state, session=None): """ For all DAG IDs in ...
def _change_state_for_tis_without_dagrun(self, simple_dag_bag, old_states, new_state, session=None): """ For all DAG IDs in ...
[ "For", "all", "DAG", "IDs", "in", "the", "SimpleDagBag", "look", "for", "task", "instances", "in", "the", "old_states", "and", "set", "them", "to", "new_state", "if", "the", "corresponding", "DagRun", "does", "not", "exist", "or", "exists", "but", "is", "n...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L957-L1012
[ "def", "_change_state_for_tis_without_dagrun", "(", "self", ",", "simple_dag_bag", ",", "old_states", ",", "new_state", ",", "session", "=", "None", ")", ":", "tis_changed", "=", "0", "query", "=", "session", ".", "query", "(", "models", ".", "TaskInstance", "...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SchedulerJob.__get_concurrency_maps
Get the concurrency maps. :param states: List of states to query for :type states: list[airflow.utils.state.State] :return: A map from (dag_id, task_id) to # of task instances and a map from (dag_id, task_id) to # of task instances in the given state list :rtype: dict[tuple[str...
airflow/jobs.py
def __get_concurrency_maps(self, states, session=None): """ Get the concurrency maps. :param states: List of states to query for :type states: list[airflow.utils.state.State] :return: A map from (dag_id, task_id) to # of task instances and a map from (dag_id, task_id) t...
def __get_concurrency_maps(self, states, session=None): """ Get the concurrency maps. :param states: List of states to query for :type states: list[airflow.utils.state.State] :return: A map from (dag_id, task_id) to # of task instances and a map from (dag_id, task_id) t...
[ "Get", "the", "concurrency", "maps", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L1015-L1039
[ "def", "__get_concurrency_maps", "(", "self", ",", "states", ",", "session", "=", "None", ")", ":", "TI", "=", "models", ".", "TaskInstance", "ti_concurrency_query", "=", "(", "session", ".", "query", "(", "TI", ".", "task_id", ",", "TI", ".", "dag_id", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SchedulerJob._find_executable_task_instances
Finds TIs that are ready for execution with respect to pool limits, dag concurrency, executor state, and priority. :param simple_dag_bag: TaskInstances associated with DAGs in the simple_dag_bag will be fetched from the DB and executed :type simple_dag_bag: airflow.utils.dag_process...
airflow/jobs.py
def _find_executable_task_instances(self, simple_dag_bag, states, session=None): """ Finds TIs that are ready for execution with respect to pool limits, dag concurrency, executor state, and priority. :param simple_dag_bag: TaskInstances associated with DAGs in the simple_dag...
def _find_executable_task_instances(self, simple_dag_bag, states, session=None): """ Finds TIs that are ready for execution with respect to pool limits, dag concurrency, executor state, and priority. :param simple_dag_bag: TaskInstances associated with DAGs in the simple_dag...
[ "Finds", "TIs", "that", "are", "ready", "for", "execution", "with", "respect", "to", "pool", "limits", "dag", "concurrency", "executor", "state", "and", "priority", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L1042-L1214
[ "def", "_find_executable_task_instances", "(", "self", ",", "simple_dag_bag", ",", "states", ",", "session", "=", "None", ")", ":", "executable_tis", "=", "[", "]", "# Get all task instances associated with scheduled", "# DagRuns which are not backfilled, in the given states,",...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SchedulerJob._change_state_for_executable_task_instances
Changes the state of task instances in the list with one of the given states to QUEUED atomically, and returns the TIs changed in SimpleTaskInstance format. :param task_instances: TaskInstances to change the state of :type task_instances: list[airflow.models.TaskInstance] :param accepta...
airflow/jobs.py
def _change_state_for_executable_task_instances(self, task_instances, acceptable_states, session=None): """ Changes the state of task instances in the list with one of the given states to QUEUED atomically, and returns the TIs changed in Simple...
def _change_state_for_executable_task_instances(self, task_instances, acceptable_states, session=None): """ Changes the state of task instances in the list with one of the given states to QUEUED atomically, and returns the TIs changed in Simple...
[ "Changes", "the", "state", "of", "task", "instances", "in", "the", "list", "with", "one", "of", "the", "given", "states", "to", "QUEUED", "atomically", "and", "returns", "the", "TIs", "changed", "in", "SimpleTaskInstance", "format", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L1217-L1280
[ "def", "_change_state_for_executable_task_instances", "(", "self", ",", "task_instances", ",", "acceptable_states", ",", "session", "=", "None", ")", ":", "if", "len", "(", "task_instances", ")", "==", "0", ":", "session", ".", "commit", "(", ")", "return", "[...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SchedulerJob._enqueue_task_instances_with_queued_state
Takes task_instances, which should have been set to queued, and enqueues them with the executor. :param simple_task_instances: TaskInstances to enqueue :type simple_task_instances: list[SimpleTaskInstance] :param simple_dag_bag: Should contains all of the task_instances' dags :t...
airflow/jobs.py
def _enqueue_task_instances_with_queued_state(self, simple_dag_bag, simple_task_instances): """ Takes task_instances, which should have been set to queued, and enqueues them with the executor. :param simple_task_instances: TaskInstances ...
def _enqueue_task_instances_with_queued_state(self, simple_dag_bag, simple_task_instances): """ Takes task_instances, which should have been set to queued, and enqueues them with the executor. :param simple_task_instances: TaskInstances ...
[ "Takes", "task_instances", "which", "should", "have", "been", "set", "to", "queued", "and", "enqueues", "them", "with", "the", "executor", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L1282-L1322
[ "def", "_enqueue_task_instances_with_queued_state", "(", "self", ",", "simple_dag_bag", ",", "simple_task_instances", ")", ":", "TI", "=", "models", ".", "TaskInstance", "# actually enqueue them", "for", "simple_task_instance", "in", "simple_task_instances", ":", "simple_da...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SchedulerJob._execute_task_instances
Attempts to execute TaskInstances that should be executed by the scheduler. There are three steps: 1. Pick TIs by priority with the constraint that they are in the expected states and that we do exceed max_active_runs or pool limits. 2. Change the state for the TIs above atomically. ...
airflow/jobs.py
def _execute_task_instances(self, simple_dag_bag, states, session=None): """ Attempts to execute TaskInstances that should be executed by the scheduler. There are three steps: 1. Pick TIs by ...
def _execute_task_instances(self, simple_dag_bag, states, session=None): """ Attempts to execute TaskInstances that should be executed by the scheduler. There are three steps: 1. Pick TIs by ...
[ "Attempts", "to", "execute", "TaskInstances", "that", "should", "be", "executed", "by", "the", "scheduler", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L1325-L1359
[ "def", "_execute_task_instances", "(", "self", ",", "simple_dag_bag", ",", "states", ",", "session", "=", "None", ")", ":", "executable_tis", "=", "self", ".", "_find_executable_task_instances", "(", "simple_dag_bag", ",", "states", ",", "session", "=", "session",...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SchedulerJob._change_state_for_tasks_failed_to_execute
If there are tasks left over in the executor, we set them back to SCHEDULED to avoid creating hanging tasks. :param session: session for ORM operations
airflow/jobs.py
def _change_state_for_tasks_failed_to_execute(self, session): """ If there are tasks left over in the executor, we set them back to SCHEDULED to avoid creating hanging tasks. :param session: session for ORM operations """ if self.executor.queued_tasks: TI = m...
def _change_state_for_tasks_failed_to_execute(self, session): """ If there are tasks left over in the executor, we set them back to SCHEDULED to avoid creating hanging tasks. :param session: session for ORM operations """ if self.executor.queued_tasks: TI = m...
[ "If", "there", "are", "tasks", "left", "over", "in", "the", "executor", "we", "set", "them", "back", "to", "SCHEDULED", "to", "avoid", "creating", "hanging", "tasks", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L1362-L1399
[ "def", "_change_state_for_tasks_failed_to_execute", "(", "self", ",", "session", ")", ":", "if", "self", ".", "executor", ".", "queued_tasks", ":", "TI", "=", "models", ".", "TaskInstance", "filter_for_ti_state_change", "=", "(", "[", "and_", "(", "TI", ".", "...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SchedulerJob._process_dags
Iterates over the dags and processes them. Processing includes: 1. Create appropriate DagRun(s) in the DB. 2. Create appropriate TaskInstance(s) in the DB. 3. Send emails for tasks that have missed SLAs. :param dagbag: a collection of DAGs to process :type dagbag: airflow.model...
airflow/jobs.py
def _process_dags(self, dagbag, dags, tis_out): """ Iterates over the dags and processes them. Processing includes: 1. Create appropriate DagRun(s) in the DB. 2. Create appropriate TaskInstance(s) in the DB. 3. Send emails for tasks that have missed SLAs. :param dagbag:...
def _process_dags(self, dagbag, dags, tis_out): """ Iterates over the dags and processes them. Processing includes: 1. Create appropriate DagRun(s) in the DB. 2. Create appropriate TaskInstance(s) in the DB. 3. Send emails for tasks that have missed SLAs. :param dagbag:...
[ "Iterates", "over", "the", "dags", "and", "processes", "them", ".", "Processing", "includes", ":" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L1401-L1439
[ "def", "_process_dags", "(", "self", ",", "dagbag", ",", "dags", ",", "tis_out", ")", ":", "for", "dag", "in", "dags", ":", "dag", "=", "dagbag", ".", "get_dag", "(", "dag", ".", "dag_id", ")", "if", "not", "dag", ":", "self", ".", "log", ".", "e...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SchedulerJob._process_executor_events
Respond to executor events.
airflow/jobs.py
def _process_executor_events(self, simple_dag_bag, session=None): """ Respond to executor events. """ # TODO: this shares quite a lot of code with _manage_executor_state TI = models.TaskInstance for key, state in list(self.executor.get_event_buffer(simple_dag_bag.dag_ids...
def _process_executor_events(self, simple_dag_bag, session=None): """ Respond to executor events. """ # TODO: this shares quite a lot of code with _manage_executor_state TI = models.TaskInstance for key, state in list(self.executor.get_event_buffer(simple_dag_bag.dag_ids...
[ "Respond", "to", "executor", "events", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L1442-L1484
[ "def", "_process_executor_events", "(", "self", ",", "simple_dag_bag", ",", "session", "=", "None", ")", ":", "# TODO: this shares quite a lot of code with _manage_executor_state", "TI", "=", "models", ".", "TaskInstance", "for", "key", ",", "state", "in", "list", "("...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SchedulerJob._execute_helper
The actual scheduler loop. The main steps in the loop are: #. Harvest DAG parsing results through DagFileProcessorAgent #. Find and queue executable tasks #. Change task instance state in DB #. Queue tasks in executor #. Heartbeat executor ...
airflow/jobs.py
def _execute_helper(self): """ The actual scheduler loop. The main steps in the loop are: #. Harvest DAG parsing results through DagFileProcessorAgent #. Find and queue executable tasks #. Change task instance state in DB #. Queue tasks in executor...
def _execute_helper(self): """ The actual scheduler loop. The main steps in the loop are: #. Harvest DAG parsing results through DagFileProcessorAgent #. Find and queue executable tasks #. Change task instance state in DB #. Queue tasks in executor...
[ "The", "actual", "scheduler", "loop", ".", "The", "main", "steps", "in", "the", "loop", "are", ":", "#", ".", "Harvest", "DAG", "parsing", "results", "through", "DagFileProcessorAgent", "#", ".", "Find", "and", "queue", "executable", "tasks", "#", ".", "Ch...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L1526-L1666
[ "def", "_execute_helper", "(", "self", ")", ":", "self", ".", "executor", ".", "start", "(", ")", "self", ".", "log", ".", "info", "(", "\"Resetting orphaned tasks for active dag runs\"", ")", "self", ".", "reset_state_for_orphaned_tasks", "(", ")", "# Start after...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SchedulerJob.process_file
Process a Python file containing Airflow DAGs. This includes: 1. Execute the file and look for DAG objects in the namespace. 2. Pickle the DAG and save it to the DB (if necessary). 3. For each DAG, see what tasks should run and create appropriate task instances in the DB. ...
airflow/jobs.py
def process_file(self, file_path, zombies, pickle_dags=False, session=None): """ Process a Python file containing Airflow DAGs. This includes: 1. Execute the file and look for DAG objects in the namespace. 2. Pickle the DAG and save it to the DB (if necessary). 3. For e...
def process_file(self, file_path, zombies, pickle_dags=False, session=None): """ Process a Python file containing Airflow DAGs. This includes: 1. Execute the file and look for DAG objects in the namespace. 2. Pickle the DAG and save it to the DB (if necessary). 3. For e...
[ "Process", "a", "Python", "file", "containing", "Airflow", "DAGs", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L1669-L1787
[ "def", "process_file", "(", "self", ",", "file_path", ",", "zombies", ",", "pickle_dags", "=", "False", ",", "session", "=", "None", ")", ":", "self", ".", "log", ".", "info", "(", "\"Processing file %s for tasks to queue\"", ",", "file_path", ")", "# As DAGs ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
BackfillJob._update_counters
Updates the counters per state of the tasks that were running. Can re-add to tasks to run in case required. :param ti_status: the internal status of the backfill job tasks :type ti_status: BackfillJob._DagRunTaskStatus
airflow/jobs.py
def _update_counters(self, ti_status): """ Updates the counters per state of the tasks that were running. Can re-add to tasks to run in case required. :param ti_status: the internal status of the backfill job tasks :type ti_status: BackfillJob._DagRunTaskStatus """ ...
def _update_counters(self, ti_status): """ Updates the counters per state of the tasks that were running. Can re-add to tasks to run in case required. :param ti_status: the internal status of the backfill job tasks :type ti_status: BackfillJob._DagRunTaskStatus """ ...
[ "Updates", "the", "counters", "per", "state", "of", "the", "tasks", "that", "were", "running", ".", "Can", "re", "-", "add", "to", "tasks", "to", "run", "in", "case", "required", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L1929-L1977
[ "def", "_update_counters", "(", "self", ",", "ti_status", ")", ":", "for", "key", ",", "ti", "in", "list", "(", "ti_status", ".", "running", ".", "items", "(", ")", ")", ":", "ti", ".", "refresh_from_db", "(", ")", "if", "ti", ".", "state", "==", "...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
BackfillJob._manage_executor_state
Checks if the executor agrees with the state of task instances that are running :param running: dict of key, task to verify
airflow/jobs.py
def _manage_executor_state(self, running): """ Checks if the executor agrees with the state of task instances that are running :param running: dict of key, task to verify """ executor = self.executor for key, state in list(executor.get_event_buffer().items()): ...
def _manage_executor_state(self, running): """ Checks if the executor agrees with the state of task instances that are running :param running: dict of key, task to verify """ executor = self.executor for key, state in list(executor.get_event_buffer().items()): ...
[ "Checks", "if", "the", "executor", "agrees", "with", "the", "state", "of", "task", "instances", "that", "are", "running" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L1979-L2007
[ "def", "_manage_executor_state", "(", "self", ",", "running", ")", ":", "executor", "=", "self", ".", "executor", "for", "key", ",", "state", "in", "list", "(", "executor", ".", "get_event_buffer", "(", ")", ".", "items", "(", ")", ")", ":", "if", "key...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
BackfillJob._get_dag_run
Returns a dag run for the given run date, which will be matched to an existing dag run if available or create a new dag run otherwise. If the max_active_runs limit is reached, this function will return None. :param run_date: the execution date for the dag run :type run_date: datetime.da...
airflow/jobs.py
def _get_dag_run(self, run_date, session=None): """ Returns a dag run for the given run date, which will be matched to an existing dag run if available or create a new dag run otherwise. If the max_active_runs limit is reached, this function will return None. :param run_date: th...
def _get_dag_run(self, run_date, session=None): """ Returns a dag run for the given run date, which will be matched to an existing dag run if available or create a new dag run otherwise. If the max_active_runs limit is reached, this function will return None. :param run_date: th...
[ "Returns", "a", "dag", "run", "for", "the", "given", "run", "date", "which", "will", "be", "matched", "to", "an", "existing", "dag", "run", "if", "available", "or", "create", "a", "new", "dag", "run", "otherwise", ".", "If", "the", "max_active_runs", "li...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L2010-L2068
[ "def", "_get_dag_run", "(", "self", ",", "run_date", ",", "session", "=", "None", ")", ":", "run_id", "=", "BackfillJob", ".", "ID_FORMAT_PREFIX", ".", "format", "(", "run_date", ".", "isoformat", "(", ")", ")", "# consider max_active_runs but ignore when running ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
BackfillJob._task_instances_for_dag_run
Returns a map of task instance key to task instance object for the tasks to run in the given dag run. :param dag_run: the dag run to get the tasks from :type dag_run: airflow.models.DagRun :param session: the database session object :type session: sqlalchemy.orm.session.Session
airflow/jobs.py
def _task_instances_for_dag_run(self, dag_run, session=None): """ Returns a map of task instance key to task instance object for the tasks to run in the given dag run. :param dag_run: the dag run to get the tasks from :type dag_run: airflow.models.DagRun :param session: ...
def _task_instances_for_dag_run(self, dag_run, session=None): """ Returns a map of task instance key to task instance object for the tasks to run in the given dag run. :param dag_run: the dag run to get the tasks from :type dag_run: airflow.models.DagRun :param session: ...
[ "Returns", "a", "map", "of", "task", "instance", "key", "to", "task", "instance", "object", "for", "the", "tasks", "to", "run", "in", "the", "given", "dag", "run", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L2071-L2101
[ "def", "_task_instances_for_dag_run", "(", "self", ",", "dag_run", ",", "session", "=", "None", ")", ":", "tasks_to_run", "=", "{", "}", "if", "dag_run", "is", "None", ":", "return", "tasks_to_run", "# check if we have orphaned tasks", "self", ".", "reset_state_fo...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
BackfillJob._process_backfill_task_instances
Process a set of task instances from a set of dag runs. Special handling is done to account for different task instance states that could be present when running them in a backfill process. :param ti_status: the internal status of the job :type ti_status: BackfillJob._DagRunTaskStatus ...
airflow/jobs.py
def _process_backfill_task_instances(self, ti_status, executor, pickle_id, start_date=None, session=None): """ Process a set of task instanc...
def _process_backfill_task_instances(self, ti_status, executor, pickle_id, start_date=None, session=None): """ Process a set of task instanc...
[ "Process", "a", "set", "of", "task", "instances", "from", "a", "set", "of", "dag", "runs", ".", "Special", "handling", "is", "done", "to", "account", "for", "different", "task", "instance", "states", "that", "could", "be", "present", "when", "running", "th...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L2118-L2366
[ "def", "_process_backfill_task_instances", "(", "self", ",", "ti_status", ",", "executor", ",", "pickle_id", ",", "start_date", "=", "None", ",", "session", "=", "None", ")", ":", "executed_run_dates", "=", "[", "]", "while", "(", "(", "len", "(", "ti_status...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
BackfillJob._execute_for_run_dates
Computes the dag runs and their respective task instances for the given run dates and executes the task instances. Returns a list of execution dates of the dag runs that were executed. :param run_dates: Execution dates for dag runs :type run_dates: list :param ti_status: interna...
airflow/jobs.py
def _execute_for_run_dates(self, run_dates, ti_status, executor, pickle_id, start_date, session=None): """ Computes the dag runs and their respective task instances for the given run dates and executes the task instances. Returns a list of execution dates o...
def _execute_for_run_dates(self, run_dates, ti_status, executor, pickle_id, start_date, session=None): """ Computes the dag runs and their respective task instances for the given run dates and executes the task instances. Returns a list of execution dates o...
[ "Computes", "the", "dag", "runs", "and", "their", "respective", "task", "instances", "for", "the", "given", "run", "dates", "and", "executes", "the", "task", "instances", ".", "Returns", "a", "list", "of", "execution", "dates", "of", "the", "dag", "runs", ...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L2405-L2442
[ "def", "_execute_for_run_dates", "(", "self", ",", "run_dates", ",", "ti_status", ",", "executor", ",", "pickle_id", ",", "start_date", ",", "session", "=", "None", ")", ":", "for", "next_run_date", "in", "run_dates", ":", "dag_run", "=", "self", ".", "_get_...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
BackfillJob._set_unfinished_dag_runs_to_failed
Go through the dag_runs and update the state based on the task_instance state. Then set DAG runs that are not finished to failed. :param dag_runs: DAG runs :param session: session :return: None
airflow/jobs.py
def _set_unfinished_dag_runs_to_failed(self, dag_runs, session=None): """ Go through the dag_runs and update the state based on the task_instance state. Then set DAG runs that are not finished to failed. :param dag_runs: DAG runs :param session: session :return: None ...
def _set_unfinished_dag_runs_to_failed(self, dag_runs, session=None): """ Go through the dag_runs and update the state based on the task_instance state. Then set DAG runs that are not finished to failed. :param dag_runs: DAG runs :param session: session :return: None ...
[ "Go", "through", "the", "dag_runs", "and", "update", "the", "state", "based", "on", "the", "task_instance", "state", ".", "Then", "set", "DAG", "runs", "that", "are", "not", "finished", "to", "failed", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L2445-L2458
[ "def", "_set_unfinished_dag_runs_to_failed", "(", "self", ",", "dag_runs", ",", "session", "=", "None", ")", ":", "for", "dag_run", "in", "dag_runs", ":", "dag_run", ".", "update_state", "(", ")", "if", "dag_run", ".", "state", "not", "in", "State", ".", "...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
BackfillJob._execute
Initializes all components required to run a dag for a specified date range and calls helper method to execute the tasks.
airflow/jobs.py
def _execute(self, session=None): """ Initializes all components required to run a dag for a specified date range and calls helper method to execute the tasks. """ ti_status = BackfillJob._DagRunTaskStatus() start_date = self.bf_start_date # Get intervals betwee...
def _execute(self, session=None): """ Initializes all components required to run a dag for a specified date range and calls helper method to execute the tasks. """ ti_status = BackfillJob._DagRunTaskStatus() start_date = self.bf_start_date # Get intervals betwee...
[ "Initializes", "all", "components", "required", "to", "run", "a", "dag", "for", "a", "specified", "date", "range", "and", "calls", "helper", "method", "to", "execute", "the", "tasks", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L2461-L2536
[ "def", "_execute", "(", "self", ",", "session", "=", "None", ")", ":", "ti_status", "=", "BackfillJob", ".", "_DagRunTaskStatus", "(", ")", "start_date", "=", "self", ".", "bf_start_date", "# Get intervals between the start/end dates, which will turn into dag runs", "ru...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
LocalTaskJob.heartbeat_callback
Self destruct task if state has been moved away from running externally
airflow/jobs.py
def heartbeat_callback(self, session=None): """Self destruct task if state has been moved away from running externally""" if self.terminating: # ensure termination if processes are created later self.task_runner.terminate() return self.task_instance.refresh_...
def heartbeat_callback(self, session=None): """Self destruct task if state has been moved away from running externally""" if self.terminating: # ensure termination if processes are created later self.task_runner.terminate() return self.task_instance.refresh_...
[ "Self", "destruct", "task", "if", "state", "has", "been", "moved", "away", "from", "running", "externally" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/jobs.py#L2637-L2673
[ "def", "heartbeat_callback", "(", "self", ",", "session", "=", "None", ")", ":", "if", "self", ".", "terminating", ":", "# ensure termination if processes are created later", "self", ".", "task_runner", ".", "terminate", "(", ")", "return", "self", ".", "task_inst...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
CloudSpannerHook._get_client
Provides a client for interacting with the Cloud Spanner API. :param project_id: The ID of the GCP project. :type project_id: str :return: google.cloud.spanner_v1.client.Client :rtype: object
airflow/contrib/hooks/gcp_spanner_hook.py
def _get_client(self, project_id): """ Provides a client for interacting with the Cloud Spanner API. :param project_id: The ID of the GCP project. :type project_id: str :return: google.cloud.spanner_v1.client.Client :rtype: object """ if not self._client...
def _get_client(self, project_id): """ Provides a client for interacting with the Cloud Spanner API. :param project_id: The ID of the GCP project. :type project_id: str :return: google.cloud.spanner_v1.client.Client :rtype: object """ if not self._client...
[ "Provides", "a", "client", "for", "interacting", "with", "the", "Cloud", "Spanner", "API", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_spanner_hook.py#L41-L52
[ "def", "_get_client", "(", "self", ",", "project_id", ")", ":", "if", "not", "self", ".", "_client", ":", "self", ".", "_client", "=", "Client", "(", "project", "=", "project_id", ",", "credentials", "=", "self", ".", "_get_credentials", "(", ")", ")", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
CloudSpannerHook.get_instance
Gets information about a particular instance. :param project_id: Optional, The ID of the GCP project that owns the Cloud Spanner database. If set to None or missing, the default project_id from the GCP connection is used. :type project_id: str :param instance_id: The ID of the Clo...
airflow/contrib/hooks/gcp_spanner_hook.py
def get_instance(self, instance_id, project_id=None): """ Gets information about a particular instance. :param project_id: Optional, The ID of the GCP project that owns the Cloud Spanner database. If set to None or missing, the default project_id from the GCP connection is used. ...
def get_instance(self, instance_id, project_id=None): """ Gets information about a particular instance. :param project_id: Optional, The ID of the GCP project that owns the Cloud Spanner database. If set to None or missing, the default project_id from the GCP connection is used. ...
[ "Gets", "information", "about", "a", "particular", "instance", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_spanner_hook.py#L55-L70
[ "def", "get_instance", "(", "self", ",", "instance_id", ",", "project_id", "=", "None", ")", ":", "instance", "=", "self", ".", "_get_client", "(", "project_id", "=", "project_id", ")", ".", "instance", "(", "instance_id", "=", "instance_id", ")", "if", "n...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
CloudSpannerHook._apply_to_instance
Invokes a method on a given instance by applying a specified Callable. :param project_id: The ID of the GCP project that owns the Cloud Spanner database. :type project_id: str :param instance_id: The ID of the instance. :type instance_id: str :param configuration_na...
airflow/contrib/hooks/gcp_spanner_hook.py
def _apply_to_instance(self, project_id, instance_id, configuration_name, node_count, display_name, func): """ Invokes a method on a given instance by applying a specified Callable. :param project_id: The ID of the GCP project that owns the Cloud Spanner ...
def _apply_to_instance(self, project_id, instance_id, configuration_name, node_count, display_name, func): """ Invokes a method on a given instance by applying a specified Callable. :param project_id: The ID of the GCP project that owns the Cloud Spanner ...
[ "Invokes", "a", "method", "on", "a", "given", "instance", "by", "applying", "a", "specified", "Callable", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_spanner_hook.py#L72-L106
[ "def", "_apply_to_instance", "(", "self", ",", "project_id", ",", "instance_id", ",", "configuration_name", ",", "node_count", ",", "display_name", ",", "func", ")", ":", "# noinspection PyUnresolvedReferences", "instance", "=", "self", ".", "_get_client", "(", "pro...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
CloudSpannerHook.create_instance
Creates a new Cloud Spanner instance. :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param configuration_name: The name of the instance configuration defining how the instance will be created. Possible configuration values can be retrieved via ...
airflow/contrib/hooks/gcp_spanner_hook.py
def create_instance(self, instance_id, configuration_name, node_count, display_name, project_id=None): """ Creates a new Cloud Spanner instance. :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param configuration_name: Th...
def create_instance(self, instance_id, configuration_name, node_count, display_name, project_id=None): """ Creates a new Cloud Spanner instance. :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param configuration_name: Th...
[ "Creates", "a", "new", "Cloud", "Spanner", "instance", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_spanner_hook.py#L109-L133
[ "def", "create_instance", "(", "self", ",", "instance_id", ",", "configuration_name", ",", "node_count", ",", "display_name", ",", "project_id", "=", "None", ")", ":", "self", ".", "_apply_to_instance", "(", "project_id", ",", "instance_id", ",", "configuration_na...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
CloudSpannerHook.update_instance
Updates an existing Cloud Spanner instance. :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param configuration_name: The name of the instance configuration defining how the instance will be created. Possible configuration values can be retrieved vi...
airflow/contrib/hooks/gcp_spanner_hook.py
def update_instance(self, instance_id, configuration_name, node_count, display_name, project_id=None): """ Updates an existing Cloud Spanner instance. :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param configuration_na...
def update_instance(self, instance_id, configuration_name, node_count, display_name, project_id=None): """ Updates an existing Cloud Spanner instance. :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param configuration_na...
[ "Updates", "an", "existing", "Cloud", "Spanner", "instance", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_spanner_hook.py#L136-L160
[ "def", "update_instance", "(", "self", ",", "instance_id", ",", "configuration_name", ",", "node_count", ",", "display_name", ",", "project_id", "=", "None", ")", ":", "return", "self", ".", "_apply_to_instance", "(", "project_id", ",", "instance_id", ",", "conf...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
CloudSpannerHook.delete_instance
Deletes an existing Cloud Spanner instance. :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param project_id: Optional, the ID of the GCP project that owns the Cloud Spanner database. If set to None or missing, the default project_id from the GCP co...
airflow/contrib/hooks/gcp_spanner_hook.py
def delete_instance(self, instance_id, project_id=None): """ Deletes an existing Cloud Spanner instance. :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param project_id: Optional, the ID of the GCP project that owns the Cloud Spanner ...
def delete_instance(self, instance_id, project_id=None): """ Deletes an existing Cloud Spanner instance. :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param project_id: Optional, the ID of the GCP project that owns the Cloud Spanner ...
[ "Deletes", "an", "existing", "Cloud", "Spanner", "instance", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_spanner_hook.py#L163-L181
[ "def", "delete_instance", "(", "self", ",", "instance_id", ",", "project_id", "=", "None", ")", ":", "instance", "=", "self", ".", "_get_client", "(", "project_id", "=", "project_id", ")", ".", "instance", "(", "instance_id", ")", "try", ":", "instance", "...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
CloudSpannerHook.get_database
Retrieves a database in Cloud Spanner. If the database does not exist in the specified instance, it returns None. :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param database_id: The ID of the database in Cloud Spanner. :type database_id: str ...
airflow/contrib/hooks/gcp_spanner_hook.py
def get_database(self, instance_id, database_id, project_id=None): """ Retrieves a database in Cloud Spanner. If the database does not exist in the specified instance, it returns None. :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :para...
def get_database(self, instance_id, database_id, project_id=None): """ Retrieves a database in Cloud Spanner. If the database does not exist in the specified instance, it returns None. :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :para...
[ "Retrieves", "a", "database", "in", "Cloud", "Spanner", ".", "If", "the", "database", "does", "not", "exist", "in", "the", "specified", "instance", "it", "returns", "None", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_spanner_hook.py#L184-L209
[ "def", "get_database", "(", "self", ",", "instance_id", ",", "database_id", ",", "project_id", "=", "None", ")", ":", "instance", "=", "self", ".", "_get_client", "(", "project_id", "=", "project_id", ")", ".", "instance", "(", "instance_id", "=", "instance_...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
CloudSpannerHook.create_database
Creates a new database in Cloud Spanner. :type project_id: str :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param database_id: The ID of the database to create in Cloud Spanner. :type database_id: str :param ddl_statements: The string...
airflow/contrib/hooks/gcp_spanner_hook.py
def create_database(self, instance_id, database_id, ddl_statements, project_id=None): """ Creates a new database in Cloud Spanner. :type project_id: str :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param database_id: The ID of the dat...
def create_database(self, instance_id, database_id, ddl_statements, project_id=None): """ Creates a new database in Cloud Spanner. :type project_id: str :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param database_id: The ID of the dat...
[ "Creates", "a", "new", "database", "in", "Cloud", "Spanner", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_spanner_hook.py#L212-L244
[ "def", "create_database", "(", "self", ",", "instance_id", ",", "database_id", ",", "ddl_statements", ",", "project_id", "=", "None", ")", ":", "instance", "=", "self", ".", "_get_client", "(", "project_id", "=", "project_id", ")", ".", "instance", "(", "ins...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
CloudSpannerHook.update_database
Updates DDL of a database in Cloud Spanner. :type project_id: str :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param database_id: The ID of the database in Cloud Spanner. :type database_id: str :param ddl_statements: The string list c...
airflow/contrib/hooks/gcp_spanner_hook.py
def update_database(self, instance_id, database_id, ddl_statements, project_id=None, operation_id=None): """ Updates DDL of a database in Cloud Spanner. :type project_id: str :param instance_id: The ID of the Cloud Spanner instance. ...
def update_database(self, instance_id, database_id, ddl_statements, project_id=None, operation_id=None): """ Updates DDL of a database in Cloud Spanner. :type project_id: str :param instance_id: The ID of the Cloud Spanner instance. ...
[ "Updates", "DDL", "of", "a", "database", "in", "Cloud", "Spanner", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_spanner_hook.py#L247-L288
[ "def", "update_database", "(", "self", ",", "instance_id", ",", "database_id", ",", "ddl_statements", ",", "project_id", "=", "None", ",", "operation_id", "=", "None", ")", ":", "instance", "=", "self", ".", "_get_client", "(", "project_id", "=", "project_id",...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
CloudSpannerHook.delete_database
Drops a database in Cloud Spanner. :type project_id: str :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param database_id: The ID of the database in Cloud Spanner. :type database_id: str :param project_id: Optional, the ID of the GCP p...
airflow/contrib/hooks/gcp_spanner_hook.py
def delete_database(self, instance_id, database_id, project_id=None): """ Drops a database in Cloud Spanner. :type project_id: str :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param database_id: The ID of the database in Cloud Spanner...
def delete_database(self, instance_id, database_id, project_id=None): """ Drops a database in Cloud Spanner. :type project_id: str :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param database_id: The ID of the database in Cloud Spanner...
[ "Drops", "a", "database", "in", "Cloud", "Spanner", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_spanner_hook.py#L291-L325
[ "def", "delete_database", "(", "self", ",", "instance_id", ",", "database_id", ",", "project_id", "=", "None", ")", ":", "instance", "=", "self", ".", "_get_client", "(", "project_id", "=", "project_id", ")", ".", "instance", "(", "instance_id", "=", "instan...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
CloudSpannerHook.execute_dml
Executes an arbitrary DML query (INSERT, UPDATE, DELETE). :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param database_id: The ID of the database in Cloud Spanner. :type database_id: str :param queries: The queries to execute. :type qu...
airflow/contrib/hooks/gcp_spanner_hook.py
def execute_dml(self, instance_id, database_id, queries, project_id=None): """ Executes an arbitrary DML query (INSERT, UPDATE, DELETE). :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param database_id: The ID of the database in Cloud Spanner. ...
def execute_dml(self, instance_id, database_id, queries, project_id=None): """ Executes an arbitrary DML query (INSERT, UPDATE, DELETE). :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param database_id: The ID of the database in Cloud Spanner. ...
[ "Executes", "an", "arbitrary", "DML", "query", "(", "INSERT", "UPDATE", "DELETE", ")", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_spanner_hook.py#L328-L344
[ "def", "execute_dml", "(", "self", ",", "instance_id", ",", "database_id", ",", "queries", ",", "project_id", "=", "None", ")", ":", "self", ".", "_get_client", "(", "project_id", "=", "project_id", ")", ".", "instance", "(", "instance_id", "=", "instance_id...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
ImapAttachmentSensor.poke
Pokes for a mail attachment on the mail server. :param context: The context that is being provided when poking. :type context: dict :return: True if attachment with the given name is present and False if not. :rtype: bool
airflow/contrib/sensors/imap_attachment_sensor.py
def poke(self, context): """ Pokes for a mail attachment on the mail server. :param context: The context that is being provided when poking. :type context: dict :return: True if attachment with the given name is present and False if not. :rtype: bool """ ...
def poke(self, context): """ Pokes for a mail attachment on the mail server. :param context: The context that is being provided when poking. :type context: dict :return: True if attachment with the given name is present and False if not. :rtype: bool """ ...
[ "Pokes", "for", "a", "mail", "attachment", "on", "the", "mail", "server", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/sensors/imap_attachment_sensor.py#L60-L76
[ "def", "poke", "(", "self", ",", "context", ")", ":", "self", ".", "log", ".", "info", "(", "'Poking for %s'", ",", "self", ".", "attachment_name", ")", "with", "ImapHook", "(", "imap_conn_id", "=", "self", ".", "conn_id", ")", "as", "imap_hook", ":", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
prepare_additional_parameters
Creates additional_properties parameter based on language_hints, web_detection_params and additional_properties parameters specified by the user
airflow/contrib/operators/gcp_vision_operator.py
def prepare_additional_parameters(additional_properties, language_hints, web_detection_params): """ Creates additional_properties parameter based on language_hints, web_detection_params and additional_properties parameters specified by the user """ if language_hints is None and web_detection_params ...
def prepare_additional_parameters(additional_properties, language_hints, web_detection_params): """ Creates additional_properties parameter based on language_hints, web_detection_params and additional_properties parameters specified by the user """ if language_hints is None and web_detection_params ...
[ "Creates", "additional_properties", "parameter", "based", "on", "language_hints", "web_detection_params", "and", "additional_properties", "parameters", "specified", "by", "the", "user" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/gcp_vision_operator.py#L1221-L1244
[ "def", "prepare_additional_parameters", "(", "additional_properties", ",", "language_hints", ",", "web_detection_params", ")", ":", "if", "language_hints", "is", "None", "and", "web_detection_params", "is", "None", ":", "return", "additional_properties", "if", "additional...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
CassandraHook.get_conn
Returns a cassandra Session object
airflow/contrib/hooks/cassandra_hook.py
def get_conn(self): """ Returns a cassandra Session object """ if self.session and not self.session.is_shutdown: return self.session self.session = self.cluster.connect(self.keyspace) return self.session
def get_conn(self): """ Returns a cassandra Session object """ if self.session and not self.session.is_shutdown: return self.session self.session = self.cluster.connect(self.keyspace) return self.session
[ "Returns", "a", "cassandra", "Session", "object" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/cassandra_hook.py#L108-L115
[ "def", "get_conn", "(", "self", ")", ":", "if", "self", ".", "session", "and", "not", "self", ".", "session", ".", "is_shutdown", ":", "return", "self", ".", "session", "self", ".", "session", "=", "self", ".", "cluster", ".", "connect", "(", "self", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
CassandraHook.table_exists
Checks if a table exists in Cassandra :param table: Target Cassandra table. Use dot notation to target a specific keyspace. :type table: str
airflow/contrib/hooks/cassandra_hook.py
def table_exists(self, table): """ Checks if a table exists in Cassandra :param table: Target Cassandra table. Use dot notation to target a specific keyspace. :type table: str """ keyspace = self.keyspace if '.' in table: keyspac...
def table_exists(self, table): """ Checks if a table exists in Cassandra :param table: Target Cassandra table. Use dot notation to target a specific keyspace. :type table: str """ keyspace = self.keyspace if '.' in table: keyspac...
[ "Checks", "if", "a", "table", "exists", "in", "Cassandra" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/cassandra_hook.py#L164-L177
[ "def", "table_exists", "(", "self", ",", "table", ")", ":", "keyspace", "=", "self", ".", "keyspace", "if", "'.'", "in", "table", ":", "keyspace", ",", "table", "=", "table", ".", "split", "(", "'.'", ",", "1", ")", "cluster_metadata", "=", "self", "...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
CassandraHook.record_exists
Checks if a record exists in Cassandra :param table: Target Cassandra table. Use dot notation to target a specific keyspace. :type table: str :param keys: The keys and their values to check the existence. :type keys: dict
airflow/contrib/hooks/cassandra_hook.py
def record_exists(self, table, keys): """ Checks if a record exists in Cassandra :param table: Target Cassandra table. Use dot notation to target a specific keyspace. :type table: str :param keys: The keys and their values to check the existence. :t...
def record_exists(self, table, keys): """ Checks if a record exists in Cassandra :param table: Target Cassandra table. Use dot notation to target a specific keyspace. :type table: str :param keys: The keys and their values to check the existence. :t...
[ "Checks", "if", "a", "record", "exists", "in", "Cassandra" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/cassandra_hook.py#L179-L200
[ "def", "record_exists", "(", "self", ",", "table", ",", "keys", ")", ":", "keyspace", "=", "self", ".", "keyspace", "if", "'.'", "in", "table", ":", "keyspace", ",", "table", "=", "table", ".", "split", "(", "'.'", ",", "1", ")", "ks", "=", "\" AND...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SparkSubmitHook._build_spark_submit_command
Construct the spark-submit command to execute. :param application: command to append to the spark-submit command :type application: str :return: full command to be executed
airflow/contrib/hooks/spark_submit_hook.py
def _build_spark_submit_command(self, application): """ Construct the spark-submit command to execute. :param application: command to append to the spark-submit command :type application: str :return: full command to be executed """ connection_cmd = self._get_spar...
def _build_spark_submit_command(self, application): """ Construct the spark-submit command to execute. :param application: command to append to the spark-submit command :type application: str :return: full command to be executed """ connection_cmd = self._get_spar...
[ "Construct", "the", "spark", "-", "submit", "command", "to", "execute", ".", ":", "param", "application", ":", "command", "to", "append", "to", "the", "spark", "-", "submit", "command", ":", "type", "application", ":", "str", ":", "return", ":", "full", ...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/spark_submit_hook.py#L215-L297
[ "def", "_build_spark_submit_command", "(", "self", ",", "application", ")", ":", "connection_cmd", "=", "self", ".", "_get_spark_binary_path", "(", ")", "# The url ot the spark master", "connection_cmd", "+=", "[", "\"--master\"", ",", "self", ".", "_connection", "[",...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SparkSubmitHook._build_track_driver_status_command
Construct the command to poll the driver status. :return: full command to be executed
airflow/contrib/hooks/spark_submit_hook.py
def _build_track_driver_status_command(self): """ Construct the command to poll the driver status. :return: full command to be executed """ connection_cmd = self._get_spark_binary_path() # The url ot the spark master connection_cmd += ["--master", self._connecti...
def _build_track_driver_status_command(self): """ Construct the command to poll the driver status. :return: full command to be executed """ connection_cmd = self._get_spark_binary_path() # The url ot the spark master connection_cmd += ["--master", self._connecti...
[ "Construct", "the", "command", "to", "poll", "the", "driver", "status", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/spark_submit_hook.py#L299-L320
[ "def", "_build_track_driver_status_command", "(", "self", ")", ":", "connection_cmd", "=", "self", ".", "_get_spark_binary_path", "(", ")", "# The url ot the spark master", "connection_cmd", "+=", "[", "\"--master\"", ",", "self", ".", "_connection", "[", "'master'", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SparkSubmitHook.submit
Remote Popen to execute the spark-submit job :param application: Submitted application, jar or py file :type application: str :param kwargs: extra arguments to Popen (see subprocess.Popen)
airflow/contrib/hooks/spark_submit_hook.py
def submit(self, application="", **kwargs): """ Remote Popen to execute the spark-submit job :param application: Submitted application, jar or py file :type application: str :param kwargs: extra arguments to Popen (see subprocess.Popen) """ spark_submit_cmd = sel...
def submit(self, application="", **kwargs): """ Remote Popen to execute the spark-submit job :param application: Submitted application, jar or py file :type application: str :param kwargs: extra arguments to Popen (see subprocess.Popen) """ spark_submit_cmd = sel...
[ "Remote", "Popen", "to", "execute", "the", "spark", "-", "submit", "job" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/spark_submit_hook.py#L322-L376
[ "def", "submit", "(", "self", ",", "application", "=", "\"\"", ",", "*", "*", "kwargs", ")", ":", "spark_submit_cmd", "=", "self", ".", "_build_spark_submit_command", "(", "application", ")", "if", "hasattr", "(", "self", ",", "'_env'", ")", ":", "env", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SparkSubmitHook._process_spark_submit_log
Processes the log files and extracts useful information out of it. If the deploy-mode is 'client', log the output of the submit command as those are the output logs of the Spark worker directly. Remark: If the driver needs to be tracked for its status, the log-level of the spark deploy...
airflow/contrib/hooks/spark_submit_hook.py
def _process_spark_submit_log(self, itr): """ Processes the log files and extracts useful information out of it. If the deploy-mode is 'client', log the output of the submit command as those are the output logs of the Spark worker directly. Remark: If the driver needs to be tra...
def _process_spark_submit_log(self, itr): """ Processes the log files and extracts useful information out of it. If the deploy-mode is 'client', log the output of the submit command as those are the output logs of the Spark worker directly. Remark: If the driver needs to be tra...
[ "Processes", "the", "log", "files", "and", "extracts", "useful", "information", "out", "of", "it", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/spark_submit_hook.py#L378-L429
[ "def", "_process_spark_submit_log", "(", "self", ",", "itr", ")", ":", "# Consume the iterator", "for", "line", "in", "itr", ":", "line", "=", "line", ".", "strip", "(", ")", "# If we run yarn cluster mode, we want to extract the application id from", "# the logs so we ca...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SparkSubmitHook._process_spark_status_log
parses the logs of the spark driver status query process :param itr: An iterator which iterates over the input of the subprocess
airflow/contrib/hooks/spark_submit_hook.py
def _process_spark_status_log(self, itr): """ parses the logs of the spark driver status query process :param itr: An iterator which iterates over the input of the subprocess """ # Consume the iterator for line in itr: line = line.strip() # Check...
def _process_spark_status_log(self, itr): """ parses the logs of the spark driver status query process :param itr: An iterator which iterates over the input of the subprocess """ # Consume the iterator for line in itr: line = line.strip() # Check...
[ "parses", "the", "logs", "of", "the", "spark", "driver", "status", "query", "process" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/spark_submit_hook.py#L431-L446
[ "def", "_process_spark_status_log", "(", "self", ",", "itr", ")", ":", "# Consume the iterator", "for", "line", "in", "itr", ":", "line", "=", "line", ".", "strip", "(", ")", "# Check if the log line is about the driver status and extract the status.", "if", "\"driverSt...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SparkSubmitHook._start_driver_status_tracking
Polls the driver based on self._driver_id to get the status. Finish successfully when the status is FINISHED. Finish failed when the status is ERROR/UNKNOWN/KILLED/FAILED. Possible status: SUBMITTED Submitted but not yet scheduled on a worker RUNNING Has...
airflow/contrib/hooks/spark_submit_hook.py
def _start_driver_status_tracking(self): """ Polls the driver based on self._driver_id to get the status. Finish successfully when the status is FINISHED. Finish failed when the status is ERROR/UNKNOWN/KILLED/FAILED. Possible status: SUBMITTED Submitted but ...
def _start_driver_status_tracking(self): """ Polls the driver based on self._driver_id to get the status. Finish successfully when the status is FINISHED. Finish failed when the status is ERROR/UNKNOWN/KILLED/FAILED. Possible status: SUBMITTED Submitted but ...
[ "Polls", "the", "driver", "based", "on", "self", ".", "_driver_id", "to", "get", "the", "status", ".", "Finish", "successfully", "when", "the", "status", "is", "FINISHED", ".", "Finish", "failed", "when", "the", "status", "is", "ERROR", "/", "UNKNOWN", "/"...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/spark_submit_hook.py#L448-L511
[ "def", "_start_driver_status_tracking", "(", "self", ")", ":", "# When your Spark Standalone cluster is not performing well", "# due to misconfiguration or heavy loads.", "# it is possible that the polling request will timeout.", "# Therefore we use a simple retry mechanism.", "missed_job_status...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SparkSubmitHook._build_spark_driver_kill_command
Construct the spark-submit command to kill a driver. :return: full command to kill a driver
airflow/contrib/hooks/spark_submit_hook.py
def _build_spark_driver_kill_command(self): """ Construct the spark-submit command to kill a driver. :return: full command to kill a driver """ # If the spark_home is passed then build the spark-submit executable path using # the spark_home; otherwise assume that spark-s...
def _build_spark_driver_kill_command(self): """ Construct the spark-submit command to kill a driver. :return: full command to kill a driver """ # If the spark_home is passed then build the spark-submit executable path using # the spark_home; otherwise assume that spark-s...
[ "Construct", "the", "spark", "-", "submit", "command", "to", "kill", "a", "driver", ".", ":", "return", ":", "full", "command", "to", "kill", "a", "driver" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/spark_submit_hook.py#L513-L537
[ "def", "_build_spark_driver_kill_command", "(", "self", ")", ":", "# If the spark_home is passed then build the spark-submit executable path using", "# the spark_home; otherwise assume that spark-submit is present in the path to", "# the executing user", "if", "self", ".", "_connection", "...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
get_task_runner
Get the task runner that can be used to run the given job. :param local_task_job: The LocalTaskJob associated with the TaskInstance that needs to be executed. :type local_task_job: airflow.jobs.LocalTaskJob :return: The task runner to use to run the task. :rtype: airflow.task.task_runner.base_t...
airflow/task/task_runner/__init__.py
def get_task_runner(local_task_job): """ Get the task runner that can be used to run the given job. :param local_task_job: The LocalTaskJob associated with the TaskInstance that needs to be executed. :type local_task_job: airflow.jobs.LocalTaskJob :return: The task runner to use to run the ...
def get_task_runner(local_task_job): """ Get the task runner that can be used to run the given job. :param local_task_job: The LocalTaskJob associated with the TaskInstance that needs to be executed. :type local_task_job: airflow.jobs.LocalTaskJob :return: The task runner to use to run the ...
[ "Get", "the", "task", "runner", "that", "can", "be", "used", "to", "run", "the", "given", "job", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/task/task_runner/__init__.py#L27-L43
[ "def", "get_task_runner", "(", "local_task_job", ")", ":", "if", "_TASK_RUNNER", "==", "\"StandardTaskRunner\"", ":", "return", "StandardTaskRunner", "(", "local_task_job", ")", "elif", "_TASK_RUNNER", "==", "\"CgroupTaskRunner\"", ":", "from", "airflow", ".", "contri...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AWSBatchOperator._wait_for_task_ended
Try to use a waiter from the below pull request * https://github.com/boto/botocore/pull/1307 If the waiter is not available apply a exponential backoff * docs.aws.amazon.com/general/latest/gr/api-retries.html
airflow/contrib/operators/awsbatch_operator.py
def _wait_for_task_ended(self): """ Try to use a waiter from the below pull request * https://github.com/boto/botocore/pull/1307 If the waiter is not available apply a exponential backoff * docs.aws.amazon.com/general/latest/gr/api-retries.html """ try:...
def _wait_for_task_ended(self): """ Try to use a waiter from the below pull request * https://github.com/boto/botocore/pull/1307 If the waiter is not available apply a exponential backoff * docs.aws.amazon.com/general/latest/gr/api-retries.html """ try:...
[ "Try", "to", "use", "a", "waiter", "from", "the", "below", "pull", "request" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/awsbatch_operator.py#L117-L145
[ "def", "_wait_for_task_ended", "(", "self", ")", ":", "try", ":", "waiter", "=", "self", ".", "client", ".", "get_waiter", "(", "'job_execution_complete'", ")", "waiter", ".", "config", ".", "max_attempts", "=", "sys", ".", "maxsize", "# timeout is managed by ai...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
MySqlToGoogleCloudStorageOperator._query_mysql
Queries mysql and returns a cursor to the results.
airflow/contrib/operators/mysql_to_gcs.py
def _query_mysql(self): """ Queries mysql and returns a cursor to the results. """ mysql = MySqlHook(mysql_conn_id=self.mysql_conn_id) conn = mysql.get_conn() cursor = conn.cursor() cursor.execute(self.sql) return cursor
def _query_mysql(self): """ Queries mysql and returns a cursor to the results. """ mysql = MySqlHook(mysql_conn_id=self.mysql_conn_id) conn = mysql.get_conn() cursor = conn.cursor() cursor.execute(self.sql) return cursor
[ "Queries", "mysql", "and", "returns", "a", "cursor", "to", "the", "results", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/mysql_to_gcs.py#L134-L142
[ "def", "_query_mysql", "(", "self", ")", ":", "mysql", "=", "MySqlHook", "(", "mysql_conn_id", "=", "self", ".", "mysql_conn_id", ")", "conn", "=", "mysql", ".", "get_conn", "(", ")", "cursor", "=", "conn", ".", "cursor", "(", ")", "cursor", ".", "exec...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
MySqlToGoogleCloudStorageOperator._write_local_data_files
Takes a cursor, and writes results to a local file. :return: A dictionary where keys are filenames to be used as object names in GCS, and values are file handles to local files that contain the data for the GCS objects.
airflow/contrib/operators/mysql_to_gcs.py
def _write_local_data_files(self, cursor): """ Takes a cursor, and writes results to a local file. :return: A dictionary where keys are filenames to be used as object names in GCS, and values are file handles to local files that contain the data for the GCS objects. ...
def _write_local_data_files(self, cursor): """ Takes a cursor, and writes results to a local file. :return: A dictionary where keys are filenames to be used as object names in GCS, and values are file handles to local files that contain the data for the GCS objects. ...
[ "Takes", "a", "cursor", "and", "writes", "results", "to", "a", "local", "file", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/mysql_to_gcs.py#L144-L199
[ "def", "_write_local_data_files", "(", "self", ",", "cursor", ")", ":", "schema", "=", "list", "(", "map", "(", "lambda", "schema_tuple", ":", "schema_tuple", "[", "0", "]", ",", "cursor", ".", "description", ")", ")", "col_type_dict", "=", "self", ".", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
MySqlToGoogleCloudStorageOperator._configure_csv_file
Configure a csv writer with the file_handle and write schema as headers for the new file.
airflow/contrib/operators/mysql_to_gcs.py
def _configure_csv_file(self, file_handle, schema): """Configure a csv writer with the file_handle and write schema as headers for the new file. """ csv_writer = csv.writer(file_handle, encoding='utf-8', delimiter=self.field_delimiter) csv_writer.w...
def _configure_csv_file(self, file_handle, schema): """Configure a csv writer with the file_handle and write schema as headers for the new file. """ csv_writer = csv.writer(file_handle, encoding='utf-8', delimiter=self.field_delimiter) csv_writer.w...
[ "Configure", "a", "csv", "writer", "with", "the", "file_handle", "and", "write", "schema", "as", "headers", "for", "the", "new", "file", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/mysql_to_gcs.py#L201-L208
[ "def", "_configure_csv_file", "(", "self", ",", "file_handle", ",", "schema", ")", ":", "csv_writer", "=", "csv", ".", "writer", "(", "file_handle", ",", "encoding", "=", "'utf-8'", ",", "delimiter", "=", "self", ".", "field_delimiter", ")", "csv_writer", "....
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
MySqlToGoogleCloudStorageOperator._write_local_schema_file
Takes a cursor, and writes the BigQuery schema in .json format for the results to a local file system. :return: A dictionary where key is a filename to be used as an object name in GCS, and values are file handles to local files that contains the BigQuery schema fields in .json ...
airflow/contrib/operators/mysql_to_gcs.py
def _write_local_schema_file(self, cursor): """ Takes a cursor, and writes the BigQuery schema in .json format for the results to a local file system. :return: A dictionary where key is a filename to be used as an object name in GCS, and values are file handles to local file...
def _write_local_schema_file(self, cursor): """ Takes a cursor, and writes the BigQuery schema in .json format for the results to a local file system. :return: A dictionary where key is a filename to be used as an object name in GCS, and values are file handles to local file...
[ "Takes", "a", "cursor", "and", "writes", "the", "BigQuery", "schema", "in", ".", "json", "format", "for", "the", "results", "to", "a", "local", "file", "system", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/mysql_to_gcs.py#L210-L253
[ "def", "_write_local_schema_file", "(", "self", ",", "cursor", ")", ":", "schema_str", "=", "None", "schema_file_mime_type", "=", "'application/json'", "tmp_schema_file_handle", "=", "NamedTemporaryFile", "(", "delete", "=", "True", ")", "if", "self", ".", "schema",...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
MySqlToGoogleCloudStorageOperator._upload_to_gcs
Upload all of the file splits (and optionally the schema .json file) to Google cloud storage.
airflow/contrib/operators/mysql_to_gcs.py
def _upload_to_gcs(self, files_to_upload): """ Upload all of the file splits (and optionally the schema .json file) to Google cloud storage. """ hook = GoogleCloudStorageHook( google_cloud_storage_conn_id=self.google_cloud_storage_conn_id, delegate_to=self...
def _upload_to_gcs(self, files_to_upload): """ Upload all of the file splits (and optionally the schema .json file) to Google cloud storage. """ hook = GoogleCloudStorageHook( google_cloud_storage_conn_id=self.google_cloud_storage_conn_id, delegate_to=self...
[ "Upload", "all", "of", "the", "file", "splits", "(", "and", "optionally", "the", "schema", ".", "json", "file", ")", "to", "Google", "cloud", "storage", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/mysql_to_gcs.py#L255-L266
[ "def", "_upload_to_gcs", "(", "self", ",", "files_to_upload", ")", ":", "hook", "=", "GoogleCloudStorageHook", "(", "google_cloud_storage_conn_id", "=", "self", ".", "google_cloud_storage_conn_id", ",", "delegate_to", "=", "self", ".", "delegate_to", ")", "for", "tm...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
MySqlToGoogleCloudStorageOperator._convert_types
Takes a value from MySQLdb, and converts it to a value that's safe for JSON/Google cloud storage/BigQuery. Dates are converted to UTC seconds. Decimals are converted to floats. Binary type fields are encoded with base64, as imported BYTES data must be base64-encoded according to Bigquery SQL ...
airflow/contrib/operators/mysql_to_gcs.py
def _convert_types(schema, col_type_dict, row): """ Takes a value from MySQLdb, and converts it to a value that's safe for JSON/Google cloud storage/BigQuery. Dates are converted to UTC seconds. Decimals are converted to floats. Binary type fields are encoded with base64, as impo...
def _convert_types(schema, col_type_dict, row): """ Takes a value from MySQLdb, and converts it to a value that's safe for JSON/Google cloud storage/BigQuery. Dates are converted to UTC seconds. Decimals are converted to floats. Binary type fields are encoded with base64, as impo...
[ "Takes", "a", "value", "from", "MySQLdb", "and", "converts", "it", "to", "a", "value", "that", "s", "safe", "for", "JSON", "/", "Google", "cloud", "storage", "/", "BigQuery", ".", "Dates", "are", "converted", "to", "UTC", "seconds", ".", "Decimals", "are...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/mysql_to_gcs.py#L269-L288
[ "def", "_convert_types", "(", "schema", ",", "col_type_dict", ",", "row", ")", ":", "converted_row", "=", "[", "]", "for", "col_name", ",", "col_val", "in", "zip", "(", "schema", ",", "row", ")", ":", "if", "type", "(", "col_val", ")", "in", "(", "da...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
MySqlToGoogleCloudStorageOperator._get_col_type_dict
Return a dict of column name and column type based on self.schema if not None.
airflow/contrib/operators/mysql_to_gcs.py
def _get_col_type_dict(self): """ Return a dict of column name and column type based on self.schema if not None. """ schema = [] if isinstance(self.schema, string_types): schema = json.loads(self.schema) elif isinstance(self.schema, list): schema =...
def _get_col_type_dict(self): """ Return a dict of column name and column type based on self.schema if not None. """ schema = [] if isinstance(self.schema, string_types): schema = json.loads(self.schema) elif isinstance(self.schema, list): schema =...
[ "Return", "a", "dict", "of", "column", "name", "and", "column", "type", "based", "on", "self", ".", "schema", "if", "not", "None", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/mysql_to_gcs.py#L290-L310
[ "def", "_get_col_type_dict", "(", "self", ")", ":", "schema", "=", "[", "]", "if", "isinstance", "(", "self", ".", "schema", ",", "string_types", ")", ":", "schema", "=", "json", ".", "loads", "(", "self", ".", "schema", ")", "elif", "isinstance", "(",...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
MySqlToGoogleCloudStorageOperator.type_map
Helper function that maps from MySQL fields to BigQuery fields. Used when a schema_filename is set.
airflow/contrib/operators/mysql_to_gcs.py
def type_map(cls, mysql_type): """ Helper function that maps from MySQL fields to BigQuery fields. Used when a schema_filename is set. """ d = { FIELD_TYPE.INT24: 'INTEGER', FIELD_TYPE.TINY: 'INTEGER', FIELD_TYPE.BIT: 'INTEGER', FIE...
def type_map(cls, mysql_type): """ Helper function that maps from MySQL fields to BigQuery fields. Used when a schema_filename is set. """ d = { FIELD_TYPE.INT24: 'INTEGER', FIELD_TYPE.TINY: 'INTEGER', FIELD_TYPE.BIT: 'INTEGER', FIE...
[ "Helper", "function", "that", "maps", "from", "MySQL", "fields", "to", "BigQuery", "fields", ".", "Used", "when", "a", "schema_filename", "is", "set", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/mysql_to_gcs.py#L313-L334
[ "def", "type_map", "(", "cls", ",", "mysql_type", ")", ":", "d", "=", "{", "FIELD_TYPE", ".", "INT24", ":", "'INTEGER'", ",", "FIELD_TYPE", ".", "TINY", ":", "'INTEGER'", ",", "FIELD_TYPE", ".", "BIT", ":", "'INTEGER'", ",", "FIELD_TYPE", ".", "DATETIME"...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
authenticate
Authenticate a PasswordUser with the specified username/password. :param session: An active SQLAlchemy session :param username: The username :param password: The password :raise AuthenticationError: if an error occurred :return: a PasswordUser
airflow/contrib/auth/backends/password_auth.py
def authenticate(session, username, password): """ Authenticate a PasswordUser with the specified username/password. :param session: An active SQLAlchemy session :param username: The username :param password: The password :raise AuthenticationError: if an error occurred :return: a Pass...
def authenticate(session, username, password): """ Authenticate a PasswordUser with the specified username/password. :param session: An active SQLAlchemy session :param username: The username :param password: The password :raise AuthenticationError: if an error occurred :return: a Pass...
[ "Authenticate", "a", "PasswordUser", "with", "the", "specified", "username", "/", "password", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/auth/backends/password_auth.py#L107-L132
[ "def", "authenticate", "(", "session", ",", "username", ",", "password", ")", ":", "if", "not", "username", "or", "not", "password", ":", "raise", "AuthenticationError", "(", ")", "user", "=", "session", ".", "query", "(", "PasswordUser", ")", ".", "filter...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SqoopOperator.execute
Execute sqoop job
airflow/contrib/operators/sqoop_operator.py
def execute(self, context): """ Execute sqoop job """ self.hook = SqoopHook( conn_id=self.conn_id, verbose=self.verbose, num_mappers=self.num_mappers, hcatalog_database=self.hcatalog_database, hcatalog_table=self.hcatalog_table,...
def execute(self, context): """ Execute sqoop job """ self.hook = SqoopHook( conn_id=self.conn_id, verbose=self.verbose, num_mappers=self.num_mappers, hcatalog_database=self.hcatalog_database, hcatalog_table=self.hcatalog_table,...
[ "Execute", "sqoop", "job" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/sqoop_operator.py#L166-L234
[ "def", "execute", "(", "self", ",", "context", ")", ":", "self", ".", "hook", "=", "SqoopHook", "(", "conn_id", "=", "self", ".", "conn_id", ",", "verbose", "=", "self", ".", "verbose", ",", "num_mappers", "=", "self", ".", "num_mappers", ",", "hcatalo...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
apply_lineage
Saves the lineage to XCom and if configured to do so sends it to the backend.
airflow/lineage/__init__.py
def apply_lineage(func): """ Saves the lineage to XCom and if configured to do so sends it to the backend. """ backend = _get_backend() @wraps(func) def wrapper(self, context, *args, **kwargs): self.log.debug("Backend: %s, Lineage called with inlets: %s, outlets: %s", ...
def apply_lineage(func): """ Saves the lineage to XCom and if configured to do so sends it to the backend. """ backend = _get_backend() @wraps(func) def wrapper(self, context, *args, **kwargs): self.log.debug("Backend: %s, Lineage called with inlets: %s, outlets: %s", ...
[ "Saves", "the", "lineage", "to", "XCom", "and", "if", "configured", "to", "do", "so", "sends", "it", "to", "the", "backend", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/lineage/__init__.py#L48-L82
[ "def", "apply_lineage", "(", "func", ")", ":", "backend", "=", "_get_backend", "(", ")", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "self", ",", "context", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "log", ".", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
prepare_lineage
Prepares the lineage inlets and outlets. Inlets can be: * "auto" -> picks up any outlets from direct upstream tasks that have outlets defined, as such that if A -> B -> C and B does not have outlets but A does, these are provided as inlets. * "list of task_ids" -> picks up outlets from the upstream task_...
airflow/lineage/__init__.py
def prepare_lineage(func): """ Prepares the lineage inlets and outlets. Inlets can be: * "auto" -> picks up any outlets from direct upstream tasks that have outlets defined, as such that if A -> B -> C and B does not have outlets but A does, these are provided as inlets. * "list of task_ids" -> p...
def prepare_lineage(func): """ Prepares the lineage inlets and outlets. Inlets can be: * "auto" -> picks up any outlets from direct upstream tasks that have outlets defined, as such that if A -> B -> C and B does not have outlets but A does, these are provided as inlets. * "list of task_ids" -> p...
[ "Prepares", "the", "lineage", "inlets", "and", "outlets", ".", "Inlets", "can", "be", ":" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/lineage/__init__.py#L85-L140
[ "def", "prepare_lineage", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "self", ",", "context", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "log", ".", "debug", "(", "\"Preparing lineage inlets and ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
Connection.extra_dejson
Returns the extra property by deserializing json.
airflow/models/connection.py
def extra_dejson(self): """Returns the extra property by deserializing json.""" obj = {} if self.extra: try: obj = json.loads(self.extra) except Exception as e: self.log.exception(e) self.log.error("Failed parsing the json f...
def extra_dejson(self): """Returns the extra property by deserializing json.""" obj = {} if self.extra: try: obj = json.loads(self.extra) except Exception as e: self.log.exception(e) self.log.error("Failed parsing the json f...
[ "Returns", "the", "extra", "property", "by", "deserializing", "json", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/models/connection.py#L286-L296
[ "def", "extra_dejson", "(", "self", ")", ":", "obj", "=", "{", "}", "if", "self", ".", "extra", ":", "try", ":", "obj", "=", "json", ".", "loads", "(", "self", ".", "extra", ")", "except", "Exception", "as", "e", ":", "self", ".", "log", ".", "...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
date_range
Get a set of dates as a list based on a start, end and delta, delta can be something that can be added to `datetime.datetime` or a cron expression as a `str` :Example:: date_range(datetime(2016, 1, 1), datetime(2016, 1, 3), delta=timedelta(1)) [datetime.datetime(2016, 1, 1, 0, 0), date...
airflow/utils/dates.py
def date_range(start_date, end_date=None, num=None, delta=None): """ Get a set of dates as a list based on a start, end and delta, delta can be something that can be added to `datetime.datetime` or a cron expression as a `str` :Example:: date_range(datetime(2016, 1, 1), datetime(2016, 1, 3...
def date_range(start_date, end_date=None, num=None, delta=None): """ Get a set of dates as a list based on a start, end and delta, delta can be something that can be added to `datetime.datetime` or a cron expression as a `str` :Example:: date_range(datetime(2016, 1, 1), datetime(2016, 1, 3...
[ "Get", "a", "set", "of", "dates", "as", "a", "list", "based", "on", "a", "start", "end", "and", "delta", "delta", "can", "be", "something", "that", "can", "be", "added", "to", "datetime", ".", "datetime", "or", "a", "cron", "expression", "as", "a", "...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dates.py#L36-L111
[ "def", "date_range", "(", "start_date", ",", "end_date", "=", "None", ",", "num", "=", "None", ",", "delta", "=", "None", ")", ":", "if", "not", "delta", ":", "return", "[", "]", "if", "end_date", "and", "start_date", ">", "end_date", ":", "raise", "...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
round_time
Returns the datetime of the form start_date + i * delta which is closest to dt for any non-negative integer i. Note that delta may be a datetime.timedelta or a dateutil.relativedelta >>> round_time(datetime(2015, 1, 1, 6), timedelta(days=1)) datetime.datetime(2015, 1, 1, 0, 0) >>> round_time(datetim...
airflow/utils/dates.py
def round_time(dt, delta, start_date=timezone.make_aware(datetime.min)): """ Returns the datetime of the form start_date + i * delta which is closest to dt for any non-negative integer i. Note that delta may be a datetime.timedelta or a dateutil.relativedelta >>> round_time(datetime(2015, 1, 1, 6), ...
def round_time(dt, delta, start_date=timezone.make_aware(datetime.min)): """ Returns the datetime of the form start_date + i * delta which is closest to dt for any non-negative integer i. Note that delta may be a datetime.timedelta or a dateutil.relativedelta >>> round_time(datetime(2015, 1, 1, 6), ...
[ "Returns", "the", "datetime", "of", "the", "form", "start_date", "+", "i", "*", "delta", "which", "is", "closest", "to", "dt", "for", "any", "non", "-", "negative", "integer", "i", ".", "Note", "that", "delta", "may", "be", "a", "datetime", ".", "timed...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dates.py#L114-L188
[ "def", "round_time", "(", "dt", ",", "delta", ",", "start_date", "=", "timezone", ".", "make_aware", "(", "datetime", ".", "min", ")", ")", ":", "if", "isinstance", "(", "delta", ",", "six", ".", "string_types", ")", ":", "# It's cron based, so it's easy", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
infer_time_unit
Determine the most appropriate time unit for an array of time durations specified in seconds. e.g. 5400 seconds => 'minutes', 36000 seconds => 'hours'
airflow/utils/dates.py
def infer_time_unit(time_seconds_arr): """ Determine the most appropriate time unit for an array of time durations specified in seconds. e.g. 5400 seconds => 'minutes', 36000 seconds => 'hours' """ if len(time_seconds_arr) == 0: return 'hours' max_time_seconds = max(time_seconds_arr)...
def infer_time_unit(time_seconds_arr): """ Determine the most appropriate time unit for an array of time durations specified in seconds. e.g. 5400 seconds => 'minutes', 36000 seconds => 'hours' """ if len(time_seconds_arr) == 0: return 'hours' max_time_seconds = max(time_seconds_arr)...
[ "Determine", "the", "most", "appropriate", "time", "unit", "for", "an", "array", "of", "time", "durations", "specified", "in", "seconds", ".", "e", ".", "g", ".", "5400", "seconds", "=", ">", "minutes", "36000", "seconds", "=", ">", "hours" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dates.py#L195-L211
[ "def", "infer_time_unit", "(", "time_seconds_arr", ")", ":", "if", "len", "(", "time_seconds_arr", ")", "==", "0", ":", "return", "'hours'", "max_time_seconds", "=", "max", "(", "time_seconds_arr", ")", "if", "max_time_seconds", "<=", "60", "*", "2", ":", "r...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
scale_time_units
Convert an array of time durations in seconds to the specified time unit.
airflow/utils/dates.py
def scale_time_units(time_seconds_arr, unit): """ Convert an array of time durations in seconds to the specified time unit. """ if unit == 'minutes': return list(map(lambda x: x * 1.0 / 60, time_seconds_arr)) elif unit == 'hours': return list(map(lambda x: x * 1.0 / (60 * 60), time_s...
def scale_time_units(time_seconds_arr, unit): """ Convert an array of time durations in seconds to the specified time unit. """ if unit == 'minutes': return list(map(lambda x: x * 1.0 / 60, time_seconds_arr)) elif unit == 'hours': return list(map(lambda x: x * 1.0 / (60 * 60), time_s...
[ "Convert", "an", "array", "of", "time", "durations", "in", "seconds", "to", "the", "specified", "time", "unit", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dates.py#L214-L224
[ "def", "scale_time_units", "(", "time_seconds_arr", ",", "unit", ")", ":", "if", "unit", "==", "'minutes'", ":", "return", "list", "(", "map", "(", "lambda", "x", ":", "x", "*", "1.0", "/", "60", ",", "time_seconds_arr", ")", ")", "elif", "unit", "==",...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
days_ago
Get a datetime object representing `n` days ago. By default the time is set to midnight.
airflow/utils/dates.py
def days_ago(n, hour=0, minute=0, second=0, microsecond=0): """ Get a datetime object representing `n` days ago. By default the time is set to midnight. """ today = timezone.utcnow().replace( hour=hour, minute=minute, second=second, microsecond=microsecond) return...
def days_ago(n, hour=0, minute=0, second=0, microsecond=0): """ Get a datetime object representing `n` days ago. By default the time is set to midnight. """ today = timezone.utcnow().replace( hour=hour, minute=minute, second=second, microsecond=microsecond) return...
[ "Get", "a", "datetime", "object", "representing", "n", "days", "ago", ".", "By", "default", "the", "time", "is", "set", "to", "midnight", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dates.py#L227-L237
[ "def", "days_ago", "(", "n", ",", "hour", "=", "0", ",", "minute", "=", "0", ",", "second", "=", "0", ",", "microsecond", "=", "0", ")", ":", "today", "=", "timezone", ".", "utcnow", "(", ")", ".", "replace", "(", "hour", "=", "hour", ",", "min...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
get_dag_runs
Returns a list of Dag Runs for a specific DAG ID. :param dag_id: String identifier of a DAG :param state: queued|running|success... :return: List of DAG runs of a DAG with requested state, or all runs if the state is not specified
airflow/api/common/experimental/get_dag_runs.py
def get_dag_runs(dag_id, state=None): """ Returns a list of Dag Runs for a specific DAG ID. :param dag_id: String identifier of a DAG :param state: queued|running|success... :return: List of DAG runs of a DAG with requested state, or all runs if the state is not specified """ dagbag = Da...
def get_dag_runs(dag_id, state=None): """ Returns a list of Dag Runs for a specific DAG ID. :param dag_id: String identifier of a DAG :param state: queued|running|success... :return: List of DAG runs of a DAG with requested state, or all runs if the state is not specified """ dagbag = Da...
[ "Returns", "a", "list", "of", "Dag", "Runs", "for", "a", "specific", "DAG", "ID", ".", ":", "param", "dag_id", ":", "String", "identifier", "of", "a", "DAG", ":", "param", "state", ":", "queued|running|success", "...", ":", "return", ":", "List", "of", ...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/api/common/experimental/get_dag_runs.py#L25-L55
[ "def", "get_dag_runs", "(", "dag_id", ",", "state", "=", "None", ")", ":", "dagbag", "=", "DagBag", "(", ")", "# Check DAG exists.", "if", "dag_id", "not", "in", "dagbag", ".", "dags", ":", "error_message", "=", "\"Dag id {} not found\"", ".", "format", "(",...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AirflowSecurityManager.init_role
Initialize the role with the permissions and related view-menus. :param role_name: :param role_vms: :param role_perms: :return:
airflow/www/security.py
def init_role(self, role_name, role_vms, role_perms): """ Initialize the role with the permissions and related view-menus. :param role_name: :param role_vms: :param role_perms: :return: """ pvms = self.get_session.query(sqla_models.PermissionView).all() ...
def init_role(self, role_name, role_vms, role_perms): """ Initialize the role with the permissions and related view-menus. :param role_name: :param role_vms: :param role_perms: :return: """ pvms = self.get_session.query(sqla_models.PermissionView).all() ...
[ "Initialize", "the", "role", "with", "the", "permissions", "and", "related", "view", "-", "menus", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/security.py#L175-L202
[ "def", "init_role", "(", "self", ",", "role_name", ",", "role_vms", ",", "role_perms", ")", ":", "pvms", "=", "self", ".", "get_session", ".", "query", "(", "sqla_models", ".", "PermissionView", ")", ".", "all", "(", ")", "pvms", "=", "[", "p", "for", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AirflowSecurityManager.delete_role
Delete the given Role :param role_name: the name of a role in the ab_role table
airflow/www/security.py
def delete_role(self, role_name): """Delete the given Role :param role_name: the name of a role in the ab_role table """ session = self.get_session role = session.query(sqla_models.Role)\ .filter(sqla_models.Role.name == role_name)\ .f...
def delete_role(self, role_name): """Delete the given Role :param role_name: the name of a role in the ab_role table """ session = self.get_session role = session.query(sqla_models.Role)\ .filter(sqla_models.Role.name == role_name)\ .f...
[ "Delete", "the", "given", "Role" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/security.py#L204-L219
[ "def", "delete_role", "(", "self", ",", "role_name", ")", ":", "session", "=", "self", ".", "get_session", "role", "=", "session", ".", "query", "(", "sqla_models", ".", "Role", ")", ".", "filter", "(", "sqla_models", ".", "Role", ".", "name", "==", "r...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AirflowSecurityManager.get_user_roles
Get all the roles associated with the user. :param user: the ab_user in FAB model. :return: a list of roles associated with the user.
airflow/www/security.py
def get_user_roles(self, user=None): """ Get all the roles associated with the user. :param user: the ab_user in FAB model. :return: a list of roles associated with the user. """ if user is None: user = g.user if user.is_anonymous: public_...
def get_user_roles(self, user=None): """ Get all the roles associated with the user. :param user: the ab_user in FAB model. :return: a list of roles associated with the user. """ if user is None: user = g.user if user.is_anonymous: public_...
[ "Get", "all", "the", "roles", "associated", "with", "the", "user", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/security.py#L221-L234
[ "def", "get_user_roles", "(", "self", ",", "user", "=", "None", ")", ":", "if", "user", "is", "None", ":", "user", "=", "g", ".", "user", "if", "user", ".", "is_anonymous", ":", "public_role", "=", "appbuilder", ".", "config", ".", "get", "(", "'AUTH...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AirflowSecurityManager.get_all_permissions_views
Returns a set of tuples with the perm name and view menu name
airflow/www/security.py
def get_all_permissions_views(self): """ Returns a set of tuples with the perm name and view menu name """ perms_views = set() for role in self.get_user_roles(): perms_views.update({(perm_view.permission.name, perm_view.view_menu.name) ...
def get_all_permissions_views(self): """ Returns a set of tuples with the perm name and view menu name """ perms_views = set() for role in self.get_user_roles(): perms_views.update({(perm_view.permission.name, perm_view.view_menu.name) ...
[ "Returns", "a", "set", "of", "tuples", "with", "the", "perm", "name", "and", "view", "menu", "name" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/security.py#L236-L244
[ "def", "get_all_permissions_views", "(", "self", ")", ":", "perms_views", "=", "set", "(", ")", "for", "role", "in", "self", ".", "get_user_roles", "(", ")", ":", "perms_views", ".", "update", "(", "{", "(", "perm_view", ".", "permission", ".", "name", "...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AirflowSecurityManager.get_accessible_dag_ids
Return a set of dags that user has access to(either read or write). :param username: Name of the user. :return: A set of dag ids that the user could access.
airflow/www/security.py
def get_accessible_dag_ids(self, username=None): """ Return a set of dags that user has access to(either read or write). :param username: Name of the user. :return: A set of dag ids that the user could access. """ if not username: username = g.user i...
def get_accessible_dag_ids(self, username=None): """ Return a set of dags that user has access to(either read or write). :param username: Name of the user. :return: A set of dag ids that the user could access. """ if not username: username = g.user i...
[ "Return", "a", "set", "of", "dags", "that", "user", "has", "access", "to", "(", "either", "read", "or", "write", ")", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/security.py#L246-L266
[ "def", "get_accessible_dag_ids", "(", "self", ",", "username", "=", "None", ")", ":", "if", "not", "username", ":", "username", "=", "g", ".", "user", "if", "username", ".", "is_anonymous", "or", "'Public'", "in", "username", ".", "roles", ":", "# return a...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AirflowSecurityManager.has_access
Verify whether a given user could perform certain permission (e.g can_read, can_write) on the given dag_id. :param permission: permission on dag_id(e.g can_read, can_edit). :type permission: str :param view_name: name of view-menu(e.g dag id is a view-menu as well). :type view_n...
airflow/www/security.py
def has_access(self, permission, view_name, user=None): """ Verify whether a given user could perform certain permission (e.g can_read, can_write) on the given dag_id. :param permission: permission on dag_id(e.g can_read, can_edit). :type permission: str :param view_name...
def has_access(self, permission, view_name, user=None): """ Verify whether a given user could perform certain permission (e.g can_read, can_write) on the given dag_id. :param permission: permission on dag_id(e.g can_read, can_edit). :type permission: str :param view_name...
[ "Verify", "whether", "a", "given", "user", "could", "perform", "certain", "permission", "(", "e", ".", "g", "can_read", "can_write", ")", "on", "the", "given", "dag_id", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/security.py#L268-L286
[ "def", "has_access", "(", "self", ",", "permission", ",", "view_name", ",", "user", "=", "None", ")", ":", "if", "not", "user", ":", "user", "=", "g", ".", "user", "if", "user", ".", "is_anonymous", ":", "return", "self", ".", "is_item_public", "(", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AirflowSecurityManager._has_role
Whether the user has this role name
airflow/www/security.py
def _has_role(self, role_name_or_list): """ Whether the user has this role name """ if not isinstance(role_name_or_list, list): role_name_or_list = [role_name_or_list] return any( [r.name in role_name_or_list for r in self.get_user_roles()])
def _has_role(self, role_name_or_list): """ Whether the user has this role name """ if not isinstance(role_name_or_list, list): role_name_or_list = [role_name_or_list] return any( [r.name in role_name_or_list for r in self.get_user_roles()])
[ "Whether", "the", "user", "has", "this", "role", "name" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/security.py#L294-L301
[ "def", "_has_role", "(", "self", ",", "role_name_or_list", ")", ":", "if", "not", "isinstance", "(", "role_name_or_list", ",", "list", ")", ":", "role_name_or_list", "=", "[", "role_name_or_list", "]", "return", "any", "(", "[", "r", ".", "name", "in", "ro...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AirflowSecurityManager._has_perm
Whether the user has this perm
airflow/www/security.py
def _has_perm(self, permission_name, view_menu_name): """ Whether the user has this perm """ if hasattr(self, 'perms'): if (permission_name, view_menu_name) in self.perms: return True # rebuild the permissions set self._get_and_cache_perms() ...
def _has_perm(self, permission_name, view_menu_name): """ Whether the user has this perm """ if hasattr(self, 'perms'): if (permission_name, view_menu_name) in self.perms: return True # rebuild the permissions set self._get_and_cache_perms() ...
[ "Whether", "the", "user", "has", "this", "perm" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/security.py#L303-L312
[ "def", "_has_perm", "(", "self", ",", "permission_name", ",", "view_menu_name", ")", ":", "if", "hasattr", "(", "self", ",", "'perms'", ")", ":", "if", "(", "permission_name", ",", "view_menu_name", ")", "in", "self", ".", "perms", ":", "return", "True", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AirflowSecurityManager.clean_perms
FAB leaves faulty permissions that need to be cleaned up
airflow/www/security.py
def clean_perms(self): """ FAB leaves faulty permissions that need to be cleaned up """ self.log.debug('Cleaning faulty perms') sesh = self.get_session pvms = ( sesh.query(sqla_models.PermissionView) .filter(or_( sqla_models.Permiss...
def clean_perms(self): """ FAB leaves faulty permissions that need to be cleaned up """ self.log.debug('Cleaning faulty perms') sesh = self.get_session pvms = ( sesh.query(sqla_models.PermissionView) .filter(or_( sqla_models.Permiss...
[ "FAB", "leaves", "faulty", "permissions", "that", "need", "to", "be", "cleaned", "up" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/security.py#L326-L342
[ "def", "clean_perms", "(", "self", ")", ":", "self", ".", "log", ".", "debug", "(", "'Cleaning faulty perms'", ")", "sesh", "=", "self", ".", "get_session", "pvms", "=", "(", "sesh", ".", "query", "(", "sqla_models", ".", "PermissionView", ")", ".", "fil...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AirflowSecurityManager._merge_perm
Add the new permission , view_menu to ab_permission_view_role if not exists. It will add the related entry to ab_permission and ab_view_menu two meta tables as well. :param permission_name: Name of the permission. :type permission_name: str :param view_menu_name: Name of the vie...
airflow/www/security.py
def _merge_perm(self, permission_name, view_menu_name): """ Add the new permission , view_menu to ab_permission_view_role if not exists. It will add the related entry to ab_permission and ab_view_menu two meta tables as well. :param permission_name: Name of the permission. ...
def _merge_perm(self, permission_name, view_menu_name): """ Add the new permission , view_menu to ab_permission_view_role if not exists. It will add the related entry to ab_permission and ab_view_menu two meta tables as well. :param permission_name: Name of the permission. ...
[ "Add", "the", "new", "permission", "view_menu", "to", "ab_permission_view_role", "if", "not", "exists", ".", "It", "will", "add", "the", "related", "entry", "to", "ab_permission", "and", "ab_view_menu", "two", "meta", "tables", "as", "well", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/security.py#L344-L363
[ "def", "_merge_perm", "(", "self", ",", "permission_name", ",", "view_menu_name", ")", ":", "permission", "=", "self", ".", "find_permission", "(", "permission_name", ")", "view_menu", "=", "self", ".", "find_view_menu", "(", "view_menu_name", ")", "pv", "=", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AirflowSecurityManager.create_custom_dag_permission_view
Workflow: 1. Fetch all the existing (permissions, view-menu) from Airflow DB. 2. Fetch all the existing dag models that are either active or paused. Exclude the subdags. 3. Create both read and write permission view-menus relation for every dags from step 2 4. Find out all the dag specif...
airflow/www/security.py
def create_custom_dag_permission_view(self, session=None): """ Workflow: 1. Fetch all the existing (permissions, view-menu) from Airflow DB. 2. Fetch all the existing dag models that are either active or paused. Exclude the subdags. 3. Create both read and write permission view-m...
def create_custom_dag_permission_view(self, session=None): """ Workflow: 1. Fetch all the existing (permissions, view-menu) from Airflow DB. 2. Fetch all the existing dag models that are either active or paused. Exclude the subdags. 3. Create both read and write permission view-m...
[ "Workflow", ":", "1", ".", "Fetch", "all", "the", "existing", "(", "permissions", "view", "-", "menu", ")", "from", "Airflow", "DB", ".", "2", ".", "Fetch", "all", "the", "existing", "dag", "models", "that", "are", "either", "active", "or", "paused", "...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/security.py#L366-L438
[ "def", "create_custom_dag_permission_view", "(", "self", ",", "session", "=", "None", ")", ":", "self", ".", "log", ".", "debug", "(", "'Fetching a set of all permission, view_menu from FAB meta-table'", ")", "def", "merge_pv", "(", "perm", ",", "view_menu", ")", ":...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AirflowSecurityManager.update_admin_perm_view
Admin should have all the permission-views. Add the missing ones to the table for admin. :return: None.
airflow/www/security.py
def update_admin_perm_view(self): """ Admin should have all the permission-views. Add the missing ones to the table for admin. :return: None. """ pvms = self.get_session.query(sqla_models.PermissionView).all() pvms = [p for p in pvms if p.permission and p.view_me...
def update_admin_perm_view(self): """ Admin should have all the permission-views. Add the missing ones to the table for admin. :return: None. """ pvms = self.get_session.query(sqla_models.PermissionView).all() pvms = [p for p in pvms if p.permission and p.view_me...
[ "Admin", "should", "have", "all", "the", "permission", "-", "views", ".", "Add", "the", "missing", "ones", "to", "the", "table", "for", "admin", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/security.py#L440-L453
[ "def", "update_admin_perm_view", "(", "self", ")", ":", "pvms", "=", "self", ".", "get_session", ".", "query", "(", "sqla_models", ".", "PermissionView", ")", ".", "all", "(", ")", "pvms", "=", "[", "p", "for", "p", "in", "pvms", "if", "p", ".", "per...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AirflowSecurityManager.sync_roles
1. Init the default role(Admin, Viewer, User, Op, public) with related permissions. 2. Init the custom role(dag-user) with related permissions. :return: None.
airflow/www/security.py
def sync_roles(self): """ 1. Init the default role(Admin, Viewer, User, Op, public) with related permissions. 2. Init the custom role(dag-user) with related permissions. :return: None. """ self.log.debug('Start syncing user roles.') # Create global all...
def sync_roles(self): """ 1. Init the default role(Admin, Viewer, User, Op, public) with related permissions. 2. Init the custom role(dag-user) with related permissions. :return: None. """ self.log.debug('Start syncing user roles.') # Create global all...
[ "1", ".", "Init", "the", "default", "role", "(", "Admin", "Viewer", "User", "Op", "public", ")", "with", "related", "permissions", ".", "2", ".", "Init", "the", "custom", "role", "(", "dag", "-", "user", ")", "with", "related", "permissions", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/security.py#L455-L477
[ "def", "sync_roles", "(", "self", ")", ":", "self", ".", "log", ".", "debug", "(", "'Start syncing user roles.'", ")", "# Create global all-dag VM", "self", ".", "create_perm_vm_for_all_dag", "(", ")", "# Create default user role.", "for", "config", "in", "self", "....
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AirflowSecurityManager.sync_perm_for_dag
Sync permissions for given dag id. The dag id surely exists in our dag bag as only / refresh button or cli.sync_perm will call this function :param dag_id: the ID of the DAG whose permissions should be updated :type dag_id: string :param access_control: a dict where each key is a rolena...
airflow/www/security.py
def sync_perm_for_dag(self, dag_id, access_control=None): """ Sync permissions for given dag id. The dag id surely exists in our dag bag as only / refresh button or cli.sync_perm will call this function :param dag_id: the ID of the DAG whose permissions should be updated :type d...
def sync_perm_for_dag(self, dag_id, access_control=None): """ Sync permissions for given dag id. The dag id surely exists in our dag bag as only / refresh button or cli.sync_perm will call this function :param dag_id: the ID of the DAG whose permissions should be updated :type d...
[ "Sync", "permissions", "for", "given", "dag", "id", ".", "The", "dag", "id", "surely", "exists", "in", "our", "dag", "bag", "as", "only", "/", "refresh", "button", "or", "cli", ".", "sync_perm", "will", "call", "this", "function" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/security.py#L479-L498
[ "def", "sync_perm_for_dag", "(", "self", ",", "dag_id", ",", "access_control", "=", "None", ")", ":", "for", "dag_perm", "in", "self", ".", "DAG_PERMS", ":", "perm_on_dag", "=", "self", ".", "find_permission_view_menu", "(", "dag_perm", ",", "dag_id", ")", "...
b69c686ad8a0c89b9136bb4b31767257eb7b2597