_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q266200 | GCPTextToSpeechHook.synthesize_speech | test | def synthesize_speech(self, input_data, voice, audio_config, retry=None, timeout=None):
"""
Synthesizes text input
:param input_data: text input to be synthesized. See more:
https://googleapis.github.io/google-cloud-python/latest/texttospeech/gapic/v1/types.html#google.cloud.texttos... | python | {
"resource": ""
} |
q266201 | S3TaskHandler.close | test | def close(self):
"""
Close and upload local log file to remote storage S3.
"""
# When application exit, system shuts down all handlers by
# calling close method. Here we check if logger is already
# closed to prevent uploading the log to remote storage multiple
# ... | python | {
"resource": ""
} |
q266202 | WorkerConfiguration._get_init_containers | test | def _get_init_containers(self):
"""When using git to retrieve the DAGs, use the GitSync Init Container"""
# If we're using volume claims to mount the dags, no init container is needed
if self.kube_config.dags_volume_claim or \
self.kube_config.dags_volume_host or self.kube_config.dags... | python | {
"resource": ""
} |
q266203 | WorkerConfiguration._get_environment | test | def _get_environment(self):
"""Defines any necessary environment variables for the pod executor"""
env = {}
for env_var_name, env_var_val in six.iteritems(self.kube_config.kube_env_vars):
env[env_var_name] = env_var_val
env["AIRFLOW__CORE__EXECUTOR"] = "LocalExecutor"
... | python | {
"resource": ""
} |
q266204 | WorkerConfiguration._get_secrets | test | def _get_secrets(self):
"""Defines any necessary secrets for the pod executor"""
worker_secrets = []
for env_var_name, obj_key_pair in six.iteritems(self.kube_config.kube_secrets):
k8s_secret_obj, k8s_secret_key = obj_key_pair.split('=')
worker_secrets.append(
... | python | {
"resource": ""
} |
q266205 | WorkerConfiguration._get_security_context | test | def _get_security_context(self):
"""Defines the security context"""
security_context = {}
if self.kube_config.worker_run_as_user:
security_context['runAsUser'] = self.kube_config.worker_run_as_user
if self.kube_config.worker_fs_group:
security_context['fsGroup']... | python | {
"resource": ""
} |
q266206 | QuboleHook.get_extra_links | test | def get_extra_links(self, operator, dttm):
"""
Get link to qubole command result page.
:param operator: operator
:param dttm: datetime
:return: url link
"""
conn = BaseHook.get_connection(operator.kwargs['qubole_conn_id'])
if conn and conn.host:
... | python | {
"resource": ""
} |
q266207 | BaseJob.heartbeat | test | def heartbeat(self):
"""
Heartbeats update the job's entry in the database with a timestamp
for the latest_heartbeat and allows for the job to be killed
externally. This allows at the system level to monitor what is
actually active.
For instance, an old heartbeat for Sch... | python | {
"resource": ""
} |
q266208 | DagFileProcessor._launch_process | test | def _launch_process(result_queue,
file_path,
pickle_dags,
dag_id_white_list,
thread_name,
zombies):
"""
Launch a process to process the given file.
:param result_queue: the qu... | python | {
"resource": ""
} |
q266209 | DagFileProcessor.start | test | def start(self):
"""
Launch the process and start processing the DAG.
"""
self._process = DagFileProcessor._launch_process(
self._result_queue,
self.file_path,
self._pickle_dags,
self._dag_id_white_list,
"DagFileProcessor{}".for... | python | {
"resource": ""
} |
q266210 | DagFileProcessor.done | test | def done(self):
"""
Check if the process launched to process this file is done.
:return: whether the process is finished running
:rtype: bool
"""
if self._process is None:
raise AirflowException("Tried to see if it's done before starting!")
if self._... | python | {
"resource": ""
} |
q266211 | SchedulerJob._exit_gracefully | test | def _exit_gracefully(self, signum, frame):
"""
Helper method to clean up processor_agent to avoid leaving orphan processes.
"""
self.log.info("Exiting gracefully upon receiving signal %s", signum)
if self.processor_agent:
self.processor_agent.end()
sys.exit(os... | python | {
"resource": ""
} |
q266212 | SchedulerJob.update_import_errors | test | def update_import_errors(session, dagbag):
"""
For the DAGs in the given DagBag, record any associated import errors and clears
errors for files that no longer have them. These are usually displayed through the
Airflow UI so that users know that there are issues parsing DAGs.
:p... | python | {
"resource": ""
} |
q266213 | SchedulerJob._process_task_instances | test | def _process_task_instances(self, dag, queue, session=None):
"""
This method schedules the tasks for a single DAG by looking at the
active DAG runs and adding task instances that should run to the
queue.
"""
# update the state of the previously active dag runs
da... | python | {
"resource": ""
} |
q266214 | SchedulerJob._change_state_for_tis_without_dagrun | test | def _change_state_for_tis_without_dagrun(self,
simple_dag_bag,
old_states,
new_state,
session=None):
"""
For all DAG IDs in ... | python | {
"resource": ""
} |
q266215 | SchedulerJob.__get_concurrency_maps | test | def __get_concurrency_maps(self, states, session=None):
"""
Get the concurrency maps.
:param states: List of states to query for
:type states: list[airflow.utils.state.State]
:return: A map from (dag_id, task_id) to # of task instances and
a map from (dag_id, task_id) t... | python | {
"resource": ""
} |
q266216 | SchedulerJob._change_state_for_executable_task_instances | test | def _change_state_for_executable_task_instances(self, task_instances,
acceptable_states, session=None):
"""
Changes the state of task instances in the list with one of the given states
to QUEUED atomically, and returns the TIs changed in Simple... | python | {
"resource": ""
} |
q266217 | SchedulerJob._enqueue_task_instances_with_queued_state | test | def _enqueue_task_instances_with_queued_state(self, simple_dag_bag,
simple_task_instances):
"""
Takes task_instances, which should have been set to queued, and enqueues them
with the executor.
:param simple_task_instances: TaskInstances ... | python | {
"resource": ""
} |
q266218 | SchedulerJob._execute_task_instances | test | def _execute_task_instances(self,
simple_dag_bag,
states,
session=None):
"""
Attempts to execute TaskInstances that should be executed by the scheduler.
There are three steps:
1. Pick TIs by ... | python | {
"resource": ""
} |
q266219 | SchedulerJob._change_state_for_tasks_failed_to_execute | test | def _change_state_for_tasks_failed_to_execute(self, session):
"""
If there are tasks left over in the executor,
we set them back to SCHEDULED to avoid creating hanging tasks.
:param session: session for ORM operations
"""
if self.executor.queued_tasks:
TI = m... | python | {
"resource": ""
} |
q266220 | SchedulerJob._process_executor_events | test | def _process_executor_events(self, simple_dag_bag, session=None):
"""
Respond to executor events.
"""
# TODO: this shares quite a lot of code with _manage_executor_state
TI = models.TaskInstance
for key, state in list(self.executor.get_event_buffer(simple_dag_bag.dag_ids... | python | {
"resource": ""
} |
q266221 | SchedulerJob.process_file | test | def process_file(self, file_path, zombies, pickle_dags=False, session=None):
"""
Process a Python file containing Airflow DAGs.
This includes:
1. Execute the file and look for DAG objects in the namespace.
2. Pickle the DAG and save it to the DB (if necessary).
3. For e... | python | {
"resource": ""
} |
q266222 | BackfillJob._update_counters | test | def _update_counters(self, ti_status):
"""
Updates the counters per state of the tasks that were running. Can re-add
to tasks to run in case required.
:param ti_status: the internal status of the backfill job tasks
:type ti_status: BackfillJob._DagRunTaskStatus
"""
... | python | {
"resource": ""
} |
q266223 | BackfillJob._manage_executor_state | test | def _manage_executor_state(self, running):
"""
Checks if the executor agrees with the state of task instances
that are running
:param running: dict of key, task to verify
"""
executor = self.executor
for key, state in list(executor.get_event_buffer().items()):
... | python | {
"resource": ""
} |
q266224 | BackfillJob._get_dag_run | test | def _get_dag_run(self, run_date, session=None):
"""
Returns a dag run for the given run date, which will be matched to an existing
dag run if available or create a new dag run otherwise. If the max_active_runs
limit is reached, this function will return None.
:param run_date: th... | python | {
"resource": ""
} |
q266225 | BackfillJob._task_instances_for_dag_run | test | def _task_instances_for_dag_run(self, dag_run, session=None):
"""
Returns a map of task instance key to task instance object for the tasks to
run in the given dag run.
:param dag_run: the dag run to get the tasks from
:type dag_run: airflow.models.DagRun
:param session: ... | python | {
"resource": ""
} |
q266226 | BackfillJob._execute_for_run_dates | test | def _execute_for_run_dates(self, run_dates, ti_status, executor, pickle_id,
start_date, session=None):
"""
Computes the dag runs and their respective task instances for
the given run dates and executes the task instances.
Returns a list of execution dates o... | python | {
"resource": ""
} |
q266227 | BackfillJob._set_unfinished_dag_runs_to_failed | test | def _set_unfinished_dag_runs_to_failed(self, dag_runs, session=None):
"""
Go through the dag_runs and update the state based on the task_instance state.
Then set DAG runs that are not finished to failed.
:param dag_runs: DAG runs
:param session: session
:return: None
... | python | {
"resource": ""
} |
q266228 | BackfillJob._execute | test | def _execute(self, session=None):
"""
Initializes all components required to run a dag for a specified date range and
calls helper method to execute the tasks.
"""
ti_status = BackfillJob._DagRunTaskStatus()
start_date = self.bf_start_date
# Get intervals betwee... | python | {
"resource": ""
} |
q266229 | LocalTaskJob.heartbeat_callback | test | def heartbeat_callback(self, session=None):
"""Self destruct task if state has been moved away from running externally"""
if self.terminating:
# ensure termination if processes are created later
self.task_runner.terminate()
return
self.task_instance.refresh_... | python | {
"resource": ""
} |
q266230 | CloudSpannerHook._get_client | test | def _get_client(self, project_id):
"""
Provides a client for interacting with the Cloud Spanner API.
:param project_id: The ID of the GCP project.
:type project_id: str
:return: google.cloud.spanner_v1.client.Client
:rtype: object
"""
if not self._client... | python | {
"resource": ""
} |
q266231 | CloudSpannerHook.get_instance | test | def get_instance(self, instance_id, project_id=None):
"""
Gets information about a particular instance.
:param project_id: Optional, The ID of the GCP project that owns the Cloud Spanner
database. If set to None or missing, the default project_id from the GCP connection is used.
... | python | {
"resource": ""
} |
q266232 | CloudSpannerHook._apply_to_instance | test | def _apply_to_instance(self, project_id, instance_id, configuration_name, node_count,
display_name, func):
"""
Invokes a method on a given instance by applying a specified Callable.
:param project_id: The ID of the GCP project that owns the Cloud Spanner
... | python | {
"resource": ""
} |
q266233 | CloudSpannerHook.create_instance | test | def create_instance(self, instance_id, configuration_name, node_count,
display_name, project_id=None):
"""
Creates a new Cloud Spanner instance.
:param instance_id: The ID of the Cloud Spanner instance.
:type instance_id: str
:param configuration_name: Th... | python | {
"resource": ""
} |
q266234 | CloudSpannerHook.update_instance | test | def update_instance(self, instance_id, configuration_name, node_count,
display_name, project_id=None):
"""
Updates an existing Cloud Spanner instance.
:param instance_id: The ID of the Cloud Spanner instance.
:type instance_id: str
:param configuration_na... | python | {
"resource": ""
} |
q266235 | CloudSpannerHook.delete_instance | test | def delete_instance(self, instance_id, project_id=None):
"""
Deletes an existing Cloud Spanner instance.
:param instance_id: The ID of the Cloud Spanner instance.
:type instance_id: str
:param project_id: Optional, the ID of the GCP project that owns the Cloud Spanner
... | python | {
"resource": ""
} |
q266236 | CloudSpannerHook.get_database | test | def get_database(self, instance_id, database_id, project_id=None):
"""
Retrieves a database in Cloud Spanner. If the database does not exist
in the specified instance, it returns None.
:param instance_id: The ID of the Cloud Spanner instance.
:type instance_id: str
:para... | python | {
"resource": ""
} |
q266237 | CloudSpannerHook.create_database | test | def create_database(self, instance_id, database_id, ddl_statements, project_id=None):
"""
Creates a new database in Cloud Spanner.
:type project_id: str
:param instance_id: The ID of the Cloud Spanner instance.
:type instance_id: str
:param database_id: The ID of the dat... | python | {
"resource": ""
} |
q266238 | CloudSpannerHook.update_database | test | def update_database(self, instance_id, database_id, ddl_statements,
project_id=None,
operation_id=None):
"""
Updates DDL of a database in Cloud Spanner.
:type project_id: str
:param instance_id: The ID of the Cloud Spanner instance.
... | python | {
"resource": ""
} |
q266239 | CloudSpannerHook.delete_database | test | def delete_database(self, instance_id, database_id, project_id=None):
"""
Drops a database in Cloud Spanner.
:type project_id: str
:param instance_id: The ID of the Cloud Spanner instance.
:type instance_id: str
:param database_id: The ID of the database in Cloud Spanner... | python | {
"resource": ""
} |
q266240 | ImapAttachmentSensor.poke | test | def poke(self, context):
"""
Pokes for a mail attachment on the mail server.
:param context: The context that is being provided when poking.
:type context: dict
:return: True if attachment with the given name is present and False if not.
:rtype: bool
"""
... | python | {
"resource": ""
} |
q266241 | prepare_additional_parameters | test | def prepare_additional_parameters(additional_properties, language_hints, web_detection_params):
"""
Creates additional_properties parameter based on language_hints, web_detection_params and
additional_properties parameters specified by the user
"""
if language_hints is None and web_detection_params ... | python | {
"resource": ""
} |
q266242 | CassandraHook.get_conn | test | def get_conn(self):
"""
Returns a cassandra Session object
"""
if self.session and not self.session.is_shutdown:
return self.session
self.session = self.cluster.connect(self.keyspace)
return self.session | python | {
"resource": ""
} |
q266243 | CassandraHook.table_exists | test | def table_exists(self, table):
"""
Checks if a table exists in Cassandra
:param table: Target Cassandra table.
Use dot notation to target a specific keyspace.
:type table: str
"""
keyspace = self.keyspace
if '.' in table:
keyspac... | python | {
"resource": ""
} |
q266244 | CassandraHook.record_exists | test | def record_exists(self, table, keys):
"""
Checks if a record exists in Cassandra
:param table: Target Cassandra table.
Use dot notation to target a specific keyspace.
:type table: str
:param keys: The keys and their values to check the existence.
:t... | python | {
"resource": ""
} |
q266245 | SparkSubmitHook._build_track_driver_status_command | test | def _build_track_driver_status_command(self):
"""
Construct the command to poll the driver status.
:return: full command to be executed
"""
connection_cmd = self._get_spark_binary_path()
# The url ot the spark master
connection_cmd += ["--master", self._connecti... | python | {
"resource": ""
} |
q266246 | SparkSubmitHook.submit | test | def submit(self, application="", **kwargs):
"""
Remote Popen to execute the spark-submit job
:param application: Submitted application, jar or py file
:type application: str
:param kwargs: extra arguments to Popen (see subprocess.Popen)
"""
spark_submit_cmd = sel... | python | {
"resource": ""
} |
q266247 | SparkSubmitHook._process_spark_submit_log | test | def _process_spark_submit_log(self, itr):
"""
Processes the log files and extracts useful information out of it.
If the deploy-mode is 'client', log the output of the submit command as those
are the output logs of the Spark worker directly.
Remark: If the driver needs to be tra... | python | {
"resource": ""
} |
q266248 | SparkSubmitHook._process_spark_status_log | test | def _process_spark_status_log(self, itr):
"""
parses the logs of the spark driver status query process
:param itr: An iterator which iterates over the input of the subprocess
"""
# Consume the iterator
for line in itr:
line = line.strip()
# Check... | python | {
"resource": ""
} |
q266249 | get_task_runner | test | def get_task_runner(local_task_job):
"""
Get the task runner that can be used to run the given job.
:param local_task_job: The LocalTaskJob associated with the TaskInstance
that needs to be executed.
:type local_task_job: airflow.jobs.LocalTaskJob
:return: The task runner to use to run the ... | python | {
"resource": ""
} |
q266250 | AWSBatchOperator._wait_for_task_ended | test | def _wait_for_task_ended(self):
"""
Try to use a waiter from the below pull request
* https://github.com/boto/botocore/pull/1307
If the waiter is not available apply a exponential backoff
* docs.aws.amazon.com/general/latest/gr/api-retries.html
"""
try:... | python | {
"resource": ""
} |
q266251 | MySqlToGoogleCloudStorageOperator._query_mysql | test | def _query_mysql(self):
"""
Queries mysql and returns a cursor to the results.
"""
mysql = MySqlHook(mysql_conn_id=self.mysql_conn_id)
conn = mysql.get_conn()
cursor = conn.cursor()
cursor.execute(self.sql)
return cursor | python | {
"resource": ""
} |
q266252 | MySqlToGoogleCloudStorageOperator._configure_csv_file | test | def _configure_csv_file(self, file_handle, schema):
"""Configure a csv writer with the file_handle and write schema
as headers for the new file.
"""
csv_writer = csv.writer(file_handle, encoding='utf-8',
delimiter=self.field_delimiter)
csv_writer.w... | python | {
"resource": ""
} |
q266253 | MySqlToGoogleCloudStorageOperator._write_local_schema_file | test | def _write_local_schema_file(self, cursor):
"""
Takes a cursor, and writes the BigQuery schema in .json format for the
results to a local file system.
:return: A dictionary where key is a filename to be used as an object
name in GCS, and values are file handles to local file... | python | {
"resource": ""
} |
q266254 | MySqlToGoogleCloudStorageOperator._get_col_type_dict | test | def _get_col_type_dict(self):
"""
Return a dict of column name and column type based on self.schema if not None.
"""
schema = []
if isinstance(self.schema, string_types):
schema = json.loads(self.schema)
elif isinstance(self.schema, list):
schema =... | python | {
"resource": ""
} |
q266255 | MySqlToGoogleCloudStorageOperator.type_map | test | def type_map(cls, mysql_type):
"""
Helper function that maps from MySQL fields to BigQuery fields. Used
when a schema_filename is set.
"""
d = {
FIELD_TYPE.INT24: 'INTEGER',
FIELD_TYPE.TINY: 'INTEGER',
FIELD_TYPE.BIT: 'INTEGER',
FIE... | python | {
"resource": ""
} |
q266256 | SqoopOperator.execute | test | def execute(self, context):
"""
Execute sqoop job
"""
self.hook = SqoopHook(
conn_id=self.conn_id,
verbose=self.verbose,
num_mappers=self.num_mappers,
hcatalog_database=self.hcatalog_database,
hcatalog_table=self.hcatalog_table,... | python | {
"resource": ""
} |
q266257 | apply_lineage | test | def apply_lineage(func):
"""
Saves the lineage to XCom and if configured to do so sends it
to the backend.
"""
backend = _get_backend()
@wraps(func)
def wrapper(self, context, *args, **kwargs):
self.log.debug("Backend: %s, Lineage called with inlets: %s, outlets: %s",
... | python | {
"resource": ""
} |
q266258 | Connection.extra_dejson | test | def extra_dejson(self):
"""Returns the extra property by deserializing json."""
obj = {}
if self.extra:
try:
obj = json.loads(self.extra)
except Exception as e:
self.log.exception(e)
self.log.error("Failed parsing the json f... | python | {
"resource": ""
} |
q266259 | date_range | test | def date_range(start_date, end_date=None, num=None, delta=None):
"""
Get a set of dates as a list based on a start, end and delta, delta
can be something that can be added to `datetime.datetime`
or a cron expression as a `str`
:Example::
date_range(datetime(2016, 1, 1), datetime(2016, 1, 3... | python | {
"resource": ""
} |
q266260 | scale_time_units | test | def scale_time_units(time_seconds_arr, unit):
"""
Convert an array of time durations in seconds to the specified time unit.
"""
if unit == 'minutes':
return list(map(lambda x: x * 1.0 / 60, time_seconds_arr))
elif unit == 'hours':
return list(map(lambda x: x * 1.0 / (60 * 60), time_s... | python | {
"resource": ""
} |
q266261 | days_ago | test | def days_ago(n, hour=0, minute=0, second=0, microsecond=0):
"""
Get a datetime object representing `n` days ago. By default the time is
set to midnight.
"""
today = timezone.utcnow().replace(
hour=hour,
minute=minute,
second=second,
microsecond=microsecond)
return... | python | {
"resource": ""
} |
q266262 | AirflowSecurityManager.init_role | test | def init_role(self, role_name, role_vms, role_perms):
"""
Initialize the role with the permissions and related view-menus.
:param role_name:
:param role_vms:
:param role_perms:
:return:
"""
pvms = self.get_session.query(sqla_models.PermissionView).all()
... | python | {
"resource": ""
} |
q266263 | AirflowSecurityManager.delete_role | test | def delete_role(self, role_name):
"""Delete the given Role
:param role_name: the name of a role in the ab_role table
"""
session = self.get_session
role = session.query(sqla_models.Role)\
.filter(sqla_models.Role.name == role_name)\
.f... | python | {
"resource": ""
} |
q266264 | AirflowSecurityManager.get_user_roles | test | def get_user_roles(self, user=None):
"""
Get all the roles associated with the user.
:param user: the ab_user in FAB model.
:return: a list of roles associated with the user.
"""
if user is None:
user = g.user
if user.is_anonymous:
public_... | python | {
"resource": ""
} |
q266265 | AirflowSecurityManager.get_all_permissions_views | test | def get_all_permissions_views(self):
"""
Returns a set of tuples with the perm name and view menu name
"""
perms_views = set()
for role in self.get_user_roles():
perms_views.update({(perm_view.permission.name, perm_view.view_menu.name)
... | python | {
"resource": ""
} |
q266266 | AirflowSecurityManager._has_role | test | def _has_role(self, role_name_or_list):
"""
Whether the user has this role name
"""
if not isinstance(role_name_or_list, list):
role_name_or_list = [role_name_or_list]
return any(
[r.name in role_name_or_list for r in self.get_user_roles()]) | python | {
"resource": ""
} |
q266267 | AirflowSecurityManager._has_perm | test | def _has_perm(self, permission_name, view_menu_name):
"""
Whether the user has this perm
"""
if hasattr(self, 'perms'):
if (permission_name, view_menu_name) in self.perms:
return True
# rebuild the permissions set
self._get_and_cache_perms()
... | python | {
"resource": ""
} |
q266268 | AirflowSecurityManager.clean_perms | test | def clean_perms(self):
"""
FAB leaves faulty permissions that need to be cleaned up
"""
self.log.debug('Cleaning faulty perms')
sesh = self.get_session
pvms = (
sesh.query(sqla_models.PermissionView)
.filter(or_(
sqla_models.Permiss... | python | {
"resource": ""
} |
q266269 | AirflowSecurityManager._merge_perm | test | def _merge_perm(self, permission_name, view_menu_name):
"""
Add the new permission , view_menu to ab_permission_view_role if not exists.
It will add the related entry to ab_permission
and ab_view_menu two meta tables as well.
:param permission_name: Name of the permission.
... | python | {
"resource": ""
} |
q266270 | AirflowSecurityManager.update_admin_perm_view | test | def update_admin_perm_view(self):
"""
Admin should have all the permission-views.
Add the missing ones to the table for admin.
:return: None.
"""
pvms = self.get_session.query(sqla_models.PermissionView).all()
pvms = [p for p in pvms if p.permission and p.view_me... | python | {
"resource": ""
} |
q266271 | AirflowSecurityManager._sync_dag_view_permissions | test | def _sync_dag_view_permissions(self, dag_id, access_control):
"""Set the access policy on the given DAG's ViewModel.
:param dag_id: the ID of the DAG whose permissions should be updated
:type dag_id: string
:param access_control: a dict where each key is a rolename and
each ... | python | {
"resource": ""
} |
q266272 | AirflowSecurityManager.create_perm_vm_for_all_dag | test | def create_perm_vm_for_all_dag(self):
"""
Create perm-vm if not exist and insert into FAB security model for all-dags.
"""
# create perm for global logical dag
for dag_vm in self.DAG_VMS:
for perm in self.DAG_PERMS:
self._merge_perm(permission_name=per... | python | {
"resource": ""
} |
q266273 | get_fernet | test | def get_fernet():
"""
Deferred load of Fernet key.
This function could fail either because Cryptography is not installed
or because the Fernet key is invalid.
:return: Fernet object
:raises: airflow.exceptions.AirflowException if there's a problem trying to load Fernet
"""
global _fern... | python | {
"resource": ""
} |
q266274 | AwsGlueCatalogPartitionSensor.poke | test | def poke(self, context):
"""
Checks for existence of the partition in the AWS Glue Catalog table
"""
if '.' in self.table_name:
self.database_name, self.table_name = self.table_name.split('.')
self.log.info(
'Poking for table %s. %s, expression %s', self.d... | python | {
"resource": ""
} |
q266275 | AwsGlueCatalogPartitionSensor.get_hook | test | def get_hook(self):
"""
Gets the AwsGlueCatalogHook
"""
if not hasattr(self, 'hook'):
from airflow.contrib.hooks.aws_glue_catalog_hook import AwsGlueCatalogHook
self.hook = AwsGlueCatalogHook(
aws_conn_id=self.aws_conn_id,
region_na... | python | {
"resource": ""
} |
q266276 | SQSSensor.poke | test | def poke(self, context):
"""
Check for message on subscribed queue and write to xcom the message with key ``messages``
:param context: the context object
:type context: dict
:return: ``True`` if message is available or ``False``
"""
sqs_hook = SQSHook(aws_conn_i... | python | {
"resource": ""
} |
q266277 | HDFSHook.get_conn | test | def get_conn(self):
"""
Returns a snakebite HDFSClient object.
"""
# When using HAClient, proxy_user must be the same, so is ok to always
# take the first.
effective_user = self.proxy_user
autoconfig = self.autoconfig
use_sasl = configuration.conf.get('cor... | python | {
"resource": ""
} |
q266278 | WebHDFSHook.get_conn | test | def get_conn(self):
"""
Establishes a connection depending on the security mode set via config or environment variable.
:return: a hdfscli InsecureClient or KerberosClient object.
:rtype: hdfs.InsecureClient or hdfs.ext.kerberos.KerberosClient
"""
connections = self.get_... | python | {
"resource": ""
} |
q266279 | WebHDFSHook.check_for_path | test | def check_for_path(self, hdfs_path):
"""
Check for the existence of a path in HDFS by querying FileStatus.
:param hdfs_path: The path to check.
:type hdfs_path: str
:return: True if the path exists and False if not.
:rtype: bool
"""
conn = self.get_conn()... | python | {
"resource": ""
} |
q266280 | WebHDFSHook.load_file | test | def load_file(self, source, destination, overwrite=True, parallelism=1, **kwargs):
r"""
Uploads a file to HDFS.
:param source: Local path to file or folder.
If it's a folder, all the files inside of it will be uploaded.
.. note:: This implies that folders empty of files ... | python | {
"resource": ""
} |
q266281 | PinotDbApiHook.get_conn | test | def get_conn(self):
"""
Establish a connection to pinot broker through pinot dbqpi.
"""
conn = self.get_connection(self.pinot_broker_conn_id)
pinot_broker_conn = connect(
host=conn.host,
port=conn.port,
path=conn.extra_dejson.get('endpoint', '/... | python | {
"resource": ""
} |
q266282 | PinotDbApiHook.get_uri | test | def get_uri(self):
"""
Get the connection uri for pinot broker.
e.g: http://localhost:9000/pql
"""
conn = self.get_connection(getattr(self, self.conn_name_attr))
host = conn.host
if conn.port is not None:
host += ':{port}'.format(port=conn.port)
... | python | {
"resource": ""
} |
q266283 | TransferJobPreprocessor._convert_date_to_dict | test | def _convert_date_to_dict(field_date):
"""
Convert native python ``datetime.date`` object to a format supported by the API
"""
return {DAY: field_date.day, MONTH: field_date.month, YEAR: field_date.year} | python | {
"resource": ""
} |
q266284 | TransferJobPreprocessor._convert_time_to_dict | test | def _convert_time_to_dict(time):
"""
Convert native python ``datetime.time`` object to a format supported by the API
"""
return {HOURS: time.hour, MINUTES: time.minute, SECONDS: time.second} | python | {
"resource": ""
} |
q266285 | RedisHook.get_conn | test | def get_conn(self):
"""
Returns a Redis connection.
"""
conn = self.get_connection(self.redis_conn_id)
self.host = conn.host
self.port = conn.port
self.password = None if str(conn.password).lower() in ['none', 'false', ''] else conn.password
self.db = conn... | python | {
"resource": ""
} |
q266286 | DbApiHook.get_pandas_df | test | def get_pandas_df(self, sql, parameters=None):
"""
Executes the sql and returns a pandas dataframe
:param sql: the sql statement to be executed (str) or a list of
sql statements to execute
:type sql: str or list
:param parameters: The parameters to render the SQL que... | python | {
"resource": ""
} |
q266287 | DbApiHook.run | test | def run(self, sql, autocommit=False, parameters=None):
"""
Runs a command or a list of commands. Pass a list of sql
statements to the sql parameter to get them to execute
sequentially
:param sql: the sql statement to be executed (str) or a list of
sql statements to e... | python | {
"resource": ""
} |
q266288 | DbApiHook.set_autocommit | test | def set_autocommit(self, conn, autocommit):
"""
Sets the autocommit flag on the connection
"""
if not self.supports_autocommit and autocommit:
self.log.warn(
("%s connection doesn't support "
"autocommit but autocommit activated."),
... | python | {
"resource": ""
} |
q266289 | DbApiHook.insert_rows | test | def insert_rows(self, table, rows, target_fields=None, commit_every=1000,
replace=False):
"""
A generic way to insert a set of tuples into a table,
a new transaction is created every commit_every rows
:param table: Name of the target table
:type table: str
... | python | {
"resource": ""
} |
q266290 | DbApiHook._serialize_cell | test | def _serialize_cell(cell, conn=None):
"""
Returns the SQL literal of the cell as a string.
:param cell: The cell to insert into the table
:type cell: object
:param conn: The database connection
:type conn: connection object
:return: The serialized cell
:r... | python | {
"resource": ""
} |
q266291 | Airflow.health | test | def health(self, session=None):
"""
An endpoint helping check the health status of the Airflow instance,
including metadatabase and scheduler.
"""
BJ = jobs.BaseJob
payload = {}
scheduler_health_check_threshold = timedelta(seconds=conf.getint('scheduler',
... | python | {
"resource": ""
} |
q266292 | Airflow.extra_links | test | def extra_links(self):
"""
A restful endpoint that returns external links for a given Operator
It queries the operator that sent the request for the links it wishes
to provide for a given external link name.
API: GET
Args: dag_id: The id of the dag containing the task i... | python | {
"resource": ""
} |
q266293 | CloudantHook.get_conn | test | def get_conn(self):
"""
Opens a connection to the cloudant service and closes it automatically if used as context manager.
.. note::
In the connection form:
- 'host' equals the 'Account' (optional)
- 'login' equals the 'Username (or API Key)' (required)
... | python | {
"resource": ""
} |
q266294 | SlackWebhookOperator.execute | test | def execute(self, context):
"""
Call the SlackWebhookHook to post the provided Slack message
"""
self.hook = SlackWebhookHook(
self.http_conn_id,
self.webhook_token,
self.message,
self.attachments,
self.channel,
self... | python | {
"resource": ""
} |
q266295 | GoogleCloudBaseHook._get_credentials | test | def _get_credentials(self):
"""
Returns the Credentials object for Google API
"""
key_path = self._get_field('key_path', False)
keyfile_dict = self._get_field('keyfile_dict', False)
scope = self._get_field('scope', None)
if scope:
scopes = [s.strip() f... | python | {
"resource": ""
} |
q266296 | GoogleCloudBaseHook._authorize | test | def _authorize(self):
"""
Returns an authorized HTTP object to be used to build a Google cloud
service hook connection.
"""
credentials = self._get_credentials()
http = httplib2.Http()
authed_http = google_auth_httplib2.AuthorizedHttp(
credentials, htt... | python | {
"resource": ""
} |
q266297 | GoogleCloudBaseHook.catch_http_exception | test | def catch_http_exception(func):
"""
Function decorator that intercepts HTTP Errors and raises AirflowException
with more informative message.
"""
@functools.wraps(func)
def wrapper_decorator(self, *args, **kwargs):
try:
return func(self, *args... | python | {
"resource": ""
} |
q266298 | GoogleCloudBaseHook.fallback_to_default_project_id | test | def fallback_to_default_project_id(func):
"""
Decorator that provides fallback for Google Cloud Platform project id. If
the project is None it will be replaced with the project_id from the
service account the Hook is authenticated with. Project id can be specified
either via proj... | python | {
"resource": ""
} |
q266299 | State.unfinished | test | def unfinished(cls):
"""
A list of states indicating that a task either has not completed
a run or has not even started.
"""
return [
cls.NONE,
cls.SCHEDULED,
cls.QUEUED,
cls.RUNNING,
cls.SHUTDOWN,
cls.UP_FOR... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.