_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q266100
BigtableHook.update_cluster
test
def update_cluster(instance, cluster_id, nodes): """ Updates number of nodes in the specified Cloud Bigtable cluster. Raises google.api_core.exceptions.NotFound if the cluster does not exist. :type instance: Instance :param instance: The Cloud Bigtable instance that owns the clu...
python
{ "resource": "" }
q266101
HiveCliHook._prepare_cli_cmd
test
def _prepare_cli_cmd(self): """ This function creates the command list from available information """ conn = self.conn hive_bin = 'hive' cmd_extra = [] if self.use_beeline: hive_bin = 'beeline' jdbc_url = "jdbc:hive2://{host}:{port}/{schem...
python
{ "resource": "" }
q266102
HiveCliHook._prepare_hiveconf
test
def _prepare_hiveconf(d): """ This function prepares a list of hiveconf params from a dictionary of key value pairs. :param d: :type d: dict >>> hh = HiveCliHook() >>> hive_conf = {"hive.exec.dynamic.partition": "true", ... "hive.exec.dynamic.partition.m...
python
{ "resource": "" }
q266103
HiveCliHook.load_df
test
def load_df( self, df, table, field_dict=None, delimiter=',', encoding='utf8', pandas_kwargs=None, **kwargs): """ Loads a pandas DataFrame into hive. Hive data types will be inferred if not passed but column nam...
python
{ "resource": "" }
q266104
HiveCliHook.load_file
test
def load_file( self, filepath, table, delimiter=",", field_dict=None, create=True, overwrite=True, partition=None, recreate=False, tblproperties=None): """ Loads a local file into Hive...
python
{ "resource": "" }
q266105
HiveMetastoreHook.get_metastore_client
test
def get_metastore_client(self): """ Returns a Hive thrift client. """ import hmsclient from thrift.transport import TSocket, TTransport from thrift.protocol import TBinaryProtocol ms = self.metastore_conn auth_mechanism = ms.extra_dejson.get('authMechanism...
python
{ "resource": "" }
q266106
HiveMetastoreHook.check_for_named_partition
test
def check_for_named_partition(self, schema, table, partition_name): """ Checks whether a partition with a given name exists :param schema: Name of hive schema (database) @table belongs to :type schema: str :param table: Name of hive table @partition belongs to :type sche...
python
{ "resource": "" }
q266107
HiveMetastoreHook.table_exists
test
def table_exists(self, table_name, db='default'): """ Check if table exists >>> hh = HiveMetastoreHook() >>> hh.table_exists(db='airflow', table_name='static_babynames') True >>> hh.table_exists(db='airflow', table_name='does_not_exist') False """ ...
python
{ "resource": "" }
q266108
HiveServer2Hook.get_conn
test
def get_conn(self, schema=None): """ Returns a Hive connection object. """ db = self.get_connection(self.hiveserver2_conn_id) auth_mechanism = db.extra_dejson.get('authMechanism', 'NONE') if auth_mechanism == 'NONE' and db.login is None: # we need to give a us...
python
{ "resource": "" }
q266109
HiveServer2Hook.get_results
test
def get_results(self, hql, schema='default', fetch_size=None, hive_conf=None): """ Get results of the provided hql in target schema. :param hql: hql to be executed. :type hql: str or list :param schema: target schema, default to 'default'. :type schema: str :para...
python
{ "resource": "" }
q266110
HiveServer2Hook.to_csv
test
def to_csv( self, hql, csv_filepath, schema='default', delimiter=',', lineterminator='\r\n', output_header=True, fetch_size=1000, hive_conf=None): """ Execute hql in target schema and write result...
python
{ "resource": "" }
q266111
HiveServer2Hook.get_records
test
def get_records(self, hql, schema='default', hive_conf=None): """ Get a set of records from a Hive query. :param hql: hql to be executed. :type hql: str or list :param schema: target schema, default to 'default'. :type schema: str :param hive_conf: hive_conf to e...
python
{ "resource": "" }
q266112
HiveServer2Hook.get_pandas_df
test
def get_pandas_df(self, hql, schema='default'): """ Get a pandas dataframe from a Hive query :param hql: hql to be executed. :type hql: str or list :param schema: target schema, default to 'default'. :type schema: str :return: result of hql execution :rty...
python
{ "resource": "" }
q266113
CloudVisionHook.get_conn
test
def get_conn(self): """ Retrieves connection to Cloud Vision. :return: Google Cloud Vision client object. :rtype: google.cloud.vision_v1.ProductSearchClient """ if not self._client: self._client = ProductSearchClient(credentials=self._get_credentials()) ...
python
{ "resource": "" }
q266114
DingdingHook._get_endpoint
test
def _get_endpoint(self): """ Get Dingding endpoint for sending message. """ conn = self.get_connection(self.http_conn_id) token = conn.password if not token: raise AirflowException('Dingding token is requests but get nothing, ' ...
python
{ "resource": "" }
q266115
DingdingHook.send
test
def send(self): """ Send Dingding message """ support_type = ['text', 'link', 'markdown', 'actionCard', 'feedCard'] if self.message_type not in support_type: raise ValueError('DingdingWebhookHook only support {} ' 'so far, but receive {}'....
python
{ "resource": "" }
q266116
_bind_parameters
test
def _bind_parameters(operation, parameters): """ Helper method that binds parameters to a SQL query. """ # inspired by MySQL Python Connector (conversion.py) string_parameters = {} for (name, value) in iteritems(parameters): if value is None: string_parameters[name] = 'NULL' ...
python
{ "resource": "" }
q266117
_escape
test
def _escape(s): """ Helper method that escapes parameters to a SQL query. """ e = s e = e.replace('\\', '\\\\') e = e.replace('\n', '\\n') e = e.replace('\r', '\\r') e = e.replace("'", "\\'") e = e.replace('"', '\\"') return e
python
{ "resource": "" }
q266118
_bq_cast
test
def _bq_cast(string_field, bq_type): """ Helper method that casts a BigQuery row to the appropriate data types. This is useful because BigQuery returns all fields as strings. """ if string_field is None: return None elif bq_type == 'INTEGER': return int(string_field) elif bq_...
python
{ "resource": "" }
q266119
_validate_value
test
def _validate_value(key, value, expected_type): """ function to check expected type and raise error if type is not correct """ if not isinstance(value, expected_type): raise TypeError("{} argument must have a type {} not {}".format( key, expected_type, type(value)))
python
{ "resource": "" }
q266120
BigQueryHook.get_conn
test
def get_conn(self): """ Returns a BigQuery PEP 249 connection object. """ service = self.get_service() project = self._get_field('project') return BigQueryConnection( service=service, project_id=project, use_legacy_sql=self.use_legacy_s...
python
{ "resource": "" }
q266121
BigQueryHook.get_service
test
def get_service(self): """ Returns a BigQuery service object. """ http_authorized = self._authorize() return build( 'bigquery', 'v2', http=http_authorized, cache_discovery=False)
python
{ "resource": "" }
q266122
BigQueryHook.table_exists
test
def table_exists(self, project_id, dataset_id, table_id): """ Checks for the existence of a table in Google BigQuery. :param project_id: The Google cloud project in which to look for the table. The connection supplied to the hook must provide access to the specified proj...
python
{ "resource": "" }
q266123
BigQueryBaseCursor.create_empty_table
test
def create_empty_table(self, project_id, dataset_id, table_id, schema_fields=None, time_partitioning=None, cluster_fields=None, lab...
python
{ "resource": "" }
q266124
BigQueryBaseCursor.patch_table
test
def patch_table(self, dataset_id, table_id, project_id=None, description=None, expiration_time=None, external_data_configuration=None, friendly_name=None, label...
python
{ "resource": "" }
q266125
BigQueryBaseCursor.cancel_query
test
def cancel_query(self): """ Cancel all started queries that have not yet completed """ jobs = self.service.jobs() if (self.running_job_id and not self.poll_job_complete(self.running_job_id)): self.log.info('Attempting to cancel job : %s, %s', self.proj...
python
{ "resource": "" }
q266126
BigQueryBaseCursor.run_table_delete
test
def run_table_delete(self, deletion_dataset_table, ignore_if_missing=False): """ Delete an existing table from the dataset; If the table does not exist, return an error unless ignore_if_missing is set to True. :param deletion_dataset_table: A dotted ...
python
{ "resource": "" }
q266127
BigQueryBaseCursor.run_table_upsert
test
def run_table_upsert(self, dataset_id, table_resource, project_id=None): """ creates a new, empty table in the dataset; If the table already exists, update the existing table. Since BigQuery does not natively allow table upserts, this is not an atomic operation. :param d...
python
{ "resource": "" }
q266128
BigQueryBaseCursor.run_grant_dataset_view_access
test
def run_grant_dataset_view_access(self, source_dataset, view_dataset, view_table, source_project=None, view_project=None): ...
python
{ "resource": "" }
q266129
BigQueryBaseCursor.get_dataset
test
def get_dataset(self, dataset_id, project_id=None): """ Method returns dataset_resource if dataset exist and raised 404 error if dataset does not exist :param dataset_id: The BigQuery Dataset ID :type dataset_id: str :param project_id: The GCP Project ID :type pr...
python
{ "resource": "" }
q266130
BigQueryBaseCursor.get_datasets_list
test
def get_datasets_list(self, project_id=None): """ Method returns full list of BigQuery datasets in the current project .. seealso:: For more information, see: https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets/list :param project_id: Google Cloud ...
python
{ "resource": "" }
q266131
BigQueryBaseCursor.insert_all
test
def insert_all(self, project_id, dataset_id, table_id, rows, ignore_unknown_values=False, skip_invalid_rows=False, fail_on_error=False): """ Method to stream data into BigQuery one record at a time without needing to run a load job .. seealso:: ...
python
{ "resource": "" }
q266132
BigQueryCursor.execute
test
def execute(self, operation, parameters=None): """ Executes a BigQuery query, and returns the job ID. :param operation: The query to execute. :type operation: str :param parameters: Parameters to substitute into the query. :type parameters: dict """ sql =...
python
{ "resource": "" }
q266133
BigQueryCursor.executemany
test
def executemany(self, operation, seq_of_parameters): """ Execute a BigQuery query multiple times with different parameters. :param operation: The query to execute. :type operation: str :param seq_of_parameters: List of dictionary parameters to substitute into the que...
python
{ "resource": "" }
q266134
BigQueryCursor.next
test
def next(self): """ Helper method for fetchone, which returns the next row from a buffer. If the buffer is empty, attempts to paginate through the result set for the next page, and load it into the buffer. """ if not self.job_id: return None if len(se...
python
{ "resource": "" }
q266135
PostgresToGoogleCloudStorageOperator._query_postgres
test
def _query_postgres(self): """ Queries Postgres and returns a cursor to the results. """ postgres = PostgresHook(postgres_conn_id=self.postgres_conn_id) conn = postgres.get_conn() cursor = conn.cursor() cursor.execute(self.sql, self.parameters) return curs...
python
{ "resource": "" }
q266136
_make_intermediate_dirs
test
def _make_intermediate_dirs(sftp_client, remote_directory): """ Create all the intermediate directories in a remote host :param sftp_client: A Paramiko SFTP client. :param remote_directory: Absolute Path of the directory containing the file :return: """ if remote_directory == '/': s...
python
{ "resource": "" }
q266137
SQSHook.create_queue
test
def create_queue(self, queue_name, attributes=None): """ Create queue using connection object :param queue_name: name of the queue. :type queue_name: str :param attributes: additional attributes for the queue (default: None) For details of the attributes parameter se...
python
{ "resource": "" }
q266138
SQSHook.send_message
test
def send_message(self, queue_url, message_body, delay_seconds=0, message_attributes=None): """ Send message to the queue :param queue_url: queue url :type queue_url: str :param message_body: the contents of the message :type message_body: str :param delay_seconds...
python
{ "resource": "" }
q266139
BaseTaskRunner.run_command
test
def run_command(self, run_with=None, join_args=False): """ Run the task command. :param run_with: list of tokens to run the task command with e.g. ``['bash', '-c']`` :type run_with: list :param join_args: whether to concatenate the list of command tokens e.g. ``['airflow', 'run'...
python
{ "resource": "" }
q266140
BaseTaskRunner.on_finish
test
def on_finish(self): """ A callback that should be called when this is done running. """ if self._cfg_path and os.path.isfile(self._cfg_path): if self.run_as_user: subprocess.call(['sudo', 'rm', self._cfg_path], close_fds=True) else: ...
python
{ "resource": "" }
q266141
_main
test
def _main(): """ Parse options and process commands """ # Parse arguments usage = "usage: nvd3.py [options]" parser = OptionParser(usage=usage, version=("python-nvd3 - Charts generator with " "nvd3.js and d3.js")) parser.add_option...
python
{ "resource": "" }
q266142
NVD3Chart.buildhtmlheader
test
def buildhtmlheader(self): """generate HTML header content""" self.htmlheader = '' # If the JavaScript assets have already been injected, don't bother re-sourcing them. global _js_initialized if '_js_initialized' not in globals() or not _js_initialized: for css in sel...
python
{ "resource": "" }
q266143
NVD3Chart.buildcontainer
test
def buildcontainer(self): """generate HTML div""" if self.container: return # Create SVG div with style if self.width: if self.width[-1] != '%': self.style += 'width:%spx;' % self.width else: self.style += 'width:%s;' %...
python
{ "resource": "" }
q266144
NVD3Chart.buildjschart
test
def buildjschart(self): """generate javascript code for the chart""" self.jschart = '' # add custom tooltip string in jschart # default condition (if build_custom_tooltip is not called explicitly with date_flag=True) if self.tooltip_condition_string == '': self.toolt...
python
{ "resource": "" }
q266145
NVD3Chart.create_x_axis
test
def create_x_axis(self, name, label=None, format=None, date=False, custom_format=False): """Create X-axis""" axis = {} if custom_format and format: axis['tickFormat'] = format elif format: if format == 'AM_PM': axis['tickFormat'] = "function(d) { r...
python
{ "resource": "" }
q266146
NVD3Chart.create_y_axis
test
def create_y_axis(self, name, label=None, format=None, custom_format=False): """ Create Y-axis """ axis = {} if custom_format and format: axis['tickFormat'] = format elif format: axis['tickFormat'] = "d3.format(',%s')" % format if label: ...
python
{ "resource": "" }
q266147
SqliteHook.get_conn
test
def get_conn(self): """ Returns a sqlite connection object """ conn = self.get_connection(self.sqlite_conn_id) conn = sqlite3.connect(conn.host) return conn
python
{ "resource": "" }
q266148
action_logging
test
def action_logging(f): """ Decorator to log user actions """ @functools.wraps(f) def wrapper(*args, **kwargs): with create_session() as session: if g.user.is_anonymous: user = 'anonymous' else: user = g.user.username log =...
python
{ "resource": "" }
q266149
gzipped
test
def gzipped(f): """ Decorator to make a view compressed """ @functools.wraps(f) def view_func(*args, **kwargs): @after_this_request def zipper(response): accept_encoding = request.headers.get('Accept-Encoding', '') if 'gzip' not in accept_encoding.lower(): ...
python
{ "resource": "" }
q266150
get_last_dagrun
test
def get_last_dagrun(dag_id, session, include_externally_triggered=False): """ Returns the last dag run for a dag, None if there was none. Last dag run can be any type of run eg. scheduled or backfilled. Overridden DagRuns are ignored. """ DR = DagRun query = session.query(DR).filter(DR.dag_i...
python
{ "resource": "" }
q266151
DagModel.create_dagrun
test
def create_dagrun(self, run_id, state, execution_date, start_date=None, external_trigger=False, conf=None, session=None): """ Creates a dag run from t...
python
{ "resource": "" }
q266152
SQSPublishOperator.execute
test
def execute(self, context): """ Publish the message to SQS queue :param context: the context object :type context: dict :return: dict with information about the message sent For details of the returned dict see :py:meth:`botocore.client.SQS.send_message` :rty...
python
{ "resource": "" }
q266153
json_response
test
def json_response(obj): """ returns a json response from a json serializable python object """ return Response( response=json.dumps( obj, indent=4, cls=AirflowJsonEncoder), status=200, mimetype="application/json")
python
{ "resource": "" }
q266154
open_maybe_zipped
test
def open_maybe_zipped(f, mode='r'): """ Opens the given file. If the path contains a folder with a .zip suffix, then the folder is treated as a zip archive, opening the file inside the archive. :return: a file object, as in `open`, or as in `ZipFile.open`. """ _, archive, filename = ZIP_REGEX....
python
{ "resource": "" }
q266155
make_cache_key
test
def make_cache_key(*args, **kwargs): """ Used by cache to get a unique key per URL """ path = request.path args = str(hash(frozenset(request.args.items()))) return (path + args).encode('ascii', 'ignore')
python
{ "resource": "" }
q266156
CloudVideoIntelligenceHook.get_conn
test
def get_conn(self): """ Returns Gcp Video Intelligence Service client :rtype: google.cloud.videointelligence_v1.VideoIntelligenceServiceClient """ if not self._conn: self._conn = VideoIntelligenceServiceClient(credentials=self._get_credentials()) return self....
python
{ "resource": "" }
q266157
CloudVideoIntelligenceHook.annotate_video
test
def annotate_video( self, input_uri=None, input_content=None, features=None, video_context=None, output_uri=None, location=None, retry=None, timeout=None, metadata=None, ): """ Performs video annotation. :param ...
python
{ "resource": "" }
q266158
OpsgenieAlertHook._get_api_key
test
def _get_api_key(self): """ Get Opsgenie api_key for creating alert """ conn = self.get_connection(self.http_conn_id) api_key = conn.password if not api_key: raise AirflowException('Opsgenie API Key is required for this hook, ' ...
python
{ "resource": "" }
q266159
OpsgenieAlertHook.get_conn
test
def get_conn(self, headers=None): """ Overwrite HttpHook get_conn because this hook just needs base_url and headers, and does not need generic params :param headers: additional headers to be passed through as a dictionary :type headers: dict """ conn = self.get_c...
python
{ "resource": "" }
q266160
OpsgenieAlertHook.execute
test
def execute(self, payload={}): """ Execute the Opsgenie Alert call :param payload: Opsgenie API Create Alert payload values See https://docs.opsgenie.com/docs/alert-api#section-create-alert :type payload: dict """ api_key = self._get_api_key() return ...
python
{ "resource": "" }
q266161
OpsgenieAlertOperator._build_opsgenie_payload
test
def _build_opsgenie_payload(self): """ Construct the Opsgenie JSON payload. All relevant parameters are combined here to a valid Opsgenie JSON payload. :return: Opsgenie payload (dict) to send """ payload = {} for key in [ "message", "alias", "descri...
python
{ "resource": "" }
q266162
OpsgenieAlertOperator.execute
test
def execute(self, context): """ Call the OpsgenieAlertHook to post message """ self.hook = OpsgenieAlertHook(self.opsgenie_conn_id) self.hook.execute(self._build_opsgenie_payload())
python
{ "resource": "" }
q266163
AWSAthenaHook.get_conn
test
def get_conn(self): """ check if aws conn exists already or create one and return it :return: boto3 session """ if not self.conn: self.conn = self.get_client_type('athena') return self.conn
python
{ "resource": "" }
q266164
AWSAthenaHook.run_query
test
def run_query(self, query, query_context, result_configuration, client_request_token=None): """ Run Presto query on athena with provided config and return submitted query_execution_id :param query: Presto query to run :type query: str :param query_context: Context in which query...
python
{ "resource": "" }
q266165
AWSAthenaHook.check_query_status
test
def check_query_status(self, query_execution_id): """ Fetch the status of submitted athena query. Returns None or one of valid query states. :param query_execution_id: Id of submitted athena query :type query_execution_id: str :return: str """ response = self.con...
python
{ "resource": "" }
q266166
AWSAthenaHook.poll_query_status
test
def poll_query_status(self, query_execution_id, max_tries=None): """ Poll the status of submitted athena query until query state reaches final state. Returns one of the final states :param query_execution_id: Id of submitted athena query :type query_execution_id: str :pa...
python
{ "resource": "" }
q266167
SFTPHook.get_conn
test
def get_conn(self): """ Returns an SFTP connection object """ if self.conn is None: cnopts = pysftp.CnOpts() if self.no_host_key_check: cnopts.hostkeys = None cnopts.compression = self.compress conn_params = { ...
python
{ "resource": "" }
q266168
ZendeskHook.__handle_rate_limit_exception
test
def __handle_rate_limit_exception(self, rate_limit_exception): """ Sleep for the time specified in the exception. If not specified, wait for 60 seconds. """ retry_after = int( rate_limit_exception.response.headers.get('Retry-After', 60)) self.log.info( ...
python
{ "resource": "" }
q266169
ZendeskHook.call
test
def call(self, path, query=None, get_all_pages=True, side_loading=False): """ Call Zendesk API and return results :param path: The Zendesk API to call :param query: Query parameters :param get_all_pages: Accumulate results over all pages before returning. Due to s...
python
{ "resource": "" }
q266170
AwsGlueCatalogHook.get_partitions
test
def get_partitions(self, database_name, table_name, expression='', page_size=None, max_items=None): """ Retrieves the partition values for a table. :param database_name: The name o...
python
{ "resource": "" }
q266171
AwsGlueCatalogHook.get_table
test
def get_table(self, database_name, table_name): """ Get the information of the table :param database_name: Name of hive database (schema) @table belongs to :type database_name: str :param table_name: Name of hive table :type table_name: str :rtype: dict ...
python
{ "resource": "" }
q266172
AwsGlueCatalogHook.get_table_location
test
def get_table_location(self, database_name, table_name): """ Get the physical location of the table :param database_name: Name of hive database (schema) @table belongs to :type database_name: str :param table_name: Name of hive table :type table_name: str :return...
python
{ "resource": "" }
q266173
RedshiftHook.cluster_status
test
def cluster_status(self, cluster_identifier): """ Return status of a cluster :param cluster_identifier: unique identifier of a cluster :type cluster_identifier: str """ conn = self.get_conn() try: response = conn.describe_clusters( Clu...
python
{ "resource": "" }
q266174
RedshiftHook.delete_cluster
test
def delete_cluster( self, cluster_identifier, skip_final_cluster_snapshot=True, final_cluster_snapshot_identifier=''): """ Delete a cluster and optionally create a snapshot :param cluster_identifier: unique identifier of a cluster :type cl...
python
{ "resource": "" }
q266175
RedshiftHook.describe_cluster_snapshots
test
def describe_cluster_snapshots(self, cluster_identifier): """ Gets a list of snapshots for a cluster :param cluster_identifier: unique identifier of a cluster :type cluster_identifier: str """ response = self.get_conn().describe_cluster_snapshots( ClusterIden...
python
{ "resource": "" }
q266176
RedshiftHook.restore_from_cluster_snapshot
test
def restore_from_cluster_snapshot(self, cluster_identifier, snapshot_identifier): """ Restores a cluster from its snapshot :param cluster_identifier: unique identifier of a cluster :type cluster_identifier: str :param snapshot_identifier: unique identifier for a snapshot of a cl...
python
{ "resource": "" }
q266177
RedshiftHook.create_cluster_snapshot
test
def create_cluster_snapshot(self, snapshot_identifier, cluster_identifier): """ Creates a snapshot of a cluster :param snapshot_identifier: unique identifier for a snapshot of a cluster :type snapshot_identifier: str :param cluster_identifier: unique identifier of a cluster ...
python
{ "resource": "" }
q266178
SlackAPIOperator.execute
test
def execute(self, **kwargs): """ SlackAPIOperator calls will not fail even if the call is not unsuccessful. It should not prevent a DAG from completing in success """ if not self.api_params: self.construct_api_call_params() slack = SlackHook(token=self.token, ...
python
{ "resource": "" }
q266179
EmrHook.create_job_flow
test
def create_job_flow(self, job_flow_overrides): """ Creates a job flow using the config from the EMR connection. Keys of the json extra hash may have the arguments of the boto3 run_job_flow method. Overrides for this config may be passed as the job_flow_overrides. """ ...
python
{ "resource": "" }
q266180
HdfsSensor.filter_for_filesize
test
def filter_for_filesize(result, size=None): """ Will test the filepath result and test if its size is at least self.filesize :param result: a list of dicts returned by Snakebite ls :param size: the file size in MB a file should be at least to trigger True :return: (bool) dependi...
python
{ "resource": "" }
q266181
HdfsSensor.filter_for_ignored_ext
test
def filter_for_ignored_ext(result, ignored_ext, ignore_copying): """ Will filter if instructed to do so the result to remove matching criteria :param result: list of dicts returned by Snakebite ls :type result: list[dict] :param ignored_ext: list of ignored extensions :t...
python
{ "resource": "" }
q266182
MongoToS3Operator.execute
test
def execute(self, context): """ Executed by task_instance at runtime """ s3_conn = S3Hook(self.s3_conn_id) # Grab collection and execute query according to whether or not it is a pipeline if self.is_pipeline: results = MongoHook(self.mongo_conn_id).aggregate(...
python
{ "resource": "" }
q266183
get_pool
test
def get_pool(name, session=None): """Get pool by a given name.""" if not (name and name.strip()): raise AirflowBadRequest("Pool name shouldn't be empty") pool = session.query(Pool).filter_by(pool=name).first() if pool is None: raise PoolNotFound("Pool '%s' doesn't exist" % name) re...
python
{ "resource": "" }
q266184
create_pool
test
def create_pool(name, slots, description, session=None): """Create a pool with a given parameters.""" if not (name and name.strip()): raise AirflowBadRequest("Pool name shouldn't be empty") try: slots = int(slots) except ValueError: raise AirflowBadRequest("Bad value for `slots`...
python
{ "resource": "" }
q266185
delete_pool
test
def delete_pool(name, session=None): """Delete pool by a given name.""" if not (name and name.strip()): raise AirflowBadRequest("Pool name shouldn't be empty") pool = session.query(Pool).filter_by(pool=name).first() if pool is None: raise PoolNotFound("Pool '%s' doesn't exist" % name) ...
python
{ "resource": "" }
q266186
GKEClusterHook._dict_to_proto
test
def _dict_to_proto(py_dict, proto): """ Converts a python dictionary to the proto supplied :param py_dict: The dictionary to convert :type py_dict: dict :param proto: The proto object to merge with dictionary :type proto: protobuf :return: A parsed python diction...
python
{ "resource": "" }
q266187
GKEClusterHook.wait_for_operation
test
def wait_for_operation(self, operation, project_id=None): """ Given an operation, continuously fetches the status from Google Cloud until either completion or an error occurring :param operation: The Operation to wait for :type operation: google.cloud.container_V1.gapic.enums.Op...
python
{ "resource": "" }
q266188
GKEClusterHook.get_operation
test
def get_operation(self, operation_name, project_id=None): """ Fetches the operation from Google Cloud :param operation_name: Name of operation to fetch :type operation_name: str :param project_id: Google Cloud Platform project ID :type project_id: str :return: Th...
python
{ "resource": "" }
q266189
GKEClusterHook._append_label
test
def _append_label(cluster_proto, key, val): """ Append labels to provided Cluster Protobuf Labels must fit the regex ``[a-z]([-a-z0-9]*[a-z0-9])?`` (current airflow version string follows semantic versioning spec: x.y.z). :param cluster_proto: The proto to append resource_labe...
python
{ "resource": "" }
q266190
GKEClusterHook.create_cluster
test
def create_cluster(self, cluster, project_id=None, retry=DEFAULT, timeout=DEFAULT): """ Creates a cluster, consisting of the specified number and type of Google Compute Engine instances. :param cluster: A Cluster protobuf or dict. If dict is provided, it must be of the same ...
python
{ "resource": "" }
q266191
GKEClusterHook.get_cluster
test
def get_cluster(self, name, project_id=None, retry=DEFAULT, timeout=DEFAULT): """ Gets details of specified cluster :param name: The name of the cluster to retrieve :type name: str :param project_id: Google Cloud Platform project ID :type project_id: str :param r...
python
{ "resource": "" }
q266192
DiscordWebhookHook._get_webhook_endpoint
test
def _get_webhook_endpoint(self, http_conn_id, webhook_endpoint): """ Given a Discord http_conn_id, return the default webhook endpoint or override if a webhook_endpoint is manually supplied. :param http_conn_id: The provided connection ID :param webhook_endpoint: The manually pr...
python
{ "resource": "" }
q266193
DiscordWebhookHook._build_discord_payload
test
def _build_discord_payload(self): """ Construct the Discord JSON payload. All relevant parameters are combined here to a valid Discord JSON payload. :return: Discord payload (str) to send """ payload = {} if self.username: payload['username'] = self....
python
{ "resource": "" }
q266194
DiscordWebhookHook.execute
test
def execute(self): """ Execute the Discord webhook call """ proxies = {} if self.proxy: # we only need https proxy for Discord proxies = {'https': self.proxy} discord_payload = self._build_discord_payload() self.run(endpoint=self.webhook_...
python
{ "resource": "" }
q266195
GoogleCloudKMSHook.encrypt
test
def encrypt(self, key_name, plaintext, authenticated_data=None): """ Encrypts a plaintext message using Google Cloud KMS. :param key_name: The Resource Name for the key (or key version) to be used for encyption. Of the form ``projects/*/location...
python
{ "resource": "" }
q266196
SqoopHook.import_table
test
def import_table(self, table, target_dir=None, append=False, file_type="text", columns=None, split_by=None, where=None, direct=False, driver=None, extra_import_options=None): """ Imports table from remote location to target dir. Arguments are copies of d...
python
{ "resource": "" }
q266197
SqoopHook.import_query
test
def import_query(self, query, target_dir, append=False, file_type="text", split_by=None, direct=None, driver=None, extra_import_options=None): """ Imports a specific query from the rdbms to hdfs :param query: Free format query to run :param target_dir: HDFS destinat...
python
{ "resource": "" }
q266198
SqoopHook.export_table
test
def export_table(self, table, export_dir, input_null_string, input_null_non_string, staging_table, clear_staging_table, enclosed_by, escaped_by, input_fields_terminated_by, input_lines_terminated_by, input_optionall...
python
{ "resource": "" }
q266199
GCPTextToSpeechHook.get_conn
test
def get_conn(self): """ Retrieves connection to Cloud Text to Speech. :return: Google Cloud Text to Speech client object. :rtype: google.cloud.texttospeech_v1.TextToSpeechClient """ if not self._client: self._client = TextToSpeechClient(credentials=self._get_...
python
{ "resource": "" }