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 | AirflowSecurityManager._sync_dag_view_permissions | 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 value is a set() of permission names (e.g.,
{'can_dag_read'}
... | airflow/www/security.py | 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 ... | 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 ... | [
"Set",
"the",
"access",
"policy",
"on",
"the",
"given",
"DAG",
"s",
"ViewModel",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/security.py#L500-L560 | [
"def",
"_sync_dag_view_permissions",
"(",
"self",
",",
"dag_id",
",",
"access_control",
")",
":",
"def",
"_get_or_create_dag_permission",
"(",
"perm_name",
")",
":",
"dag_perm",
"=",
"self",
".",
"find_permission_view_menu",
"(",
"perm_name",
",",
"dag_id",
")",
"... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | AirflowSecurityManager.create_perm_vm_for_all_dag | Create perm-vm if not exist and insert into FAB security model for all-dags. | airflow/www/security.py | 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... | 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... | [
"Create",
"perm",
"-",
"vm",
"if",
"not",
"exist",
"and",
"insert",
"into",
"FAB",
"security",
"model",
"for",
"all",
"-",
"dags",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/security.py#L562-L570 | [
"def",
"create_perm_vm_for_all_dag",
"(",
"self",
")",
":",
"# create perm for global logical dag",
"for",
"dag_vm",
"in",
"self",
".",
"DAG_VMS",
":",
"for",
"perm",
"in",
"self",
".",
"DAG_PERMS",
":",
"self",
".",
"_merge_perm",
"(",
"permission_name",
"=",
"... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | 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 | airflow/models/crypto.py | 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... | 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... | [
"Deferred",
"load",
"of",
"Fernet",
"key",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/models/crypto.py#L54-L97 | [
"def",
"get_fernet",
"(",
")",
":",
"global",
"_fernet",
"log",
"=",
"LoggingMixin",
"(",
")",
".",
"log",
"if",
"_fernet",
":",
"return",
"_fernet",
"try",
":",
"from",
"cryptography",
".",
"fernet",
"import",
"Fernet",
",",
"MultiFernet",
",",
"InvalidTo... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | AwsGlueCatalogPartitionSensor.poke | Checks for existence of the partition in the AWS Glue Catalog table | airflow/contrib/sensors/aws_glue_catalog_partition_sensor.py | 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... | 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... | [
"Checks",
"for",
"existence",
"of",
"the",
"partition",
"in",
"the",
"AWS",
"Glue",
"Catalog",
"table"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/sensors/aws_glue_catalog_partition_sensor.py#L70-L81 | [
"def",
"poke",
"(",
"self",
",",
"context",
")",
":",
"if",
"'.'",
"in",
"self",
".",
"table_name",
":",
"self",
".",
"database_name",
",",
"self",
".",
"table_name",
"=",
"self",
".",
"table_name",
".",
"split",
"(",
"'.'",
")",
"self",
".",
"log",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | AwsGlueCatalogPartitionSensor.get_hook | Gets the AwsGlueCatalogHook | airflow/contrib/sensors/aws_glue_catalog_partition_sensor.py | 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... | 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... | [
"Gets",
"the",
"AwsGlueCatalogHook"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/sensors/aws_glue_catalog_partition_sensor.py#L83-L93 | [
"def",
"get_hook",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'hook'",
")",
":",
"from",
"airflow",
".",
"contrib",
".",
"hooks",
".",
"aws_glue_catalog_hook",
"import",
"AwsGlueCatalogHook",
"self",
".",
"hook",
"=",
"AwsGlueCatalogHo... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | SQSSensor.poke | 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`` | airflow/contrib/sensors/aws_sqs_sensor.py | 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... | 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... | [
"Check",
"for",
"message",
"on",
"subscribed",
"queue",
"and",
"write",
"to",
"xcom",
"the",
"message",
"with",
"key",
"messages"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/sensors/aws_sqs_sensor.py#L58-L93 | [
"def",
"poke",
"(",
"self",
",",
"context",
")",
":",
"sqs_hook",
"=",
"SQSHook",
"(",
"aws_conn_id",
"=",
"self",
".",
"aws_conn_id",
")",
"sqs_conn",
"=",
"sqs_hook",
".",
"get_conn",
"(",
")",
"self",
".",
"log",
".",
"info",
"(",
"'SQSSensor checking... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | tmp_configuration_copy | Returns a path for a temporary file including a full copy of the configuration
settings.
:return: a path to a temporary file | airflow/utils/configuration.py | def tmp_configuration_copy(chmod=0o600):
"""
Returns a path for a temporary file including a full copy of the configuration
settings.
:return: a path to a temporary file
"""
cfg_dict = conf.as_dict(display_sensitive=True, raw=True)
temp_fd, cfg_path = mkstemp()
with os.fdopen(temp_fd, '... | def tmp_configuration_copy(chmod=0o600):
"""
Returns a path for a temporary file including a full copy of the configuration
settings.
:return: a path to a temporary file
"""
cfg_dict = conf.as_dict(display_sensitive=True, raw=True)
temp_fd, cfg_path = mkstemp()
with os.fdopen(temp_fd, '... | [
"Returns",
"a",
"path",
"for",
"a",
"temporary",
"file",
"including",
"a",
"full",
"copy",
"of",
"the",
"configuration",
"settings",
".",
":",
"return",
":",
"a",
"path",
"to",
"a",
"temporary",
"file"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/configuration.py#L27-L41 | [
"def",
"tmp_configuration_copy",
"(",
"chmod",
"=",
"0o600",
")",
":",
"cfg_dict",
"=",
"conf",
".",
"as_dict",
"(",
"display_sensitive",
"=",
"True",
",",
"raw",
"=",
"True",
")",
"temp_fd",
",",
"cfg_path",
"=",
"mkstemp",
"(",
")",
"with",
"os",
".",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | HDFSHook.get_conn | Returns a snakebite HDFSClient object. | airflow/hooks/hdfs_hook.py | 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... | 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... | [
"Returns",
"a",
"snakebite",
"HDFSClient",
"object",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/hdfs_hook.py#L57-L98 | [
"def",
"get_conn",
"(",
"self",
")",
":",
"# 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",
".",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | WebHDFSHook.get_conn | 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 | airflow/hooks/webhdfs_hook.py | 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_... | 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_... | [
"Establishes",
"a",
"connection",
"depending",
"on",
"the",
"security",
"mode",
"set",
"via",
"config",
"or",
"environment",
"variable",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/webhdfs_hook.py#L56-L79 | [
"def",
"get_conn",
"(",
"self",
")",
":",
"connections",
"=",
"self",
".",
"get_connections",
"(",
"self",
".",
"webhdfs_conn_id",
")",
"for",
"connection",
"in",
"connections",
":",
"try",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Trying namenode %s'",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | WebHDFSHook.check_for_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 | airflow/hooks/webhdfs_hook.py | 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()... | 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()... | [
"Check",
"for",
"the",
"existence",
"of",
"a",
"path",
"in",
"HDFS",
"by",
"querying",
"FileStatus",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/webhdfs_hook.py#L92-L104 | [
"def",
"check_for_path",
"(",
"self",
",",
"hdfs_path",
")",
":",
"conn",
"=",
"self",
".",
"get_conn",
"(",
")",
"status",
"=",
"conn",
".",
"status",
"(",
"hdfs_path",
",",
"strict",
"=",
"False",
")",
"return",
"bool",
"(",
"status",
")"
] | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | WebHDFSHook.load_file | 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 will not be created remotely.
:type source: str
:param destination: PTarge... | airflow/hooks/webhdfs_hook.py | 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 ... | 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 ... | [
"r",
"Uploads",
"a",
"file",
"to",
"HDFS",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/webhdfs_hook.py#L106-L132 | [
"def",
"load_file",
"(",
"self",
",",
"source",
",",
"destination",
",",
"overwrite",
"=",
"True",
",",
"parallelism",
"=",
"1",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"self",
".",
"get_conn",
"(",
")",
"conn",
".",
"upload",
"(",
"hdfs_path... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | PinotDbApiHook.get_conn | Establish a connection to pinot broker through pinot dbqpi. | airflow/contrib/hooks/pinot_hook.py | 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', '/... | 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', '/... | [
"Establish",
"a",
"connection",
"to",
"pinot",
"broker",
"through",
"pinot",
"dbqpi",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/pinot_hook.py#L36-L49 | [
"def",
"get_conn",
"(",
"self",
")",
":",
"conn",
"=",
"self",
".",
"get_connection",
"(",
"self",
".",
"pinot_broker_conn_id",
")",
"pinot_broker_conn",
"=",
"connect",
"(",
"host",
"=",
"conn",
".",
"host",
",",
"port",
"=",
"conn",
".",
"port",
",",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | PinotDbApiHook.get_uri | Get the connection uri for pinot broker.
e.g: http://localhost:9000/pql | airflow/contrib/hooks/pinot_hook.py | 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)
... | 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)
... | [
"Get",
"the",
"connection",
"uri",
"for",
"pinot",
"broker",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/pinot_hook.py#L51-L64 | [
"def",
"get_uri",
"(",
"self",
")",
":",
"conn",
"=",
"self",
".",
"get_connection",
"(",
"getattr",
"(",
"self",
",",
"self",
".",
"conn_name_attr",
")",
")",
"host",
"=",
"conn",
".",
"host",
"if",
"conn",
".",
"port",
"is",
"not",
"None",
":",
"... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | PinotDbApiHook.get_records | Executes the sql and returns a set of records.
:param sql: the sql statement to be executed (str) or a list of
sql statements to execute
:type sql: str | airflow/contrib/hooks/pinot_hook.py | def get_records(self, sql):
"""
Executes the sql and returns a set of records.
:param sql: the sql statement to be executed (str) or a list of
sql statements to execute
:type sql: str
"""
with self.get_conn() as cur:
cur.execute(sql)
r... | def get_records(self, sql):
"""
Executes the sql and returns a set of records.
:param sql: the sql statement to be executed (str) or a list of
sql statements to execute
:type sql: str
"""
with self.get_conn() as cur:
cur.execute(sql)
r... | [
"Executes",
"the",
"sql",
"and",
"returns",
"a",
"set",
"of",
"records",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/pinot_hook.py#L66-L76 | [
"def",
"get_records",
"(",
"self",
",",
"sql",
")",
":",
"with",
"self",
".",
"get_conn",
"(",
")",
"as",
"cur",
":",
"cur",
".",
"execute",
"(",
"sql",
")",
"return",
"cur",
".",
"fetchall",
"(",
")"
] | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | PinotDbApiHook.get_first | Executes the sql and returns the first resulting row.
:param sql: the sql statement to be executed (str) or a list of
sql statements to execute
:type sql: str or list | airflow/contrib/hooks/pinot_hook.py | def get_first(self, sql):
"""
Executes the sql and returns the first resulting row.
:param sql: the sql statement to be executed (str) or a list of
sql statements to execute
:type sql: str or list
"""
with self.get_conn() as cur:
cur.execute(sql)
... | def get_first(self, sql):
"""
Executes the sql and returns the first resulting row.
:param sql: the sql statement to be executed (str) or a list of
sql statements to execute
:type sql: str or list
"""
with self.get_conn() as cur:
cur.execute(sql)
... | [
"Executes",
"the",
"sql",
"and",
"returns",
"the",
"first",
"resulting",
"row",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/pinot_hook.py#L78-L88 | [
"def",
"get_first",
"(",
"self",
",",
"sql",
")",
":",
"with",
"self",
".",
"get_conn",
"(",
")",
"as",
"cur",
":",
"cur",
".",
"execute",
"(",
"sql",
")",
"return",
"cur",
".",
"fetchone",
"(",
")"
] | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | smart_truncate | Truncate a string.
:param string (str): string for modification
:param max_length (int): output string length
:param word_boundary (bool):
:param save_order (bool): if True then word order of output string is like input string
:param separator (str): separator between words
:return: | airflow/_vendor/slugify/slugify.py | def smart_truncate(string, max_length=0, word_boundary=False, separator=' ', save_order=False):
"""
Truncate a string.
:param string (str): string for modification
:param max_length (int): output string length
:param word_boundary (bool):
:param save_order (bool): if True then word order of outp... | def smart_truncate(string, max_length=0, word_boundary=False, separator=' ', save_order=False):
"""
Truncate a string.
:param string (str): string for modification
:param max_length (int): output string length
:param word_boundary (bool):
:param save_order (bool): if True then word order of outp... | [
"Truncate",
"a",
"string",
".",
":",
"param",
"string",
"(",
"str",
")",
":",
"string",
"for",
"modification",
":",
"param",
"max_length",
"(",
"int",
")",
":",
"output",
"string",
"length",
":",
"param",
"word_boundary",
"(",
"bool",
")",
":",
":",
"p... | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/_vendor/slugify/slugify.py#L32-L71 | [
"def",
"smart_truncate",
"(",
"string",
",",
"max_length",
"=",
"0",
",",
"word_boundary",
"=",
"False",
",",
"separator",
"=",
"' '",
",",
"save_order",
"=",
"False",
")",
":",
"string",
"=",
"string",
".",
"strip",
"(",
"separator",
")",
"if",
"not",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | slugify | Make a slug from the given text.
:param text (str): initial text
:param entities (bool):
:param decimal (bool):
:param hexadecimal (bool):
:param max_length (int): output string length
:param word_boundary (bool):
:param save_order (bool): if parameter is True and max_length > 0 return whole... | airflow/_vendor/slugify/slugify.py | def slugify(text, entities=True, decimal=True, hexadecimal=True, max_length=0, word_boundary=False,
separator=DEFAULT_SEPARATOR, save_order=False, stopwords=(), regex_pattern=None, lowercase=True,
replacements=()):
"""
Make a slug from the given text.
:param text (str): initial text
... | def slugify(text, entities=True, decimal=True, hexadecimal=True, max_length=0, word_boundary=False,
separator=DEFAULT_SEPARATOR, save_order=False, stopwords=(), regex_pattern=None, lowercase=True,
replacements=()):
"""
Make a slug from the given text.
:param text (str): initial text
... | [
"Make",
"a",
"slug",
"from",
"the",
"given",
"text",
".",
":",
"param",
"text",
"(",
"str",
")",
":",
"initial",
"text",
":",
"param",
"entities",
"(",
"bool",
")",
":",
":",
"param",
"decimal",
"(",
"bool",
")",
":",
":",
"param",
"hexadecimal",
"... | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/_vendor/slugify/slugify.py#L74-L175 | [
"def",
"slugify",
"(",
"text",
",",
"entities",
"=",
"True",
",",
"decimal",
"=",
"True",
",",
"hexadecimal",
"=",
"True",
",",
"max_length",
"=",
"0",
",",
"word_boundary",
"=",
"False",
",",
"separator",
"=",
"DEFAULT_SEPARATOR",
",",
"save_order",
"=",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | XCom.set | Store an XCom value.
TODO: "pickling" has been deprecated and JSON is preferred.
"pickling" will be removed in Airflow 2.0.
:return: None | airflow/models/xcom.py | def set(
cls,
key,
value,
execution_date,
task_id,
dag_id,
session=None):
"""
Store an XCom value.
TODO: "pickling" has been deprecated and JSON is preferred.
"pickling" will be removed in Airflow 2.0.
... | def set(
cls,
key,
value,
execution_date,
task_id,
dag_id,
session=None):
"""
Store an XCom value.
TODO: "pickling" has been deprecated and JSON is preferred.
"pickling" will be removed in Airflow 2.0.
... | [
"Store",
"an",
"XCom",
"value",
".",
"TODO",
":",
"pickling",
"has",
"been",
"deprecated",
"and",
"JSON",
"is",
"preferred",
".",
"pickling",
"will",
"be",
"removed",
"in",
"Airflow",
"2",
".",
"0",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/models/xcom.py#L88-L136 | [
"def",
"set",
"(",
"cls",
",",
"key",
",",
"value",
",",
"execution_date",
",",
"task_id",
",",
"dag_id",
",",
"session",
"=",
"None",
")",
":",
"session",
".",
"expunge_all",
"(",
")",
"enable_pickling",
"=",
"configuration",
".",
"getboolean",
"(",
"'c... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | XCom.get_one | Retrieve an XCom value, optionally meeting certain criteria.
TODO: "pickling" has been deprecated and JSON is preferred.
"pickling" will be removed in Airflow 2.0.
:return: XCom value | airflow/models/xcom.py | def get_one(cls,
execution_date,
key=None,
task_id=None,
dag_id=None,
include_prior_dates=False,
session=None):
"""
Retrieve an XCom value, optionally meeting certain criteria.
TODO: "pickling" has be... | def get_one(cls,
execution_date,
key=None,
task_id=None,
dag_id=None,
include_prior_dates=False,
session=None):
"""
Retrieve an XCom value, optionally meeting certain criteria.
TODO: "pickling" has be... | [
"Retrieve",
"an",
"XCom",
"value",
"optionally",
"meeting",
"certain",
"criteria",
".",
"TODO",
":",
"pickling",
"has",
"been",
"deprecated",
"and",
"JSON",
"is",
"preferred",
".",
"pickling",
"will",
"be",
"removed",
"in",
"Airflow",
"2",
".",
"0",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/models/xcom.py#L140-L184 | [
"def",
"get_one",
"(",
"cls",
",",
"execution_date",
",",
"key",
"=",
"None",
",",
"task_id",
"=",
"None",
",",
"dag_id",
"=",
"None",
",",
"include_prior_dates",
"=",
"False",
",",
"session",
"=",
"None",
")",
":",
"filters",
"=",
"[",
"]",
"if",
"k... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | XCom.get_many | Retrieve an XCom value, optionally meeting certain criteria
TODO: "pickling" has been deprecated and JSON is preferred.
"pickling" will be removed in Airflow 2.0. | airflow/models/xcom.py | def get_many(cls,
execution_date,
key=None,
task_ids=None,
dag_ids=None,
include_prior_dates=False,
limit=100,
session=None):
"""
Retrieve an XCom value, optionally meeting certain crit... | def get_many(cls,
execution_date,
key=None,
task_ids=None,
dag_ids=None,
include_prior_dates=False,
limit=100,
session=None):
"""
Retrieve an XCom value, optionally meeting certain crit... | [
"Retrieve",
"an",
"XCom",
"value",
"optionally",
"meeting",
"certain",
"criteria",
"TODO",
":",
"pickling",
"has",
"been",
"deprecated",
"and",
"JSON",
"is",
"preferred",
".",
"pickling",
"will",
"be",
"removed",
"in",
"Airflow",
"2",
".",
"0",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/models/xcom.py#L188-L218 | [
"def",
"get_many",
"(",
"cls",
",",
"execution_date",
",",
"key",
"=",
"None",
",",
"task_ids",
"=",
"None",
",",
"dag_ids",
"=",
"None",
",",
"include_prior_dates",
"=",
"False",
",",
"limit",
"=",
"100",
",",
"session",
"=",
"None",
")",
":",
"filter... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | TransferJobPreprocessor._convert_date_to_dict | Convert native python ``datetime.date`` object to a format supported by the API | airflow/contrib/operators/gcp_transfer_operator.py | 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} | 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} | [
"Convert",
"native",
"python",
"datetime",
".",
"date",
"object",
"to",
"a",
"format",
"supported",
"by",
"the",
"API"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/gcp_transfer_operator.py#L106-L110 | [
"def",
"_convert_date_to_dict",
"(",
"field_date",
")",
":",
"return",
"{",
"DAY",
":",
"field_date",
".",
"day",
",",
"MONTH",
":",
"field_date",
".",
"month",
",",
"YEAR",
":",
"field_date",
".",
"year",
"}"
] | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | TransferJobPreprocessor._convert_time_to_dict | Convert native python ``datetime.time`` object to a format supported by the API | airflow/contrib/operators/gcp_transfer_operator.py | 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} | 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} | [
"Convert",
"native",
"python",
"datetime",
".",
"time",
"object",
"to",
"a",
"format",
"supported",
"by",
"the",
"API"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/gcp_transfer_operator.py#L113-L117 | [
"def",
"_convert_time_to_dict",
"(",
"time",
")",
":",
"return",
"{",
"HOURS",
":",
"time",
".",
"hour",
",",
"MINUTES",
":",
"time",
".",
"minute",
",",
"SECONDS",
":",
"time",
".",
"second",
"}"
] | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | RedisHook.get_conn | Returns a Redis connection. | airflow/contrib/hooks/redis_hook.py | 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... | 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... | [
"Returns",
"a",
"Redis",
"connection",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/redis_hook.py#L45-L66 | [
"def",
"get_conn",
"(",
"self",
")",
":",
"conn",
"=",
"self",
".",
"get_connection",
"(",
"self",
".",
"redis_conn_id",
")",
"self",
".",
"host",
"=",
"conn",
".",
"host",
"self",
".",
"port",
"=",
"conn",
".",
"port",
"self",
".",
"password",
"=",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | OracleHook.get_conn | Returns a oracle connection object
Optional parameters for using a custom DSN connection
(instead of using a server alias from tnsnames.ora)
The dsn (data source name) is the TNS entry
(from the Oracle names server or tnsnames.ora file)
or is a string like the one returned from m... | airflow/hooks/oracle_hook.py | def get_conn(self):
"""
Returns a oracle connection object
Optional parameters for using a custom DSN connection
(instead of using a server alias from tnsnames.ora)
The dsn (data source name) is the TNS entry
(from the Oracle names server or tnsnames.ora file)
or ... | def get_conn(self):
"""
Returns a oracle connection object
Optional parameters for using a custom DSN connection
(instead of using a server alias from tnsnames.ora)
The dsn (data source name) is the TNS entry
(from the Oracle names server or tnsnames.ora file)
or ... | [
"Returns",
"a",
"oracle",
"connection",
"object",
"Optional",
"parameters",
"for",
"using",
"a",
"custom",
"DSN",
"connection",
"(",
"instead",
"of",
"using",
"a",
"server",
"alias",
"from",
"tnsnames",
".",
"ora",
")",
"The",
"dsn",
"(",
"data",
"source",
... | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/oracle_hook.py#L37-L115 | [
"def",
"get_conn",
"(",
"self",
")",
":",
"conn",
"=",
"self",
".",
"get_connection",
"(",
"self",
".",
"oracle_conn_id",
")",
"conn_config",
"=",
"{",
"'user'",
":",
"conn",
".",
"login",
",",
"'password'",
":",
"conn",
".",
"password",
"}",
"dsn",
"=... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | OracleHook.insert_rows | A generic way to insert a set of tuples into a table,
the whole set of inserts is treated as one transaction
Changes from standard DbApiHook implementation:
- Oracle SQL queries in cx_Oracle can not be terminated with a semicolon (`;`)
- Replace NaN values with NULL using `numpy.nan_to_... | airflow/hooks/oracle_hook.py | def insert_rows(self, table, rows, target_fields=None, commit_every=1000):
"""
A generic way to insert a set of tuples into a table,
the whole set of inserts is treated as one transaction
Changes from standard DbApiHook implementation:
- Oracle SQL queries in cx_Oracle can not b... | def insert_rows(self, table, rows, target_fields=None, commit_every=1000):
"""
A generic way to insert a set of tuples into a table,
the whole set of inserts is treated as one transaction
Changes from standard DbApiHook implementation:
- Oracle SQL queries in cx_Oracle can not b... | [
"A",
"generic",
"way",
"to",
"insert",
"a",
"set",
"of",
"tuples",
"into",
"a",
"table",
"the",
"whole",
"set",
"of",
"inserts",
"is",
"treated",
"as",
"one",
"transaction",
"Changes",
"from",
"standard",
"DbApiHook",
"implementation",
":"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/oracle_hook.py#L117-L182 | [
"def",
"insert_rows",
"(",
"self",
",",
"table",
",",
"rows",
",",
"target_fields",
"=",
"None",
",",
"commit_every",
"=",
"1000",
")",
":",
"if",
"target_fields",
":",
"target_fields",
"=",
"', '",
".",
"join",
"(",
"target_fields",
")",
"target_fields",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | OracleHook.bulk_insert_rows | A performant bulk insert for cx_Oracle
that uses prepared statements via `executemany()`.
For best performance, pass in `rows` as an iterator.
:param table: target Oracle table, use dot notation to target a
specific database
:type table: str
:param rows: the rows to ... | airflow/hooks/oracle_hook.py | def bulk_insert_rows(self, table, rows, target_fields=None, commit_every=5000):
"""
A performant bulk insert for cx_Oracle
that uses prepared statements via `executemany()`.
For best performance, pass in `rows` as an iterator.
:param table: target Oracle table, use dot notation ... | def bulk_insert_rows(self, table, rows, target_fields=None, commit_every=5000):
"""
A performant bulk insert for cx_Oracle
that uses prepared statements via `executemany()`.
For best performance, pass in `rows` as an iterator.
:param table: target Oracle table, use dot notation ... | [
"A",
"performant",
"bulk",
"insert",
"for",
"cx_Oracle",
"that",
"uses",
"prepared",
"statements",
"via",
"executemany",
"()",
".",
"For",
"best",
"performance",
"pass",
"in",
"rows",
"as",
"an",
"iterator",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/oracle_hook.py#L184-L231 | [
"def",
"bulk_insert_rows",
"(",
"self",
",",
"table",
",",
"rows",
",",
"target_fields",
"=",
"None",
",",
"commit_every",
"=",
"5000",
")",
":",
"if",
"not",
"rows",
":",
"raise",
"ValueError",
"(",
"\"parameter rows could not be None or empty iterable\"",
")",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | DbApiHook.get_conn | Returns a connection object | airflow/hooks/dbapi_hook.py | def get_conn(self):
"""Returns a connection object
"""
db = self.get_connection(getattr(self, self.conn_name_attr))
return self.connector.connect(
host=db.host,
port=db.port,
username=db.login,
schema=db.schema) | def get_conn(self):
"""Returns a connection object
"""
db = self.get_connection(getattr(self, self.conn_name_attr))
return self.connector.connect(
host=db.host,
port=db.port,
username=db.login,
schema=db.schema) | [
"Returns",
"a",
"connection",
"object"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/dbapi_hook.py#L55-L63 | [
"def",
"get_conn",
"(",
"self",
")",
":",
"db",
"=",
"self",
".",
"get_connection",
"(",
"getattr",
"(",
"self",
",",
"self",
".",
"conn_name_attr",
")",
")",
"return",
"self",
".",
"connector",
".",
"connect",
"(",
"host",
"=",
"db",
".",
"host",
",... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | DbApiHook.get_pandas_df | 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 query with.
:type parameters: mapping or iterable | airflow/hooks/dbapi_hook.py | 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... | 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... | [
"Executes",
"the",
"sql",
"and",
"returns",
"a",
"pandas",
"dataframe"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/dbapi_hook.py#L81-L94 | [
"def",
"get_pandas_df",
"(",
"self",
",",
"sql",
",",
"parameters",
"=",
"None",
")",
":",
"import",
"pandas",
".",
"io",
".",
"sql",
"as",
"psql",
"with",
"closing",
"(",
"self",
".",
"get_conn",
"(",
")",
")",
"as",
"conn",
":",
"return",
"psql",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | DbApiHook.get_records | Executes the sql and returns a set of records.
: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 query with.
:type parameters: mapping or iterable | airflow/hooks/dbapi_hook.py | def get_records(self, sql, parameters=None):
"""
Executes the sql and returns a set of records.
: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 query ... | def get_records(self, sql, parameters=None):
"""
Executes the sql and returns a set of records.
: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 query ... | [
"Executes",
"the",
"sql",
"and",
"returns",
"a",
"set",
"of",
"records",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/dbapi_hook.py#L96-L112 | [
"def",
"get_records",
"(",
"self",
",",
"sql",
",",
"parameters",
"=",
"None",
")",
":",
"with",
"closing",
"(",
"self",
".",
"get_conn",
"(",
")",
")",
"as",
"conn",
":",
"with",
"closing",
"(",
"conn",
".",
"cursor",
"(",
")",
")",
"as",
"cur",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | DbApiHook.get_first | Executes the sql and returns the first resulting row.
: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 query with.
:type parameters: mapping or iterable | airflow/hooks/dbapi_hook.py | def get_first(self, sql, parameters=None):
"""
Executes the sql and returns the first resulting row.
: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 q... | def get_first(self, sql, parameters=None):
"""
Executes the sql and returns the first resulting row.
: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 q... | [
"Executes",
"the",
"sql",
"and",
"returns",
"the",
"first",
"resulting",
"row",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/dbapi_hook.py#L114-L130 | [
"def",
"get_first",
"(",
"self",
",",
"sql",
",",
"parameters",
"=",
"None",
")",
":",
"with",
"closing",
"(",
"self",
".",
"get_conn",
"(",
")",
")",
"as",
"conn",
":",
"with",
"closing",
"(",
"conn",
".",
"cursor",
"(",
")",
")",
"as",
"cur",
"... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | DbApiHook.run | 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 execute
:type sql: str or list
:param autocommit: What to se... | airflow/hooks/dbapi_hook.py | 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... | 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... | [
"Runs",
"a",
"command",
"or",
"a",
"list",
"of",
"commands",
".",
"Pass",
"a",
"list",
"of",
"sql",
"statements",
"to",
"the",
"sql",
"parameter",
"to",
"get",
"them",
"to",
"execute",
"sequentially"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/dbapi_hook.py#L132-L166 | [
"def",
"run",
"(",
"self",
",",
"sql",
",",
"autocommit",
"=",
"False",
",",
"parameters",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"sql",
",",
"basestring",
")",
":",
"sql",
"=",
"[",
"sql",
"]",
"with",
"closing",
"(",
"self",
".",
"get_co... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | DbApiHook.set_autocommit | Sets the autocommit flag on the connection | airflow/hooks/dbapi_hook.py | 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."),
... | 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."),
... | [
"Sets",
"the",
"autocommit",
"flag",
"on",
"the",
"connection"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/dbapi_hook.py#L168-L177 | [
"def",
"set_autocommit",
"(",
"self",
",",
"conn",
",",
"autocommit",
")",
":",
"if",
"not",
"self",
".",
"supports_autocommit",
"and",
"autocommit",
":",
"self",
".",
"log",
".",
"warn",
"(",
"(",
"\"%s connection doesn't support \"",
"\"autocommit but autocommit... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | DbApiHook.insert_rows | 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
:param rows: The rows to insert into the table
:type rows: iterable of tuples
:param target_fields: The name... | airflow/hooks/dbapi_hook.py | 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
... | 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
... | [
"A",
"generic",
"way",
"to",
"insert",
"a",
"set",
"of",
"tuples",
"into",
"a",
"table",
"a",
"new",
"transaction",
"is",
"created",
"every",
"commit_every",
"rows"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/dbapi_hook.py#L200-L253 | [
"def",
"insert_rows",
"(",
"self",
",",
"table",
",",
"rows",
",",
"target_fields",
"=",
"None",
",",
"commit_every",
"=",
"1000",
",",
"replace",
"=",
"False",
")",
":",
"if",
"target_fields",
":",
"target_fields",
"=",
"\", \"",
".",
"join",
"(",
"targ... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | DbApiHook._serialize_cell | 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
:rtype: str | airflow/hooks/dbapi_hook.py | 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... | 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... | [
"Returns",
"the",
"SQL",
"literal",
"of",
"the",
"cell",
"as",
"a",
"string",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/dbapi_hook.py#L256-L272 | [
"def",
"_serialize_cell",
"(",
"cell",
",",
"conn",
"=",
"None",
")",
":",
"if",
"cell",
"is",
"None",
":",
"return",
"None",
"if",
"isinstance",
"(",
"cell",
",",
"datetime",
")",
":",
"return",
"cell",
".",
"isoformat",
"(",
")",
"return",
"str",
"... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | Airflow.health | An endpoint helping check the health status of the Airflow instance,
including metadatabase and scheduler. | airflow/www/views.py | 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',
... | 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',
... | [
"An",
"endpoint",
"helping",
"check",
"the",
"health",
"status",
"of",
"the",
"Airflow",
"instance",
"including",
"metadatabase",
"and",
"scheduler",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/views.py#L158-L190 | [
"def",
"health",
"(",
"self",
",",
"session",
"=",
"None",
")",
":",
"BJ",
"=",
"jobs",
".",
"BaseJob",
"payload",
"=",
"{",
"}",
"scheduler_health_check_threshold",
"=",
"timedelta",
"(",
"seconds",
"=",
"conf",
".",
"getint",
"(",
"'scheduler'",
",",
"... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | Airflow.extra_links | 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 in question
task_id: The id of... | airflow/www/views.py | 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... | 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... | [
"A",
"restful",
"endpoint",
"that",
"returns",
"external",
"links",
"for",
"a",
"given",
"Operator"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/views.py#L1772-L1825 | [
"def",
"extra_links",
"(",
"self",
")",
":",
"dag_id",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'dag_id'",
")",
"task_id",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'task_id'",
")",
"execution_date",
"=",
"request",
".",
"args",
".",
"get",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | DagModelView.get_query | Default filters for model | airflow/www/views.py | def get_query(self):
"""
Default filters for model
"""
return (
super().get_query()
.filter(or_(models.DagModel.is_active,
models.DagModel.is_paused))
.filter(~models.DagModel.is_subdag)
) | def get_query(self):
"""
Default filters for model
"""
return (
super().get_query()
.filter(or_(models.DagModel.is_active,
models.DagModel.is_paused))
.filter(~models.DagModel.is_subdag)
) | [
"Default",
"filters",
"for",
"model"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/views.py#L2481-L2490 | [
"def",
"get_query",
"(",
"self",
")",
":",
"return",
"(",
"super",
"(",
")",
".",
"get_query",
"(",
")",
".",
"filter",
"(",
"or_",
"(",
"models",
".",
"DagModel",
".",
"is_active",
",",
"models",
".",
"DagModel",
".",
"is_paused",
")",
")",
".",
"... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | DagModelView.get_count_query | Default filters for model | airflow/www/views.py | def get_count_query(self):
"""
Default filters for model
"""
return (
super().get_count_query()
.filter(models.DagModel.is_active)
.filter(~models.DagModel.is_subdag)
) | def get_count_query(self):
"""
Default filters for model
"""
return (
super().get_count_query()
.filter(models.DagModel.is_active)
.filter(~models.DagModel.is_subdag)
) | [
"Default",
"filters",
"for",
"model"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/views.py#L2492-L2500 | [
"def",
"get_count_query",
"(",
"self",
")",
":",
"return",
"(",
"super",
"(",
")",
".",
"get_count_query",
"(",
")",
".",
"filter",
"(",
"models",
".",
"DagModel",
".",
"is_active",
")",
".",
"filter",
"(",
"~",
"models",
".",
"DagModel",
".",
"is_subd... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudantHook.get_conn | 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)
- 'password' equals the 'Password... | airflow/contrib/hooks/cloudant_hook.py | 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)
... | 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)
... | [
"Opens",
"a",
"connection",
"to",
"the",
"cloudant",
"service",
"and",
"closes",
"it",
"automatically",
"if",
"used",
"as",
"context",
"manager",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/cloudant_hook.py#L40-L59 | [
"def",
"get_conn",
"(",
"self",
")",
":",
"conn",
"=",
"self",
".",
"get_connection",
"(",
"self",
".",
"cloudant_conn_id",
")",
"self",
".",
"_validate_connection",
"(",
"conn",
")",
"cloudant_session",
"=",
"cloudant",
"(",
"user",
"=",
"conn",
".",
"log... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | SlackWebhookOperator.execute | Call the SlackWebhookHook to post the provided Slack message | airflow/contrib/operators/slack_webhook_operator.py | 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... | 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... | [
"Call",
"the",
"SlackWebhookHook",
"to",
"post",
"the",
"provided",
"Slack",
"message"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/slack_webhook_operator.py#L84-L99 | [
"def",
"execute",
"(",
"self",
",",
"context",
")",
":",
"self",
".",
"hook",
"=",
"SlackWebhookHook",
"(",
"self",
".",
"http_conn_id",
",",
"self",
".",
"webhook_token",
",",
"self",
".",
"message",
",",
"self",
".",
"attachments",
",",
"self",
".",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | GoogleCloudBaseHook._get_credentials | Returns the Credentials object for Google API | airflow/contrib/hooks/gcp_api_base_hook.py | 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... | 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... | [
"Returns",
"the",
"Credentials",
"object",
"for",
"Google",
"API"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_api_base_hook.py#L82-L129 | [
"def",
"_get_credentials",
"(",
"self",
")",
":",
"key_path",
"=",
"self",
".",
"_get_field",
"(",
"'key_path'",
",",
"False",
")",
"keyfile_dict",
"=",
"self",
".",
"_get_field",
"(",
"'keyfile_dict'",
",",
"False",
")",
"scope",
"=",
"self",
".",
"_get_f... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | GoogleCloudBaseHook._authorize | Returns an authorized HTTP object to be used to build a Google cloud
service hook connection. | airflow/contrib/hooks/gcp_api_base_hook.py | 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... | 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... | [
"Returns",
"an",
"authorized",
"HTTP",
"object",
"to",
"be",
"used",
"to",
"build",
"a",
"Google",
"cloud",
"service",
"hook",
"connection",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_api_base_hook.py#L137-L146 | [
"def",
"_authorize",
"(",
"self",
")",
":",
"credentials",
"=",
"self",
".",
"_get_credentials",
"(",
")",
"http",
"=",
"httplib2",
".",
"Http",
"(",
")",
"authed_http",
"=",
"google_auth_httplib2",
".",
"AuthorizedHttp",
"(",
"credentials",
",",
"http",
"="... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | GoogleCloudBaseHook._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/hooks/gcp_api_base_hook.py | def _get_field(self, f, 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 formatted as sh... | def _get_field(self, f, 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 formatted as sh... | [
"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/hooks/gcp_api_base_hook.py#L148-L159 | [
"def",
"_get_field",
"(",
"self",
",",
"f",
",",
"default",
"=",
"None",
")",
":",
"long_f",
"=",
"'extra__google_cloud_platform__{}'",
".",
"format",
"(",
"f",
")",
"if",
"hasattr",
"(",
"self",
",",
"'extras'",
")",
"and",
"long_f",
"in",
"self",
".",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | GoogleCloudBaseHook.catch_http_exception | Function decorator that intercepts HTTP Errors and raises AirflowException
with more informative message. | airflow/contrib/hooks/gcp_api_base_hook.py | 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... | 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... | [
"Function",
"decorator",
"that",
"intercepts",
"HTTP",
"Errors",
"and",
"raises",
"AirflowException",
"with",
"more",
"informative",
"message",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_api_base_hook.py#L166-L192 | [
"def",
"catch_http_exception",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper_decorator",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"func",
"(",
"self",
",",
"*",... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | GoogleCloudBaseHook.fallback_to_default_project_id | 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 project_id kwarg or via first parameter in positional args.
... | airflow/contrib/hooks/gcp_api_base_hook.py | 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... | 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... | [
"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",
"i... | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_api_base_hook.py#L195-L220 | [
"def",
"fallback_to_default_project_id",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"inner_wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
">",
"0",
":",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | State.unfinished | A list of states indicating that a task either has not completed
a run or has not even started. | airflow/utils/state.py | 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... | 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... | [
"A",
"list",
"of",
"states",
"indicating",
"that",
"a",
"task",
"either",
"has",
"not",
"completed",
"a",
"run",
"or",
"has",
"not",
"even",
"started",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/state.py#L107-L120 | [
"def",
"unfinished",
"(",
"cls",
")",
":",
"return",
"[",
"cls",
".",
"NONE",
",",
"cls",
".",
"SCHEDULED",
",",
"cls",
".",
"QUEUED",
",",
"cls",
".",
"RUNNING",
",",
"cls",
".",
"SHUTDOWN",
",",
"cls",
".",
"UP_FOR_RETRY",
",",
"cls",
".",
"UP_FO... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | delete_dag | :param dag_id: the dag_id of the DAG to delete
:type dag_id: str
:param keep_records_in_log: whether keep records of the given dag_id
in the Log table in the backend database (for reasons like auditing).
The default value is True.
:type keep_records_in_log: bool | airflow/api/common/experimental/delete_dag.py | def delete_dag(dag_id, keep_records_in_log=True, session=None):
"""
:param dag_id: the dag_id of the DAG to delete
:type dag_id: str
:param keep_records_in_log: whether keep records of the given dag_id
in the Log table in the backend database (for reasons like auditing).
The default valu... | def delete_dag(dag_id, keep_records_in_log=True, session=None):
"""
:param dag_id: the dag_id of the DAG to delete
:type dag_id: str
:param keep_records_in_log: whether keep records of the given dag_id
in the Log table in the backend database (for reasons like auditing).
The default valu... | [
":",
"param",
"dag_id",
":",
"the",
"dag_id",
"of",
"the",
"DAG",
"to",
"delete",
":",
"type",
"dag_id",
":",
"str",
":",
"param",
"keep_records_in_log",
":",
"whether",
"keep",
"records",
"of",
"the",
"given",
"dag_id",
"in",
"the",
"Log",
"table",
"in"... | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/api/common/experimental/delete_dag.py#L31-L64 | [
"def",
"delete_dag",
"(",
"dag_id",
",",
"keep_records_in_log",
"=",
"True",
",",
"session",
"=",
"None",
")",
":",
"DM",
"=",
"models",
".",
"DagModel",
"dag",
"=",
"session",
".",
"query",
"(",
"DM",
")",
".",
"filter",
"(",
"DM",
".",
"dag_id",
"=... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | SparkSqlHook._prepare_command | Construct the spark-sql command to execute. Verbose output is enabled
as default.
:param cmd: command to append to the spark-sql command
:type cmd: str
:return: full command to be executed | airflow/contrib/hooks/spark_sql_hook.py | def _prepare_command(self, cmd):
"""
Construct the spark-sql command to execute. Verbose output is enabled
as default.
:param cmd: command to append to the spark-sql command
:type cmd: str
:return: full command to be executed
"""
connection_cmd = ["spark-... | def _prepare_command(self, cmd):
"""
Construct the spark-sql command to execute. Verbose output is enabled
as default.
:param cmd: command to append to the spark-sql command
:type cmd: str
:return: full command to be executed
"""
connection_cmd = ["spark-... | [
"Construct",
"the",
"spark",
"-",
"sql",
"command",
"to",
"execute",
".",
"Verbose",
"output",
"is",
"enabled",
"as",
"default",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/spark_sql_hook.py#L91-L134 | [
"def",
"_prepare_command",
"(",
"self",
",",
"cmd",
")",
":",
"connection_cmd",
"=",
"[",
"\"spark-sql\"",
"]",
"if",
"self",
".",
"_conf",
":",
"for",
"conf_el",
"in",
"self",
".",
"_conf",
".",
"split",
"(",
"\",\"",
")",
":",
"connection_cmd",
"+=",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | SparkSqlHook.run_query | Remote Popen (actually execute the Spark-sql query)
:param cmd: command to remotely execute
:param kwargs: extra arguments to Popen (see subprocess.Popen) | airflow/contrib/hooks/spark_sql_hook.py | def run_query(self, cmd="", **kwargs):
"""
Remote Popen (actually execute the Spark-sql query)
:param cmd: command to remotely execute
:param kwargs: extra arguments to Popen (see subprocess.Popen)
"""
spark_sql_cmd = self._prepare_command(cmd)
self._sp = subproc... | def run_query(self, cmd="", **kwargs):
"""
Remote Popen (actually execute the Spark-sql query)
:param cmd: command to remotely execute
:param kwargs: extra arguments to Popen (see subprocess.Popen)
"""
spark_sql_cmd = self._prepare_command(cmd)
self._sp = subproc... | [
"Remote",
"Popen",
"(",
"actually",
"execute",
"the",
"Spark",
"-",
"sql",
"query",
")"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/spark_sql_hook.py#L136-L159 | [
"def",
"run_query",
"(",
"self",
",",
"cmd",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"spark_sql_cmd",
"=",
"self",
".",
"_prepare_command",
"(",
"cmd",
")",
"self",
".",
"_sp",
"=",
"subprocess",
".",
"Popen",
"(",
"spark_sql_cmd",
",",
"stdout... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | vgg11_bn | VGG 11-layer model (configuration "A") with batch normalization
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet | torchvision/models/vgg.py | def vgg11_bn(pretrained=False, **kwargs):
"""VGG 11-layer model (configuration "A") with batch normalization
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
"""
if pretrained:
kwargs['init_weights'] = False
model = VGG(make_layers(cfg['A'], batch_norm=True)... | def vgg11_bn(pretrained=False, **kwargs):
"""VGG 11-layer model (configuration "A") with batch normalization
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
"""
if pretrained:
kwargs['init_weights'] = False
model = VGG(make_layers(cfg['A'], batch_norm=True)... | [
"VGG",
"11",
"-",
"layer",
"model",
"(",
"configuration",
"A",
")",
"with",
"batch",
"normalization"
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/models/vgg.py#L100-L111 | [
"def",
"vgg11_bn",
"(",
"pretrained",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"pretrained",
":",
"kwargs",
"[",
"'init_weights'",
"]",
"=",
"False",
"model",
"=",
"VGG",
"(",
"make_layers",
"(",
"cfg",
"[",
"'A'",
"]",
",",
"batch_norm",... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | vgg13 | VGG 13-layer model (configuration "B")
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet | torchvision/models/vgg.py | def vgg13(pretrained=False, **kwargs):
"""VGG 13-layer model (configuration "B")
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
"""
if pretrained:
kwargs['init_weights'] = False
model = VGG(make_layers(cfg['B']), **kwargs)
if pretrained:
model.... | def vgg13(pretrained=False, **kwargs):
"""VGG 13-layer model (configuration "B")
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
"""
if pretrained:
kwargs['init_weights'] = False
model = VGG(make_layers(cfg['B']), **kwargs)
if pretrained:
model.... | [
"VGG",
"13",
"-",
"layer",
"model",
"(",
"configuration",
"B",
")"
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/models/vgg.py#L114-L125 | [
"def",
"vgg13",
"(",
"pretrained",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"pretrained",
":",
"kwargs",
"[",
"'init_weights'",
"]",
"=",
"False",
"model",
"=",
"VGG",
"(",
"make_layers",
"(",
"cfg",
"[",
"'B'",
"]",
")",
",",
"*",
"*... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | alexnet | r"""AlexNet model architecture from the
`"One weird trick..." <https://arxiv.org/abs/1404.5997>`_ paper.
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet | torchvision/models/alexnet.py | def alexnet(pretrained=False, **kwargs):
r"""AlexNet model architecture from the
`"One weird trick..." <https://arxiv.org/abs/1404.5997>`_ paper.
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
"""
model = AlexNet(**kwargs)
if pretrained:
model.load_sta... | def alexnet(pretrained=False, **kwargs):
r"""AlexNet model architecture from the
`"One weird trick..." <https://arxiv.org/abs/1404.5997>`_ paper.
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
"""
model = AlexNet(**kwargs)
if pretrained:
model.load_sta... | [
"r",
"AlexNet",
"model",
"architecture",
"from",
"the",
"One",
"weird",
"trick",
"...",
"<https",
":",
"//",
"arxiv",
".",
"org",
"/",
"abs",
"/",
"1404",
".",
"5997",
">",
"_",
"paper",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/models/alexnet.py#L51-L61 | [
"def",
"alexnet",
"(",
"pretrained",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"model",
"=",
"AlexNet",
"(",
"*",
"*",
"kwargs",
")",
"if",
"pretrained",
":",
"model",
".",
"load_state_dict",
"(",
"model_zoo",
".",
"load_url",
"(",
"model_urls",
... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | densenet121 | r"""Densenet-121 model from
`"Densely Connected Convolutional Networks" <https://arxiv.org/pdf/1608.06993.pdf>`_
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet | torchvision/models/densenet.py | def densenet121(pretrained=False, **kwargs):
r"""Densenet-121 model from
`"Densely Connected Convolutional Networks" <https://arxiv.org/pdf/1608.06993.pdf>`_
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
"""
model = DenseNet(num_init_features=64, growth_rate=32, ... | def densenet121(pretrained=False, **kwargs):
r"""Densenet-121 model from
`"Densely Connected Convolutional Networks" <https://arxiv.org/pdf/1608.06993.pdf>`_
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
"""
model = DenseNet(num_init_features=64, growth_rate=32, ... | [
"r",
"Densenet",
"-",
"121",
"model",
"from",
"Densely",
"Connected",
"Convolutional",
"Networks",
"<https",
":",
"//",
"arxiv",
".",
"org",
"/",
"pdf",
"/",
"1608",
".",
"06993",
".",
"pdf",
">",
"_"
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/models/densenet.py#L137-L148 | [
"def",
"densenet121",
"(",
"pretrained",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"model",
"=",
"DenseNet",
"(",
"num_init_features",
"=",
"64",
",",
"growth_rate",
"=",
"32",
",",
"block_config",
"=",
"(",
"6",
",",
"12",
",",
"24",
",",
"16... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | to_tensor | Convert a ``PIL Image`` or ``numpy.ndarray`` to tensor.
See ``ToTensor`` for more details.
Args:
pic (PIL Image or numpy.ndarray): Image to be converted to tensor.
Returns:
Tensor: Converted image. | torchvision/transforms/functional.py | def to_tensor(pic):
"""Convert a ``PIL Image`` or ``numpy.ndarray`` to tensor.
See ``ToTensor`` for more details.
Args:
pic (PIL Image or numpy.ndarray): Image to be converted to tensor.
Returns:
Tensor: Converted image.
"""
if not(_is_pil_image(pic) or _is_numpy_image(pic)):
... | def to_tensor(pic):
"""Convert a ``PIL Image`` or ``numpy.ndarray`` to tensor.
See ``ToTensor`` for more details.
Args:
pic (PIL Image or numpy.ndarray): Image to be converted to tensor.
Returns:
Tensor: Converted image.
"""
if not(_is_pil_image(pic) or _is_numpy_image(pic)):
... | [
"Convert",
"a",
"PIL",
"Image",
"or",
"numpy",
".",
"ndarray",
"to",
"tensor",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L38-L94 | [
"def",
"to_tensor",
"(",
"pic",
")",
":",
"if",
"not",
"(",
"_is_pil_image",
"(",
"pic",
")",
"or",
"_is_numpy_image",
"(",
"pic",
")",
")",
":",
"raise",
"TypeError",
"(",
"'pic should be PIL Image or ndarray. Got {}'",
".",
"format",
"(",
"type",
"(",
"pic... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | to_pil_image | Convert a tensor or an ndarray to PIL Image.
See :class:`~torchvision.transforms.ToPILImage` for more details.
Args:
pic (Tensor or numpy.ndarray): Image to be converted to PIL Image.
mode (`PIL.Image mode`_): color space and pixel depth of input data (optional).
.. _PIL.Image mode: https... | torchvision/transforms/functional.py | def to_pil_image(pic, mode=None):
"""Convert a tensor or an ndarray to PIL Image.
See :class:`~torchvision.transforms.ToPILImage` for more details.
Args:
pic (Tensor or numpy.ndarray): Image to be converted to PIL Image.
mode (`PIL.Image mode`_): color space and pixel depth of input data (... | def to_pil_image(pic, mode=None):
"""Convert a tensor or an ndarray to PIL Image.
See :class:`~torchvision.transforms.ToPILImage` for more details.
Args:
pic (Tensor or numpy.ndarray): Image to be converted to PIL Image.
mode (`PIL.Image mode`_): color space and pixel depth of input data (... | [
"Convert",
"a",
"tensor",
"or",
"an",
"ndarray",
"to",
"PIL",
"Image",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L97-L181 | [
"def",
"to_pil_image",
"(",
"pic",
",",
"mode",
"=",
"None",
")",
":",
"if",
"not",
"(",
"isinstance",
"(",
"pic",
",",
"torch",
".",
"Tensor",
")",
"or",
"isinstance",
"(",
"pic",
",",
"np",
".",
"ndarray",
")",
")",
":",
"raise",
"TypeError",
"("... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | normalize | Normalize a tensor image with mean and standard deviation.
.. note::
This transform acts out of place by default, i.e., it does not mutates the input tensor.
See :class:`~torchvision.transforms.Normalize` for more details.
Args:
tensor (Tensor): Tensor image of size (C, H, W) to be normal... | torchvision/transforms/functional.py | def normalize(tensor, mean, std, inplace=False):
"""Normalize a tensor image with mean and standard deviation.
.. note::
This transform acts out of place by default, i.e., it does not mutates the input tensor.
See :class:`~torchvision.transforms.Normalize` for more details.
Args:
tens... | def normalize(tensor, mean, std, inplace=False):
"""Normalize a tensor image with mean and standard deviation.
.. note::
This transform acts out of place by default, i.e., it does not mutates the input tensor.
See :class:`~torchvision.transforms.Normalize` for more details.
Args:
tens... | [
"Normalize",
"a",
"tensor",
"image",
"with",
"mean",
"and",
"standard",
"deviation",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L184-L209 | [
"def",
"normalize",
"(",
"tensor",
",",
"mean",
",",
"std",
",",
"inplace",
"=",
"False",
")",
":",
"if",
"not",
"_is_tensor_image",
"(",
"tensor",
")",
":",
"raise",
"TypeError",
"(",
"'tensor is not a torch image.'",
")",
"if",
"not",
"inplace",
":",
"te... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | resize | r"""Resize the input PIL Image to the given size.
Args:
img (PIL Image): Image to be resized.
size (sequence or int): Desired output size. If size is a sequence like
(h, w), the output size will be matched to this. If size is an int,
the smaller edge of the image will be mat... | torchvision/transforms/functional.py | def resize(img, size, interpolation=Image.BILINEAR):
r"""Resize the input PIL Image to the given size.
Args:
img (PIL Image): Image to be resized.
size (sequence or int): Desired output size. If size is a sequence like
(h, w), the output size will be matched to this. If size is an i... | def resize(img, size, interpolation=Image.BILINEAR):
r"""Resize the input PIL Image to the given size.
Args:
img (PIL Image): Image to be resized.
size (sequence or int): Desired output size. If size is a sequence like
(h, w), the output size will be matched to this. If size is an i... | [
"r",
"Resize",
"the",
"input",
"PIL",
"Image",
"to",
"the",
"given",
"size",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L212-L246 | [
"def",
"resize",
"(",
"img",
",",
"size",
",",
"interpolation",
"=",
"Image",
".",
"BILINEAR",
")",
":",
"if",
"not",
"_is_pil_image",
"(",
"img",
")",
":",
"raise",
"TypeError",
"(",
"'img should be PIL Image. Got {}'",
".",
"format",
"(",
"type",
"(",
"i... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | pad | r"""Pad the given PIL Image on all sides with specified padding mode and fill value.
Args:
img (PIL Image): Image to be padded.
padding (int or tuple): Padding on each border. If a single int is provided this
is used to pad all borders. If tuple of length 2 is provided this is the paddi... | torchvision/transforms/functional.py | def pad(img, padding, fill=0, padding_mode='constant'):
r"""Pad the given PIL Image on all sides with specified padding mode and fill value.
Args:
img (PIL Image): Image to be padded.
padding (int or tuple): Padding on each border. If a single int is provided this
is used to pad all... | def pad(img, padding, fill=0, padding_mode='constant'):
r"""Pad the given PIL Image on all sides with specified padding mode and fill value.
Args:
img (PIL Image): Image to be padded.
padding (int or tuple): Padding on each border. If a single int is provided this
is used to pad all... | [
"r",
"Pad",
"the",
"given",
"PIL",
"Image",
"on",
"all",
"sides",
"with",
"specified",
"padding",
"mode",
"and",
"fill",
"value",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L255-L340 | [
"def",
"pad",
"(",
"img",
",",
"padding",
",",
"fill",
"=",
"0",
",",
"padding_mode",
"=",
"'constant'",
")",
":",
"if",
"not",
"_is_pil_image",
"(",
"img",
")",
":",
"raise",
"TypeError",
"(",
"'img should be PIL Image. Got {}'",
".",
"format",
"(",
"type... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | crop | Crop the given PIL Image.
Args:
img (PIL Image): Image to be cropped.
i (int): i in (i,j) i.e coordinates of the upper left corner.
j (int): j in (i,j) i.e coordinates of the upper left corner.
h (int): Height of the cropped image.
w (int): Width of the cropped image.
R... | torchvision/transforms/functional.py | def crop(img, i, j, h, w):
"""Crop the given PIL Image.
Args:
img (PIL Image): Image to be cropped.
i (int): i in (i,j) i.e coordinates of the upper left corner.
j (int): j in (i,j) i.e coordinates of the upper left corner.
h (int): Height of the cropped image.
w (int): ... | def crop(img, i, j, h, w):
"""Crop the given PIL Image.
Args:
img (PIL Image): Image to be cropped.
i (int): i in (i,j) i.e coordinates of the upper left corner.
j (int): j in (i,j) i.e coordinates of the upper left corner.
h (int): Height of the cropped image.
w (int): ... | [
"Crop",
"the",
"given",
"PIL",
"Image",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L343-L359 | [
"def",
"crop",
"(",
"img",
",",
"i",
",",
"j",
",",
"h",
",",
"w",
")",
":",
"if",
"not",
"_is_pil_image",
"(",
"img",
")",
":",
"raise",
"TypeError",
"(",
"'img should be PIL Image. Got {}'",
".",
"format",
"(",
"type",
"(",
"img",
")",
")",
")",
... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | resized_crop | Crop the given PIL Image and resize it to desired size.
Notably used in :class:`~torchvision.transforms.RandomResizedCrop`.
Args:
img (PIL Image): Image to be cropped.
i (int): i in (i,j) i.e coordinates of the upper left corner
j (int): j in (i,j) i.e coordinates of the upper left cor... | torchvision/transforms/functional.py | def resized_crop(img, i, j, h, w, size, interpolation=Image.BILINEAR):
"""Crop the given PIL Image and resize it to desired size.
Notably used in :class:`~torchvision.transforms.RandomResizedCrop`.
Args:
img (PIL Image): Image to be cropped.
i (int): i in (i,j) i.e coordinates of the upper... | def resized_crop(img, i, j, h, w, size, interpolation=Image.BILINEAR):
"""Crop the given PIL Image and resize it to desired size.
Notably used in :class:`~torchvision.transforms.RandomResizedCrop`.
Args:
img (PIL Image): Image to be cropped.
i (int): i in (i,j) i.e coordinates of the upper... | [
"Crop",
"the",
"given",
"PIL",
"Image",
"and",
"resize",
"it",
"to",
"desired",
"size",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L372-L392 | [
"def",
"resized_crop",
"(",
"img",
",",
"i",
",",
"j",
",",
"h",
",",
"w",
",",
"size",
",",
"interpolation",
"=",
"Image",
".",
"BILINEAR",
")",
":",
"assert",
"_is_pil_image",
"(",
"img",
")",
",",
"'img should be PIL Image'",
"img",
"=",
"crop",
"("... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | hflip | Horizontally flip the given PIL Image.
Args:
img (PIL Image): Image to be flipped.
Returns:
PIL Image: Horizontall flipped image. | torchvision/transforms/functional.py | def hflip(img):
"""Horizontally flip the given PIL Image.
Args:
img (PIL Image): Image to be flipped.
Returns:
PIL Image: Horizontall flipped image.
"""
if not _is_pil_image(img):
raise TypeError('img should be PIL Image. Got {}'.format(type(img)))
return img.transpos... | def hflip(img):
"""Horizontally flip the given PIL Image.
Args:
img (PIL Image): Image to be flipped.
Returns:
PIL Image: Horizontall flipped image.
"""
if not _is_pil_image(img):
raise TypeError('img should be PIL Image. Got {}'.format(type(img)))
return img.transpos... | [
"Horizontally",
"flip",
"the",
"given",
"PIL",
"Image",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L395-L407 | [
"def",
"hflip",
"(",
"img",
")",
":",
"if",
"not",
"_is_pil_image",
"(",
"img",
")",
":",
"raise",
"TypeError",
"(",
"'img should be PIL Image. Got {}'",
".",
"format",
"(",
"type",
"(",
"img",
")",
")",
")",
"return",
"img",
".",
"transpose",
"(",
"Imag... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | _get_perspective_coeffs | Helper function to get the coefficients (a, b, c, d, e, f, g, h) for the perspective transforms.
In Perspective Transform each pixel (x, y) in the orignal image gets transformed as,
(x, y) -> ( (ax + by + c) / (gx + hy + 1), (dx + ey + f) / (gx + hy + 1) )
Args:
List containing [top-left, top-rig... | torchvision/transforms/functional.py | def _get_perspective_coeffs(startpoints, endpoints):
"""Helper function to get the coefficients (a, b, c, d, e, f, g, h) for the perspective transforms.
In Perspective Transform each pixel (x, y) in the orignal image gets transformed as,
(x, y) -> ( (ax + by + c) / (gx + hy + 1), (dx + ey + f) / (gx + hy ... | def _get_perspective_coeffs(startpoints, endpoints):
"""Helper function to get the coefficients (a, b, c, d, e, f, g, h) for the perspective transforms.
In Perspective Transform each pixel (x, y) in the orignal image gets transformed as,
(x, y) -> ( (ax + by + c) / (gx + hy + 1), (dx + ey + f) / (gx + hy ... | [
"Helper",
"function",
"to",
"get",
"the",
"coefficients",
"(",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
")",
"for",
"the",
"perspective",
"transforms",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L410-L432 | [
"def",
"_get_perspective_coeffs",
"(",
"startpoints",
",",
"endpoints",
")",
":",
"matrix",
"=",
"[",
"]",
"for",
"p1",
",",
"p2",
"in",
"zip",
"(",
"endpoints",
",",
"startpoints",
")",
":",
"matrix",
".",
"append",
"(",
"[",
"p1",
"[",
"0",
"]",
",... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | perspective | Perform perspective transform of the given PIL Image.
Args:
img (PIL Image): Image to be transformed.
coeffs (tuple) : 8-tuple (a, b, c, d, e, f, g, h) which contains the coefficients.
for a perspective transform.
interpolation: Default- Image.BICUBIC
Returns... | torchvision/transforms/functional.py | def perspective(img, startpoints, endpoints, interpolation=Image.BICUBIC):
"""Perform perspective transform of the given PIL Image.
Args:
img (PIL Image): Image to be transformed.
coeffs (tuple) : 8-tuple (a, b, c, d, e, f, g, h) which contains the coefficients.
for ... | def perspective(img, startpoints, endpoints, interpolation=Image.BICUBIC):
"""Perform perspective transform of the given PIL Image.
Args:
img (PIL Image): Image to be transformed.
coeffs (tuple) : 8-tuple (a, b, c, d, e, f, g, h) which contains the coefficients.
for ... | [
"Perform",
"perspective",
"transform",
"of",
"the",
"given",
"PIL",
"Image",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L435-L450 | [
"def",
"perspective",
"(",
"img",
",",
"startpoints",
",",
"endpoints",
",",
"interpolation",
"=",
"Image",
".",
"BICUBIC",
")",
":",
"if",
"not",
"_is_pil_image",
"(",
"img",
")",
":",
"raise",
"TypeError",
"(",
"'img should be PIL Image. Got {}'",
".",
"form... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | vflip | Vertically flip the given PIL Image.
Args:
img (PIL Image): Image to be flipped.
Returns:
PIL Image: Vertically flipped image. | torchvision/transforms/functional.py | def vflip(img):
"""Vertically flip the given PIL Image.
Args:
img (PIL Image): Image to be flipped.
Returns:
PIL Image: Vertically flipped image.
"""
if not _is_pil_image(img):
raise TypeError('img should be PIL Image. Got {}'.format(type(img)))
return img.transpose(I... | def vflip(img):
"""Vertically flip the given PIL Image.
Args:
img (PIL Image): Image to be flipped.
Returns:
PIL Image: Vertically flipped image.
"""
if not _is_pil_image(img):
raise TypeError('img should be PIL Image. Got {}'.format(type(img)))
return img.transpose(I... | [
"Vertically",
"flip",
"the",
"given",
"PIL",
"Image",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L453-L465 | [
"def",
"vflip",
"(",
"img",
")",
":",
"if",
"not",
"_is_pil_image",
"(",
"img",
")",
":",
"raise",
"TypeError",
"(",
"'img should be PIL Image. Got {}'",
".",
"format",
"(",
"type",
"(",
"img",
")",
")",
")",
"return",
"img",
".",
"transpose",
"(",
"Imag... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | five_crop | Crop the given PIL Image into four corners and the central crop.
.. Note::
This transform returns a tuple of images and there may be a
mismatch in the number of inputs and targets your ``Dataset`` returns.
Args:
size (sequence or int): Desired output size of the crop. If size is an
... | torchvision/transforms/functional.py | def five_crop(img, size):
"""Crop the given PIL Image into four corners and the central crop.
.. Note::
This transform returns a tuple of images and there may be a
mismatch in the number of inputs and targets your ``Dataset`` returns.
Args:
size (sequence or int): Desired output siz... | def five_crop(img, size):
"""Crop the given PIL Image into four corners and the central crop.
.. Note::
This transform returns a tuple of images and there may be a
mismatch in the number of inputs and targets your ``Dataset`` returns.
Args:
size (sequence or int): Desired output siz... | [
"Crop",
"the",
"given",
"PIL",
"Image",
"into",
"four",
"corners",
"and",
"the",
"central",
"crop",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L468-L499 | [
"def",
"five_crop",
"(",
"img",
",",
"size",
")",
":",
"if",
"isinstance",
"(",
"size",
",",
"numbers",
".",
"Number",
")",
":",
"size",
"=",
"(",
"int",
"(",
"size",
")",
",",
"int",
"(",
"size",
")",
")",
"else",
":",
"assert",
"len",
"(",
"s... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | ten_crop | r"""Crop the given PIL Image into four corners and the central crop plus the
flipped version of these (horizontal flipping is used by default).
.. Note::
This transform returns a tuple of images and there may be a
mismatch in the number of inputs and targets your ``Dataset`` returns.
A... | torchvision/transforms/functional.py | def ten_crop(img, size, vertical_flip=False):
r"""Crop the given PIL Image into four corners and the central crop plus the
flipped version of these (horizontal flipping is used by default).
.. Note::
This transform returns a tuple of images and there may be a
mismatch in the number of i... | def ten_crop(img, size, vertical_flip=False):
r"""Crop the given PIL Image into four corners and the central crop plus the
flipped version of these (horizontal flipping is used by default).
.. Note::
This transform returns a tuple of images and there may be a
mismatch in the number of i... | [
"r",
"Crop",
"the",
"given",
"PIL",
"Image",
"into",
"four",
"corners",
"and",
"the",
"central",
"crop",
"plus",
"the",
"flipped",
"version",
"of",
"these",
"(",
"horizontal",
"flipping",
"is",
"used",
"by",
"default",
")",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L502-L534 | [
"def",
"ten_crop",
"(",
"img",
",",
"size",
",",
"vertical_flip",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"size",
",",
"numbers",
".",
"Number",
")",
":",
"size",
"=",
"(",
"int",
"(",
"size",
")",
",",
"int",
"(",
"size",
")",
")",
"els... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | adjust_brightness | Adjust brightness of an Image.
Args:
img (PIL Image): PIL Image to be adjusted.
brightness_factor (float): How much to adjust the brightness. Can be
any non negative number. 0 gives a black image, 1 gives the
original image while 2 increases the brightness by a factor of 2.... | torchvision/transforms/functional.py | def adjust_brightness(img, brightness_factor):
"""Adjust brightness of an Image.
Args:
img (PIL Image): PIL Image to be adjusted.
brightness_factor (float): How much to adjust the brightness. Can be
any non negative number. 0 gives a black image, 1 gives the
original im... | def adjust_brightness(img, brightness_factor):
"""Adjust brightness of an Image.
Args:
img (PIL Image): PIL Image to be adjusted.
brightness_factor (float): How much to adjust the brightness. Can be
any non negative number. 0 gives a black image, 1 gives the
original im... | [
"Adjust",
"brightness",
"of",
"an",
"Image",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L537-L554 | [
"def",
"adjust_brightness",
"(",
"img",
",",
"brightness_factor",
")",
":",
"if",
"not",
"_is_pil_image",
"(",
"img",
")",
":",
"raise",
"TypeError",
"(",
"'img should be PIL Image. Got {}'",
".",
"format",
"(",
"type",
"(",
"img",
")",
")",
")",
"enhancer",
... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | adjust_contrast | Adjust contrast of an Image.
Args:
img (PIL Image): PIL Image to be adjusted.
contrast_factor (float): How much to adjust the contrast. Can be any
non negative number. 0 gives a solid gray image, 1 gives the
original image while 2 increases the contrast by a factor of 2.
... | torchvision/transforms/functional.py | def adjust_contrast(img, contrast_factor):
"""Adjust contrast of an Image.
Args:
img (PIL Image): PIL Image to be adjusted.
contrast_factor (float): How much to adjust the contrast. Can be any
non negative number. 0 gives a solid gray image, 1 gives the
original image wh... | def adjust_contrast(img, contrast_factor):
"""Adjust contrast of an Image.
Args:
img (PIL Image): PIL Image to be adjusted.
contrast_factor (float): How much to adjust the contrast. Can be any
non negative number. 0 gives a solid gray image, 1 gives the
original image wh... | [
"Adjust",
"contrast",
"of",
"an",
"Image",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L557-L574 | [
"def",
"adjust_contrast",
"(",
"img",
",",
"contrast_factor",
")",
":",
"if",
"not",
"_is_pil_image",
"(",
"img",
")",
":",
"raise",
"TypeError",
"(",
"'img should be PIL Image. Got {}'",
".",
"format",
"(",
"type",
"(",
"img",
")",
")",
")",
"enhancer",
"="... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | adjust_saturation | Adjust color saturation of an image.
Args:
img (PIL Image): PIL Image to be adjusted.
saturation_factor (float): How much to adjust the saturation. 0 will
give a black and white image, 1 will give the original image while
2 will enhance the saturation by a factor of 2.
... | torchvision/transforms/functional.py | def adjust_saturation(img, saturation_factor):
"""Adjust color saturation of an image.
Args:
img (PIL Image): PIL Image to be adjusted.
saturation_factor (float): How much to adjust the saturation. 0 will
give a black and white image, 1 will give the original image while
... | def adjust_saturation(img, saturation_factor):
"""Adjust color saturation of an image.
Args:
img (PIL Image): PIL Image to be adjusted.
saturation_factor (float): How much to adjust the saturation. 0 will
give a black and white image, 1 will give the original image while
... | [
"Adjust",
"color",
"saturation",
"of",
"an",
"image",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L577-L594 | [
"def",
"adjust_saturation",
"(",
"img",
",",
"saturation_factor",
")",
":",
"if",
"not",
"_is_pil_image",
"(",
"img",
")",
":",
"raise",
"TypeError",
"(",
"'img should be PIL Image. Got {}'",
".",
"format",
"(",
"type",
"(",
"img",
")",
")",
")",
"enhancer",
... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | adjust_hue | Adjust hue of an image.
The image hue is adjusted by converting the image to HSV and
cyclically shifting the intensities in the hue channel (H).
The image is then converted back to original image mode.
`hue_factor` is the amount of shift in H channel and must be in the
interval `[-0.5, 0.5]`.
... | torchvision/transforms/functional.py | def adjust_hue(img, hue_factor):
"""Adjust hue of an image.
The image hue is adjusted by converting the image to HSV and
cyclically shifting the intensities in the hue channel (H).
The image is then converted back to original image mode.
`hue_factor` is the amount of shift in H channel and must be... | def adjust_hue(img, hue_factor):
"""Adjust hue of an image.
The image hue is adjusted by converting the image to HSV and
cyclically shifting the intensities in the hue channel (H).
The image is then converted back to original image mode.
`hue_factor` is the amount of shift in H channel and must be... | [
"Adjust",
"hue",
"of",
"an",
"image",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L597-L641 | [
"def",
"adjust_hue",
"(",
"img",
",",
"hue_factor",
")",
":",
"if",
"not",
"(",
"-",
"0.5",
"<=",
"hue_factor",
"<=",
"0.5",
")",
":",
"raise",
"ValueError",
"(",
"'hue_factor is not in [-0.5, 0.5].'",
".",
"format",
"(",
"hue_factor",
")",
")",
"if",
"not... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | adjust_gamma | r"""Perform gamma correction on an image.
Also known as Power Law Transform. Intensities in RGB mode are adjusted
based on the following equation:
.. math::
I_{\text{out}} = 255 \times \text{gain} \times \left(\frac{I_{\text{in}}}{255}\right)^{\gamma}
See `Gamma Correction`_ for more details.... | torchvision/transforms/functional.py | def adjust_gamma(img, gamma, gain=1):
r"""Perform gamma correction on an image.
Also known as Power Law Transform. Intensities in RGB mode are adjusted
based on the following equation:
.. math::
I_{\text{out}} = 255 \times \text{gain} \times \left(\frac{I_{\text{in}}}{255}\right)^{\gamma}
... | def adjust_gamma(img, gamma, gain=1):
r"""Perform gamma correction on an image.
Also known as Power Law Transform. Intensities in RGB mode are adjusted
based on the following equation:
.. math::
I_{\text{out}} = 255 \times \text{gain} \times \left(\frac{I_{\text{in}}}{255}\right)^{\gamma}
... | [
"r",
"Perform",
"gamma",
"correction",
"on",
"an",
"image",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L644-L677 | [
"def",
"adjust_gamma",
"(",
"img",
",",
"gamma",
",",
"gain",
"=",
"1",
")",
":",
"if",
"not",
"_is_pil_image",
"(",
"img",
")",
":",
"raise",
"TypeError",
"(",
"'img should be PIL Image. Got {}'",
".",
"format",
"(",
"type",
"(",
"img",
")",
")",
")",
... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | rotate | Rotate the image by angle.
Args:
img (PIL Image): PIL Image to be rotated.
angle (float or int): In degrees degrees counter clockwise order.
resample (``PIL.Image.NEAREST`` or ``PIL.Image.BILINEAR`` or ``PIL.Image.BICUBIC``, optional):
An optional resampling filter. See `filter... | torchvision/transforms/functional.py | def rotate(img, angle, resample=False, expand=False, center=None):
"""Rotate the image by angle.
Args:
img (PIL Image): PIL Image to be rotated.
angle (float or int): In degrees degrees counter clockwise order.
resample (``PIL.Image.NEAREST`` or ``PIL.Image.BILINEAR`` or ``PIL.Image.BI... | def rotate(img, angle, resample=False, expand=False, center=None):
"""Rotate the image by angle.
Args:
img (PIL Image): PIL Image to be rotated.
angle (float or int): In degrees degrees counter clockwise order.
resample (``PIL.Image.NEAREST`` or ``PIL.Image.BILINEAR`` or ``PIL.Image.BI... | [
"Rotate",
"the",
"image",
"by",
"angle",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L680-L705 | [
"def",
"rotate",
"(",
"img",
",",
"angle",
",",
"resample",
"=",
"False",
",",
"expand",
"=",
"False",
",",
"center",
"=",
"None",
")",
":",
"if",
"not",
"_is_pil_image",
"(",
"img",
")",
":",
"raise",
"TypeError",
"(",
"'img should be PIL Image. Got {}'",... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | affine | Apply affine transformation on the image keeping image center invariant
Args:
img (PIL Image): PIL Image to be rotated.
angle (float or int): rotation angle in degrees between -180 and 180, clockwise direction.
translate (list or tuple of integers): horizontal and vertical translations (pos... | torchvision/transforms/functional.py | def affine(img, angle, translate, scale, shear, resample=0, fillcolor=None):
"""Apply affine transformation on the image keeping image center invariant
Args:
img (PIL Image): PIL Image to be rotated.
angle (float or int): rotation angle in degrees between -180 and 180, clockwise direction.
... | def affine(img, angle, translate, scale, shear, resample=0, fillcolor=None):
"""Apply affine transformation on the image keeping image center invariant
Args:
img (PIL Image): PIL Image to be rotated.
angle (float or int): rotation angle in degrees between -180 and 180, clockwise direction.
... | [
"Apply",
"affine",
"transformation",
"on",
"the",
"image",
"keeping",
"image",
"center",
"invariant"
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L743-L770 | [
"def",
"affine",
"(",
"img",
",",
"angle",
",",
"translate",
",",
"scale",
",",
"shear",
",",
"resample",
"=",
"0",
",",
"fillcolor",
"=",
"None",
")",
":",
"if",
"not",
"_is_pil_image",
"(",
"img",
")",
":",
"raise",
"TypeError",
"(",
"'img should be ... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | to_grayscale | Convert image to grayscale version of image.
Args:
img (PIL Image): Image to be converted to grayscale.
Returns:
PIL Image: Grayscale version of the image.
if num_output_channels = 1 : returned image is single channel
if num_output_channels = 3 : returned image is 3 ch... | torchvision/transforms/functional.py | def to_grayscale(img, num_output_channels=1):
"""Convert image to grayscale version of image.
Args:
img (PIL Image): Image to be converted to grayscale.
Returns:
PIL Image: Grayscale version of the image.
if num_output_channels = 1 : returned image is single channel
... | def to_grayscale(img, num_output_channels=1):
"""Convert image to grayscale version of image.
Args:
img (PIL Image): Image to be converted to grayscale.
Returns:
PIL Image: Grayscale version of the image.
if num_output_channels = 1 : returned image is single channel
... | [
"Convert",
"image",
"to",
"grayscale",
"version",
"of",
"image",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L773-L798 | [
"def",
"to_grayscale",
"(",
"img",
",",
"num_output_channels",
"=",
"1",
")",
":",
"if",
"not",
"_is_pil_image",
"(",
"img",
")",
":",
"raise",
"TypeError",
"(",
"'img should be PIL Image. Got {}'",
".",
"format",
"(",
"type",
"(",
"img",
")",
")",
")",
"i... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | make_grid | Make a grid of images.
Args:
tensor (Tensor or list): 4D mini-batch Tensor of shape (B x C x H x W)
or a list of images all of the same size.
nrow (int, optional): Number of images displayed in each row of the grid.
The Final grid size is (B / nrow, nrow). Default is 8.
... | torchvision/utils.py | def make_grid(tensor, nrow=8, padding=2,
normalize=False, range=None, scale_each=False, pad_value=0):
"""Make a grid of images.
Args:
tensor (Tensor or list): 4D mini-batch Tensor of shape (B x C x H x W)
or a list of images all of the same size.
nrow (int, optional): ... | def make_grid(tensor, nrow=8, padding=2,
normalize=False, range=None, scale_each=False, pad_value=0):
"""Make a grid of images.
Args:
tensor (Tensor or list): 4D mini-batch Tensor of shape (B x C x H x W)
or a list of images all of the same size.
nrow (int, optional): ... | [
"Make",
"a",
"grid",
"of",
"images",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/utils.py#L6-L87 | [
"def",
"make_grid",
"(",
"tensor",
",",
"nrow",
"=",
"8",
",",
"padding",
"=",
"2",
",",
"normalize",
"=",
"False",
",",
"range",
"=",
"None",
",",
"scale_each",
"=",
"False",
",",
"pad_value",
"=",
"0",
")",
":",
"if",
"not",
"(",
"torch",
".",
... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | save_image | Save a given Tensor into an image file.
Args:
tensor (Tensor or list): Image to be saved. If given a mini-batch tensor,
saves the tensor as a grid of images by calling ``make_grid``.
**kwargs: Other arguments are documented in ``make_grid``. | torchvision/utils.py | def save_image(tensor, filename, nrow=8, padding=2,
normalize=False, range=None, scale_each=False, pad_value=0):
"""Save a given Tensor into an image file.
Args:
tensor (Tensor or list): Image to be saved. If given a mini-batch tensor,
saves the tensor as a grid of images by ... | def save_image(tensor, filename, nrow=8, padding=2,
normalize=False, range=None, scale_each=False, pad_value=0):
"""Save a given Tensor into an image file.
Args:
tensor (Tensor or list): Image to be saved. If given a mini-batch tensor,
saves the tensor as a grid of images by ... | [
"Save",
"a",
"given",
"Tensor",
"into",
"an",
"image",
"file",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/utils.py#L90-L105 | [
"def",
"save_image",
"(",
"tensor",
",",
"filename",
",",
"nrow",
"=",
"8",
",",
"padding",
"=",
"2",
",",
"normalize",
"=",
"False",
",",
"range",
"=",
"None",
",",
"scale_each",
"=",
"False",
",",
"pad_value",
"=",
"0",
")",
":",
"from",
"PIL",
"... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | DatasetFolder._find_classes | Finds the class folders in a dataset.
Args:
dir (string): Root directory path.
Returns:
tuple: (classes, class_to_idx) where classes are relative to (dir), and class_to_idx is a dictionary.
Ensures:
No class is a subdirectory of another. | torchvision/datasets/folder.py | def _find_classes(self, dir):
"""
Finds the class folders in a dataset.
Args:
dir (string): Root directory path.
Returns:
tuple: (classes, class_to_idx) where classes are relative to (dir), and class_to_idx is a dictionary.
Ensures:
No class... | def _find_classes(self, dir):
"""
Finds the class folders in a dataset.
Args:
dir (string): Root directory path.
Returns:
tuple: (classes, class_to_idx) where classes are relative to (dir), and class_to_idx is a dictionary.
Ensures:
No class... | [
"Finds",
"the",
"class",
"folders",
"in",
"a",
"dataset",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/datasets/folder.py#L107-L127 | [
"def",
"_find_classes",
"(",
"self",
",",
"dir",
")",
":",
"if",
"sys",
".",
"version_info",
">=",
"(",
"3",
",",
"5",
")",
":",
"# Faster and available in Python 3.5 and above",
"classes",
"=",
"[",
"d",
".",
"name",
"for",
"d",
"in",
"os",
".",
"scandi... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | read_image_file | Return a Tensor containing the patches | torchvision/datasets/phototour.py | def read_image_file(data_dir, image_ext, n):
"""Return a Tensor containing the patches
"""
def PIL2array(_img):
"""Convert PIL image type to numpy 2D array
"""
return np.array(_img.getdata(), dtype=np.uint8).reshape(64, 64)
def find_files(_data_dir, _image_ext):
"""Retu... | def read_image_file(data_dir, image_ext, n):
"""Return a Tensor containing the patches
"""
def PIL2array(_img):
"""Convert PIL image type to numpy 2D array
"""
return np.array(_img.getdata(), dtype=np.uint8).reshape(64, 64)
def find_files(_data_dir, _image_ext):
"""Retu... | [
"Return",
"a",
"Tensor",
"containing",
"the",
"patches"
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/datasets/phototour.py#L158-L186 | [
"def",
"read_image_file",
"(",
"data_dir",
",",
"image_ext",
",",
"n",
")",
":",
"def",
"PIL2array",
"(",
"_img",
")",
":",
"\"\"\"Convert PIL image type to numpy 2D array\n \"\"\"",
"return",
"np",
".",
"array",
"(",
"_img",
".",
"getdata",
"(",
")",
","... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | read_info_file | Return a Tensor containing the list of labels
Read the file and keep only the ID of the 3D point. | torchvision/datasets/phototour.py | def read_info_file(data_dir, info_file):
"""Return a Tensor containing the list of labels
Read the file and keep only the ID of the 3D point.
"""
labels = []
with open(os.path.join(data_dir, info_file), 'r') as f:
labels = [int(line.split()[0]) for line in f]
return torch.LongTensor(l... | def read_info_file(data_dir, info_file):
"""Return a Tensor containing the list of labels
Read the file and keep only the ID of the 3D point.
"""
labels = []
with open(os.path.join(data_dir, info_file), 'r') as f:
labels = [int(line.split()[0]) for line in f]
return torch.LongTensor(l... | [
"Return",
"a",
"Tensor",
"containing",
"the",
"list",
"of",
"labels",
"Read",
"the",
"file",
"and",
"keep",
"only",
"the",
"ID",
"of",
"the",
"3D",
"point",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/datasets/phototour.py#L189-L196 | [
"def",
"read_info_file",
"(",
"data_dir",
",",
"info_file",
")",
":",
"labels",
"=",
"[",
"]",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"data_dir",
",",
"info_file",
")",
",",
"'r'",
")",
"as",
"f",
":",
"labels",
"=",
"[",
"int",
... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | read_matches_files | Return a Tensor containing the ground truth matches
Read the file and keep only 3D point ID.
Matches are represented with a 1, non matches with a 0. | torchvision/datasets/phototour.py | def read_matches_files(data_dir, matches_file):
"""Return a Tensor containing the ground truth matches
Read the file and keep only 3D point ID.
Matches are represented with a 1, non matches with a 0.
"""
matches = []
with open(os.path.join(data_dir, matches_file), 'r') as f:
for li... | def read_matches_files(data_dir, matches_file):
"""Return a Tensor containing the ground truth matches
Read the file and keep only 3D point ID.
Matches are represented with a 1, non matches with a 0.
"""
matches = []
with open(os.path.join(data_dir, matches_file), 'r') as f:
for li... | [
"Return",
"a",
"Tensor",
"containing",
"the",
"ground",
"truth",
"matches",
"Read",
"the",
"file",
"and",
"keep",
"only",
"3D",
"point",
"ID",
".",
"Matches",
"are",
"represented",
"with",
"a",
"1",
"non",
"matches",
"with",
"a",
"0",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/datasets/phototour.py#L199-L210 | [
"def",
"read_matches_files",
"(",
"data_dir",
",",
"matches_file",
")",
":",
"matches",
"=",
"[",
"]",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"data_dir",
",",
"matches_file",
")",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | conv1x1 | 1x1 convolution | torchvision/models/resnet.py | def conv1x1(in_planes, out_planes, stride=1):
"""1x1 convolution"""
return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False) | def conv1x1(in_planes, out_planes, stride=1):
"""1x1 convolution"""
return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False) | [
"1x1",
"convolution"
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/models/resnet.py#L24-L26 | [
"def",
"conv1x1",
"(",
"in_planes",
",",
"out_planes",
",",
"stride",
"=",
"1",
")",
":",
"return",
"nn",
".",
"Conv2d",
"(",
"in_planes",
",",
"out_planes",
",",
"kernel_size",
"=",
"1",
",",
"stride",
"=",
"stride",
",",
"bias",
"=",
"False",
")"
] | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | accuracy | Computes the accuracy over the k top predictions for the specified values of k | references/classification/utils.py | def accuracy(output, target, topk=(1,)):
"""Computes the accuracy over the k top predictions for the specified values of k"""
with torch.no_grad():
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(t... | def accuracy(output, target, topk=(1,)):
"""Computes the accuracy over the k top predictions for the specified values of k"""
with torch.no_grad():
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(t... | [
"Computes",
"the",
"accuracy",
"over",
"the",
"k",
"top",
"predictions",
"for",
"the",
"specified",
"values",
"of",
"k"
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/references/classification/utils.py#L147-L161 | [
"def",
"accuracy",
"(",
"output",
",",
"target",
",",
"topk",
"=",
"(",
"1",
",",
")",
")",
":",
"with",
"torch",
".",
"no_grad",
"(",
")",
":",
"maxk",
"=",
"max",
"(",
"topk",
")",
"batch_size",
"=",
"target",
".",
"size",
"(",
"0",
")",
"_",... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | setup_for_distributed | This function disables printing when not in master process | references/classification/utils.py | def setup_for_distributed(is_master):
"""
This function disables printing when not in master process
"""
import builtins as __builtin__
builtin_print = __builtin__.print
def print(*args, **kwargs):
force = kwargs.pop('force', False)
if is_master or force:
builtin_pri... | def setup_for_distributed(is_master):
"""
This function disables printing when not in master process
"""
import builtins as __builtin__
builtin_print = __builtin__.print
def print(*args, **kwargs):
force = kwargs.pop('force', False)
if is_master or force:
builtin_pri... | [
"This",
"function",
"disables",
"printing",
"when",
"not",
"in",
"master",
"process"
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/references/classification/utils.py#L172-L184 | [
"def",
"setup_for_distributed",
"(",
"is_master",
")",
":",
"import",
"builtins",
"as",
"__builtin__",
"builtin_print",
"=",
"__builtin__",
".",
"print",
"def",
"print",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"force",
"=",
"kwargs",
".",
"pop... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | SmoothedValue.synchronize_between_processes | Warning: does not synchronize the deque! | references/classification/utils.py | def synchronize_between_processes(self):
"""
Warning: does not synchronize the deque!
"""
if not is_dist_avail_and_initialized():
return
t = torch.tensor([self.count, self.total], dtype=torch.float64, device='cuda')
dist.barrier()
dist.all_reduce(t)
... | def synchronize_between_processes(self):
"""
Warning: does not synchronize the deque!
"""
if not is_dist_avail_and_initialized():
return
t = torch.tensor([self.count, self.total], dtype=torch.float64, device='cuda')
dist.barrier()
dist.all_reduce(t)
... | [
"Warning",
":",
"does",
"not",
"synchronize",
"the",
"deque!"
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/references/classification/utils.py#L30-L41 | [
"def",
"synchronize_between_processes",
"(",
"self",
")",
":",
"if",
"not",
"is_dist_avail_and_initialized",
"(",
")",
":",
"return",
"t",
"=",
"torch",
".",
"tensor",
"(",
"[",
"self",
".",
"count",
",",
"self",
".",
"total",
"]",
",",
"dtype",
"=",
"to... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | squeezenet1_1 | r"""SqueezeNet 1.1 model from the `official SqueezeNet repo
<https://github.com/DeepScale/SqueezeNet/tree/master/SqueezeNet_v1.1>`_.
SqueezeNet 1.1 has 2.4x less computation and slightly fewer parameters
than SqueezeNet 1.0, without sacrificing accuracy.
Args:
pretrained (bool): If True, return... | torchvision/models/squeezenet.py | def squeezenet1_1(pretrained=False, **kwargs):
r"""SqueezeNet 1.1 model from the `official SqueezeNet repo
<https://github.com/DeepScale/SqueezeNet/tree/master/SqueezeNet_v1.1>`_.
SqueezeNet 1.1 has 2.4x less computation and slightly fewer parameters
than SqueezeNet 1.0, without sacrificing accuracy.
... | def squeezenet1_1(pretrained=False, **kwargs):
r"""SqueezeNet 1.1 model from the `official SqueezeNet repo
<https://github.com/DeepScale/SqueezeNet/tree/master/SqueezeNet_v1.1>`_.
SqueezeNet 1.1 has 2.4x less computation and slightly fewer parameters
than SqueezeNet 1.0, without sacrificing accuracy.
... | [
"r",
"SqueezeNet",
"1",
".",
"1",
"model",
"from",
"the",
"official",
"SqueezeNet",
"repo",
"<https",
":",
"//",
"github",
".",
"com",
"/",
"DeepScale",
"/",
"SqueezeNet",
"/",
"tree",
"/",
"master",
"/",
"SqueezeNet_v1",
".",
"1",
">",
"_",
".",
"Sque... | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/models/squeezenet.py#L117-L129 | [
"def",
"squeezenet1_1",
"(",
"pretrained",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"model",
"=",
"SqueezeNet",
"(",
"version",
"=",
"1.1",
",",
"*",
"*",
"kwargs",
")",
"if",
"pretrained",
":",
"model",
".",
"load_state_dict",
"(",
"model_zoo",
... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | makedir_exist_ok | Python2 support for os.makedirs(.., exist_ok=True) | torchvision/datasets/utils.py | def makedir_exist_ok(dirpath):
"""
Python2 support for os.makedirs(.., exist_ok=True)
"""
try:
os.makedirs(dirpath)
except OSError as e:
if e.errno == errno.EEXIST:
pass
else:
raise | def makedir_exist_ok(dirpath):
"""
Python2 support for os.makedirs(.., exist_ok=True)
"""
try:
os.makedirs(dirpath)
except OSError as e:
if e.errno == errno.EEXIST:
pass
else:
raise | [
"Python2",
"support",
"for",
"os",
".",
"makedirs",
"(",
"..",
"exist_ok",
"=",
"True",
")"
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/datasets/utils.py#L41-L51 | [
"def",
"makedir_exist_ok",
"(",
"dirpath",
")",
":",
"try",
":",
"os",
".",
"makedirs",
"(",
"dirpath",
")",
"except",
"OSError",
"as",
"e",
":",
"if",
"e",
".",
"errno",
"==",
"errno",
".",
"EEXIST",
":",
"pass",
"else",
":",
"raise"
] | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | download_url | Download a file from a url and place it in root.
Args:
url (str): URL to download file from
root (str): Directory to place downloaded file in
filename (str, optional): Name to save the file under. If None, use the basename of the URL
md5 (str, optional): MD5 checksum of the download... | torchvision/datasets/utils.py | def download_url(url, root, filename=None, md5=None):
"""Download a file from a url and place it in root.
Args:
url (str): URL to download file from
root (str): Directory to place downloaded file in
filename (str, optional): Name to save the file under. If None, use the basename of the ... | def download_url(url, root, filename=None, md5=None):
"""Download a file from a url and place it in root.
Args:
url (str): URL to download file from
root (str): Directory to place downloaded file in
filename (str, optional): Name to save the file under. If None, use the basename of the ... | [
"Download",
"a",
"file",
"from",
"a",
"url",
"and",
"place",
"it",
"in",
"root",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/datasets/utils.py#L54-L90 | [
"def",
"download_url",
"(",
"url",
",",
"root",
",",
"filename",
"=",
"None",
",",
"md5",
"=",
"None",
")",
":",
"from",
"six",
".",
"moves",
"import",
"urllib",
"root",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"root",
")",
"if",
"not",
"fil... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | list_dir | List all directories at a given root
Args:
root (str): Path to directory whose folders need to be listed
prefix (bool, optional): If true, prepends the path to each result, otherwise
only returns the name of the directories found | torchvision/datasets/utils.py | def list_dir(root, prefix=False):
"""List all directories at a given root
Args:
root (str): Path to directory whose folders need to be listed
prefix (bool, optional): If true, prepends the path to each result, otherwise
only returns the name of the directories found
"""
root... | def list_dir(root, prefix=False):
"""List all directories at a given root
Args:
root (str): Path to directory whose folders need to be listed
prefix (bool, optional): If true, prepends the path to each result, otherwise
only returns the name of the directories found
"""
root... | [
"List",
"all",
"directories",
"at",
"a",
"given",
"root"
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/datasets/utils.py#L93-L112 | [
"def",
"list_dir",
"(",
"root",
",",
"prefix",
"=",
"False",
")",
":",
"root",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"root",
")",
"directories",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"p",
":",
"os",
".",
"path",
".",
"isdir",
"(",
... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | list_files | List all files ending with a suffix at a given root
Args:
root (str): Path to directory whose folders need to be listed
suffix (str or tuple): Suffix of the files to match, e.g. '.png' or ('.jpg', '.png').
It uses the Python "str.endswith" method and is passed directly
prefix (b... | torchvision/datasets/utils.py | def list_files(root, suffix, prefix=False):
"""List all files ending with a suffix at a given root
Args:
root (str): Path to directory whose folders need to be listed
suffix (str or tuple): Suffix of the files to match, e.g. '.png' or ('.jpg', '.png').
It uses the Python "str.endswi... | def list_files(root, suffix, prefix=False):
"""List all files ending with a suffix at a given root
Args:
root (str): Path to directory whose folders need to be listed
suffix (str or tuple): Suffix of the files to match, e.g. '.png' or ('.jpg', '.png').
It uses the Python "str.endswi... | [
"List",
"all",
"files",
"ending",
"with",
"a",
"suffix",
"at",
"a",
"given",
"root"
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/datasets/utils.py#L115-L136 | [
"def",
"list_files",
"(",
"root",
",",
"suffix",
",",
"prefix",
"=",
"False",
")",
":",
"root",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"root",
")",
"files",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"p",
":",
"os",
".",
"path",
".",
"is... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | download_file_from_google_drive | Download a Google Drive file from and place it in root.
Args:
file_id (str): id of file to be downloaded
root (str): Directory to place downloaded file in
filename (str, optional): Name to save the file under. If None, use the id of the file.
md5 (str, optional): MD5 checksum of th... | torchvision/datasets/utils.py | def download_file_from_google_drive(file_id, root, filename=None, md5=None):
"""Download a Google Drive file from and place it in root.
Args:
file_id (str): id of file to be downloaded
root (str): Directory to place downloaded file in
filename (str, optional): Name to save the file und... | def download_file_from_google_drive(file_id, root, filename=None, md5=None):
"""Download a Google Drive file from and place it in root.
Args:
file_id (str): id of file to be downloaded
root (str): Directory to place downloaded file in
filename (str, optional): Name to save the file und... | [
"Download",
"a",
"Google",
"Drive",
"file",
"from",
"and",
"place",
"it",
"in",
"root",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/datasets/utils.py#L139-L171 | [
"def",
"download_file_from_google_drive",
"(",
"file_id",
",",
"root",
",",
"filename",
"=",
"None",
",",
"md5",
"=",
"None",
")",
":",
"# Based on https://stackoverflow.com/questions/38511444/python-download-files-from-google-drive-using-url",
"import",
"requests",
"url",
"=... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | RandomCrop.get_params | Get parameters for ``crop`` for a random crop.
Args:
img (PIL Image): Image to be cropped.
output_size (tuple): Expected output size of the crop.
Returns:
tuple: params (i, j, h, w) to be passed to ``crop`` for random crop. | torchvision/transforms/transforms.py | def get_params(img, output_size):
"""Get parameters for ``crop`` for a random crop.
Args:
img (PIL Image): Image to be cropped.
output_size (tuple): Expected output size of the crop.
Returns:
tuple: params (i, j, h, w) to be passed to ``crop`` for random cro... | def get_params(img, output_size):
"""Get parameters for ``crop`` for a random crop.
Args:
img (PIL Image): Image to be cropped.
output_size (tuple): Expected output size of the crop.
Returns:
tuple: params (i, j, h, w) to be passed to ``crop`` for random cro... | [
"Get",
"parameters",
"for",
"crop",
"for",
"a",
"random",
"crop",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/transforms.py#L435-L452 | [
"def",
"get_params",
"(",
"img",
",",
"output_size",
")",
":",
"w",
",",
"h",
"=",
"img",
".",
"size",
"th",
",",
"tw",
"=",
"output_size",
"if",
"w",
"==",
"tw",
"and",
"h",
"==",
"th",
":",
"return",
"0",
",",
"0",
",",
"h",
",",
"w",
"i",
... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | RandomPerspective.get_params | Get parameters for ``perspective`` for a random perspective transform.
Args:
width : width of the image.
height : height of the image.
Returns:
List containing [top-left, top-right, bottom-right, bottom-left] of the orignal image,
List containing [top-le... | torchvision/transforms/transforms.py | def get_params(width, height, distortion_scale):
"""Get parameters for ``perspective`` for a random perspective transform.
Args:
width : width of the image.
height : height of the image.
Returns:
List containing [top-left, top-right, bottom-right, bottom-lef... | def get_params(width, height, distortion_scale):
"""Get parameters for ``perspective`` for a random perspective transform.
Args:
width : width of the image.
height : height of the image.
Returns:
List containing [top-left, top-right, bottom-right, bottom-lef... | [
"Get",
"parameters",
"for",
"perspective",
"for",
"a",
"random",
"perspective",
"transform",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/transforms.py#L567-L590 | [
"def",
"get_params",
"(",
"width",
",",
"height",
",",
"distortion_scale",
")",
":",
"half_height",
"=",
"int",
"(",
"height",
"/",
"2",
")",
"half_width",
"=",
"int",
"(",
"width",
"/",
"2",
")",
"topleft",
"=",
"(",
"random",
".",
"randint",
"(",
"... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | RandomResizedCrop.get_params | Get parameters for ``crop`` for a random sized crop.
Args:
img (PIL Image): Image to be cropped.
scale (tuple): range of size of the origin size cropped
ratio (tuple): range of aspect ratio of the origin aspect ratio cropped
Returns:
tuple: params (i, j,... | torchvision/transforms/transforms.py | def get_params(img, scale, ratio):
"""Get parameters for ``crop`` for a random sized crop.
Args:
img (PIL Image): Image to be cropped.
scale (tuple): range of size of the origin size cropped
ratio (tuple): range of aspect ratio of the origin aspect ratio cropped
... | def get_params(img, scale, ratio):
"""Get parameters for ``crop`` for a random sized crop.
Args:
img (PIL Image): Image to be cropped.
scale (tuple): range of size of the origin size cropped
ratio (tuple): range of aspect ratio of the origin aspect ratio cropped
... | [
"Get",
"parameters",
"for",
"crop",
"for",
"a",
"random",
"sized",
"crop",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/transforms.py#L624-L664 | [
"def",
"get_params",
"(",
"img",
",",
"scale",
",",
"ratio",
")",
":",
"area",
"=",
"img",
".",
"size",
"[",
"0",
"]",
"*",
"img",
".",
"size",
"[",
"1",
"]",
"for",
"attempt",
"in",
"range",
"(",
"10",
")",
":",
"target_area",
"=",
"random",
"... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | ColorJitter.get_params | Get a randomized transform to be applied on image.
Arguments are same as that of __init__.
Returns:
Transform which randomly adjusts brightness, contrast and
saturation in a random order. | torchvision/transforms/transforms.py | def get_params(brightness, contrast, saturation, hue):
"""Get a randomized transform to be applied on image.
Arguments are same as that of __init__.
Returns:
Transform which randomly adjusts brightness, contrast and
saturation in a random order.
"""
tran... | def get_params(brightness, contrast, saturation, hue):
"""Get a randomized transform to be applied on image.
Arguments are same as that of __init__.
Returns:
Transform which randomly adjusts brightness, contrast and
saturation in a random order.
"""
tran... | [
"Get",
"a",
"randomized",
"transform",
"to",
"be",
"applied",
"on",
"image",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/transforms.py#L875-L905 | [
"def",
"get_params",
"(",
"brightness",
",",
"contrast",
",",
"saturation",
",",
"hue",
")",
":",
"transforms",
"=",
"[",
"]",
"if",
"brightness",
"is",
"not",
"None",
":",
"brightness_factor",
"=",
"random",
".",
"uniform",
"(",
"brightness",
"[",
"0",
... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | RandomAffine.get_params | Get parameters for affine transformation
Returns:
sequence: params to be passed to the affine transformation | torchvision/transforms/transforms.py | def get_params(degrees, translate, scale_ranges, shears, img_size):
"""Get parameters for affine transformation
Returns:
sequence: params to be passed to the affine transformation
"""
angle = random.uniform(degrees[0], degrees[1])
if translate is not None:
... | def get_params(degrees, translate, scale_ranges, shears, img_size):
"""Get parameters for affine transformation
Returns:
sequence: params to be passed to the affine transformation
"""
angle = random.uniform(degrees[0], degrees[1])
if translate is not None:
... | [
"Get",
"parameters",
"for",
"affine",
"transformation"
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/transforms.py#L1064-L1089 | [
"def",
"get_params",
"(",
"degrees",
",",
"translate",
",",
"scale_ranges",
",",
"shears",
",",
"img_size",
")",
":",
"angle",
"=",
"random",
".",
"uniform",
"(",
"degrees",
"[",
"0",
"]",
",",
"degrees",
"[",
"1",
"]",
")",
"if",
"translate",
"is",
... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | inception_v3 | r"""Inception v3 model architecture from
`"Rethinking the Inception Architecture for Computer Vision" <http://arxiv.org/abs/1512.00567>`_.
.. note::
**Important**: In contrast to the other models the inception_v3 expects tensors with a size of
N x 3 x 299 x 299, so ensure your images are sized ... | torchvision/models/inception.py | def inception_v3(pretrained=False, **kwargs):
r"""Inception v3 model architecture from
`"Rethinking the Inception Architecture for Computer Vision" <http://arxiv.org/abs/1512.00567>`_.
.. note::
**Important**: In contrast to the other models the inception_v3 expects tensors with a size of
N... | def inception_v3(pretrained=False, **kwargs):
r"""Inception v3 model architecture from
`"Rethinking the Inception Architecture for Computer Vision" <http://arxiv.org/abs/1512.00567>`_.
.. note::
**Important**: In contrast to the other models the inception_v3 expects tensors with a size of
N... | [
"r",
"Inception",
"v3",
"model",
"architecture",
"from",
"Rethinking",
"the",
"Inception",
"Architecture",
"for",
"Computer",
"Vision",
"<http",
":",
"//",
"arxiv",
".",
"org",
"/",
"abs",
"/",
"1512",
".",
"00567",
">",
"_",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/models/inception.py#L19-L49 | [
"def",
"inception_v3",
"(",
"pretrained",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"pretrained",
":",
"if",
"'transform_input'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'transform_input'",
"]",
"=",
"True",
"if",
"'aux_logits'",
"in",
"kw... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | SBU.download | Download and extract the tarball, and download each individual photo. | torchvision/datasets/sbu.py | def download(self):
"""Download and extract the tarball, and download each individual photo."""
import tarfile
if self._check_integrity():
print('Files already downloaded and verified')
return
download_url(self.url, self.root, self.filename, self.md5_checksum)
... | def download(self):
"""Download and extract the tarball, and download each individual photo."""
import tarfile
if self._check_integrity():
print('Files already downloaded and verified')
return
download_url(self.url, self.root, self.filename, self.md5_checksum)
... | [
"Download",
"and",
"extract",
"the",
"tarball",
"and",
"download",
"each",
"individual",
"photo",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/datasets/sbu.py#L87-L110 | [
"def",
"download",
"(",
"self",
")",
":",
"import",
"tarfile",
"if",
"self",
".",
"_check_integrity",
"(",
")",
":",
"print",
"(",
"'Files already downloaded and verified'",
")",
"return",
"download_url",
"(",
"self",
".",
"url",
",",
"self",
".",
"root",
",... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | googlenet | r"""GoogLeNet (Inception v1) model architecture from
`"Going Deeper with Convolutions" <http://arxiv.org/abs/1409.4842>`_.
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
aux_logits (bool): If True, adds two auxiliary branches that can improve training.
Def... | torchvision/models/googlenet.py | def googlenet(pretrained=False, **kwargs):
r"""GoogLeNet (Inception v1) model architecture from
`"Going Deeper with Convolutions" <http://arxiv.org/abs/1409.4842>`_.
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
aux_logits (bool): If True, adds two auxiliary bran... | def googlenet(pretrained=False, **kwargs):
r"""GoogLeNet (Inception v1) model architecture from
`"Going Deeper with Convolutions" <http://arxiv.org/abs/1409.4842>`_.
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
aux_logits (bool): If True, adds two auxiliary bran... | [
"r",
"GoogLeNet",
"(",
"Inception",
"v1",
")",
"model",
"architecture",
"from",
"Going",
"Deeper",
"with",
"Convolutions",
"<http",
":",
"//",
"arxiv",
".",
"org",
"/",
"abs",
"/",
"1409",
".",
"4842",
">",
"_",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/models/googlenet.py#L18-L47 | [
"def",
"googlenet",
"(",
"pretrained",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"pretrained",
":",
"if",
"'transform_input'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'transform_input'",
"]",
"=",
"True",
"if",
"'aux_logits'",
"not",
"in",... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | MNIST.download | Download the MNIST data if it doesn't exist in processed_folder already. | torchvision/datasets/mnist.py | def download(self):
"""Download the MNIST data if it doesn't exist in processed_folder already."""
if self._check_exists():
return
makedir_exist_ok(self.raw_folder)
makedir_exist_ok(self.processed_folder)
# download files
for url in self.urls:
f... | def download(self):
"""Download the MNIST data if it doesn't exist in processed_folder already."""
if self._check_exists():
return
makedir_exist_ok(self.raw_folder)
makedir_exist_ok(self.processed_folder)
# download files
for url in self.urls:
f... | [
"Download",
"the",
"MNIST",
"data",
"if",
"it",
"doesn",
"t",
"exist",
"in",
"processed_folder",
"already",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/datasets/mnist.py#L132-L164 | [
"def",
"download",
"(",
"self",
")",
":",
"if",
"self",
".",
"_check_exists",
"(",
")",
":",
"return",
"makedir_exist_ok",
"(",
"self",
".",
"raw_folder",
")",
"makedir_exist_ok",
"(",
"self",
".",
"processed_folder",
")",
"# download files",
"for",
"url",
"... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
test | EMNIST.download | Download the EMNIST data if it doesn't exist in processed_folder already. | torchvision/datasets/mnist.py | def download(self):
"""Download the EMNIST data if it doesn't exist in processed_folder already."""
import shutil
import zipfile
if self._check_exists():
return
makedir_exist_ok(self.raw_folder)
makedir_exist_ok(self.processed_folder)
# download fil... | def download(self):
"""Download the EMNIST data if it doesn't exist in processed_folder already."""
import shutil
import zipfile
if self._check_exists():
return
makedir_exist_ok(self.raw_folder)
makedir_exist_ok(self.processed_folder)
# download fil... | [
"Download",
"the",
"EMNIST",
"data",
"if",
"it",
"doesn",
"t",
"exist",
"in",
"processed_folder",
"already",
"."
] | pytorch/vision | python | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/datasets/mnist.py#L262-L304 | [
"def",
"download",
"(",
"self",
")",
":",
"import",
"shutil",
"import",
"zipfile",
"if",
"self",
".",
"_check_exists",
"(",
")",
":",
"return",
"makedir_exist_ok",
"(",
"self",
".",
"raw_folder",
")",
"makedir_exist_ok",
"(",
"self",
".",
"processed_folder",
... | 3afcf3cd49661c466c75ea536b0b2a7ff57f9a05 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.