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
_normalize_mlengine_job_id
Replaces invalid MLEngine job_id characters with '_'. This also adds a leading 'z' in case job_id starts with an invalid character. Args: job_id: A job_id str that may have invalid characters. Returns: A valid job_id representation.
airflow/contrib/operators/mlengine_operator.py
def _normalize_mlengine_job_id(job_id): """ Replaces invalid MLEngine job_id characters with '_'. This also adds a leading 'z' in case job_id starts with an invalid character. Args: job_id: A job_id str that may have invalid characters. Returns: A valid job_id representation. ...
def _normalize_mlengine_job_id(job_id): """ Replaces invalid MLEngine job_id characters with '_'. This also adds a leading 'z' in case job_id starts with an invalid character. Args: job_id: A job_id str that may have invalid characters. Returns: A valid job_id representation. ...
[ "Replaces", "invalid", "MLEngine", "job_id", "characters", "with", "_", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/mlengine_operator.py#L29-L62
[ "def", "_normalize_mlengine_job_id", "(", "job_id", ")", ":", "# Add a prefix when a job_id starts with a digit or a template", "match", "=", "re", ".", "search", "(", "r'\\d|\\{{2}'", ",", "job_id", ")", "if", "match", "and", "match", ".", "start", "(", ")", "==", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
FTPSensor._get_error_code
Extract error code from ftp exception
airflow/contrib/sensors/ftp_sensor.py
def _get_error_code(self, e): """Extract error code from ftp exception""" try: matches = self.error_code_pattern.match(str(e)) code = int(matches.group(0)) return code except ValueError: return e
def _get_error_code(self, e): """Extract error code from ftp exception""" try: matches = self.error_code_pattern.match(str(e)) code = int(matches.group(0)) return code except ValueError: return e
[ "Extract", "error", "code", "from", "ftp", "exception" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/sensors/ftp_sensor.py#L69-L76
[ "def", "_get_error_code", "(", "self", ",", "e", ")", ":", "try", ":", "matches", "=", "self", ".", "error_code_pattern", ".", "match", "(", "str", "(", "e", ")", ")", "code", "=", "int", "(", "matches", ".", "group", "(", "0", ")", ")", "return", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
_integrate_plugins
Integrate plugins to the context
airflow/sensors/__init__.py
def _integrate_plugins(): """Integrate plugins to the context""" import sys from airflow.plugins_manager import sensors_modules for sensors_module in sensors_modules: sys.modules[sensors_module.__name__] = sensors_module globals()[sensors_module._name] = sensors_module
def _integrate_plugins(): """Integrate plugins to the context""" import sys from airflow.plugins_manager import sensors_modules for sensors_module in sensors_modules: sys.modules[sensors_module.__name__] = sensors_module globals()[sensors_module._name] = sensors_module
[ "Integrate", "plugins", "to", "the", "context" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/sensors/__init__.py#L22-L28
[ "def", "_integrate_plugins", "(", ")", ":", "import", "sys", "from", "airflow", ".", "plugins_manager", "import", "sensors_modules", "for", "sensors_module", "in", "sensors_modules", ":", "sys", ".", "modules", "[", "sensors_module", ".", "__name__", "]", "=", "...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
clear_dag_runs
Remove any existing DAG runs for the perf test DAGs.
scripts/perf/scheduler_ops_metrics.py
def clear_dag_runs(): """ Remove any existing DAG runs for the perf test DAGs. """ session = settings.Session() drs = session.query(DagRun).filter( DagRun.dag_id.in_(DAG_IDS), ).all() for dr in drs: logging.info('Deleting DagRun :: {}'.format(dr)) session.delete(dr)
def clear_dag_runs(): """ Remove any existing DAG runs for the perf test DAGs. """ session = settings.Session() drs = session.query(DagRun).filter( DagRun.dag_id.in_(DAG_IDS), ).all() for dr in drs: logging.info('Deleting DagRun :: {}'.format(dr)) session.delete(dr)
[ "Remove", "any", "existing", "DAG", "runs", "for", "the", "perf", "test", "DAGs", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/scripts/perf/scheduler_ops_metrics.py#L138-L148
[ "def", "clear_dag_runs", "(", ")", ":", "session", "=", "settings", ".", "Session", "(", ")", "drs", "=", "session", ".", "query", "(", "DagRun", ")", ".", "filter", "(", "DagRun", ".", "dag_id", ".", "in_", "(", "DAG_IDS", ")", ",", ")", ".", "all...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
clear_dag_task_instances
Remove any existing task instances for the perf test DAGs.
scripts/perf/scheduler_ops_metrics.py
def clear_dag_task_instances(): """ Remove any existing task instances for the perf test DAGs. """ session = settings.Session() TI = TaskInstance tis = ( session .query(TI) .filter(TI.dag_id.in_(DAG_IDS)) .all() ) for ti in tis: logging.info('Delet...
def clear_dag_task_instances(): """ Remove any existing task instances for the perf test DAGs. """ session = settings.Session() TI = TaskInstance tis = ( session .query(TI) .filter(TI.dag_id.in_(DAG_IDS)) .all() ) for ti in tis: logging.info('Delet...
[ "Remove", "any", "existing", "task", "instances", "for", "the", "perf", "test", "DAGs", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/scripts/perf/scheduler_ops_metrics.py#L151-L166
[ "def", "clear_dag_task_instances", "(", ")", ":", "session", "=", "settings", ".", "Session", "(", ")", "TI", "=", "TaskInstance", "tis", "=", "(", "session", ".", "query", "(", "TI", ")", ".", "filter", "(", "TI", ".", "dag_id", ".", "in_", "(", "DA...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
set_dags_paused_state
Toggle the pause state of the DAGs in the test.
scripts/perf/scheduler_ops_metrics.py
def set_dags_paused_state(is_paused): """ Toggle the pause state of the DAGs in the test. """ session = settings.Session() dms = session.query(DagModel).filter( DagModel.dag_id.in_(DAG_IDS)) for dm in dms: logging.info('Setting DAG :: {} is_paused={}'.format(dm, is_paused)) ...
def set_dags_paused_state(is_paused): """ Toggle the pause state of the DAGs in the test. """ session = settings.Session() dms = session.query(DagModel).filter( DagModel.dag_id.in_(DAG_IDS)) for dm in dms: logging.info('Setting DAG :: {} is_paused={}'.format(dm, is_paused)) ...
[ "Toggle", "the", "pause", "state", "of", "the", "DAGs", "in", "the", "test", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/scripts/perf/scheduler_ops_metrics.py#L169-L179
[ "def", "set_dags_paused_state", "(", "is_paused", ")", ":", "session", "=", "settings", ".", "Session", "(", ")", "dms", "=", "session", ".", "query", "(", "DagModel", ")", ".", "filter", "(", "DagModel", ".", "dag_id", ".", "in_", "(", "DAG_IDS", ")", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SchedulerMetricsJob.print_stats
Print operational metrics for the scheduler test.
scripts/perf/scheduler_ops_metrics.py
def print_stats(self): """ Print operational metrics for the scheduler test. """ session = settings.Session() TI = TaskInstance tis = ( session .query(TI) .filter(TI.dag_id.in_(DAG_IDS)) .all() ) successful_t...
def print_stats(self): """ Print operational metrics for the scheduler test. """ session = settings.Session() TI = TaskInstance tis = ( session .query(TI) .filter(TI.dag_id.in_(DAG_IDS)) .all() ) successful_t...
[ "Print", "operational", "metrics", "for", "the", "scheduler", "test", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/scripts/perf/scheduler_ops_metrics.py#L65-L101
[ "def", "print_stats", "(", "self", ")", ":", "session", "=", "settings", ".", "Session", "(", ")", "TI", "=", "TaskInstance", "tis", "=", "(", "session", ".", "query", "(", "TI", ")", ".", "filter", "(", "TI", ".", "dag_id", ".", "in_", "(", "DAG_I...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SchedulerMetricsJob.heartbeat
Override the scheduler heartbeat to determine when the test is complete
scripts/perf/scheduler_ops_metrics.py
def heartbeat(self): """ Override the scheduler heartbeat to determine when the test is complete """ super(SchedulerMetricsJob, self).heartbeat() session = settings.Session() # Get all the relevant task instances TI = TaskInstance successful_tis = ( ...
def heartbeat(self): """ Override the scheduler heartbeat to determine when the test is complete """ super(SchedulerMetricsJob, self).heartbeat() session = settings.Session() # Get all the relevant task instances TI = TaskInstance successful_tis = ( ...
[ "Override", "the", "scheduler", "heartbeat", "to", "determine", "when", "the", "test", "is", "complete" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/scripts/perf/scheduler_ops_metrics.py#L103-L135
[ "def", "heartbeat", "(", "self", ")", ":", "super", "(", "SchedulerMetricsJob", ",", "self", ")", ".", "heartbeat", "(", ")", "session", "=", "settings", ".", "Session", "(", ")", "# Get all the relevant task instances", "TI", "=", "TaskInstance", "successful_ti...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AwsLambdaHook.invoke_lambda
Invoke Lambda Function
airflow/contrib/hooks/aws_lambda_hook.py
def invoke_lambda(self, payload): """ Invoke Lambda Function """ awslambda_conn = self.get_conn() response = awslambda_conn.invoke( FunctionName=self.function_name, InvocationType=self.invocation_type, LogType=self.log_type, Paylo...
def invoke_lambda(self, payload): """ Invoke Lambda Function """ awslambda_conn = self.get_conn() response = awslambda_conn.invoke( FunctionName=self.function_name, InvocationType=self.invocation_type, LogType=self.log_type, Paylo...
[ "Invoke", "Lambda", "Function" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/aws_lambda_hook.py#L53-L68
[ "def", "invoke_lambda", "(", "self", ",", "payload", ")", ":", "awslambda_conn", "=", "self", ".", "get_conn", "(", ")", "response", "=", "awslambda_conn", ".", "invoke", "(", "FunctionName", "=", "self", ".", "function_name", ",", "InvocationType", "=", "se...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
get_dag_run_state
Return the task object identified by the given dag_id and task_id.
airflow/api/common/experimental/get_dag_run_state.py
def get_dag_run_state(dag_id, execution_date): """Return the task object identified by the given dag_id and task_id.""" dagbag = DagBag() # Check DAG exists. if dag_id not in dagbag.dags: error_message = "Dag id {} not found".format(dag_id) raise DagNotFound(error_message) # Get D...
def get_dag_run_state(dag_id, execution_date): """Return the task object identified by the given dag_id and task_id.""" dagbag = DagBag() # Check DAG exists. if dag_id not in dagbag.dags: error_message = "Dag id {} not found".format(dag_id) raise DagNotFound(error_message) # Get D...
[ "Return", "the", "task", "object", "identified", "by", "the", "given", "dag_id", "and", "task_id", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/api/common/experimental/get_dag_run_state.py#L24-L44
[ "def", "get_dag_run_state", "(", "dag_id", ",", "execution_date", ")", ":", "dagbag", "=", "DagBag", "(", ")", "# Check DAG exists.", "if", "dag_id", "not", "in", "dagbag", ".", "dags", ":", "error_message", "=", "\"Dag id {} not found\"", ".", "format", "(", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
create_evaluate_ops
Creates Operators needed for model evaluation and returns. It gets prediction over inputs via Cloud ML Engine BatchPrediction API by calling MLEngineBatchPredictionOperator, then summarize and validate the result via Cloud Dataflow using DataFlowPythonOperator. For details and pricing about Batch pred...
airflow/contrib/utils/mlengine_operator_utils.py
def create_evaluate_ops(task_prefix, data_format, input_paths, prediction_path, metric_fn_and_keys, validate_fn, batch_prediction_job_id=None, project_i...
def create_evaluate_ops(task_prefix, data_format, input_paths, prediction_path, metric_fn_and_keys, validate_fn, batch_prediction_job_id=None, project_i...
[ "Creates", "Operators", "needed", "for", "model", "evaluation", "and", "returns", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/utils/mlengine_operator_utils.py#L32-L246
[ "def", "create_evaluate_ops", "(", "task_prefix", ",", "data_format", ",", "input_paths", ",", "prediction_path", ",", "metric_fn_and_keys", ",", "validate_fn", ",", "batch_prediction_job_id", "=", "None", ",", "project_id", "=", "None", ",", "region", "=", "None", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
mkdirs
Creates the directory specified by path, creating intermediate directories as necessary. If directory already exists, this is a no-op. :param path: The directory to create :type path: str :param mode: The mode to give to the directory e.g. 0o755, ignores umask :type mode: int
airflow/utils/file.py
def mkdirs(path, mode): """ Creates the directory specified by path, creating intermediate directories as necessary. If directory already exists, this is a no-op. :param path: The directory to create :type path: str :param mode: The mode to give to the directory e.g. 0o755, ignores umask :t...
def mkdirs(path, mode): """ Creates the directory specified by path, creating intermediate directories as necessary. If directory already exists, this is a no-op. :param path: The directory to create :type path: str :param mode: The mode to give to the directory e.g. 0o755, ignores umask :t...
[ "Creates", "the", "directory", "specified", "by", "path", "creating", "intermediate", "directories", "as", "necessary", ".", "If", "directory", "already", "exists", "this", "is", "a", "no", "-", "op", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/file.py#L42-L59
[ "def", "mkdirs", "(", "path", ",", "mode", ")", ":", "try", ":", "o_umask", "=", "os", ".", "umask", "(", "0", ")", "os", ".", "makedirs", "(", "path", ",", "mode", ")", "except", "OSError", ":", "if", "not", "os", ".", "path", ".", "isdir", "(...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
_convert_to_float_if_possible
A small helper function to convert a string to a numeric value if appropriate :param s: the string to be converted :type s: str
airflow/operators/check_operator.py
def _convert_to_float_if_possible(s): """ A small helper function to convert a string to a numeric value if appropriate :param s: the string to be converted :type s: str """ try: ret = float(s) except (ValueError, TypeError): ret = s return ret
def _convert_to_float_if_possible(s): """ A small helper function to convert a string to a numeric value if appropriate :param s: the string to be converted :type s: str """ try: ret = float(s) except (ValueError, TypeError): ret = s return ret
[ "A", "small", "helper", "function", "to", "convert", "a", "string", "to", "a", "numeric", "value", "if", "appropriate" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/operators/check_operator.py#L98-L110
[ "def", "_convert_to_float_if_possible", "(", "s", ")", ":", "try", ":", "ret", "=", "float", "(", "s", ")", "except", "(", "ValueError", ",", "TypeError", ")", ":", "ret", "=", "s", "return", "ret" ]
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
utcnow
Get the current date and time in UTC :return:
airflow/utils/timezone.py
def utcnow(): """ Get the current date and time in UTC :return: """ # pendulum utcnow() is not used as that sets a TimezoneInfo object # instead of a Timezone. This is not pickable and also creates issues # when using replace() d = dt.datetime.utcnow() d = d.replace(tzinfo=utc) ...
def utcnow(): """ Get the current date and time in UTC :return: """ # pendulum utcnow() is not used as that sets a TimezoneInfo object # instead of a Timezone. This is not pickable and also creates issues # when using replace() d = dt.datetime.utcnow() d = d.replace(tzinfo=utc) ...
[ "Get", "the", "current", "date", "and", "time", "in", "UTC", ":", "return", ":" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/timezone.py#L52-L64
[ "def", "utcnow", "(", ")", ":", "# pendulum utcnow() is not used as that sets a TimezoneInfo object", "# instead of a Timezone. This is not pickable and also creates issues", "# when using replace()", "d", "=", "dt", ".", "datetime", ".", "utcnow", "(", ")", "d", "=", "d", "....
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
utc_epoch
Gets the epoch in the users timezone :return:
airflow/utils/timezone.py
def utc_epoch(): """ Gets the epoch in the users timezone :return: """ # pendulum utcnow() is not used as that sets a TimezoneInfo object # instead of a Timezone. This is not pickable and also creates issues # when using replace() d = dt.datetime(1970, 1, 1) d = d.replace(tzinfo=utc...
def utc_epoch(): """ Gets the epoch in the users timezone :return: """ # pendulum utcnow() is not used as that sets a TimezoneInfo object # instead of a Timezone. This is not pickable and also creates issues # when using replace() d = dt.datetime(1970, 1, 1) d = d.replace(tzinfo=utc...
[ "Gets", "the", "epoch", "in", "the", "users", "timezone", ":", "return", ":" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/timezone.py#L67-L79
[ "def", "utc_epoch", "(", ")", ":", "# pendulum utcnow() is not used as that sets a TimezoneInfo object", "# instead of a Timezone. This is not pickable and also creates issues", "# when using replace()", "d", "=", "dt", ".", "datetime", "(", "1970", ",", "1", ",", "1", ")", "...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
convert_to_utc
Returns the datetime with the default timezone added if timezone information was not associated :param value: datetime :return: datetime with tzinfo
airflow/utils/timezone.py
def convert_to_utc(value): """ Returns the datetime with the default timezone added if timezone information was not associated :param value: datetime :return: datetime with tzinfo """ if not value: return value if not is_localized(value): value = pendulum.instance(value,...
def convert_to_utc(value): """ Returns the datetime with the default timezone added if timezone information was not associated :param value: datetime :return: datetime with tzinfo """ if not value: return value if not is_localized(value): value = pendulum.instance(value,...
[ "Returns", "the", "datetime", "with", "the", "default", "timezone", "added", "if", "timezone", "information", "was", "not", "associated", ":", "param", "value", ":", "datetime", ":", "return", ":", "datetime", "with", "tzinfo" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/timezone.py#L82-L95
[ "def", "convert_to_utc", "(", "value", ")", ":", "if", "not", "value", ":", "return", "value", "if", "not", "is_localized", "(", "value", ")", ":", "value", "=", "pendulum", ".", "instance", "(", "value", ",", "TIMEZONE", ")", "return", "value", ".", "...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
make_aware
Make a naive datetime.datetime in a given time zone aware. :param value: datetime :param timezone: timezone :return: localized datetime in settings.TIMEZONE or timezone
airflow/utils/timezone.py
def make_aware(value, timezone=None): """ Make a naive datetime.datetime in a given time zone aware. :param value: datetime :param timezone: timezone :return: localized datetime in settings.TIMEZONE or timezone """ if timezone is None: timezone = TIMEZONE # Check that we won't...
def make_aware(value, timezone=None): """ Make a naive datetime.datetime in a given time zone aware. :param value: datetime :param timezone: timezone :return: localized datetime in settings.TIMEZONE or timezone """ if timezone is None: timezone = TIMEZONE # Check that we won't...
[ "Make", "a", "naive", "datetime", ".", "datetime", "in", "a", "given", "time", "zone", "aware", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/timezone.py#L98-L128
[ "def", "make_aware", "(", "value", ",", "timezone", "=", "None", ")", ":", "if", "timezone", "is", "None", ":", "timezone", "=", "TIMEZONE", "# Check that we won't overwrite the timezone of an aware datetime.", "if", "is_localized", "(", "value", ")", ":", "raise", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
make_naive
Make an aware datetime.datetime naive in a given time zone. :param value: datetime :param timezone: timezone :return: naive datetime
airflow/utils/timezone.py
def make_naive(value, timezone=None): """ Make an aware datetime.datetime naive in a given time zone. :param value: datetime :param timezone: timezone :return: naive datetime """ if timezone is None: timezone = TIMEZONE # Emulate the behavior of astimezone() on Python < 3.6. ...
def make_naive(value, timezone=None): """ Make an aware datetime.datetime naive in a given time zone. :param value: datetime :param timezone: timezone :return: naive datetime """ if timezone is None: timezone = TIMEZONE # Emulate the behavior of astimezone() on Python < 3.6. ...
[ "Make", "an", "aware", "datetime", ".", "datetime", "naive", "in", "a", "given", "time", "zone", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/timezone.py#L131-L157
[ "def", "make_naive", "(", "value", ",", "timezone", "=", "None", ")", ":", "if", "timezone", "is", "None", ":", "timezone", "=", "TIMEZONE", "# Emulate the behavior of astimezone() on Python < 3.6.", "if", "is_naive", "(", "value", ")", ":", "raise", "ValueError",...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
datetime
Wrapper around datetime.datetime that adds settings.TIMEZONE if tzinfo not specified :return: datetime.datetime
airflow/utils/timezone.py
def datetime(*args, **kwargs): """ Wrapper around datetime.datetime that adds settings.TIMEZONE if tzinfo not specified :return: datetime.datetime """ if 'tzinfo' not in kwargs: kwargs['tzinfo'] = TIMEZONE return dt.datetime(*args, **kwargs)
def datetime(*args, **kwargs): """ Wrapper around datetime.datetime that adds settings.TIMEZONE if tzinfo not specified :return: datetime.datetime """ if 'tzinfo' not in kwargs: kwargs['tzinfo'] = TIMEZONE return dt.datetime(*args, **kwargs)
[ "Wrapper", "around", "datetime", ".", "datetime", "that", "adds", "settings", ".", "TIMEZONE", "if", "tzinfo", "not", "specified" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/timezone.py#L160-L169
[ "def", "datetime", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "'tzinfo'", "not", "in", "kwargs", ":", "kwargs", "[", "'tzinfo'", "]", "=", "TIMEZONE", "return", "dt", ".", "datetime", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
GKEPodOperator._set_env_from_extras
Sets the environment variable `GOOGLE_APPLICATION_CREDENTIALS` with either: - The path to the keyfile from the specified connection id - A generated file's path if the user specified JSON in the connection id. The file is assumed to be deleted after the process dies due to how mkstemp() ...
airflow/contrib/operators/gcp_container_operator.py
def _set_env_from_extras(self, extras): """ Sets the environment variable `GOOGLE_APPLICATION_CREDENTIALS` with either: - The path to the keyfile from the specified connection id - A generated file's path if the user specified JSON in the connection id. The file is assumed t...
def _set_env_from_extras(self, extras): """ Sets the environment variable `GOOGLE_APPLICATION_CREDENTIALS` with either: - The path to the keyfile from the specified connection id - A generated file's path if the user specified JSON in the connection id. The file is assumed t...
[ "Sets", "the", "environment", "variable", "GOOGLE_APPLICATION_CREDENTIALS", "with", "either", ":" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/gcp_container_operator.py#L282-L308
[ "def", "_set_env_from_extras", "(", "self", ",", "extras", ")", ":", "key_path", "=", "self", ".", "_get_field", "(", "extras", ",", "'key_path'", ",", "False", ")", "keyfile_json_str", "=", "self", ".", "_get_field", "(", "extras", ",", "'keyfile_dict'", ",...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
GKEPodOperator._get_field
Fetches a field from extras, and returns it. This is some Airflow magic. The google_cloud_platform hook type adds custom UI elements to the hook page, which allow admins to specify service_account, key_path, etc. They get formatted as shown below.
airflow/contrib/operators/gcp_container_operator.py
def _get_field(self, extras, field, default=None): """ Fetches a field from extras, and returns it. This is some Airflow magic. The google_cloud_platform hook type adds custom UI elements to the hook page, which allow admins to specify service_account, key_path, etc. They get for...
def _get_field(self, extras, field, default=None): """ Fetches a field from extras, and returns it. This is some Airflow magic. The google_cloud_platform hook type adds custom UI elements to the hook page, which allow admins to specify service_account, key_path, etc. They get for...
[ "Fetches", "a", "field", "from", "extras", "and", "returns", "it", ".", "This", "is", "some", "Airflow", "magic", ".", "The", "google_cloud_platform", "hook", "type", "adds", "custom", "UI", "elements", "to", "the", "hook", "page", "which", "allow", "admins"...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/gcp_container_operator.py#L310-L322
[ "def", "_get_field", "(", "self", ",", "extras", ",", "field", ",", "default", "=", "None", ")", ":", "long_f", "=", "'extra__google_cloud_platform__{}'", ".", "format", "(", "field", ")", "if", "long_f", "in", "extras", ":", "return", "extras", "[", "long...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DruidDbApiHook.get_conn
Establish a connection to druid broker.
airflow/hooks/druid_hook.py
def get_conn(self): """ Establish a connection to druid broker. """ conn = self.get_connection(self.druid_broker_conn_id) druid_broker_conn = connect( host=conn.host, port=conn.port, path=conn.extra_dejson.get('endpoint', '/druid/v2/sql'), ...
def get_conn(self): """ Establish a connection to druid broker. """ conn = self.get_connection(self.druid_broker_conn_id) druid_broker_conn = connect( host=conn.host, port=conn.port, path=conn.extra_dejson.get('endpoint', '/druid/v2/sql'), ...
[ "Establish", "a", "connection", "to", "druid", "broker", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/druid_hook.py#L127-L139
[ "def", "get_conn", "(", "self", ")", ":", "conn", "=", "self", ".", "get_connection", "(", "self", ".", "druid_broker_conn_id", ")", "druid_broker_conn", "=", "connect", "(", "host", "=", "conn", ".", "host", ",", "port", "=", "conn", ".", "port", ",", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
HttpHook.get_conn
Returns http session for use with requests :param headers: additional headers to be passed through as a dictionary :type headers: dict
airflow/hooks/http_hook.py
def get_conn(self, headers=None): """ Returns http session for use with requests :param headers: additional headers to be passed through as a dictionary :type headers: dict """ session = requests.Session() if self.http_conn_id: conn = self.get_connect...
def get_conn(self, headers=None): """ Returns http session for use with requests :param headers: additional headers to be passed through as a dictionary :type headers: dict """ session = requests.Session() if self.http_conn_id: conn = self.get_connect...
[ "Returns", "http", "session", "for", "use", "with", "requests" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/http_hook.py#L53-L83
[ "def", "get_conn", "(", "self", ",", "headers", "=", "None", ")", ":", "session", "=", "requests", ".", "Session", "(", ")", "if", "self", ".", "http_conn_id", ":", "conn", "=", "self", ".", "get_connection", "(", "self", ".", "http_conn_id", ")", "if"...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
HttpHook.run
Performs the request :param endpoint: the endpoint to be called i.e. resource/v1/query? :type endpoint: str :param data: payload to be uploaded or request parameters :type data: dict :param headers: additional headers to be passed through as a dictionary :type headers: d...
airflow/hooks/http_hook.py
def run(self, endpoint, data=None, headers=None, extra_options=None): """ Performs the request :param endpoint: the endpoint to be called i.e. resource/v1/query? :type endpoint: str :param data: payload to be uploaded or request parameters :type data: dict :param...
def run(self, endpoint, data=None, headers=None, extra_options=None): """ Performs the request :param endpoint: the endpoint to be called i.e. resource/v1/query? :type endpoint: str :param data: payload to be uploaded or request parameters :type data: dict :param...
[ "Performs", "the", "request" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/http_hook.py#L85-L131
[ "def", "run", "(", "self", ",", "endpoint", ",", "data", "=", "None", ",", "headers", "=", "None", ",", "extra_options", "=", "None", ")", ":", "extra_options", "=", "extra_options", "or", "{", "}", "session", "=", "self", ".", "get_conn", "(", "header...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
HttpHook.check_response
Checks the status code and raise an AirflowException exception on non 2XX or 3XX status codes :param response: A requests response object :type response: requests.response
airflow/hooks/http_hook.py
def check_response(self, response): """ Checks the status code and raise an AirflowException exception on non 2XX or 3XX status codes :param response: A requests response object :type response: requests.response """ try: response.raise_for_status() ...
def check_response(self, response): """ Checks the status code and raise an AirflowException exception on non 2XX or 3XX status codes :param response: A requests response object :type response: requests.response """ try: response.raise_for_status() ...
[ "Checks", "the", "status", "code", "and", "raise", "an", "AirflowException", "exception", "on", "non", "2XX", "or", "3XX", "status", "codes" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/http_hook.py#L133-L147
[ "def", "check_response", "(", "self", ",", "response", ")", ":", "try", ":", "response", ".", "raise_for_status", "(", ")", "except", "requests", ".", "exceptions", ".", "HTTPError", ":", "self", ".", "log", ".", "error", "(", "\"HTTP error: %s\"", ",", "r...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
HttpHook.run_and_check
Grabs extra options like timeout and actually runs the request, checking for the result :param session: the session to be used to execute the request :type session: requests.Session :param prepped_request: the prepared request generated in run() :type prepped_request: session.pr...
airflow/hooks/http_hook.py
def run_and_check(self, session, prepped_request, extra_options): """ Grabs extra options like timeout and actually runs the request, checking for the result :param session: the session to be used to execute the request :type session: requests.Session :param prepped_requ...
def run_and_check(self, session, prepped_request, extra_options): """ Grabs extra options like timeout and actually runs the request, checking for the result :param session: the session to be used to execute the request :type session: requests.Session :param prepped_requ...
[ "Grabs", "extra", "options", "like", "timeout", "and", "actually", "runs", "the", "request", "checking", "for", "the", "result" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/http_hook.py#L149-L181
[ "def", "run_and_check", "(", "self", ",", "session", ",", "prepped_request", ",", "extra_options", ")", ":", "extra_options", "=", "extra_options", "or", "{", "}", "try", ":", "response", "=", "session", ".", "send", "(", "prepped_request", ",", "stream", "=...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
HttpHook.run_with_advanced_retry
Runs Hook.run() with a Tenacity decorator attached to it. This is useful for connectors which might be disturbed by intermittent issues and should not instantly fail. :param _retry_args: Arguments which define the retry behaviour. See Tenacity documentation at https://github.com/jd/...
airflow/hooks/http_hook.py
def run_with_advanced_retry(self, _retry_args, *args, **kwargs): """ Runs Hook.run() with a Tenacity decorator attached to it. This is useful for connectors which might be disturbed by intermittent issues and should not instantly fail. :param _retry_args: Arguments which define ...
def run_with_advanced_retry(self, _retry_args, *args, **kwargs): """ Runs Hook.run() with a Tenacity decorator attached to it. This is useful for connectors which might be disturbed by intermittent issues and should not instantly fail. :param _retry_args: Arguments which define ...
[ "Runs", "Hook", ".", "run", "()", "with", "a", "Tenacity", "decorator", "attached", "to", "it", ".", "This", "is", "useful", "for", "connectors", "which", "might", "be", "disturbed", "by", "intermittent", "issues", "and", "should", "not", "instantly", "fail"...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/http_hook.py#L183-L211
[ "def", "run_with_advanced_retry", "(", "self", ",", "_retry_args", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_retry_obj", "=", "tenacity", ".", "Retrying", "(", "*", "*", "_retry_args", ")", "self", ".", "_retry_obj", "(", "self"...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
create_session
Contextmanager that will create and teardown a session.
airflow/utils/db.py
def create_session(): """ Contextmanager that will create and teardown a session. """ session = settings.Session() try: yield session session.commit() except Exception: session.rollback() raise finally: session.close()
def create_session(): """ Contextmanager that will create and teardown a session. """ session = settings.Session() try: yield session session.commit() except Exception: session.rollback() raise finally: session.close()
[ "Contextmanager", "that", "will", "create", "and", "teardown", "a", "session", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/db.py#L32-L44
[ "def", "create_session", "(", ")", ":", "session", "=", "settings", ".", "Session", "(", ")", "try", ":", "yield", "session", "session", ".", "commit", "(", ")", "except", "Exception", ":", "session", ".", "rollback", "(", ")", "raise", "finally", ":", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
provide_session
Function decorator that provides a session if it isn't provided. If you want to reuse a session or run the function as part of a database transaction, you pass it to the function, if not this wrapper will create one and close it for you.
airflow/utils/db.py
def provide_session(func): """ Function decorator that provides a session if it isn't provided. If you want to reuse a session or run the function as part of a database transaction, you pass it to the function, if not this wrapper will create one and close it for you. """ @wraps(func) de...
def provide_session(func): """ Function decorator that provides a session if it isn't provided. If you want to reuse a session or run the function as part of a database transaction, you pass it to the function, if not this wrapper will create one and close it for you. """ @wraps(func) de...
[ "Function", "decorator", "that", "provides", "a", "session", "if", "it", "isn", "t", "provided", ".", "If", "you", "want", "to", "reuse", "a", "session", "or", "run", "the", "function", "as", "part", "of", "a", "database", "transaction", "you", "pass", "...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/db.py#L47-L70
[ "def", "provide_session", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "arg_session", "=", "'session'", "func_params", "=", "func", ".", "__code__", ".", "co_varnames", "s...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
resetdb
Clear out the database
airflow/utils/db.py
def resetdb(): """ Clear out the database """ from airflow import models # alembic adds significant import time, so we import it lazily from alembic.migration import MigrationContext log.info("Dropping tables that exist") models.base.Base.metadata.drop_all(settings.engine) mc = Mi...
def resetdb(): """ Clear out the database """ from airflow import models # alembic adds significant import time, so we import it lazily from alembic.migration import MigrationContext log.info("Dropping tables that exist") models.base.Base.metadata.drop_all(settings.engine) mc = Mi...
[ "Clear", "out", "the", "database" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/db.py#L312-L331
[ "def", "resetdb", "(", ")", ":", "from", "airflow", "import", "models", "# alembic adds significant import time, so we import it lazily", "from", "alembic", ".", "migration", "import", "MigrationContext", "log", ".", "info", "(", "\"Dropping tables that exist\"", ")", "mo...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
FileToWasbOperator.execute
Upload a file to Azure Blob Storage.
airflow/contrib/operators/file_to_wasb.py
def execute(self, context): """Upload a file to Azure Blob Storage.""" hook = WasbHook(wasb_conn_id=self.wasb_conn_id) self.log.info( 'Uploading %s to wasb://%s ' 'as %s'.format(self.file_path, self.container_name, self.blob_name) ) hook.load_file(self.fil...
def execute(self, context): """Upload a file to Azure Blob Storage.""" hook = WasbHook(wasb_conn_id=self.wasb_conn_id) self.log.info( 'Uploading %s to wasb://%s ' 'as %s'.format(self.file_path, self.container_name, self.blob_name) ) hook.load_file(self.fil...
[ "Upload", "a", "file", "to", "Azure", "Blob", "Storage", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/file_to_wasb.py#L56-L64
[ "def", "execute", "(", "self", ",", "context", ")", ":", "hook", "=", "WasbHook", "(", "wasb_conn_id", "=", "self", ".", "wasb_conn_id", ")", "self", ".", "log", ".", "info", "(", "'Uploading %s to wasb://%s '", "'as %s'", ".", "format", "(", "self", ".", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
PrestoHook.get_conn
Returns a connection object
airflow/hooks/presto_hook.py
def get_conn(self): """Returns a connection object""" db = self.get_connection(self.presto_conn_id) reqkwargs = None if db.password is not None: reqkwargs = {'auth': HTTPBasicAuth(db.login, db.password)} return presto.connect( host=db.host, por...
def get_conn(self): """Returns a connection object""" db = self.get_connection(self.presto_conn_id) reqkwargs = None if db.password is not None: reqkwargs = {'auth': HTTPBasicAuth(db.login, db.password)} return presto.connect( host=db.host, por...
[ "Returns", "a", "connection", "object" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/presto_hook.py#L46-L60
[ "def", "get_conn", "(", "self", ")", ":", "db", "=", "self", ".", "get_connection", "(", "self", ".", "presto_conn_id", ")", "reqkwargs", "=", "None", "if", "db", ".", "password", "is", "not", "None", ":", "reqkwargs", "=", "{", "'auth'", ":", "HTTPBas...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
PrestoHook._get_pretty_exception_message
Parses some DatabaseError to provide a better error message
airflow/hooks/presto_hook.py
def _get_pretty_exception_message(e): """ Parses some DatabaseError to provide a better error message """ if (hasattr(e, 'message') and 'errorName' in e.message and 'message' in e.message): return ('{name}: {message}'.format( na...
def _get_pretty_exception_message(e): """ Parses some DatabaseError to provide a better error message """ if (hasattr(e, 'message') and 'errorName' in e.message and 'message' in e.message): return ('{name}: {message}'.format( na...
[ "Parses", "some", "DatabaseError", "to", "provide", "a", "better", "error", "message" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/presto_hook.py#L67-L78
[ "def", "_get_pretty_exception_message", "(", "e", ")", ":", "if", "(", "hasattr", "(", "e", ",", "'message'", ")", "and", "'errorName'", "in", "e", ".", "message", "and", "'message'", "in", "e", ".", "message", ")", ":", "return", "(", "'{name}: {message}'...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
PrestoHook.get_records
Get a set of records from Presto
airflow/hooks/presto_hook.py
def get_records(self, hql, parameters=None): """ Get a set of records from Presto """ try: return super().get_records( self._strip_sql(hql), parameters) except DatabaseError as e: raise PrestoException(self._get_pretty_exception_message(e))
def get_records(self, hql, parameters=None): """ Get a set of records from Presto """ try: return super().get_records( self._strip_sql(hql), parameters) except DatabaseError as e: raise PrestoException(self._get_pretty_exception_message(e))
[ "Get", "a", "set", "of", "records", "from", "Presto" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/presto_hook.py#L80-L88
[ "def", "get_records", "(", "self", ",", "hql", ",", "parameters", "=", "None", ")", ":", "try", ":", "return", "super", "(", ")", ".", "get_records", "(", "self", ".", "_strip_sql", "(", "hql", ")", ",", "parameters", ")", "except", "DatabaseError", "a...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
PrestoHook.get_pandas_df
Get a pandas dataframe from a sql query.
airflow/hooks/presto_hook.py
def get_pandas_df(self, hql, parameters=None): """ Get a pandas dataframe from a sql query. """ import pandas cursor = self.get_cursor() try: cursor.execute(self._strip_sql(hql), parameters) data = cursor.fetchall() except DatabaseError as ...
def get_pandas_df(self, hql, parameters=None): """ Get a pandas dataframe from a sql query. """ import pandas cursor = self.get_cursor() try: cursor.execute(self._strip_sql(hql), parameters) data = cursor.fetchall() except DatabaseError as ...
[ "Get", "a", "pandas", "dataframe", "from", "a", "sql", "query", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/presto_hook.py#L101-L118
[ "def", "get_pandas_df", "(", "self", ",", "hql", ",", "parameters", "=", "None", ")", ":", "import", "pandas", "cursor", "=", "self", ".", "get_cursor", "(", ")", "try", ":", "cursor", ".", "execute", "(", "self", ".", "_strip_sql", "(", "hql", ")", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
PrestoHook.run
Execute the statement against Presto. Can be used to create views.
airflow/hooks/presto_hook.py
def run(self, hql, parameters=None): """ Execute the statement against Presto. Can be used to create views. """ return super().run(self._strip_sql(hql), parameters)
def run(self, hql, parameters=None): """ Execute the statement against Presto. Can be used to create views. """ return super().run(self._strip_sql(hql), parameters)
[ "Execute", "the", "statement", "against", "Presto", ".", "Can", "be", "used", "to", "create", "views", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/presto_hook.py#L120-L124
[ "def", "run", "(", "self", ",", "hql", ",", "parameters", "=", "None", ")", ":", "return", "super", "(", ")", ".", "run", "(", "self", ".", "_strip_sql", "(", "hql", ")", ",", "parameters", ")" ]
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
PrestoHook.insert_rows
A generic way to insert a set of tuples into a table. :param table: Name of the target table :type table: str :param rows: The rows to insert into the table :type rows: iterable of tuples :param target_fields: The names of the columns to fill in the table :type target_fi...
airflow/hooks/presto_hook.py
def insert_rows(self, table, rows, target_fields=None): """ A generic way to insert a set of tuples into a table. :param table: Name of the target table :type table: str :param rows: The rows to insert into the table :type rows: iterable of tuples :param target_f...
def insert_rows(self, table, rows, target_fields=None): """ A generic way to insert a set of tuples into a table. :param table: Name of the target table :type table: str :param rows: The rows to insert into the table :type rows: iterable of tuples :param target_f...
[ "A", "generic", "way", "to", "insert", "a", "set", "of", "tuples", "into", "a", "table", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/presto_hook.py#L129-L140
[ "def", "insert_rows", "(", "self", ",", "table", ",", "rows", ",", "target_fields", "=", "None", ")", ":", "super", "(", ")", ".", "insert_rows", "(", "table", ",", "rows", ",", "target_fields", ",", "0", ")" ]
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AzureCosmosDBHook.get_conn
Return a cosmos db client.
airflow/contrib/hooks/azure_cosmos_hook.py
def get_conn(self): """ Return a cosmos db client. """ if self.cosmos_client is not None: return self.cosmos_client # Initialize the Python Azure Cosmos DB client self.cosmos_client = cosmos_client.CosmosClient(self.endpoint_uri, {'masterKey': self.master_key...
def get_conn(self): """ Return a cosmos db client. """ if self.cosmos_client is not None: return self.cosmos_client # Initialize the Python Azure Cosmos DB client self.cosmos_client = cosmos_client.CosmosClient(self.endpoint_uri, {'masterKey': self.master_key...
[ "Return", "a", "cosmos", "db", "client", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/azure_cosmos_hook.py#L50-L60
[ "def", "get_conn", "(", "self", ")", ":", "if", "self", ".", "cosmos_client", "is", "not", "None", ":", "return", "self", ".", "cosmos_client", "# Initialize the Python Azure Cosmos DB client", "self", ".", "cosmos_client", "=", "cosmos_client", ".", "CosmosClient",...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AzureCosmosDBHook.does_collection_exist
Checks if a collection exists in CosmosDB.
airflow/contrib/hooks/azure_cosmos_hook.py
def does_collection_exist(self, collection_name, database_name=None): """ Checks if a collection exists in CosmosDB. """ if collection_name is None: raise AirflowBadRequest("Collection name cannot be None.") existing_container = list(self.get_conn().QueryContainers( ...
def does_collection_exist(self, collection_name, database_name=None): """ Checks if a collection exists in CosmosDB. """ if collection_name is None: raise AirflowBadRequest("Collection name cannot be None.") existing_container = list(self.get_conn().QueryContainers( ...
[ "Checks", "if", "a", "collection", "exists", "in", "CosmosDB", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/azure_cosmos_hook.py#L82-L99
[ "def", "does_collection_exist", "(", "self", ",", "collection_name", ",", "database_name", "=", "None", ")", ":", "if", "collection_name", "is", "None", ":", "raise", "AirflowBadRequest", "(", "\"Collection name cannot be None.\"", ")", "existing_container", "=", "lis...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AzureCosmosDBHook.create_collection
Creates a new collection in the CosmosDB database.
airflow/contrib/hooks/azure_cosmos_hook.py
def create_collection(self, collection_name, database_name=None): """ Creates a new collection in the CosmosDB database. """ if collection_name is None: raise AirflowBadRequest("Collection name cannot be None.") # We need to check to see if this container already exi...
def create_collection(self, collection_name, database_name=None): """ Creates a new collection in the CosmosDB database. """ if collection_name is None: raise AirflowBadRequest("Collection name cannot be None.") # We need to check to see if this container already exi...
[ "Creates", "a", "new", "collection", "in", "the", "CosmosDB", "database", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/azure_cosmos_hook.py#L101-L122
[ "def", "create_collection", "(", "self", ",", "collection_name", ",", "database_name", "=", "None", ")", ":", "if", "collection_name", "is", "None", ":", "raise", "AirflowBadRequest", "(", "\"Collection name cannot be None.\"", ")", "# We need to check to see if this cont...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AzureCosmosDBHook.does_database_exist
Checks if a database exists in CosmosDB.
airflow/contrib/hooks/azure_cosmos_hook.py
def does_database_exist(self, database_name): """ Checks if a database exists in CosmosDB. """ if database_name is None: raise AirflowBadRequest("Database name cannot be None.") existing_database = list(self.get_conn().QueryDatabases({ "query": "SELECT * ...
def does_database_exist(self, database_name): """ Checks if a database exists in CosmosDB. """ if database_name is None: raise AirflowBadRequest("Database name cannot be None.") existing_database = list(self.get_conn().QueryDatabases({ "query": "SELECT * ...
[ "Checks", "if", "a", "database", "exists", "in", "CosmosDB", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/azure_cosmos_hook.py#L124-L140
[ "def", "does_database_exist", "(", "self", ",", "database_name", ")", ":", "if", "database_name", "is", "None", ":", "raise", "AirflowBadRequest", "(", "\"Database name cannot be None.\"", ")", "existing_database", "=", "list", "(", "self", ".", "get_conn", "(", "...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AzureCosmosDBHook.create_database
Creates a new database in CosmosDB.
airflow/contrib/hooks/azure_cosmos_hook.py
def create_database(self, database_name): """ Creates a new database in CosmosDB. """ if database_name is None: raise AirflowBadRequest("Database name cannot be None.") # We need to check to see if this database already exists so we don't try # to create it t...
def create_database(self, database_name): """ Creates a new database in CosmosDB. """ if database_name is None: raise AirflowBadRequest("Database name cannot be None.") # We need to check to see if this database already exists so we don't try # to create it t...
[ "Creates", "a", "new", "database", "in", "CosmosDB", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/azure_cosmos_hook.py#L142-L160
[ "def", "create_database", "(", "self", ",", "database_name", ")", ":", "if", "database_name", "is", "None", ":", "raise", "AirflowBadRequest", "(", "\"Database name cannot be None.\"", ")", "# We need to check to see if this database already exists so we don't try", "# to creat...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AzureCosmosDBHook.delete_database
Deletes an existing database in CosmosDB.
airflow/contrib/hooks/azure_cosmos_hook.py
def delete_database(self, database_name): """ Deletes an existing database in CosmosDB. """ if database_name is None: raise AirflowBadRequest("Database name cannot be None.") self.get_conn().DeleteDatabase(get_database_link(database_name))
def delete_database(self, database_name): """ Deletes an existing database in CosmosDB. """ if database_name is None: raise AirflowBadRequest("Database name cannot be None.") self.get_conn().DeleteDatabase(get_database_link(database_name))
[ "Deletes", "an", "existing", "database", "in", "CosmosDB", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/azure_cosmos_hook.py#L162-L169
[ "def", "delete_database", "(", "self", ",", "database_name", ")", ":", "if", "database_name", "is", "None", ":", "raise", "AirflowBadRequest", "(", "\"Database name cannot be None.\"", ")", "self", ".", "get_conn", "(", ")", ".", "DeleteDatabase", "(", "get_databa...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AzureCosmosDBHook.delete_collection
Deletes an existing collection in the CosmosDB database.
airflow/contrib/hooks/azure_cosmos_hook.py
def delete_collection(self, collection_name, database_name=None): """ Deletes an existing collection in the CosmosDB database. """ if collection_name is None: raise AirflowBadRequest("Collection name cannot be None.") self.get_conn().DeleteContainer( get_...
def delete_collection(self, collection_name, database_name=None): """ Deletes an existing collection in the CosmosDB database. """ if collection_name is None: raise AirflowBadRequest("Collection name cannot be None.") self.get_conn().DeleteContainer( get_...
[ "Deletes", "an", "existing", "collection", "in", "the", "CosmosDB", "database", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/azure_cosmos_hook.py#L171-L179
[ "def", "delete_collection", "(", "self", ",", "collection_name", ",", "database_name", "=", "None", ")", ":", "if", "collection_name", "is", "None", ":", "raise", "AirflowBadRequest", "(", "\"Collection name cannot be None.\"", ")", "self", ".", "get_conn", "(", "...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AzureCosmosDBHook.upsert_document
Inserts a new document (or updates an existing one) into an existing collection in the CosmosDB database.
airflow/contrib/hooks/azure_cosmos_hook.py
def upsert_document(self, document, database_name=None, collection_name=None, document_id=None): """ Inserts a new document (or updates an existing one) into an existing collection in the CosmosDB database. """ # Assign unique ID if one isn't provided if document_id is No...
def upsert_document(self, document, database_name=None, collection_name=None, document_id=None): """ Inserts a new document (or updates an existing one) into an existing collection in the CosmosDB database. """ # Assign unique ID if one isn't provided if document_id is No...
[ "Inserts", "a", "new", "document", "(", "or", "updates", "an", "existing", "one", ")", "into", "an", "existing", "collection", "in", "the", "CosmosDB", "database", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/azure_cosmos_hook.py#L181-L206
[ "def", "upsert_document", "(", "self", ",", "document", ",", "database_name", "=", "None", ",", "collection_name", "=", "None", ",", "document_id", "=", "None", ")", ":", "# Assign unique ID if one isn't provided", "if", "document_id", "is", "None", ":", "document...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AzureCosmosDBHook.insert_documents
Insert a list of new documents into an existing collection in the CosmosDB database.
airflow/contrib/hooks/azure_cosmos_hook.py
def insert_documents(self, documents, database_name=None, collection_name=None): """ Insert a list of new documents into an existing collection in the CosmosDB database. """ if documents is None: raise AirflowBadRequest("You cannot insert empty documents") created_do...
def insert_documents(self, documents, database_name=None, collection_name=None): """ Insert a list of new documents into an existing collection in the CosmosDB database. """ if documents is None: raise AirflowBadRequest("You cannot insert empty documents") created_do...
[ "Insert", "a", "list", "of", "new", "documents", "into", "an", "existing", "collection", "in", "the", "CosmosDB", "database", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/azure_cosmos_hook.py#L208-L224
[ "def", "insert_documents", "(", "self", ",", "documents", ",", "database_name", "=", "None", ",", "collection_name", "=", "None", ")", ":", "if", "documents", "is", "None", ":", "raise", "AirflowBadRequest", "(", "\"You cannot insert empty documents\"", ")", "crea...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AzureCosmosDBHook.delete_document
Delete an existing document out of a collection in the CosmosDB database.
airflow/contrib/hooks/azure_cosmos_hook.py
def delete_document(self, document_id, database_name=None, collection_name=None): """ Delete an existing document out of a collection in the CosmosDB database. """ if document_id is None: raise AirflowBadRequest("Cannot delete a document without an id") self.get_conn...
def delete_document(self, document_id, database_name=None, collection_name=None): """ Delete an existing document out of a collection in the CosmosDB database. """ if document_id is None: raise AirflowBadRequest("Cannot delete a document without an id") self.get_conn...
[ "Delete", "an", "existing", "document", "out", "of", "a", "collection", "in", "the", "CosmosDB", "database", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/azure_cosmos_hook.py#L226-L237
[ "def", "delete_document", "(", "self", ",", "document_id", ",", "database_name", "=", "None", ",", "collection_name", "=", "None", ")", ":", "if", "document_id", "is", "None", ":", "raise", "AirflowBadRequest", "(", "\"Cannot delete a document without an id\"", ")",...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AzureCosmosDBHook.get_document
Get a document from an existing collection in the CosmosDB database.
airflow/contrib/hooks/azure_cosmos_hook.py
def get_document(self, document_id, database_name=None, collection_name=None): """ Get a document from an existing collection in the CosmosDB database. """ if document_id is None: raise AirflowBadRequest("Cannot get a document without an id") try: return ...
def get_document(self, document_id, database_name=None, collection_name=None): """ Get a document from an existing collection in the CosmosDB database. """ if document_id is None: raise AirflowBadRequest("Cannot get a document without an id") try: return ...
[ "Get", "a", "document", "from", "an", "existing", "collection", "in", "the", "CosmosDB", "database", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/azure_cosmos_hook.py#L239-L253
[ "def", "get_document", "(", "self", ",", "document_id", ",", "database_name", "=", "None", ",", "collection_name", "=", "None", ")", ":", "if", "document_id", "is", "None", ":", "raise", "AirflowBadRequest", "(", "\"Cannot get a document without an id\"", ")", "tr...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AzureCosmosDBHook.get_documents
Get a list of documents from an existing collection in the CosmosDB database via SQL query.
airflow/contrib/hooks/azure_cosmos_hook.py
def get_documents(self, sql_string, database_name=None, collection_name=None, partition_key=None): """ Get a list of documents from an existing collection in the CosmosDB database via SQL query. """ if sql_string is None: raise AirflowBadRequest("SQL query string cannot be No...
def get_documents(self, sql_string, database_name=None, collection_name=None, partition_key=None): """ Get a list of documents from an existing collection in the CosmosDB database via SQL query. """ if sql_string is None: raise AirflowBadRequest("SQL query string cannot be No...
[ "Get", "a", "list", "of", "documents", "from", "an", "existing", "collection", "in", "the", "CosmosDB", "database", "via", "SQL", "query", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/azure_cosmos_hook.py#L255-L275
[ "def", "get_documents", "(", "self", ",", "sql_string", ",", "database_name", "=", "None", ",", "collection_name", "=", "None", ",", "partition_key", "=", "None", ")", ":", "if", "sql_string", "is", "None", ":", "raise", "AirflowBadRequest", "(", "\"SQL query ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
get_code
Return python code of a given dag_id.
airflow/api/common/experimental/get_code.py
def get_code(dag_id): """Return python code of a given dag_id.""" session = settings.Session() DM = models.DagModel dag = session.query(DM).filter(DM.dag_id == dag_id).first() session.close() # Check DAG exists. if dag is None: error_message = "Dag id {} not found".format(dag_id) ...
def get_code(dag_id): """Return python code of a given dag_id.""" session = settings.Session() DM = models.DagModel dag = session.query(DM).filter(DM.dag_id == dag_id).first() session.close() # Check DAG exists. if dag is None: error_message = "Dag id {} not found".format(dag_id) ...
[ "Return", "python", "code", "of", "a", "given", "dag_id", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/api/common/experimental/get_code.py#L25-L42
[ "def", "get_code", "(", "dag_id", ")", ":", "session", "=", "settings", ".", "Session", "(", ")", "DM", "=", "models", ".", "DagModel", "dag", "=", "session", ".", "query", "(", "DM", ")", ".", "filter", "(", "DM", ".", "dag_id", "==", "dag_id", ")...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
GcfHook.get_function
Returns the Cloud Function with the given name. :param name: Name of the function. :type name: str :return: A Cloud Functions object representing the function. :rtype: dict
airflow/contrib/hooks/gcp_function_hook.py
def get_function(self, name): """ Returns the Cloud Function with the given name. :param name: Name of the function. :type name: str :return: A Cloud Functions object representing the function. :rtype: dict """ return self.get_conn().projects().locations(...
def get_function(self, name): """ Returns the Cloud Function with the given name. :param name: Name of the function. :type name: str :return: A Cloud Functions object representing the function. :rtype: dict """ return self.get_conn().projects().locations(...
[ "Returns", "the", "Cloud", "Function", "with", "the", "given", "name", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_function_hook.py#L76-L86
[ "def", "get_function", "(", "self", ",", "name", ")", ":", "return", "self", ".", "get_conn", "(", ")", ".", "projects", "(", ")", ".", "locations", "(", ")", ".", "functions", "(", ")", ".", "get", "(", "name", "=", "name", ")", ".", "execute", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
GcfHook.create_new_function
Creates a new function in Cloud Function in the location specified in the body. :param location: The location of the function. :type location: str :param body: The body required by the Cloud Functions insert API. :type body: dict :param project_id: Optional, Google Cloud Project...
airflow/contrib/hooks/gcp_function_hook.py
def create_new_function(self, location, body, project_id=None): """ Creates a new function in Cloud Function in the location specified in the body. :param location: The location of the function. :type location: str :param body: The body required by the Cloud Functions insert API...
def create_new_function(self, location, body, project_id=None): """ Creates a new function in Cloud Function in the location specified in the body. :param location: The location of the function. :type location: str :param body: The body required by the Cloud Functions insert API...
[ "Creates", "a", "new", "function", "in", "Cloud", "Function", "in", "the", "location", "specified", "in", "the", "body", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_function_hook.py#L89-L107
[ "def", "create_new_function", "(", "self", ",", "location", ",", "body", ",", "project_id", "=", "None", ")", ":", "response", "=", "self", ".", "get_conn", "(", ")", ".", "projects", "(", ")", ".", "locations", "(", ")", ".", "functions", "(", ")", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
GcfHook.update_function
Updates Cloud Functions according to the specified update mask. :param name: The name of the function. :type name: str :param body: The body required by the cloud function patch API. :type body: dict :param update_mask: The update mask - array of fields that should be patched. ...
airflow/contrib/hooks/gcp_function_hook.py
def update_function(self, name, body, update_mask): """ Updates Cloud Functions according to the specified update mask. :param name: The name of the function. :type name: str :param body: The body required by the cloud function patch API. :type body: dict :param ...
def update_function(self, name, body, update_mask): """ Updates Cloud Functions according to the specified update mask. :param name: The name of the function. :type name: str :param body: The body required by the cloud function patch API. :type body: dict :param ...
[ "Updates", "Cloud", "Functions", "according", "to", "the", "specified", "update", "mask", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_function_hook.py#L109-L127
[ "def", "update_function", "(", "self", ",", "name", ",", "body", ",", "update_mask", ")", ":", "response", "=", "self", ".", "get_conn", "(", ")", ".", "projects", "(", ")", ".", "locations", "(", ")", ".", "functions", "(", ")", ".", "patch", "(", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
GcfHook.upload_function_zip
Uploads zip file with sources. :param location: The location where the function is created. :type location: str :param zip_path: The path of the valid .zip file to upload. :type zip_path: str :param project_id: Optional, Google Cloud Project project_id where the function belongs...
airflow/contrib/hooks/gcp_function_hook.py
def upload_function_zip(self, location, zip_path, project_id=None): """ Uploads zip file with sources. :param location: The location where the function is created. :type location: str :param zip_path: The path of the valid .zip file to upload. :type zip_path: str ...
def upload_function_zip(self, location, zip_path, project_id=None): """ Uploads zip file with sources. :param location: The location where the function is created. :type location: str :param zip_path: The path of the valid .zip file to upload. :type zip_path: str ...
[ "Uploads", "zip", "file", "with", "sources", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_function_hook.py#L130-L159
[ "def", "upload_function_zip", "(", "self", ",", "location", ",", "zip_path", ",", "project_id", "=", "None", ")", ":", "response", "=", "self", ".", "get_conn", "(", ")", ".", "projects", "(", ")", ".", "locations", "(", ")", ".", "functions", "(", ")"...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
GcfHook.delete_function
Deletes the specified Cloud Function. :param name: The name of the function. :type name: str :return: None
airflow/contrib/hooks/gcp_function_hook.py
def delete_function(self, name): """ Deletes the specified Cloud Function. :param name: The name of the function. :type name: str :return: None """ response = self.get_conn().projects().locations().functions().delete( name=name).execute(num_retries=se...
def delete_function(self, name): """ Deletes the specified Cloud Function. :param name: The name of the function. :type name: str :return: None """ response = self.get_conn().projects().locations().functions().delete( name=name).execute(num_retries=se...
[ "Deletes", "the", "specified", "Cloud", "Function", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_function_hook.py#L161-L172
[ "def", "delete_function", "(", "self", ",", "name", ")", ":", "response", "=", "self", ".", "get_conn", "(", ")", ".", "projects", "(", ")", ".", "locations", "(", ")", ".", "functions", "(", ")", ".", "delete", "(", "name", "=", "name", ")", ".", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
GcfHook._wait_for_operation_to_complete
Waits for the named operation to complete - checks status of the asynchronous call. :param operation_name: The name of the operation. :type operation_name: str :return: The response returned by the operation. :rtype: dict :exception: AirflowException in case error is ret...
airflow/contrib/hooks/gcp_function_hook.py
def _wait_for_operation_to_complete(self, operation_name): """ Waits for the named operation to complete - checks status of the asynchronous call. :param operation_name: The name of the operation. :type operation_name: str :return: The response returned by the operation....
def _wait_for_operation_to_complete(self, operation_name): """ Waits for the named operation to complete - checks status of the asynchronous call. :param operation_name: The name of the operation. :type operation_name: str :return: The response returned by the operation....
[ "Waits", "for", "the", "named", "operation", "to", "complete", "-", "checks", "status", "of", "the", "asynchronous", "call", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_function_hook.py#L174-L198
[ "def", "_wait_for_operation_to_complete", "(", "self", ",", "operation_name", ")", ":", "service", "=", "self", ".", "get_conn", "(", ")", "while", "True", ":", "operation_response", "=", "service", ".", "operations", "(", ")", ".", "get", "(", "name", "=", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
PubSubHook.publish
Publishes messages to a Pub/Sub topic. :param project: the GCP project ID in which to publish :type project: str :param topic: the Pub/Sub topic to which to publish; do not include the ``projects/{project}/topics/`` prefix. :type topic: str :param messages: messages ...
airflow/contrib/hooks/gcp_pubsub_hook.py
def publish(self, project, topic, messages): """Publishes messages to a Pub/Sub topic. :param project: the GCP project ID in which to publish :type project: str :param topic: the Pub/Sub topic to which to publish; do not include the ``projects/{project}/topics/`` prefix. ...
def publish(self, project, topic, messages): """Publishes messages to a Pub/Sub topic. :param project: the GCP project ID in which to publish :type project: str :param topic: the Pub/Sub topic to which to publish; do not include the ``projects/{project}/topics/`` prefix. ...
[ "Publishes", "messages", "to", "a", "Pub", "/", "Sub", "topic", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_pubsub_hook.py#L60-L81
[ "def", "publish", "(", "self", ",", "project", ",", "topic", ",", "messages", ")", ":", "body", "=", "{", "'messages'", ":", "messages", "}", "full_topic", "=", "_format_topic", "(", "project", ",", "topic", ")", "request", "=", "self", ".", "get_conn", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
PubSubHook.create_topic
Creates a Pub/Sub topic, if it does not already exist. :param project: the GCP project ID in which to create the topic :type project: str :param topic: the Pub/Sub topic name to create; do not include the ``projects/{project}/topics/`` prefix. :type topic: str ...
airflow/contrib/hooks/gcp_pubsub_hook.py
def create_topic(self, project, topic, fail_if_exists=False): """Creates a Pub/Sub topic, if it does not already exist. :param project: the GCP project ID in which to create the topic :type project: str :param topic: the Pub/Sub topic name to create; do not inclu...
def create_topic(self, project, topic, fail_if_exists=False): """Creates a Pub/Sub topic, if it does not already exist. :param project: the GCP project ID in which to create the topic :type project: str :param topic: the Pub/Sub topic name to create; do not inclu...
[ "Creates", "a", "Pub", "/", "Sub", "topic", "if", "it", "does", "not", "already", "exist", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_pubsub_hook.py#L83-L110
[ "def", "create_topic", "(", "self", ",", "project", ",", "topic", ",", "fail_if_exists", "=", "False", ")", ":", "service", "=", "self", ".", "get_conn", "(", ")", "full_topic", "=", "_format_topic", "(", "project", ",", "topic", ")", "try", ":", "servic...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
PubSubHook.delete_topic
Deletes a Pub/Sub topic if it exists. :param project: the GCP project ID in which to delete the topic :type project: str :param topic: the Pub/Sub topic name to delete; do not include the ``projects/{project}/topics/`` prefix. :type topic: str :param fail_if_not_exis...
airflow/contrib/hooks/gcp_pubsub_hook.py
def delete_topic(self, project, topic, fail_if_not_exists=False): """Deletes a Pub/Sub topic if it exists. :param project: the GCP project ID in which to delete the topic :type project: str :param topic: the Pub/Sub topic name to delete; do not include the ``projects/{projec...
def delete_topic(self, project, topic, fail_if_not_exists=False): """Deletes a Pub/Sub topic if it exists. :param project: the GCP project ID in which to delete the topic :type project: str :param topic: the Pub/Sub topic name to delete; do not include the ``projects/{projec...
[ "Deletes", "a", "Pub", "/", "Sub", "topic", "if", "it", "exists", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_pubsub_hook.py#L112-L137
[ "def", "delete_topic", "(", "self", ",", "project", ",", "topic", ",", "fail_if_not_exists", "=", "False", ")", ":", "service", "=", "self", ".", "get_conn", "(", ")", "full_topic", "=", "_format_topic", "(", "project", ",", "topic", ")", "try", ":", "se...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
PubSubHook.create_subscription
Creates a Pub/Sub subscription, if it does not already exist. :param topic_project: the GCP project ID of the topic that the subscription will be bound to. :type topic_project: str :param topic: the Pub/Sub topic name that the subscription will be bound to create; do not...
airflow/contrib/hooks/gcp_pubsub_hook.py
def create_subscription(self, topic_project, topic, subscription=None, subscription_project=None, ack_deadline_secs=10, fail_if_exists=False): """Creates a Pub/Sub subscription, if it does not already exist. :param topic_project: the GCP project I...
def create_subscription(self, topic_project, topic, subscription=None, subscription_project=None, ack_deadline_secs=10, fail_if_exists=False): """Creates a Pub/Sub subscription, if it does not already exist. :param topic_project: the GCP project I...
[ "Creates", "a", "Pub", "/", "Sub", "subscription", "if", "it", "does", "not", "already", "exist", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_pubsub_hook.py#L139-L194
[ "def", "create_subscription", "(", "self", ",", "topic_project", ",", "topic", ",", "subscription", "=", "None", ",", "subscription_project", "=", "None", ",", "ack_deadline_secs", "=", "10", ",", "fail_if_exists", "=", "False", ")", ":", "service", "=", "self...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
PubSubHook.delete_subscription
Deletes a Pub/Sub subscription, if it exists. :param project: the GCP project ID where the subscription exists :type project: str :param subscription: the Pub/Sub subscription name to delete; do not include the ``projects/{project}/subscriptions/`` prefix. :type subscription...
airflow/contrib/hooks/gcp_pubsub_hook.py
def delete_subscription(self, project, subscription, fail_if_not_exists=False): """Deletes a Pub/Sub subscription, if it exists. :param project: the GCP project ID where the subscription exists :type project: str :param subscription: the Pub/Sub subscription ...
def delete_subscription(self, project, subscription, fail_if_not_exists=False): """Deletes a Pub/Sub subscription, if it exists. :param project: the GCP project ID where the subscription exists :type project: str :param subscription: the Pub/Sub subscription ...
[ "Deletes", "a", "Pub", "/", "Sub", "subscription", "if", "it", "exists", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_pubsub_hook.py#L196-L225
[ "def", "delete_subscription", "(", "self", ",", "project", ",", "subscription", ",", "fail_if_not_exists", "=", "False", ")", ":", "service", "=", "self", ".", "get_conn", "(", ")", "full_subscription", "=", "_format_subscription", "(", "project", ",", "subscrip...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
PubSubHook.pull
Pulls up to ``max_messages`` messages from Pub/Sub subscription. :param project: the GCP project ID where the subscription exists :type project: str :param subscription: the Pub/Sub subscription name to pull from; do not include the 'projects/{project}/topics/' prefix. :type...
airflow/contrib/hooks/gcp_pubsub_hook.py
def pull(self, project, subscription, max_messages, return_immediately=False): """Pulls up to ``max_messages`` messages from Pub/Sub subscription. :param project: the GCP project ID where the subscription exists :type project: str :param subscription: the Pub/Sub subscripti...
def pull(self, project, subscription, max_messages, return_immediately=False): """Pulls up to ``max_messages`` messages from Pub/Sub subscription. :param project: the GCP project ID where the subscription exists :type project: str :param subscription: the Pub/Sub subscripti...
[ "Pulls", "up", "to", "max_messages", "messages", "from", "Pub", "/", "Sub", "subscription", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_pubsub_hook.py#L227-L261
[ "def", "pull", "(", "self", ",", "project", ",", "subscription", ",", "max_messages", ",", "return_immediately", "=", "False", ")", ":", "service", "=", "self", ".", "get_conn", "(", ")", "full_subscription", "=", "_format_subscription", "(", "project", ",", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
PubSubHook.acknowledge
Pulls up to ``max_messages`` messages from Pub/Sub subscription. :param project: the GCP project name or ID in which to create the topic :type project: str :param subscription: the Pub/Sub subscription name to delete; do not include the 'projects/{project}/topics/' prefi...
airflow/contrib/hooks/gcp_pubsub_hook.py
def acknowledge(self, project, subscription, ack_ids): """Pulls up to ``max_messages`` messages from Pub/Sub subscription. :param project: the GCP project name or ID in which to create the topic :type project: str :param subscription: the Pub/Sub subscription name to delete;...
def acknowledge(self, project, subscription, ack_ids): """Pulls up to ``max_messages`` messages from Pub/Sub subscription. :param project: the GCP project name or ID in which to create the topic :type project: str :param subscription: the Pub/Sub subscription name to delete;...
[ "Pulls", "up", "to", "max_messages", "messages", "from", "Pub", "/", "Sub", "subscription", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_pubsub_hook.py#L263-L285
[ "def", "acknowledge", "(", "self", ",", "project", ",", "subscription", ",", "ack_ids", ")", ":", "service", "=", "self", ".", "get_conn", "(", ")", "full_subscription", "=", "_format_subscription", "(", "project", ",", "subscription", ")", "try", ":", "serv...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
BaseTIDep.get_dep_statuses
Wrapper around the private _get_dep_statuses method that contains some global checks for all dependencies. :param ti: the task instance to get the dependency status for :type ti: airflow.models.TaskInstance :param session: database session :type session: sqlalchemy.orm.session.S...
airflow/ti_deps/deps/base_ti_dep.py
def get_dep_statuses(self, ti, session, dep_context=None): """ Wrapper around the private _get_dep_statuses method that contains some global checks for all dependencies. :param ti: the task instance to get the dependency status for :type ti: airflow.models.TaskInstance :...
def get_dep_statuses(self, ti, session, dep_context=None): """ Wrapper around the private _get_dep_statuses method that contains some global checks for all dependencies. :param ti: the task instance to get the dependency status for :type ti: airflow.models.TaskInstance :...
[ "Wrapper", "around", "the", "private", "_get_dep_statuses", "method", "that", "contains", "some", "global", "checks", "for", "all", "dependencies", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/ti_deps/deps/base_ti_dep.py#L78-L107
[ "def", "get_dep_statuses", "(", "self", ",", "ti", ",", "session", ",", "dep_context", "=", "None", ")", ":", "# this avoids a circular dependency", "from", "airflow", ".", "ti_deps", ".", "dep_context", "import", "DepContext", "if", "dep_context", "is", "None", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
BaseTIDep.is_met
Returns whether or not this dependency is met for a given task instance. A dependency is considered met if all of the dependency statuses it reports are passing. :param ti: the task instance to see if this dependency is met for :type ti: airflow.models.TaskInstance :param sessio...
airflow/ti_deps/deps/base_ti_dep.py
def is_met(self, ti, session, dep_context=None): """ Returns whether or not this dependency is met for a given task instance. A dependency is considered met if all of the dependency statuses it reports are passing. :param ti: the task instance to see if this dependency is met fo...
def is_met(self, ti, session, dep_context=None): """ Returns whether or not this dependency is met for a given task instance. A dependency is considered met if all of the dependency statuses it reports are passing. :param ti: the task instance to see if this dependency is met fo...
[ "Returns", "whether", "or", "not", "this", "dependency", "is", "met", "for", "a", "given", "task", "instance", ".", "A", "dependency", "is", "considered", "met", "if", "all", "of", "the", "dependency", "statuses", "it", "reports", "are", "passing", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/ti_deps/deps/base_ti_dep.py#L110-L125
[ "def", "is_met", "(", "self", ",", "ti", ",", "session", ",", "dep_context", "=", "None", ")", ":", "return", "all", "(", "status", ".", "passed", "for", "status", "in", "self", ".", "get_dep_statuses", "(", "ti", ",", "session", ",", "dep_context", ")...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
BaseTIDep.get_failure_reasons
Returns an iterable of strings that explain why this dependency wasn't met. :param ti: the task instance to see if this dependency is met for :type ti: airflow.models.TaskInstance :param session: database session :type session: sqlalchemy.orm.session.Session :param dep_context: ...
airflow/ti_deps/deps/base_ti_dep.py
def get_failure_reasons(self, ti, session, dep_context=None): """ Returns an iterable of strings that explain why this dependency wasn't met. :param ti: the task instance to see if this dependency is met for :type ti: airflow.models.TaskInstance :param session: database session ...
def get_failure_reasons(self, ti, session, dep_context=None): """ Returns an iterable of strings that explain why this dependency wasn't met. :param ti: the task instance to see if this dependency is met for :type ti: airflow.models.TaskInstance :param session: database session ...
[ "Returns", "an", "iterable", "of", "strings", "that", "explain", "why", "this", "dependency", "wasn", "t", "met", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/ti_deps/deps/base_ti_dep.py#L128-L142
[ "def", "get_failure_reasons", "(", "self", ",", "ti", ",", "session", ",", "dep_context", "=", "None", ")", ":", "for", "dep_status", "in", "self", ".", "get_dep_statuses", "(", "ti", ",", "session", ",", "dep_context", ")", ":", "if", "not", "dep_status",...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
_parse_s3_config
Parses a config file for s3 credentials. Can currently parse boto, s3cmd.conf and AWS SDK config formats :param config_file_name: path to the config file :type config_file_name: str :param config_format: config type. One of "boto", "s3cmd" or "aws". Defaults to "boto" :type config_format: s...
airflow/contrib/hooks/aws_hook.py
def _parse_s3_config(config_file_name, config_format='boto', profile=None): """ Parses a config file for s3 credentials. Can currently parse boto, s3cmd.conf and AWS SDK config formats :param config_file_name: path to the config file :type config_file_name: str :param config_format: config type...
def _parse_s3_config(config_file_name, config_format='boto', profile=None): """ Parses a config file for s3 credentials. Can currently parse boto, s3cmd.conf and AWS SDK config formats :param config_file_name: path to the config file :type config_file_name: str :param config_format: config type...
[ "Parses", "a", "config", "file", "for", "s3", "credentials", ".", "Can", "currently", "parse", "boto", "s3cmd", ".", "conf", "and", "AWS", "SDK", "config", "formats" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/aws_hook.py#L28-L77
[ "def", "_parse_s3_config", "(", "config_file_name", ",", "config_format", "=", "'boto'", ",", "profile", "=", "None", ")", ":", "config", "=", "configparser", ".", "ConfigParser", "(", ")", "if", "config", ".", "read", "(", "config_file_name", ")", ":", "# p...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AwsHook.get_credentials
Get the underlying `botocore.Credentials` object. This contains the following authentication attributes: access_key, secret_key and token.
airflow/contrib/hooks/aws_hook.py
def get_credentials(self, region_name=None): """Get the underlying `botocore.Credentials` object. This contains the following authentication attributes: access_key, secret_key and token. """ session, _ = self._get_credentials(region_name) # Credentials are refreshable, so access...
def get_credentials(self, region_name=None): """Get the underlying `botocore.Credentials` object. This contains the following authentication attributes: access_key, secret_key and token. """ session, _ = self._get_credentials(region_name) # Credentials are refreshable, so access...
[ "Get", "the", "underlying", "botocore", ".", "Credentials", "object", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/aws_hook.py#L183-L192
[ "def", "get_credentials", "(", "self", ",", "region_name", "=", "None", ")", ":", "session", ",", "_", "=", "self", ".", "_get_credentials", "(", "region_name", ")", "# Credentials are refreshable, so accessing your access key and", "# secret key separately can lead to a ra...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
AwsHook.expand_role
If the IAM role is a role name, get the Amazon Resource Name (ARN) for the role. If IAM role is already an IAM role ARN, no change is made. :param role: IAM role name or ARN :return: IAM role ARN
airflow/contrib/hooks/aws_hook.py
def expand_role(self, role): """ If the IAM role is a role name, get the Amazon Resource Name (ARN) for the role. If IAM role is already an IAM role ARN, no change is made. :param role: IAM role name or ARN :return: IAM role ARN """ if '/' in role: re...
def expand_role(self, role): """ If the IAM role is a role name, get the Amazon Resource Name (ARN) for the role. If IAM role is already an IAM role ARN, no change is made. :param role: IAM role name or ARN :return: IAM role ARN """ if '/' in role: re...
[ "If", "the", "IAM", "role", "is", "a", "role", "name", "get", "the", "Amazon", "Resource", "Name", "(", "ARN", ")", "for", "the", "role", ".", "If", "IAM", "role", "is", "already", "an", "IAM", "role", "ARN", "no", "change", "is", "made", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/aws_hook.py#L194-L205
[ "def", "expand_role", "(", "self", ",", "role", ")", ":", "if", "'/'", "in", "role", ":", "return", "role", "else", ":", "return", "self", ".", "get_client_type", "(", "'iam'", ")", ".", "get_role", "(", "RoleName", "=", "role", ")", "[", "'Role'", "...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
VerticaHook.get_conn
Returns verticaql connection object
airflow/contrib/hooks/vertica_hook.py
def get_conn(self): """ Returns verticaql connection object """ conn = self.get_connection(self.vertica_conn_id) conn_config = { "user": conn.login, "password": conn.password or '', "database": conn.schema, "host": conn.host or 'loc...
def get_conn(self): """ Returns verticaql connection object """ conn = self.get_connection(self.vertica_conn_id) conn_config = { "user": conn.login, "password": conn.password or '', "database": conn.schema, "host": conn.host or 'loc...
[ "Returns", "verticaql", "connection", "object" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/vertica_hook.py#L35-L53
[ "def", "get_conn", "(", "self", ")", ":", "conn", "=", "self", ".", "get_connection", "(", "self", ".", "vertica_conn_id", ")", "conn_config", "=", "{", "\"user\"", ":", "conn", ".", "login", ",", "\"password\"", ":", "conn", ".", "password", "or", "''",...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
set_context
Walks the tree of loggers and tries to set the context for each handler :param logger: logger :param value: value to set
airflow/utils/log/logging_mixin.py
def set_context(logger, value): """ Walks the tree of loggers and tries to set the context for each handler :param logger: logger :param value: value to set """ _logger = logger while _logger: for handler in _logger.handlers: try: handler.set_context(value...
def set_context(logger, value): """ Walks the tree of loggers and tries to set the context for each handler :param logger: logger :param value: value to set """ _logger = logger while _logger: for handler in _logger.handlers: try: handler.set_context(value...
[ "Walks", "the", "tree", "of", "loggers", "and", "tries", "to", "set", "the", "context", "for", "each", "handler", ":", "param", "logger", ":", "logger", ":", "param", "value", ":", "value", "to", "set" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/log/logging_mixin.py#L166-L184
[ "def", "set_context", "(", "logger", ",", "value", ")", ":", "_logger", "=", "logger", "while", "_logger", ":", "for", "handler", "in", "_logger", ".", "handlers", ":", "try", ":", "handler", ".", "set_context", "(", "value", ")", "except", "AttributeError...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
StreamLogWriter.write
Do whatever it takes to actually log the specified logging record :param message: message to log
airflow/utils/log/logging_mixin.py
def write(self, message): """ Do whatever it takes to actually log the specified logging record :param message: message to log """ if not message.endswith("\n"): self._buffer += message else: self._buffer += message self.logger.log(self...
def write(self, message): """ Do whatever it takes to actually log the specified logging record :param message: message to log """ if not message.endswith("\n"): self._buffer += message else: self._buffer += message self.logger.log(self...
[ "Do", "whatever", "it", "takes", "to", "actually", "log", "the", "specified", "logging", "record", ":", "param", "message", ":", "message", "to", "log" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/log/logging_mixin.py#L92-L102
[ "def", "write", "(", "self", ",", "message", ")", ":", "if", "not", "message", ".", "endswith", "(", "\"\\n\"", ")", ":", "self", ".", "_buffer", "+=", "message", "else", ":", "self", ".", "_buffer", "+=", "message", "self", ".", "logger", ".", "log"...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
StreamLogWriter.flush
Ensure all logging output has been flushed
airflow/utils/log/logging_mixin.py
def flush(self): """ Ensure all logging output has been flushed """ if len(self._buffer) > 0: self.logger.log(self.level, self._buffer) self._buffer = str()
def flush(self): """ Ensure all logging output has been flushed """ if len(self._buffer) > 0: self.logger.log(self.level, self._buffer) self._buffer = str()
[ "Ensure", "all", "logging", "output", "has", "been", "flushed" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/log/logging_mixin.py#L104-L110
[ "def", "flush", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_buffer", ")", ">", "0", ":", "self", ".", "logger", ".", "log", "(", "self", ".", "level", ",", "self", ".", "_buffer", ")", "self", ".", "_buffer", "=", "str", "(", ")" ]
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
correct_maybe_zipped
If the path contains a folder with a .zip suffix, then the folder is treated as a zip archive and path to zip is returned.
airflow/utils/dag_processing.py
def correct_maybe_zipped(fileloc): """ If the path contains a folder with a .zip suffix, then the folder is treated as a zip archive and path to zip is returned. """ _, archive, filename = re.search( r'((.*\.zip){})?(.*)'.format(re.escape(os.sep)), fileloc).groups() if archive and zipfi...
def correct_maybe_zipped(fileloc): """ If the path contains a folder with a .zip suffix, then the folder is treated as a zip archive and path to zip is returned. """ _, archive, filename = re.search( r'((.*\.zip){})?(.*)'.format(re.escape(os.sep)), fileloc).groups() if archive and zipfi...
[ "If", "the", "path", "contains", "a", "folder", "with", "a", ".", "zip", "suffix", "then", "the", "folder", "is", "treated", "as", "a", "zip", "archive", "and", "path", "to", "zip", "is", "returned", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L275-L286
[ "def", "correct_maybe_zipped", "(", "fileloc", ")", ":", "_", ",", "archive", ",", "filename", "=", "re", ".", "search", "(", "r'((.*\\.zip){})?(.*)'", ".", "format", "(", "re", ".", "escape", "(", "os", ".", "sep", ")", ")", ",", "fileloc", ")", ".", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
list_py_file_paths
Traverse a directory and look for Python files. :param directory: the directory to traverse :type directory: unicode :param safe_mode: whether to use a heuristic to determine whether a file contains Airflow DAG definitions :return: a list of paths to Python files in the specified directory ...
airflow/utils/dag_processing.py
def list_py_file_paths(directory, safe_mode=True, include_examples=None): """ Traverse a directory and look for Python files. :param directory: the directory to traverse :type directory: unicode :param safe_mode: whether to use a heuristic to determine whether a file ...
def list_py_file_paths(directory, safe_mode=True, include_examples=None): """ Traverse a directory and look for Python files. :param directory: the directory to traverse :type directory: unicode :param safe_mode: whether to use a heuristic to determine whether a file ...
[ "Traverse", "a", "directory", "and", "look", "for", "Python", "files", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L289-L365
[ "def", "list_py_file_paths", "(", "directory", ",", "safe_mode", "=", "True", ",", "include_examples", "=", "None", ")", ":", "if", "include_examples", "is", "None", ":", "include_examples", "=", "conf", ".", "getboolean", "(", "'core'", ",", "'LOAD_EXAMPLES'", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SimpleTaskInstance.construct_task_instance
Construct a TaskInstance from the database based on the primary key :param session: DB session. :param lock_for_update: if True, indicates that the database should lock the TaskInstance (issuing a FOR UPDATE clause) until the session is committed.
airflow/utils/dag_processing.py
def construct_task_instance(self, session=None, lock_for_update=False): """ Construct a TaskInstance from the database based on the primary key :param session: DB session. :param lock_for_update: if True, indicates that the database should lock the TaskInstance (issuing a FO...
def construct_task_instance(self, session=None, lock_for_update=False): """ Construct a TaskInstance from the database based on the primary key :param session: DB session. :param lock_for_update: if True, indicates that the database should lock the TaskInstance (issuing a FO...
[ "Construct", "a", "TaskInstance", "from", "the", "database", "based", "on", "the", "primary", "key" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L213-L233
[ "def", "construct_task_instance", "(", "self", ",", "session", "=", "None", ",", "lock_for_update", "=", "False", ")", ":", "TI", "=", "airflow", ".", "models", ".", "TaskInstance", "qry", "=", "session", ".", "query", "(", "TI", ")", ".", "filter", "(",...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
SimpleDagBag.get_dag
:param dag_id: DAG ID :type dag_id: unicode :return: if the given DAG ID exists in the bag, return the BaseDag corresponding to that ID. Otherwise, throw an Exception :rtype: airflow.utils.dag_processing.SimpleDag
airflow/utils/dag_processing.py
def get_dag(self, dag_id): """ :param dag_id: DAG ID :type dag_id: unicode :return: if the given DAG ID exists in the bag, return the BaseDag corresponding to that ID. Otherwise, throw an Exception :rtype: airflow.utils.dag_processing.SimpleDag """ if dag_...
def get_dag(self, dag_id): """ :param dag_id: DAG ID :type dag_id: unicode :return: if the given DAG ID exists in the bag, return the BaseDag corresponding to that ID. Otherwise, throw an Exception :rtype: airflow.utils.dag_processing.SimpleDag """ if dag_...
[ ":", "param", "dag_id", ":", "DAG", "ID", ":", "type", "dag_id", ":", "unicode", ":", "return", ":", "if", "the", "given", "DAG", "ID", "exists", "in", "the", "bag", "return", "the", "BaseDag", "corresponding", "to", "that", "ID", ".", "Otherwise", "th...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L262-L272
[ "def", "get_dag", "(", "self", ",", "dag_id", ")", ":", "if", "dag_id", "not", "in", "self", ".", "dag_id_to_simple_dag", ":", "raise", "AirflowException", "(", "\"Unknown DAG ID {}\"", ".", "format", "(", "dag_id", ")", ")", "return", "self", ".", "dag_id_t...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorAgent.start
Launch DagFileProcessorManager processor and start DAG parsing loop in manager.
airflow/utils/dag_processing.py
def start(self): """ Launch DagFileProcessorManager processor and start DAG parsing loop in manager. """ self._process = self._launch_process(self._dag_directory, self._file_paths, self._max_runs, ...
def start(self): """ Launch DagFileProcessorManager processor and start DAG parsing loop in manager. """ self._process = self._launch_process(self._dag_directory, self._file_paths, self._max_runs, ...
[ "Launch", "DagFileProcessorManager", "processor", "and", "start", "DAG", "parsing", "loop", "in", "manager", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L512-L524
[ "def", "start", "(", "self", ")", ":", "self", ".", "_process", "=", "self", ".", "_launch_process", "(", "self", ".", "_dag_directory", ",", "self", ".", "_file_paths", ",", "self", ".", "_max_runs", ",", "self", ".", "_processor_factory", ",", "self", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorAgent.harvest_simple_dags
Harvest DAG parsing results from result queue and sync metadata from stat queue. :return: List of parsing result in SimpleDag format.
airflow/utils/dag_processing.py
def harvest_simple_dags(self): """ Harvest DAG parsing results from result queue and sync metadata from stat queue. :return: List of parsing result in SimpleDag format. """ # Metadata and results to be harvested can be inconsistent, # but it should not be a big problem. ...
def harvest_simple_dags(self): """ Harvest DAG parsing results from result queue and sync metadata from stat queue. :return: List of parsing result in SimpleDag format. """ # Metadata and results to be harvested can be inconsistent, # but it should not be a big problem. ...
[ "Harvest", "DAG", "parsing", "results", "from", "result", "queue", "and", "sync", "metadata", "from", "stat", "queue", ".", ":", "return", ":", "List", "of", "parsing", "result", "in", "SimpleDag", "format", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L580-L602
[ "def", "harvest_simple_dags", "(", "self", ")", ":", "# Metadata and results to be harvested can be inconsistent,", "# but it should not be a big problem.", "self", ".", "_sync_metadata", "(", ")", "# Heartbeating after syncing metadata so we do not restart manager", "# if it processed a...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorAgent._heartbeat_manager
Heartbeat DAG file processor and start it if it is not alive. :return:
airflow/utils/dag_processing.py
def _heartbeat_manager(self): """ Heartbeat DAG file processor and start it if it is not alive. :return: """ if self._process and not self._process.is_alive() and not self.done: self.start()
def _heartbeat_manager(self): """ Heartbeat DAG file processor and start it if it is not alive. :return: """ if self._process and not self._process.is_alive() and not self.done: self.start()
[ "Heartbeat", "DAG", "file", "processor", "and", "start", "it", "if", "it", "is", "not", "alive", ".", ":", "return", ":" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L604-L610
[ "def", "_heartbeat_manager", "(", "self", ")", ":", "if", "self", ".", "_process", "and", "not", "self", ".", "_process", ".", "is_alive", "(", ")", "and", "not", "self", ".", "done", ":", "self", ".", "start", "(", ")" ]
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorAgent._sync_metadata
Sync metadata from stat queue and only keep the latest stat. :return:
airflow/utils/dag_processing.py
def _sync_metadata(self): """ Sync metadata from stat queue and only keep the latest stat. :return: """ while not self._stat_queue.empty(): stat = self._stat_queue.get() self._file_paths = stat.file_paths self._all_pids = stat.all_pids ...
def _sync_metadata(self): """ Sync metadata from stat queue and only keep the latest stat. :return: """ while not self._stat_queue.empty(): stat = self._stat_queue.get() self._file_paths = stat.file_paths self._all_pids = stat.all_pids ...
[ "Sync", "metadata", "from", "stat", "queue", "and", "only", "keep", "the", "latest", "stat", ".", ":", "return", ":" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L612-L623
[ "def", "_sync_metadata", "(", "self", ")", ":", "while", "not", "self", ".", "_stat_queue", ".", "empty", "(", ")", ":", "stat", "=", "self", ".", "_stat_queue", ".", "get", "(", ")", "self", ".", "_file_paths", "=", "stat", ".", "file_paths", "self", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorAgent.terminate
Send termination signal to DAG parsing processor manager and expect it to terminate all DAG file processors.
airflow/utils/dag_processing.py
def terminate(self): """ Send termination signal to DAG parsing processor manager and expect it to terminate all DAG file processors. """ self.log.info("Sending termination message to manager.") self._child_signal_conn.send(DagParsingSignal.TERMINATE_MANAGER)
def terminate(self): """ Send termination signal to DAG parsing processor manager and expect it to terminate all DAG file processors. """ self.log.info("Sending termination message to manager.") self._child_signal_conn.send(DagParsingSignal.TERMINATE_MANAGER)
[ "Send", "termination", "signal", "to", "DAG", "parsing", "processor", "manager", "and", "expect", "it", "to", "terminate", "all", "DAG", "file", "processors", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L637-L643
[ "def", "terminate", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "\"Sending termination message to manager.\"", ")", "self", ".", "_child_signal_conn", ".", "send", "(", "DagParsingSignal", ".", "TERMINATE_MANAGER", ")" ]
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorAgent.end
Terminate (and then kill) the manager process launched. :return:
airflow/utils/dag_processing.py
def end(self): """ Terminate (and then kill) the manager process launched. :return: """ if not self._process: self.log.warn('Ending without manager process.') return this_process = psutil.Process(os.getpid()) try: manager_proces...
def end(self): """ Terminate (and then kill) the manager process launched. :return: """ if not self._process: self.log.warn('Ending without manager process.') return this_process = psutil.Process(os.getpid()) try: manager_proces...
[ "Terminate", "(", "and", "then", "kill", ")", "the", "manager", "process", "launched", ".", ":", "return", ":" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L645-L679
[ "def", "end", "(", "self", ")", ":", "if", "not", "self", ".", "_process", ":", "self", ".", "log", ".", "warn", "(", "'Ending without manager process.'", ")", "return", "this_process", "=", "psutil", ".", "Process", "(", "os", ".", "getpid", "(", ")", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorManager._exit_gracefully
Helper method to clean up DAG file processors to avoid leaving orphan processes.
airflow/utils/dag_processing.py
def _exit_gracefully(self, signum, frame): """ Helper method to clean up DAG file processors to avoid leaving orphan processes. """ self.log.info("Exiting gracefully upon receiving signal %s", signum) self.terminate() self.end() self.log.debug("Finished terminatin...
def _exit_gracefully(self, signum, frame): """ Helper method to clean up DAG file processors to avoid leaving orphan processes. """ self.log.info("Exiting gracefully upon receiving signal %s", signum) self.terminate() self.end() self.log.debug("Finished terminatin...
[ "Helper", "method", "to", "clean", "up", "DAG", "file", "processors", "to", "avoid", "leaving", "orphan", "processes", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L779-L787
[ "def", "_exit_gracefully", "(", "self", ",", "signum", ",", "frame", ")", ":", "self", ".", "log", ".", "info", "(", "\"Exiting gracefully upon receiving signal %s\"", ",", "signum", ")", "self", ".", "terminate", "(", ")", "self", ".", "end", "(", ")", "s...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorManager.start
Use multiple processes to parse and generate tasks for the DAGs in parallel. By processing them in separate processes, we can get parallelism and isolation from potentially harmful user code.
airflow/utils/dag_processing.py
def start(self): """ Use multiple processes to parse and generate tasks for the DAGs in parallel. By processing them in separate processes, we can get parallelism and isolation from potentially harmful user code. """ self.log.info("Processing files using up to %s...
def start(self): """ Use multiple processes to parse and generate tasks for the DAGs in parallel. By processing them in separate processes, we can get parallelism and isolation from potentially harmful user code. """ self.log.info("Processing files using up to %s...
[ "Use", "multiple", "processes", "to", "parse", "and", "generate", "tasks", "for", "the", "DAGs", "in", "parallel", ".", "By", "processing", "them", "in", "separate", "processes", "we", "can", "get", "parallelism", "and", "isolation", "from", "potentially", "ha...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L789-L808
[ "def", "start", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "\"Processing files using up to %s processes at a time \"", ",", "self", ".", "_parallelism", ")", "self", ".", "log", ".", "info", "(", "\"Process each file at most once every %s seconds\"",...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorManager.start_in_async
Parse DAG files repeatedly in a standalone loop.
airflow/utils/dag_processing.py
def start_in_async(self): """ Parse DAG files repeatedly in a standalone loop. """ while True: loop_start_time = time.time() if self._signal_conn.poll(): agent_signal = self._signal_conn.recv() if agent_signal == DagParsingSignal.T...
def start_in_async(self): """ Parse DAG files repeatedly in a standalone loop. """ while True: loop_start_time = time.time() if self._signal_conn.poll(): agent_signal = self._signal_conn.recv() if agent_signal == DagParsingSignal.T...
[ "Parse", "DAG", "files", "repeatedly", "in", "a", "standalone", "loop", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L810-L854
[ "def", "start_in_async", "(", "self", ")", ":", "while", "True", ":", "loop_start_time", "=", "time", ".", "time", "(", ")", "if", "self", ".", "_signal_conn", ".", "poll", "(", ")", ":", "agent_signal", "=", "self", ".", "_signal_conn", ".", "recv", "...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorManager.start_in_sync
Parse DAG files in a loop controlled by DagParsingSignal. Actual DAG parsing loop will run once upon receiving one agent heartbeat message and will report done when finished the loop.
airflow/utils/dag_processing.py
def start_in_sync(self): """ Parse DAG files in a loop controlled by DagParsingSignal. Actual DAG parsing loop will run once upon receiving one agent heartbeat message and will report done when finished the loop. """ while True: agent_signal = self._signal_con...
def start_in_sync(self): """ Parse DAG files in a loop controlled by DagParsingSignal. Actual DAG parsing loop will run once upon receiving one agent heartbeat message and will report done when finished the loop. """ while True: agent_signal = self._signal_con...
[ "Parse", "DAG", "files", "in", "a", "loop", "controlled", "by", "DagParsingSignal", ".", "Actual", "DAG", "parsing", "loop", "will", "run", "once", "upon", "receiving", "one", "agent", "heartbeat", "message", "and", "will", "report", "done", "when", "finished"...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L856-L898
[ "def", "start_in_sync", "(", "self", ")", ":", "while", "True", ":", "agent_signal", "=", "self", ".", "_signal_conn", ".", "recv", "(", ")", "if", "agent_signal", "==", "DagParsingSignal", ".", "TERMINATE_MANAGER", ":", "self", ".", "terminate", "(", ")", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorManager._refresh_dag_dir
Refresh file paths from dag dir if we haven't done it for too long.
airflow/utils/dag_processing.py
def _refresh_dag_dir(self): """ Refresh file paths from dag dir if we haven't done it for too long. """ elapsed_time_since_refresh = (timezone.utcnow() - self.last_dag_dir_refresh_time).total_seconds() if elapsed_time_since_refresh > self.dag...
def _refresh_dag_dir(self): """ Refresh file paths from dag dir if we haven't done it for too long. """ elapsed_time_since_refresh = (timezone.utcnow() - self.last_dag_dir_refresh_time).total_seconds() if elapsed_time_since_refresh > self.dag...
[ "Refresh", "file", "paths", "from", "dag", "dir", "if", "we", "haven", "t", "done", "it", "for", "too", "long", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L900-L918
[ "def", "_refresh_dag_dir", "(", "self", ")", ":", "elapsed_time_since_refresh", "=", "(", "timezone", ".", "utcnow", "(", ")", "-", "self", ".", "last_dag_dir_refresh_time", ")", ".", "total_seconds", "(", ")", "if", "elapsed_time_since_refresh", ">", "self", "....
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorManager._print_stat
Occasionally print out stats about how fast the files are getting processed
airflow/utils/dag_processing.py
def _print_stat(self): """ Occasionally print out stats about how fast the files are getting processed """ if ((timezone.utcnow() - self.last_stat_print_time).total_seconds() > self.print_stats_interval): if len(self._file_paths) > 0: self._log...
def _print_stat(self): """ Occasionally print out stats about how fast the files are getting processed """ if ((timezone.utcnow() - self.last_stat_print_time).total_seconds() > self.print_stats_interval): if len(self._file_paths) > 0: self._log...
[ "Occasionally", "print", "out", "stats", "about", "how", "fast", "the", "files", "are", "getting", "processed" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L920-L928
[ "def", "_print_stat", "(", "self", ")", ":", "if", "(", "(", "timezone", ".", "utcnow", "(", ")", "-", "self", ".", "last_stat_print_time", ")", ".", "total_seconds", "(", ")", ">", "self", ".", "print_stats_interval", ")", ":", "if", "len", "(", "self...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorManager.clear_nonexistent_import_errors
Clears import errors for files that no longer exist. :param session: session for ORM operations :type session: sqlalchemy.orm.session.Session
airflow/utils/dag_processing.py
def clear_nonexistent_import_errors(self, session): """ Clears import errors for files that no longer exist. :param session: session for ORM operations :type session: sqlalchemy.orm.session.Session """ query = session.query(errors.ImportError) if self._file_paths...
def clear_nonexistent_import_errors(self, session): """ Clears import errors for files that no longer exist. :param session: session for ORM operations :type session: sqlalchemy.orm.session.Session """ query = session.query(errors.ImportError) if self._file_paths...
[ "Clears", "import", "errors", "for", "files", "that", "no", "longer", "exist", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L931-L944
[ "def", "clear_nonexistent_import_errors", "(", "self", ",", "session", ")", ":", "query", "=", "session", ".", "query", "(", "errors", ".", "ImportError", ")", "if", "self", ".", "_file_paths", ":", "query", "=", "query", ".", "filter", "(", "~", "errors",...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorManager._log_file_processing_stats
Print out stats about how files are getting processed. :param known_file_paths: a list of file paths that may contain Airflow DAG definitions :type known_file_paths: list[unicode] :return: None
airflow/utils/dag_processing.py
def _log_file_processing_stats(self, known_file_paths): """ Print out stats about how files are getting processed. :param known_file_paths: a list of file paths that may contain Airflow DAG definitions :type known_file_paths: list[unicode] :return: None """ ...
def _log_file_processing_stats(self, known_file_paths): """ Print out stats about how files are getting processed. :param known_file_paths: a list of file paths that may contain Airflow DAG definitions :type known_file_paths: list[unicode] :return: None """ ...
[ "Print", "out", "stats", "about", "how", "files", "are", "getting", "processed", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L946-L1020
[ "def", "_log_file_processing_stats", "(", "self", ",", "known_file_paths", ")", ":", "# File Path: Path to the file containing the DAG definition", "# PID: PID associated with the process that's processing the file. May", "# be empty.", "# Runtime: If the process is currently running, how long...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorManager.get_pid
:param file_path: the path to the file that's being processed :type file_path: unicode :return: the PID of the process processing the given file or None if the specified file is not being processed :rtype: int
airflow/utils/dag_processing.py
def get_pid(self, file_path): """ :param file_path: the path to the file that's being processed :type file_path: unicode :return: the PID of the process processing the given file or None if the specified file is not being processed :rtype: int """ if f...
def get_pid(self, file_path): """ :param file_path: the path to the file that's being processed :type file_path: unicode :return: the PID of the process processing the given file or None if the specified file is not being processed :rtype: int """ if f...
[ ":", "param", "file_path", ":", "the", "path", "to", "the", "file", "that", "s", "being", "processed", ":", "type", "file_path", ":", "unicode", ":", "return", ":", "the", "PID", "of", "the", "process", "processing", "the", "given", "file", "or", "None",...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L1026-L1036
[ "def", "get_pid", "(", "self", ",", "file_path", ")", ":", "if", "file_path", "in", "self", ".", "_processors", ":", "return", "self", ".", "_processors", "[", "file_path", "]", ".", "pid", "return", "None" ]
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorManager.get_runtime
:param file_path: the path to the file that's being processed :type file_path: unicode :return: the current runtime (in seconds) of the process that's processing the specified file or None if the file is not currently being processed
airflow/utils/dag_processing.py
def get_runtime(self, file_path): """ :param file_path: the path to the file that's being processed :type file_path: unicode :return: the current runtime (in seconds) of the process that's processing the specified file or None if the file is not currently being pr...
def get_runtime(self, file_path): """ :param file_path: the path to the file that's being processed :type file_path: unicode :return: the current runtime (in seconds) of the process that's processing the specified file or None if the file is not currently being pr...
[ ":", "param", "file_path", ":", "the", "path", "to", "the", "file", "that", "s", "being", "processed", ":", "type", "file_path", ":", "unicode", ":", "return", ":", "the", "current", "runtime", "(", "in", "seconds", ")", "of", "the", "process", "that", ...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L1045-L1056
[ "def", "get_runtime", "(", "self", ",", "file_path", ")", ":", "if", "file_path", "in", "self", ".", "_processors", ":", "return", "(", "timezone", ".", "utcnow", "(", ")", "-", "self", ".", "_processors", "[", "file_path", "]", ".", "start_time", ")", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorManager.get_start_time
:param file_path: the path to the file that's being processed :type file_path: unicode :return: the start time of the process that's processing the specified file or None if the file is not currently being processed :rtype: datetime
airflow/utils/dag_processing.py
def get_start_time(self, file_path): """ :param file_path: the path to the file that's being processed :type file_path: unicode :return: the start time of the process that's processing the specified file or None if the file is not currently being processed :rtype: dat...
def get_start_time(self, file_path): """ :param file_path: the path to the file that's being processed :type file_path: unicode :return: the start time of the process that's processing the specified file or None if the file is not currently being processed :rtype: dat...
[ ":", "param", "file_path", ":", "the", "path", "to", "the", "file", "that", "s", "being", "processed", ":", "type", "file_path", ":", "unicode", ":", "return", ":", "the", "start", "time", "of", "the", "process", "that", "s", "processing", "the", "specif...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L1078-L1088
[ "def", "get_start_time", "(", "self", ",", "file_path", ")", ":", "if", "file_path", "in", "self", ".", "_processors", ":", "return", "self", ".", "_processors", "[", "file_path", "]", ".", "start_time", "return", "None" ]
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorManager.set_file_paths
Update this with a new set of paths to DAG definition files. :param new_file_paths: list of paths to DAG definition files :type new_file_paths: list[unicode] :return: None
airflow/utils/dag_processing.py
def set_file_paths(self, new_file_paths): """ Update this with a new set of paths to DAG definition files. :param new_file_paths: list of paths to DAG definition files :type new_file_paths: list[unicode] :return: None """ self._file_paths = new_file_paths ...
def set_file_paths(self, new_file_paths): """ Update this with a new set of paths to DAG definition files. :param new_file_paths: list of paths to DAG definition files :type new_file_paths: list[unicode] :return: None """ self._file_paths = new_file_paths ...
[ "Update", "this", "with", "a", "new", "set", "of", "paths", "to", "DAG", "definition", "files", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L1090-L1109
[ "def", "set_file_paths", "(", "self", ",", "new_file_paths", ")", ":", "self", ".", "_file_paths", "=", "new_file_paths", "self", ".", "_file_path_queue", "=", "[", "x", "for", "x", "in", "self", ".", "_file_path_queue", "if", "x", "in", "new_file_paths", "]...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorManager.wait_until_finished
Sleeps until all the processors are done.
airflow/utils/dag_processing.py
def wait_until_finished(self): """ Sleeps until all the processors are done. """ for file_path, processor in self._processors.items(): while not processor.done: time.sleep(0.1)
def wait_until_finished(self): """ Sleeps until all the processors are done. """ for file_path, processor in self._processors.items(): while not processor.done: time.sleep(0.1)
[ "Sleeps", "until", "all", "the", "processors", "are", "done", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L1118-L1124
[ "def", "wait_until_finished", "(", "self", ")", ":", "for", "file_path", ",", "processor", "in", "self", ".", "_processors", ".", "items", "(", ")", ":", "while", "not", "processor", ".", "done", ":", "time", ".", "sleep", "(", "0.1", ")" ]
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorManager.heartbeat
This should be periodically called by the manager loop. This method will kick off new processes to process DAG definition files and read the results from the finished processors. :return: a list of SimpleDags that were produced by processors that have finished since the last time th...
airflow/utils/dag_processing.py
def heartbeat(self): """ This should be periodically called by the manager loop. This method will kick off new processes to process DAG definition files and read the results from the finished processors. :return: a list of SimpleDags that were produced by processors that ...
def heartbeat(self): """ This should be periodically called by the manager loop. This method will kick off new processes to process DAG definition files and read the results from the finished processors. :return: a list of SimpleDags that were produced by processors that ...
[ "This", "should", "be", "periodically", "called", "by", "the", "manager", "loop", ".", "This", "method", "will", "kick", "off", "new", "processes", "to", "process", "DAG", "definition", "files", "and", "read", "the", "results", "from", "the", "finished", "pr...
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L1126-L1227
[ "def", "heartbeat", "(", "self", ")", ":", "finished_processors", "=", "{", "}", "\"\"\":type : dict[unicode, AbstractDagFileProcessor]\"\"\"", "running_processors", "=", "{", "}", "\"\"\":type : dict[unicode, AbstractDagFileProcessor]\"\"\"", "for", "file_path", ",", "processo...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorManager._find_zombies
Find zombie task instances, which are tasks haven't heartbeated for too long. :return: Zombie task instances in SimpleTaskInstance format.
airflow/utils/dag_processing.py
def _find_zombies(self, session): """ Find zombie task instances, which are tasks haven't heartbeated for too long. :return: Zombie task instances in SimpleTaskInstance format. """ now = timezone.utcnow() zombies = [] if (now - self._last_zombie_query_time).total_...
def _find_zombies(self, session): """ Find zombie task instances, which are tasks haven't heartbeated for too long. :return: Zombie task instances in SimpleTaskInstance format. """ now = timezone.utcnow() zombies = [] if (now - self._last_zombie_query_time).total_...
[ "Find", "zombie", "task", "instances", "which", "are", "tasks", "haven", "t", "heartbeated", "for", "too", "long", ".", ":", "return", ":", "Zombie", "task", "instances", "in", "SimpleTaskInstance", "format", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L1230-L1262
[ "def", "_find_zombies", "(", "self", ",", "session", ")", ":", "now", "=", "timezone", ".", "utcnow", "(", ")", "zombies", "=", "[", "]", "if", "(", "now", "-", "self", ".", "_last_zombie_query_time", ")", ".", "total_seconds", "(", ")", ">", "self", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorManager.max_runs_reached
:return: whether all file paths have been processed max_runs times
airflow/utils/dag_processing.py
def max_runs_reached(self): """ :return: whether all file paths have been processed max_runs times """ if self._max_runs == -1: # Unlimited runs. return False for file_path in self._file_paths: if self._run_count[file_path] < self._max_runs: ...
def max_runs_reached(self): """ :return: whether all file paths have been processed max_runs times """ if self._max_runs == -1: # Unlimited runs. return False for file_path in self._file_paths: if self._run_count[file_path] < self._max_runs: ...
[ ":", "return", ":", "whether", "all", "file", "paths", "have", "been", "processed", "max_runs", "times" ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L1264-L1275
[ "def", "max_runs_reached", "(", "self", ")", ":", "if", "self", ".", "_max_runs", "==", "-", "1", ":", "# Unlimited runs.", "return", "False", "for", "file_path", "in", "self", ".", "_file_paths", ":", "if", "self", ".", "_run_count", "[", "file_path", "]"...
b69c686ad8a0c89b9136bb4b31767257eb7b2597
test
DagFileProcessorManager.end
Kill all child processes on exit since we don't want to leave them as orphaned.
airflow/utils/dag_processing.py
def end(self): """ Kill all child processes on exit since we don't want to leave them as orphaned. """ pids_to_kill = self.get_all_pids() if len(pids_to_kill) > 0: # First try SIGTERM this_process = psutil.Process(os.getpid()) # Only ch...
def end(self): """ Kill all child processes on exit since we don't want to leave them as orphaned. """ pids_to_kill = self.get_all_pids() if len(pids_to_kill) > 0: # First try SIGTERM this_process = psutil.Process(os.getpid()) # Only ch...
[ "Kill", "all", "child", "processes", "on", "exit", "since", "we", "don", "t", "want", "to", "leave", "them", "as", "orphaned", "." ]
apache/airflow
python
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L1285-L1320
[ "def", "end", "(", "self", ")", ":", "pids_to_kill", "=", "self", ".", "get_all_pids", "(", ")", "if", "len", "(", "pids_to_kill", ")", ">", "0", ":", "# First try SIGTERM", "this_process", "=", "psutil", ".", "Process", "(", "os", ".", "getpid", "(", ...
b69c686ad8a0c89b9136bb4b31767257eb7b2597