id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
5,000 | googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table._init_job_from_response | def _init_job_from_response(self, response):
""" Helper function to create a Job instance from a response. """
job = None
if response and 'jobReference' in response:
job = _job.Job(job_id=response['jobReference']['jobId'], context=self._context)
return job | python | def _init_job_from_response(self, response):
""" Helper function to create a Job instance from a response. """
job = None
if response and 'jobReference' in response:
job = _job.Job(job_id=response['jobReference']['jobId'], context=self._context)
return job | [
"def",
"_init_job_from_response",
"(",
"self",
",",
"response",
")",
":",
"job",
"=",
"None",
"if",
"response",
"and",
"'jobReference'",
"in",
"response",
":",
"job",
"=",
"_job",
".",
"Job",
"(",
"job_id",
"=",
"response",
"[",
"'jobReference'",
"]",
"[",... | Helper function to create a Job instance from a response. | [
"Helper",
"function",
"to",
"create",
"a",
"Job",
"instance",
"from",
"a",
"response",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L393-L398 |
5,001 | googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table.extract_async | def extract_async(self, destination, format='csv', csv_delimiter=None, csv_header=True,
compress=False):
"""Starts a job to export the table to GCS.
Args:
destination: the destination URI(s). Can be a single URI or a list.
format: the format to use for the exported data; one of ... | python | def extract_async(self, destination, format='csv', csv_delimiter=None, csv_header=True,
compress=False):
"""Starts a job to export the table to GCS.
Args:
destination: the destination URI(s). Can be a single URI or a list.
format: the format to use for the exported data; one of ... | [
"def",
"extract_async",
"(",
"self",
",",
"destination",
",",
"format",
"=",
"'csv'",
",",
"csv_delimiter",
"=",
"None",
",",
"csv_header",
"=",
"True",
",",
"compress",
"=",
"False",
")",
":",
"format",
"=",
"format",
".",
"upper",
"(",
")",
"if",
"fo... | Starts a job to export the table to GCS.
Args:
destination: the destination URI(s). Can be a single URI or a list.
format: the format to use for the exported data; one of 'csv', 'json', or 'avro'
(default 'csv').
csv_delimiter: for CSV exports, the field delimiter to use. Defaults to ',... | [
"Starts",
"a",
"job",
"to",
"export",
"the",
"table",
"to",
"GCS",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L400-L426 |
5,002 | googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table.extract | def extract(self, destination, format='csv', csv_delimiter=None, csv_header=True, compress=False):
"""Exports the table to GCS; blocks until complete.
Args:
destination: the destination URI(s). Can be a single URI or a list.
format: the format to use for the exported data; one of 'csv', 'json', or ... | python | def extract(self, destination, format='csv', csv_delimiter=None, csv_header=True, compress=False):
"""Exports the table to GCS; blocks until complete.
Args:
destination: the destination URI(s). Can be a single URI or a list.
format: the format to use for the exported data; one of 'csv', 'json', or ... | [
"def",
"extract",
"(",
"self",
",",
"destination",
",",
"format",
"=",
"'csv'",
",",
"csv_delimiter",
"=",
"None",
",",
"csv_header",
"=",
"True",
",",
"compress",
"=",
"False",
")",
":",
"job",
"=",
"self",
".",
"extract_async",
"(",
"destination",
",",... | Exports the table to GCS; blocks until complete.
Args:
destination: the destination URI(s). Can be a single URI or a list.
format: the format to use for the exported data; one of 'csv', 'json', or 'avro'
(default 'csv').
csv_delimiter: for CSV exports, the field delimiter to use. Defaul... | [
"Exports",
"the",
"table",
"to",
"GCS",
";",
"blocks",
"until",
"complete",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L428-L446 |
5,003 | googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table.load_async | def load_async(self, source, mode='create', source_format='csv', csv_options=None,
ignore_unknown_values=False, max_bad_records=0):
""" Starts importing a table from GCS and return a Future.
Args:
source: the URL of the source objects(s). Can include a wildcard '*' at the end of the item... | python | def load_async(self, source, mode='create', source_format='csv', csv_options=None,
ignore_unknown_values=False, max_bad_records=0):
""" Starts importing a table from GCS and return a Future.
Args:
source: the URL of the source objects(s). Can include a wildcard '*' at the end of the item... | [
"def",
"load_async",
"(",
"self",
",",
"source",
",",
"mode",
"=",
"'create'",
",",
"source_format",
"=",
"'csv'",
",",
"csv_options",
"=",
"None",
",",
"ignore_unknown_values",
"=",
"False",
",",
"max_bad_records",
"=",
"0",
")",
":",
"if",
"source_format",... | Starts importing a table from GCS and return a Future.
Args:
source: the URL of the source objects(s). Can include a wildcard '*' at the end of the item
name. Can be a single source or a list.
mode: one of 'create', 'append', or 'overwrite'. 'append' or 'overwrite' will fail if the
t... | [
"Starts",
"importing",
"a",
"table",
"from",
"GCS",
"and",
"return",
"a",
"Future",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L448-L499 |
5,004 | googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table.load | def load(self, source, mode='create', source_format='csv', csv_options=None,
ignore_unknown_values=False, max_bad_records=0):
""" Load the table from GCS.
Args:
source: the URL of the source objects(s). Can include a wildcard '*' at the end of the item
name. Can be a single source or ... | python | def load(self, source, mode='create', source_format='csv', csv_options=None,
ignore_unknown_values=False, max_bad_records=0):
""" Load the table from GCS.
Args:
source: the URL of the source objects(s). Can include a wildcard '*' at the end of the item
name. Can be a single source or ... | [
"def",
"load",
"(",
"self",
",",
"source",
",",
"mode",
"=",
"'create'",
",",
"source_format",
"=",
"'csv'",
",",
"csv_options",
"=",
"None",
",",
"ignore_unknown_values",
"=",
"False",
",",
"max_bad_records",
"=",
"0",
")",
":",
"job",
"=",
"self",
".",... | Load the table from GCS.
Args:
source: the URL of the source objects(s). Can include a wildcard '*' at the end of the item
name. Can be a single source or a list.
mode: one of 'create', 'append', or 'overwrite'. 'append' or 'overwrite' will fail if the
table does not already exist, w... | [
"Load",
"the",
"table",
"from",
"GCS",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L501-L529 |
5,005 | googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table._get_row_fetcher | def _get_row_fetcher(self, start_row=0, max_rows=None, page_size=_DEFAULT_PAGE_SIZE):
""" Get a function that can retrieve a page of rows.
The function returned is a closure so that it can have a signature suitable for use
by Iterator.
Args:
start_row: the row to start fetching from; default 0.
... | python | def _get_row_fetcher(self, start_row=0, max_rows=None, page_size=_DEFAULT_PAGE_SIZE):
""" Get a function that can retrieve a page of rows.
The function returned is a closure so that it can have a signature suitable for use
by Iterator.
Args:
start_row: the row to start fetching from; default 0.
... | [
"def",
"_get_row_fetcher",
"(",
"self",
",",
"start_row",
"=",
"0",
",",
"max_rows",
"=",
"None",
",",
"page_size",
"=",
"_DEFAULT_PAGE_SIZE",
")",
":",
"if",
"not",
"start_row",
":",
"start_row",
"=",
"0",
"elif",
"start_row",
"<",
"0",
":",
"# We are mea... | Get a function that can retrieve a page of rows.
The function returned is a closure so that it can have a signature suitable for use
by Iterator.
Args:
start_row: the row to start fetching from; default 0.
max_rows: the maximum number of rows to fetch (across all calls, not per-call). Default
... | [
"Get",
"a",
"function",
"that",
"can",
"retrieve",
"a",
"page",
"of",
"rows",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L531-L588 |
5,006 | googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table.schema | def schema(self):
"""Retrieves the schema of the table.
Returns:
A Schema object containing a list of schema fields and associated metadata.
Raises
Exception if the request could not be executed or the response was malformed.
"""
if not self._schema:
try:
self._load_info()... | python | def schema(self):
"""Retrieves the schema of the table.
Returns:
A Schema object containing a list of schema fields and associated metadata.
Raises
Exception if the request could not be executed or the response was malformed.
"""
if not self._schema:
try:
self._load_info()... | [
"def",
"schema",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_schema",
":",
"try",
":",
"self",
".",
"_load_info",
"(",
")",
"self",
".",
"_schema",
"=",
"_schema",
".",
"Schema",
"(",
"self",
".",
"_info",
"[",
"'schema'",
"]",
"[",
"'fields... | Retrieves the schema of the table.
Returns:
A Schema object containing a list of schema fields and associated metadata.
Raises
Exception if the request could not be executed or the response was malformed. | [
"Retrieves",
"the",
"schema",
"of",
"the",
"table",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L662-L676 |
5,007 | googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table.snapshot | def snapshot(self, at):
""" Return a new Table which is a snapshot of this table at the specified time.
Args:
at: the time of the snapshot. This can be a Python datetime (absolute) or timedelta
(relative to current time). The result must be after the table was created and no more
than... | python | def snapshot(self, at):
""" Return a new Table which is a snapshot of this table at the specified time.
Args:
at: the time of the snapshot. This can be a Python datetime (absolute) or timedelta
(relative to current time). The result must be after the table was created and no more
than... | [
"def",
"snapshot",
"(",
"self",
",",
"at",
")",
":",
"if",
"self",
".",
"_name_parts",
".",
"decorator",
"!=",
"''",
":",
"raise",
"Exception",
"(",
"\"Cannot use snapshot() on an already decorated table\"",
")",
"value",
"=",
"Table",
".",
"_convert_decorator_tim... | Return a new Table which is a snapshot of this table at the specified time.
Args:
at: the time of the snapshot. This can be a Python datetime (absolute) or timedelta
(relative to current time). The result must be after the table was created and no more
than seven days in the past. Passing... | [
"Return",
"a",
"new",
"Table",
"which",
"is",
"a",
"snapshot",
"of",
"this",
"table",
"at",
"the",
"specified",
"time",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L803-L826 |
5,008 | googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table.window | def window(self, begin, end=None):
""" Return a new Table limited to the rows added to this Table during the specified time range.
Args:
begin: the start time of the window. This can be a Python datetime (absolute) or timedelta
(relative to current time). The result must be after the table was ... | python | def window(self, begin, end=None):
""" Return a new Table limited to the rows added to this Table during the specified time range.
Args:
begin: the start time of the window. This can be a Python datetime (absolute) or timedelta
(relative to current time). The result must be after the table was ... | [
"def",
"window",
"(",
"self",
",",
"begin",
",",
"end",
"=",
"None",
")",
":",
"if",
"self",
".",
"_name_parts",
".",
"decorator",
"!=",
"''",
":",
"raise",
"Exception",
"(",
"\"Cannot use window() on an already decorated table\"",
")",
"start",
"=",
"Table",
... | Return a new Table limited to the rows added to this Table during the specified time range.
Args:
begin: the start time of the window. This can be a Python datetime (absolute) or timedelta
(relative to current time). The result must be after the table was created and no more
than seven da... | [
"Return",
"a",
"new",
"Table",
"limited",
"to",
"the",
"rows",
"added",
"to",
"this",
"Table",
"during",
"the",
"specified",
"time",
"range",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L828-L870 |
5,009 | googledatalab/pydatalab | solutionbox/ml_workbench/xgboost/transform.py | serialize_example | def serialize_example(transformed_json_data, features, feature_indices, target_name):
"""Makes an instance of data in libsvm format.
Args:
transformed_json_data: dict of transformed data.
features: features config.
feature_indices: output of feature_transforms.get_transformed_feature_indices()
Retur... | python | def serialize_example(transformed_json_data, features, feature_indices, target_name):
"""Makes an instance of data in libsvm format.
Args:
transformed_json_data: dict of transformed data.
features: features config.
feature_indices: output of feature_transforms.get_transformed_feature_indices()
Retur... | [
"def",
"serialize_example",
"(",
"transformed_json_data",
",",
"features",
",",
"feature_indices",
",",
"target_name",
")",
":",
"import",
"six",
"import",
"tensorflow",
"as",
"tf",
"from",
"trainer",
"import",
"feature_transforms",
"line",
"=",
"str",
"(",
"trans... | Makes an instance of data in libsvm format.
Args:
transformed_json_data: dict of transformed data.
features: features config.
feature_indices: output of feature_transforms.get_transformed_feature_indices()
Returns:
The text line representation of an instance in libsvm format. | [
"Makes",
"an",
"instance",
"of",
"data",
"in",
"libsvm",
"format",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/xgboost/transform.py#L392-L421 |
5,010 | googledatalab/pydatalab | datalab/bigquery/_dataset.py | Dataset.delete | def delete(self, delete_contents=False):
"""Issues a request to delete the dataset.
Args:
delete_contents: if True, any tables and views in the dataset will be deleted. If False
and the dataset is non-empty an exception will be raised.
Returns:
None on success.
Raises:
Excep... | python | def delete(self, delete_contents=False):
"""Issues a request to delete the dataset.
Args:
delete_contents: if True, any tables and views in the dataset will be deleted. If False
and the dataset is non-empty an exception will be raised.
Returns:
None on success.
Raises:
Excep... | [
"def",
"delete",
"(",
"self",
",",
"delete_contents",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"exists",
"(",
")",
":",
"raise",
"Exception",
"(",
"'Cannot delete non-existent dataset %s'",
"%",
"self",
".",
"_full_name",
")",
"try",
":",
"self",
... | Issues a request to delete the dataset.
Args:
delete_contents: if True, any tables and views in the dataset will be deleted. If False
and the dataset is non-empty an exception will be raised.
Returns:
None on success.
Raises:
Exception if the delete fails (including if table was... | [
"Issues",
"a",
"request",
"to",
"delete",
"the",
"dataset",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_dataset.py#L101-L119 |
5,011 | googledatalab/pydatalab | datalab/bigquery/_dataset.py | Dataset.create | def create(self, friendly_name=None, description=None):
"""Creates the Dataset with the specified friendly name and description.
Args:
friendly_name: (optional) the friendly name for the dataset if it is being created.
description: (optional) a description for the dataset if it is being created.
... | python | def create(self, friendly_name=None, description=None):
"""Creates the Dataset with the specified friendly name and description.
Args:
friendly_name: (optional) the friendly name for the dataset if it is being created.
description: (optional) a description for the dataset if it is being created.
... | [
"def",
"create",
"(",
"self",
",",
"friendly_name",
"=",
"None",
",",
"description",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"exists",
"(",
")",
":",
"try",
":",
"response",
"=",
"self",
".",
"_api",
".",
"datasets_insert",
"(",
"self",
".",... | Creates the Dataset with the specified friendly name and description.
Args:
friendly_name: (optional) the friendly name for the dataset if it is being created.
description: (optional) a description for the dataset if it is being created.
Returns:
The Dataset.
Raises:
Exception if th... | [
"Creates",
"the",
"Dataset",
"with",
"the",
"specified",
"friendly",
"name",
"and",
"description",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_dataset.py#L121-L141 |
5,012 | googledatalab/pydatalab | datalab/bigquery/_dataset.py | Dataset.update | def update(self, friendly_name=None, description=None):
""" Selectively updates Dataset information.
Args:
friendly_name: if not None, the new friendly name.
description: if not None, the new description.
Returns:
"""
self._get_info()
if self._info:
if friendly_name:
... | python | def update(self, friendly_name=None, description=None):
""" Selectively updates Dataset information.
Args:
friendly_name: if not None, the new friendly name.
description: if not None, the new description.
Returns:
"""
self._get_info()
if self._info:
if friendly_name:
... | [
"def",
"update",
"(",
"self",
",",
"friendly_name",
"=",
"None",
",",
"description",
"=",
"None",
")",
":",
"self",
".",
"_get_info",
"(",
")",
"if",
"self",
".",
"_info",
":",
"if",
"friendly_name",
":",
"self",
".",
"_info",
"[",
"'friendlyName'",
"]... | Selectively updates Dataset information.
Args:
friendly_name: if not None, the new friendly name.
description: if not None, the new description.
Returns: | [
"Selectively",
"updates",
"Dataset",
"information",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_dataset.py#L143-L164 |
5,013 | googledatalab/pydatalab | google/datalab/bigquery/_view.py | View.query | def query(self):
"""The Query that defines the view."""
if not self.exists():
return None
self._table._load_info()
if 'view' in self._table._info and 'query' in self._table._info['view']:
return _query.Query(self._table._info['view']['query'])
return None | python | def query(self):
"""The Query that defines the view."""
if not self.exists():
return None
self._table._load_info()
if 'view' in self._table._info and 'query' in self._table._info['view']:
return _query.Query(self._table._info['view']['query'])
return None | [
"def",
"query",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"exists",
"(",
")",
":",
"return",
"None",
"self",
".",
"_table",
".",
"_load_info",
"(",
")",
"if",
"'view'",
"in",
"self",
".",
"_table",
".",
"_info",
"and",
"'query'",
"in",
"self... | The Query that defines the view. | [
"The",
"Query",
"that",
"defines",
"the",
"view",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_view.py#L70-L77 |
5,014 | googledatalab/pydatalab | solutionbox/structured_data/mltoolbox/_structured_data/preprocess/local_preprocess.py | run_numerical_categorical_analysis | def run_numerical_categorical_analysis(args, schema_list):
"""Makes the numerical and categorical analysis files.
Args:
args: the command line args
schema_list: python object of the schema json file.
Raises:
ValueError: if schema contains unknown column types.
"""
header = [column['name'] for co... | python | def run_numerical_categorical_analysis(args, schema_list):
"""Makes the numerical and categorical analysis files.
Args:
args: the command line args
schema_list: python object of the schema json file.
Raises:
ValueError: if schema contains unknown column types.
"""
header = [column['name'] for co... | [
"def",
"run_numerical_categorical_analysis",
"(",
"args",
",",
"schema_list",
")",
":",
"header",
"=",
"[",
"column",
"[",
"'name'",
"]",
"for",
"column",
"in",
"schema_list",
"]",
"input_files",
"=",
"file_io",
".",
"get_matching_files",
"(",
"args",
".",
"in... | Makes the numerical and categorical analysis files.
Args:
args: the command line args
schema_list: python object of the schema json file.
Raises:
ValueError: if schema contains unknown column types. | [
"Makes",
"the",
"numerical",
"and",
"categorical",
"analysis",
"files",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/structured_data/mltoolbox/_structured_data/preprocess/local_preprocess.py#L69-L144 |
5,015 | googledatalab/pydatalab | solutionbox/structured_data/mltoolbox/_structured_data/preprocess/local_preprocess.py | run_analysis | def run_analysis(args):
"""Builds an analysis files for training."""
# Read the schema and input feature types
schema_list = json.loads(
file_io.read_file_to_string(args.schema_file))
run_numerical_categorical_analysis(args, schema_list)
# Also save a copy of the schema in the output folder.
file_i... | python | def run_analysis(args):
"""Builds an analysis files for training."""
# Read the schema and input feature types
schema_list = json.loads(
file_io.read_file_to_string(args.schema_file))
run_numerical_categorical_analysis(args, schema_list)
# Also save a copy of the schema in the output folder.
file_i... | [
"def",
"run_analysis",
"(",
"args",
")",
":",
"# Read the schema and input feature types",
"schema_list",
"=",
"json",
".",
"loads",
"(",
"file_io",
".",
"read_file_to_string",
"(",
"args",
".",
"schema_file",
")",
")",
"run_numerical_categorical_analysis",
"(",
"args... | Builds an analysis files for training. | [
"Builds",
"an",
"analysis",
"files",
"for",
"training",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/structured_data/mltoolbox/_structured_data/preprocess/local_preprocess.py#L147-L159 |
5,016 | googledatalab/pydatalab | google/datalab/utils/commands/_html.py | Html._repr_html_ | def _repr_html_(self):
"""Generates the HTML representation.
"""
parts = []
if self._class:
parts.append('<div id="hh_%s" class="%s">%s</div>' % (self._id, self._class, self._markup))
else:
parts.append('<div id="hh_%s">%s</div>' % (self._id, self._markup))
if len(self._script) != 0... | python | def _repr_html_(self):
"""Generates the HTML representation.
"""
parts = []
if self._class:
parts.append('<div id="hh_%s" class="%s">%s</div>' % (self._id, self._class, self._markup))
else:
parts.append('<div id="hh_%s">%s</div>' % (self._id, self._markup))
if len(self._script) != 0... | [
"def",
"_repr_html_",
"(",
"self",
")",
":",
"parts",
"=",
"[",
"]",
"if",
"self",
".",
"_class",
":",
"parts",
".",
"append",
"(",
"'<div id=\"hh_%s\" class=\"%s\">%s</div>'",
"%",
"(",
"self",
".",
"_id",
",",
"self",
".",
"_class",
",",
"self",
".",
... | Generates the HTML representation. | [
"Generates",
"the",
"HTML",
"representation",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_html.py#L64-L84 |
5,017 | googledatalab/pydatalab | google/datalab/utils/commands/_html.py | HtmlBuilder._render_objects | def _render_objects(self, items, attributes=None, datatype='object'):
"""Renders an HTML table with the specified list of objects.
Args:
items: the iterable collection of objects to render.
attributes: the optional list of properties or keys to render.
datatype: the type of data; one of 'obje... | python | def _render_objects(self, items, attributes=None, datatype='object'):
"""Renders an HTML table with the specified list of objects.
Args:
items: the iterable collection of objects to render.
attributes: the optional list of properties or keys to render.
datatype: the type of data; one of 'obje... | [
"def",
"_render_objects",
"(",
"self",
",",
"items",
",",
"attributes",
"=",
"None",
",",
"datatype",
"=",
"'object'",
")",
":",
"if",
"not",
"items",
":",
"return",
"if",
"datatype",
"==",
"'chartdata'",
":",
"if",
"not",
"attributes",
":",
"attributes",
... | Renders an HTML table with the specified list of objects.
Args:
items: the iterable collection of objects to render.
attributes: the optional list of properties or keys to render.
datatype: the type of data; one of 'object' for Python objects, 'dict' for a list
of dictionaries, or 'char... | [
"Renders",
"an",
"HTML",
"table",
"with",
"the",
"specified",
"list",
"of",
"objects",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_html.py#L96-L149 |
5,018 | googledatalab/pydatalab | google/datalab/utils/commands/_html.py | HtmlBuilder._render_list | def _render_list(self, items, empty='<pre><empty></pre>'):
"""Renders an HTML list with the specified list of strings.
Args:
items: the iterable collection of objects to render.
empty: what to render if the list is None or empty.
"""
if not items or len(items) == 0:
self._segmen... | python | def _render_list(self, items, empty='<pre><empty></pre>'):
"""Renders an HTML list with the specified list of strings.
Args:
items: the iterable collection of objects to render.
empty: what to render if the list is None or empty.
"""
if not items or len(items) == 0:
self._segmen... | [
"def",
"_render_list",
"(",
"self",
",",
"items",
",",
"empty",
"=",
"'<pre><empty></pre>'",
")",
":",
"if",
"not",
"items",
"or",
"len",
"(",
"items",
")",
"==",
"0",
":",
"self",
".",
"_segments",
".",
"append",
"(",
"empty",
")",
"return",
"se... | Renders an HTML list with the specified list of strings.
Args:
items: the iterable collection of objects to render.
empty: what to render if the list is None or empty. | [
"Renders",
"an",
"HTML",
"list",
"with",
"the",
"specified",
"list",
"of",
"strings",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_html.py#L161-L176 |
5,019 | googledatalab/pydatalab | datalab/bigquery/_table.py | Table.sample | def sample(self, fields=None, count=5, sampling=None, use_cache=True, dialect=None,
billing_tier=None):
"""Retrieves a sampling of data from the table.
Args:
fields: an optional list of field names to retrieve.
count: an optional count of rows to retrieve which is used if a specific
... | python | def sample(self, fields=None, count=5, sampling=None, use_cache=True, dialect=None,
billing_tier=None):
"""Retrieves a sampling of data from the table.
Args:
fields: an optional list of field names to retrieve.
count: an optional count of rows to retrieve which is used if a specific
... | [
"def",
"sample",
"(",
"self",
",",
"fields",
"=",
"None",
",",
"count",
"=",
"5",
",",
"sampling",
"=",
"None",
",",
"use_cache",
"=",
"True",
",",
"dialect",
"=",
"None",
",",
"billing_tier",
"=",
"None",
")",
":",
"# Do import here to avoid top-level cir... | Retrieves a sampling of data from the table.
Args:
fields: an optional list of field names to retrieve.
count: an optional count of rows to retrieve which is used if a specific
sampling is not specified.
sampling: an optional sampling strategy to apply to the table.
use_cache: whe... | [
"Retrieves",
"a",
"sampling",
"of",
"data",
"from",
"the",
"table",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_table.py#L248-L277 |
5,020 | googledatalab/pydatalab | datalab/bigquery/_table.py | Table._encode_dict_as_row | def _encode_dict_as_row(record, column_name_map):
""" Encode a dictionary representing a table row in a form suitable for streaming to BQ.
This includes encoding timestamps as ISO-compatible strings and removing invalid
characters from column names.
Args:
record: a Python dictionary represen... | python | def _encode_dict_as_row(record, column_name_map):
""" Encode a dictionary representing a table row in a form suitable for streaming to BQ.
This includes encoding timestamps as ISO-compatible strings and removing invalid
characters from column names.
Args:
record: a Python dictionary represen... | [
"def",
"_encode_dict_as_row",
"(",
"record",
",",
"column_name_map",
")",
":",
"for",
"k",
"in",
"list",
"(",
"record",
".",
"keys",
"(",
")",
")",
":",
"v",
"=",
"record",
"[",
"k",
"]",
"# If the column is a date, convert to ISO string.",
"if",
"isinstance",... | Encode a dictionary representing a table row in a form suitable for streaming to BQ.
This includes encoding timestamps as ISO-compatible strings and removing invalid
characters from column names.
Args:
record: a Python dictionary representing the table row.
column_name_map: a dictionary ma... | [
"Encode",
"a",
"dictionary",
"representing",
"a",
"table",
"row",
"in",
"a",
"form",
"suitable",
"for",
"streaming",
"to",
"BQ",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_table.py#L280-L307 |
5,021 | googledatalab/pydatalab | datalab/bigquery/_table.py | Table.insert_data | def insert_data(self, data, include_index=False, index_name=None):
""" Insert the contents of a Pandas DataFrame or a list of dictionaries into the table.
The insertion will be performed using at most 500 rows per POST, and at most 10 POSTs per
second, as BigQuery has some limits on streaming rates.
A... | python | def insert_data(self, data, include_index=False, index_name=None):
""" Insert the contents of a Pandas DataFrame or a list of dictionaries into the table.
The insertion will be performed using at most 500 rows per POST, and at most 10 POSTs per
second, as BigQuery has some limits on streaming rates.
A... | [
"def",
"insert_data",
"(",
"self",
",",
"data",
",",
"include_index",
"=",
"False",
",",
"index_name",
"=",
"None",
")",
":",
"# TODO(gram): we could create the Table here is it doesn't exist using a schema derived",
"# from the data. IIRC we decided not to but doing so seems less ... | Insert the contents of a Pandas DataFrame or a list of dictionaries into the table.
The insertion will be performed using at most 500 rows per POST, and at most 10 POSTs per
second, as BigQuery has some limits on streaming rates.
Args:
data: the DataFrame or list to insert.
include_index: whet... | [
"Insert",
"the",
"contents",
"of",
"a",
"Pandas",
"DataFrame",
"or",
"a",
"list",
"of",
"dictionaries",
"into",
"the",
"table",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_table.py#L309-L417 |
5,022 | googledatalab/pydatalab | datalab/bigquery/_table.py | Table.range | def range(self, start_row=0, max_rows=None):
""" Get an iterator to iterate through a set of table rows.
Args:
start_row: the row of the table at which to start the iteration (default 0)
max_rows: an upper limit on the number of rows to iterate through (default None)
Returns:
A row itera... | python | def range(self, start_row=0, max_rows=None):
""" Get an iterator to iterate through a set of table rows.
Args:
start_row: the row of the table at which to start the iteration (default 0)
max_rows: an upper limit on the number of rows to iterate through (default None)
Returns:
A row itera... | [
"def",
"range",
"(",
"self",
",",
"start_row",
"=",
"0",
",",
"max_rows",
"=",
"None",
")",
":",
"fetcher",
"=",
"self",
".",
"_get_row_fetcher",
"(",
"start_row",
"=",
"start_row",
",",
"max_rows",
"=",
"max_rows",
")",
"return",
"iter",
"(",
"datalab",... | Get an iterator to iterate through a set of table rows.
Args:
start_row: the row of the table at which to start the iteration (default 0)
max_rows: an upper limit on the number of rows to iterate through (default None)
Returns:
A row iterator. | [
"Get",
"an",
"iterator",
"to",
"iterate",
"through",
"a",
"set",
"of",
"table",
"rows",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_table.py#L614-L625 |
5,023 | googledatalab/pydatalab | datalab/bigquery/_table.py | Table.to_file_async | def to_file_async(self, destination, format='csv', csv_delimiter=',', csv_header=True):
"""Start saving the results to a local file in CSV format and return a Job for completion.
Args:
destination: path on the local filesystem for the saved results.
format: the format to use for the exported data; ... | python | def to_file_async(self, destination, format='csv', csv_delimiter=',', csv_header=True):
"""Start saving the results to a local file in CSV format and return a Job for completion.
Args:
destination: path on the local filesystem for the saved results.
format: the format to use for the exported data; ... | [
"def",
"to_file_async",
"(",
"self",
",",
"destination",
",",
"format",
"=",
"'csv'",
",",
"csv_delimiter",
"=",
"','",
",",
"csv_header",
"=",
"True",
")",
":",
"self",
".",
"to_file",
"(",
"destination",
",",
"format",
"=",
"format",
",",
"csv_delimiter"... | Start saving the results to a local file in CSV format and return a Job for completion.
Args:
destination: path on the local filesystem for the saved results.
format: the format to use for the exported data; currently only 'csv' is supported.
csv_delimiter: for CSV exports, the field delimiter to... | [
"Start",
"saving",
"the",
"results",
"to",
"a",
"local",
"file",
"in",
"CSV",
"format",
"and",
"return",
"a",
"Job",
"for",
"completion",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_table.py#L680-L693 |
5,024 | googledatalab/pydatalab | datalab/bigquery/_table.py | Table.update | def update(self, friendly_name=None, description=None, expiry=None, schema=None):
""" Selectively updates Table information.
Any parameters that are omitted or None are not updated.
Args:
friendly_name: if not None, the new friendly name.
description: if not None, the new description.
ex... | python | def update(self, friendly_name=None, description=None, expiry=None, schema=None):
""" Selectively updates Table information.
Any parameters that are omitted or None are not updated.
Args:
friendly_name: if not None, the new friendly name.
description: if not None, the new description.
ex... | [
"def",
"update",
"(",
"self",
",",
"friendly_name",
"=",
"None",
",",
"description",
"=",
"None",
",",
"expiry",
"=",
"None",
",",
"schema",
"=",
"None",
")",
":",
"self",
".",
"_load_info",
"(",
")",
"if",
"friendly_name",
"is",
"not",
"None",
":",
... | Selectively updates Table information.
Any parameters that are omitted or None are not updated.
Args:
friendly_name: if not None, the new friendly name.
description: if not None, the new description.
expiry: if not None, the new expiry time, either as a DateTime or milliseconds since epoch.
... | [
"Selectively",
"updates",
"Table",
"information",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_table.py#L712-L742 |
5,025 | googledatalab/pydatalab | datalab/bigquery/_table.py | Table.to_query | def to_query(self, fields=None):
""" Return a Query for this Table.
Args:
fields: the fields to return. If None, all fields will be returned. This can be a string
which will be injected into the Query after SELECT, or a list of field names.
Returns:
A Query object that will return th... | python | def to_query(self, fields=None):
""" Return a Query for this Table.
Args:
fields: the fields to return. If None, all fields will be returned. This can be a string
which will be injected into the Query after SELECT, or a list of field names.
Returns:
A Query object that will return th... | [
"def",
"to_query",
"(",
"self",
",",
"fields",
"=",
"None",
")",
":",
"# Do import here to avoid top-level circular dependencies.",
"from",
".",
"import",
"_query",
"if",
"fields",
"is",
"None",
":",
"fields",
"=",
"'*'",
"elif",
"isinstance",
"(",
"fields",
","... | Return a Query for this Table.
Args:
fields: the fields to return. If None, all fields will be returned. This can be a string
which will be injected into the Query after SELECT, or a list of field names.
Returns:
A Query object that will return the specified fields from the records in th... | [
"Return",
"a",
"Query",
"for",
"this",
"Table",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_table.py#L914-L930 |
5,026 | googledatalab/pydatalab | datalab/storage/_item.py | Item.copy_to | def copy_to(self, new_key, bucket=None):
"""Copies this item to the specified new key.
Args:
new_key: the new key to copy this item to.
bucket: the bucket of the new item; if None (the default) use the same bucket.
Returns:
An Item corresponding to new key.
Raises:
Exception if ... | python | def copy_to(self, new_key, bucket=None):
"""Copies this item to the specified new key.
Args:
new_key: the new key to copy this item to.
bucket: the bucket of the new item; if None (the default) use the same bucket.
Returns:
An Item corresponding to new key.
Raises:
Exception if ... | [
"def",
"copy_to",
"(",
"self",
",",
"new_key",
",",
"bucket",
"=",
"None",
")",
":",
"if",
"bucket",
"is",
"None",
":",
"bucket",
"=",
"self",
".",
"_bucket",
"try",
":",
"new_info",
"=",
"self",
".",
"_api",
".",
"objects_copy",
"(",
"self",
".",
... | Copies this item to the specified new key.
Args:
new_key: the new key to copy this item to.
bucket: the bucket of the new item; if None (the default) use the same bucket.
Returns:
An Item corresponding to new key.
Raises:
Exception if there was an error copying the item. | [
"Copies",
"this",
"item",
"to",
"the",
"specified",
"new",
"key",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/storage/_item.py#L111-L128 |
5,027 | googledatalab/pydatalab | datalab/storage/_item.py | Item.exists | def exists(self):
""" Checks if the item exists. """
try:
return self.metadata is not None
except datalab.utils.RequestException:
return False
except Exception as e:
raise e | python | def exists(self):
""" Checks if the item exists. """
try:
return self.metadata is not None
except datalab.utils.RequestException:
return False
except Exception as e:
raise e | [
"def",
"exists",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"metadata",
"is",
"not",
"None",
"except",
"datalab",
".",
"utils",
".",
"RequestException",
":",
"return",
"False",
"except",
"Exception",
"as",
"e",
":",
"raise",
"e"
] | Checks if the item exists. | [
"Checks",
"if",
"the",
"item",
"exists",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/storage/_item.py#L130-L137 |
5,028 | googledatalab/pydatalab | datalab/storage/_item.py | Item.delete | def delete(self):
"""Deletes this item from its bucket.
Raises:
Exception if there was an error deleting the item.
"""
if self.exists():
try:
self._api.objects_delete(self._bucket, self._key)
except Exception as e:
raise e | python | def delete(self):
"""Deletes this item from its bucket.
Raises:
Exception if there was an error deleting the item.
"""
if self.exists():
try:
self._api.objects_delete(self._bucket, self._key)
except Exception as e:
raise e | [
"def",
"delete",
"(",
"self",
")",
":",
"if",
"self",
".",
"exists",
"(",
")",
":",
"try",
":",
"self",
".",
"_api",
".",
"objects_delete",
"(",
"self",
".",
"_bucket",
",",
"self",
".",
"_key",
")",
"except",
"Exception",
"as",
"e",
":",
"raise",
... | Deletes this item from its bucket.
Raises:
Exception if there was an error deleting the item. | [
"Deletes",
"this",
"item",
"from",
"its",
"bucket",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/storage/_item.py#L139-L149 |
5,029 | googledatalab/pydatalab | datalab/storage/_item.py | Item.write_to | def write_to(self, content, content_type):
"""Writes text content to this item.
Args:
content: the text content to be written.
content_type: the type of text content.
Raises:
Exception if there was an error requesting the item's content.
"""
try:
self._api.object_upload(self... | python | def write_to(self, content, content_type):
"""Writes text content to this item.
Args:
content: the text content to be written.
content_type: the type of text content.
Raises:
Exception if there was an error requesting the item's content.
"""
try:
self._api.object_upload(self... | [
"def",
"write_to",
"(",
"self",
",",
"content",
",",
"content_type",
")",
":",
"try",
":",
"self",
".",
"_api",
".",
"object_upload",
"(",
"self",
".",
"_bucket",
",",
"self",
".",
"_key",
",",
"content",
",",
"content_type",
")",
"except",
"Exception",
... | Writes text content to this item.
Args:
content: the text content to be written.
content_type: the type of text content.
Raises:
Exception if there was an error requesting the item's content. | [
"Writes",
"text",
"content",
"to",
"this",
"item",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/storage/_item.py#L212-L224 |
5,030 | googledatalab/pydatalab | datalab/storage/_item.py | Items.contains | def contains(self, key):
"""Checks if the specified item exists.
Args:
key: the key of the item to lookup.
Returns:
True if the item exists; False otherwise.
Raises:
Exception if there was an error requesting information about the item.
"""
try:
self._api.objects_get(sel... | python | def contains(self, key):
"""Checks if the specified item exists.
Args:
key: the key of the item to lookup.
Returns:
True if the item exists; False otherwise.
Raises:
Exception if there was an error requesting information about the item.
"""
try:
self._api.objects_get(sel... | [
"def",
"contains",
"(",
"self",
",",
"key",
")",
":",
"try",
":",
"self",
".",
"_api",
".",
"objects_get",
"(",
"self",
".",
"_bucket",
",",
"key",
")",
"except",
"datalab",
".",
"utils",
".",
"RequestException",
"as",
"e",
":",
"if",
"e",
".",
"st... | Checks if the specified item exists.
Args:
key: the key of the item to lookup.
Returns:
True if the item exists; False otherwise.
Raises:
Exception if there was an error requesting information about the item. | [
"Checks",
"if",
"the",
"specified",
"item",
"exists",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/storage/_item.py#L252-L270 |
5,031 | googledatalab/pydatalab | google/datalab/utils/_http.py | Http.request | def request(url, args=None, data=None, headers=None, method=None,
credentials=None, raw_response=False, stats=None):
"""Issues HTTP requests.
Args:
url: the URL to request.
args: optional query string arguments.
data: optional data to be sent within the request.
headers: o... | python | def request(url, args=None, data=None, headers=None, method=None,
credentials=None, raw_response=False, stats=None):
"""Issues HTTP requests.
Args:
url: the URL to request.
args: optional query string arguments.
data: optional data to be sent within the request.
headers: o... | [
"def",
"request",
"(",
"url",
",",
"args",
"=",
"None",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"method",
"=",
"None",
",",
"credentials",
"=",
"None",
",",
"raw_response",
"=",
"False",
",",
"stats",
"=",
"None",
")",
":",
"if"... | Issues HTTP requests.
Args:
url: the URL to request.
args: optional query string arguments.
data: optional data to be sent within the request.
headers: optional headers to include in the request.
method: optional HTTP method to use. If unspecified this is inferred
(GET or PO... | [
"Issues",
"HTTP",
"requests",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/_http.py#L81-L167 |
5,032 | googledatalab/pydatalab | google/datalab/contrib/pipeline/commands/_pipeline.py | _add_command | def _add_command(parser, subparser_fn, handler, cell_required=False,
cell_prohibited=False):
""" Create and initialize a pipeline subcommand handler. """
sub_parser = subparser_fn(parser)
sub_parser.set_defaults(func=lambda args, cell: _dispatch_handler(
args, cell, sub_parser, handler, cel... | python | def _add_command(parser, subparser_fn, handler, cell_required=False,
cell_prohibited=False):
""" Create and initialize a pipeline subcommand handler. """
sub_parser = subparser_fn(parser)
sub_parser.set_defaults(func=lambda args, cell: _dispatch_handler(
args, cell, sub_parser, handler, cel... | [
"def",
"_add_command",
"(",
"parser",
",",
"subparser_fn",
",",
"handler",
",",
"cell_required",
"=",
"False",
",",
"cell_prohibited",
"=",
"False",
")",
":",
"sub_parser",
"=",
"subparser_fn",
"(",
"parser",
")",
"sub_parser",
".",
"set_defaults",
"(",
"func"... | Create and initialize a pipeline subcommand handler. | [
"Create",
"and",
"initialize",
"a",
"pipeline",
"subcommand",
"handler",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/pipeline/commands/_pipeline.py#L57-L63 |
5,033 | googledatalab/pydatalab | google/datalab/contrib/pipeline/commands/_pipeline.py | pipeline | def pipeline(line, cell=None):
"""Implements the pipeline cell magic for ipython notebooks.
The supported syntax is:
%%pipeline <command> [<args>]
<cell>
or:
%pipeline <command> [<args>]
Use %pipeline --help for a list of commands, or %pipeline <command> --help for
help on a specific command.... | python | def pipeline(line, cell=None):
"""Implements the pipeline cell magic for ipython notebooks.
The supported syntax is:
%%pipeline <command> [<args>]
<cell>
or:
%pipeline <command> [<args>]
Use %pipeline --help for a list of commands, or %pipeline <command> --help for
help on a specific command.... | [
"def",
"pipeline",
"(",
"line",
",",
"cell",
"=",
"None",
")",
":",
"return",
"google",
".",
"datalab",
".",
"utils",
".",
"commands",
".",
"handle_magic_line",
"(",
"line",
",",
"cell",
",",
"_pipeline_parser",
")"
] | Implements the pipeline cell magic for ipython notebooks.
The supported syntax is:
%%pipeline <command> [<args>]
<cell>
or:
%pipeline <command> [<args>]
Use %pipeline --help for a list of commands, or %pipeline <command> --help for
help on a specific command. | [
"Implements",
"the",
"pipeline",
"cell",
"magic",
"for",
"ipython",
"notebooks",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/pipeline/commands/_pipeline.py#L90-L105 |
5,034 | googledatalab/pydatalab | google/datalab/contrib/pipeline/commands/_pipeline.py | _dispatch_handler | def _dispatch_handler(args, cell, parser, handler, cell_required=False,
cell_prohibited=False):
""" Makes sure cell magics include cell and line magics don't, before
dispatching to handler.
Args:
args: the parsed arguments from the magic line.
cell: the contents of the cell, if an... | python | def _dispatch_handler(args, cell, parser, handler, cell_required=False,
cell_prohibited=False):
""" Makes sure cell magics include cell and line magics don't, before
dispatching to handler.
Args:
args: the parsed arguments from the magic line.
cell: the contents of the cell, if an... | [
"def",
"_dispatch_handler",
"(",
"args",
",",
"cell",
",",
"parser",
",",
"handler",
",",
"cell_required",
"=",
"False",
",",
"cell_prohibited",
"=",
"False",
")",
":",
"if",
"cell_prohibited",
":",
"if",
"cell",
"and",
"len",
"(",
"cell",
".",
"strip",
... | Makes sure cell magics include cell and line magics don't, before
dispatching to handler.
Args:
args: the parsed arguments from the magic line.
cell: the contents of the cell, if any.
parser: the argument parser for <cmd>; used for error message.
handler: the handler to call if the cell present/a... | [
"Makes",
"sure",
"cell",
"magics",
"include",
"cell",
"and",
"line",
"magics",
"don",
"t",
"before",
"dispatching",
"to",
"handler",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/pipeline/commands/_pipeline.py#L108-L138 |
5,035 | googledatalab/pydatalab | solutionbox/ml_workbench/xgboost/trainer/feature_analysis.py | expand_defaults | def expand_defaults(schema, features):
"""Add to features any default transformations.
Not every column in the schema has an explicit feature transformation listed
in the featurs file. For these columns, add a default transformation based on
the schema's type. The features dict is modified by this function cal... | python | def expand_defaults(schema, features):
"""Add to features any default transformations.
Not every column in the schema has an explicit feature transformation listed
in the featurs file. For these columns, add a default transformation based on
the schema's type. The features dict is modified by this function cal... | [
"def",
"expand_defaults",
"(",
"schema",
",",
"features",
")",
":",
"schema_names",
"=",
"[",
"x",
"[",
"'name'",
"]",
"for",
"x",
"in",
"schema",
"]",
"# Add missing source columns",
"for",
"name",
",",
"transform",
"in",
"six",
".",
"iteritems",
"(",
"fe... | Add to features any default transformations.
Not every column in the schema has an explicit feature transformation listed
in the featurs file. For these columns, add a default transformation based on
the schema's type. The features dict is modified by this function call.
After this function call, every column... | [
"Add",
"to",
"features",
"any",
"default",
"transformations",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/xgboost/trainer/feature_analysis.py#L114-L167 |
5,036 | googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | _sample_cell | def _sample_cell(args, cell_body):
"""Implements the bigquery sample cell magic for ipython notebooks.
Args:
args: the optional arguments following '%%bigquery sample'.
cell_body: optional contents of the cell interpreted as SQL, YAML or JSON.
Returns:
The results of executing the sampling query, or ... | python | def _sample_cell(args, cell_body):
"""Implements the bigquery sample cell magic for ipython notebooks.
Args:
args: the optional arguments following '%%bigquery sample'.
cell_body: optional contents of the cell interpreted as SQL, YAML or JSON.
Returns:
The results of executing the sampling query, or ... | [
"def",
"_sample_cell",
"(",
"args",
",",
"cell_body",
")",
":",
"env",
"=",
"datalab",
".",
"utils",
".",
"commands",
".",
"notebook_environment",
"(",
")",
"query",
"=",
"None",
"table",
"=",
"None",
"view",
"=",
"None",
"if",
"args",
"[",
"'query'",
... | Implements the bigquery sample cell magic for ipython notebooks.
Args:
args: the optional arguments following '%%bigquery sample'.
cell_body: optional contents of the cell interpreted as SQL, YAML or JSON.
Returns:
The results of executing the sampling query, or a profile of the sample data. | [
"Implements",
"the",
"bigquery",
"sample",
"cell",
"magic",
"for",
"ipython",
"notebooks",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L285-L339 |
5,037 | googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | _create_cell | def _create_cell(args, cell_body):
"""Implements the BigQuery cell magic used to create datasets and tables.
The supported syntax is:
%%bigquery create dataset -n|--name <name> [-f|--friendly <friendlyname>]
[<description>]
or:
%%bigquery create table -n|--name <tablename> [--overwrite]
... | python | def _create_cell(args, cell_body):
"""Implements the BigQuery cell magic used to create datasets and tables.
The supported syntax is:
%%bigquery create dataset -n|--name <name> [-f|--friendly <friendlyname>]
[<description>]
or:
%%bigquery create table -n|--name <tablename> [--overwrite]
... | [
"def",
"_create_cell",
"(",
"args",
",",
"cell_body",
")",
":",
"if",
"args",
"[",
"'command'",
"]",
"==",
"'dataset'",
":",
"try",
":",
"datalab",
".",
"bigquery",
".",
"Dataset",
"(",
"args",
"[",
"'name'",
"]",
")",
".",
"create",
"(",
"friendly_nam... | Implements the BigQuery cell magic used to create datasets and tables.
The supported syntax is:
%%bigquery create dataset -n|--name <name> [-f|--friendly <friendlyname>]
[<description>]
or:
%%bigquery create table -n|--name <tablename> [--overwrite]
[<YAML or JSON cell_body defining schema... | [
"Implements",
"the",
"BigQuery",
"cell",
"magic",
"used",
"to",
"create",
"datasets",
"and",
"tables",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L342-L375 |
5,038 | googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | _delete_cell | def _delete_cell(args, _):
"""Implements the BigQuery cell magic used to delete datasets and tables.
The supported syntax is:
%%bigquery delete dataset -n|--name <name>
or:
%%bigquery delete table -n|--name <name>
Args:
args: the argument following '%bigquery delete <command>'.
"""
# TO... | python | def _delete_cell(args, _):
"""Implements the BigQuery cell magic used to delete datasets and tables.
The supported syntax is:
%%bigquery delete dataset -n|--name <name>
or:
%%bigquery delete table -n|--name <name>
Args:
args: the argument following '%bigquery delete <command>'.
"""
# TO... | [
"def",
"_delete_cell",
"(",
"args",
",",
"_",
")",
":",
"# TODO(gram): add support for wildchars and multiple arguments at some point. The latter is",
"# easy, the former a bit more tricky if non-default projects are involved.",
"if",
"args",
"[",
"'command'",
"]",
"==",
"'dataset'",... | Implements the BigQuery cell magic used to delete datasets and tables.
The supported syntax is:
%%bigquery delete dataset -n|--name <name>
or:
%%bigquery delete table -n|--name <name>
Args:
args: the argument following '%bigquery delete <command>'. | [
"Implements",
"the",
"BigQuery",
"cell",
"magic",
"used",
"to",
"delete",
"datasets",
"and",
"tables",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L378-L403 |
5,039 | googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | _udf_cell | def _udf_cell(args, js):
"""Implements the bigquery_udf cell magic for ipython notebooks.
The supported syntax is:
%%bigquery udf --module <var>
<js function>
Args:
args: the optional arguments following '%%bigquery udf'.
js: the UDF declaration (inputs and outputs) and implementation in javascript.... | python | def _udf_cell(args, js):
"""Implements the bigquery_udf cell magic for ipython notebooks.
The supported syntax is:
%%bigquery udf --module <var>
<js function>
Args:
args: the optional arguments following '%%bigquery udf'.
js: the UDF declaration (inputs and outputs) and implementation in javascript.... | [
"def",
"_udf_cell",
"(",
"args",
",",
"js",
")",
":",
"variable_name",
"=",
"args",
"[",
"'module'",
"]",
"if",
"not",
"variable_name",
":",
"raise",
"Exception",
"(",
"'Declaration must be of the form %%bigquery udf --module <variable name>'",
")",
"# Parse out the inp... | Implements the bigquery_udf cell magic for ipython notebooks.
The supported syntax is:
%%bigquery udf --module <var>
<js function>
Args:
args: the optional arguments following '%%bigquery udf'.
js: the UDF declaration (inputs and outputs) and implementation in javascript.
Returns:
The results of... | [
"Implements",
"the",
"bigquery_udf",
"cell",
"magic",
"for",
"ipython",
"notebooks",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L428-L492 |
5,040 | googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | _pipeline_cell | def _pipeline_cell(args, cell_body):
"""Implements the BigQuery cell magic used to validate, execute or deploy BQ pipelines.
The supported syntax is:
%%bigquery pipeline [-q|--sql <query identifier>] <other args> <action>
[<YAML or JSON cell_body or inline SQL>]
Args:
args: the arguments following '%... | python | def _pipeline_cell(args, cell_body):
"""Implements the BigQuery cell magic used to validate, execute or deploy BQ pipelines.
The supported syntax is:
%%bigquery pipeline [-q|--sql <query identifier>] <other args> <action>
[<YAML or JSON cell_body or inline SQL>]
Args:
args: the arguments following '%... | [
"def",
"_pipeline_cell",
"(",
"args",
",",
"cell_body",
")",
":",
"if",
"args",
"[",
"'action'",
"]",
"==",
"'deploy'",
":",
"raise",
"Exception",
"(",
"'Deploying a pipeline is not yet supported'",
")",
"env",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in"... | Implements the BigQuery cell magic used to validate, execute or deploy BQ pipelines.
The supported syntax is:
%%bigquery pipeline [-q|--sql <query identifier>] <other args> <action>
[<YAML or JSON cell_body or inline SQL>]
Args:
args: the arguments following '%bigquery pipeline'.
cell_body: optiona... | [
"Implements",
"the",
"BigQuery",
"cell",
"magic",
"used",
"to",
"validate",
"execute",
"or",
"deploy",
"BQ",
"pipelines",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L516-L548 |
5,041 | googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | _table_line | def _table_line(args):
"""Implements the BigQuery table magic used to display tables.
The supported syntax is:
%bigquery table -t|--table <name> <other args>
Args:
args: the arguments following '%bigquery table'.
Returns:
The HTML rendering for the table.
"""
# TODO(gram): It would be good to ... | python | def _table_line(args):
"""Implements the BigQuery table magic used to display tables.
The supported syntax is:
%bigquery table -t|--table <name> <other args>
Args:
args: the arguments following '%bigquery table'.
Returns:
The HTML rendering for the table.
"""
# TODO(gram): It would be good to ... | [
"def",
"_table_line",
"(",
"args",
")",
":",
"# TODO(gram): It would be good to turn _table_viewer into a class that has a registered",
"# renderer. That would allow this to return a table viewer object which is easier to test.",
"name",
"=",
"args",
"[",
"'table'",
"]",
"table",
"=",
... | Implements the BigQuery table magic used to display tables.
The supported syntax is:
%bigquery table -t|--table <name> <other args>
Args:
args: the arguments following '%bigquery table'.
Returns:
The HTML rendering for the table. | [
"Implements",
"the",
"BigQuery",
"table",
"magic",
"used",
"to",
"display",
"tables",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L551-L571 |
5,042 | googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | _get_schema | def _get_schema(name):
""" Given a variable or table name, get the Schema if it exists. """
item = datalab.utils.commands.get_notebook_item(name)
if not item:
item = _get_table(name)
if isinstance(item, datalab.bigquery.Schema):
return item
if hasattr(item, 'schema') and isinstance(item.schema, datal... | python | def _get_schema(name):
""" Given a variable or table name, get the Schema if it exists. """
item = datalab.utils.commands.get_notebook_item(name)
if not item:
item = _get_table(name)
if isinstance(item, datalab.bigquery.Schema):
return item
if hasattr(item, 'schema') and isinstance(item.schema, datal... | [
"def",
"_get_schema",
"(",
"name",
")",
":",
"item",
"=",
"datalab",
".",
"utils",
".",
"commands",
".",
"get_notebook_item",
"(",
"name",
")",
"if",
"not",
"item",
":",
"item",
"=",
"_get_table",
"(",
"name",
")",
"if",
"isinstance",
"(",
"item",
",",... | Given a variable or table name, get the Schema if it exists. | [
"Given",
"a",
"variable",
"or",
"table",
"name",
"get",
"the",
"Schema",
"if",
"it",
"exists",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L574-L584 |
5,043 | googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | _render_table | def _render_table(data, fields=None):
""" Helper to render a list of dictionaries as an HTML display object. """
return IPython.core.display.HTML(datalab.utils.commands.HtmlBuilder.render_table(data, fields)) | python | def _render_table(data, fields=None):
""" Helper to render a list of dictionaries as an HTML display object. """
return IPython.core.display.HTML(datalab.utils.commands.HtmlBuilder.render_table(data, fields)) | [
"def",
"_render_table",
"(",
"data",
",",
"fields",
"=",
"None",
")",
":",
"return",
"IPython",
".",
"core",
".",
"display",
".",
"HTML",
"(",
"datalab",
".",
"utils",
".",
"commands",
".",
"HtmlBuilder",
".",
"render_table",
"(",
"data",
",",
"fields",
... | Helper to render a list of dictionaries as an HTML display object. | [
"Helper",
"to",
"render",
"a",
"list",
"of",
"dictionaries",
"as",
"an",
"HTML",
"display",
"object",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L636-L638 |
5,044 | googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | _datasets_line | def _datasets_line(args):
"""Implements the BigQuery datasets magic used to display datasets in a project.
The supported syntax is:
%bigquery datasets [-f <filter>] [-p|--project <project_id>]
Args:
args: the arguments following '%bigquery datasets'.
Returns:
The HTML rendering for the table ... | python | def _datasets_line(args):
"""Implements the BigQuery datasets magic used to display datasets in a project.
The supported syntax is:
%bigquery datasets [-f <filter>] [-p|--project <project_id>]
Args:
args: the arguments following '%bigquery datasets'.
Returns:
The HTML rendering for the table ... | [
"def",
"_datasets_line",
"(",
"args",
")",
":",
"filter_",
"=",
"args",
"[",
"'filter'",
"]",
"if",
"args",
"[",
"'filter'",
"]",
"else",
"'*'",
"return",
"_render_list",
"(",
"[",
"str",
"(",
"dataset",
")",
"for",
"dataset",
"in",
"datalab",
".",
"bi... | Implements the BigQuery datasets magic used to display datasets in a project.
The supported syntax is:
%bigquery datasets [-f <filter>] [-p|--project <project_id>]
Args:
args: the arguments following '%bigquery datasets'.
Returns:
The HTML rendering for the table of datasets. | [
"Implements",
"the",
"BigQuery",
"datasets",
"magic",
"used",
"to",
"display",
"datasets",
"in",
"a",
"project",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L646-L660 |
5,045 | googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | _tables_line | def _tables_line(args):
"""Implements the BigQuery tables magic used to display tables in a dataset.
The supported syntax is:
%bigquery tables -p|--project <project_id> -d|--dataset <dataset_id>
Args:
args: the arguments following '%bigquery tables'.
Returns:
The HTML rendering for the list ... | python | def _tables_line(args):
"""Implements the BigQuery tables magic used to display tables in a dataset.
The supported syntax is:
%bigquery tables -p|--project <project_id> -d|--dataset <dataset_id>
Args:
args: the arguments following '%bigquery tables'.
Returns:
The HTML rendering for the list ... | [
"def",
"_tables_line",
"(",
"args",
")",
":",
"filter_",
"=",
"args",
"[",
"'filter'",
"]",
"if",
"args",
"[",
"'filter'",
"]",
"else",
"'*'",
"if",
"args",
"[",
"'dataset'",
"]",
":",
"if",
"args",
"[",
"'project'",
"]",
"is",
"None",
":",
"datasets... | Implements the BigQuery tables magic used to display tables in a dataset.
The supported syntax is:
%bigquery tables -p|--project <project_id> -d|--dataset <dataset_id>
Args:
args: the arguments following '%bigquery tables'.
Returns:
The HTML rendering for the list of tables. | [
"Implements",
"the",
"BigQuery",
"tables",
"magic",
"used",
"to",
"display",
"tables",
"in",
"a",
"dataset",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L663-L688 |
5,046 | googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | _extract_line | def _extract_line(args):
"""Implements the BigQuery extract magic used to extract table data to GCS.
The supported syntax is:
%bigquery extract -S|--source <table> -D|--destination <url> <other_args>
Args:
args: the arguments following '%bigquery extract'.
Returns:
A message about whether the... | python | def _extract_line(args):
"""Implements the BigQuery extract magic used to extract table data to GCS.
The supported syntax is:
%bigquery extract -S|--source <table> -D|--destination <url> <other_args>
Args:
args: the arguments following '%bigquery extract'.
Returns:
A message about whether the... | [
"def",
"_extract_line",
"(",
"args",
")",
":",
"name",
"=",
"args",
"[",
"'source'",
"]",
"source",
"=",
"datalab",
".",
"utils",
".",
"commands",
".",
"get_notebook_item",
"(",
"name",
")",
"if",
"not",
"source",
":",
"source",
"=",
"_get_table",
"(",
... | Implements the BigQuery extract magic used to extract table data to GCS.
The supported syntax is:
%bigquery extract -S|--source <table> -D|--destination <url> <other_args>
Args:
args: the arguments following '%bigquery extract'.
Returns:
A message about whether the extract succeeded or failed. | [
"Implements",
"the",
"BigQuery",
"extract",
"magic",
"used",
"to",
"extract",
"table",
"data",
"to",
"GCS",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L691-L722 |
5,047 | googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | bigquery | def bigquery(line, cell=None):
"""Implements the bigquery cell magic for ipython notebooks.
The supported syntax is:
%%bigquery <command> [<args>]
<cell>
or:
%bigquery <command> [<args>]
Use %bigquery --help for a list of commands, or %bigquery <command> --help for help
on a specific command.... | python | def bigquery(line, cell=None):
"""Implements the bigquery cell magic for ipython notebooks.
The supported syntax is:
%%bigquery <command> [<args>]
<cell>
or:
%bigquery <command> [<args>]
Use %bigquery --help for a list of commands, or %bigquery <command> --help for help
on a specific command.... | [
"def",
"bigquery",
"(",
"line",
",",
"cell",
"=",
"None",
")",
":",
"namespace",
"=",
"{",
"}",
"if",
"line",
".",
"find",
"(",
"'$'",
")",
">=",
"0",
":",
"# We likely have variables to expand; get the appropriate context.",
"namespace",
"=",
"datalab",
".",
... | Implements the bigquery cell magic for ipython notebooks.
The supported syntax is:
%%bigquery <command> [<args>]
<cell>
or:
%bigquery <command> [<args>]
Use %bigquery --help for a list of commands, or %bigquery <command> --help for help
on a specific command. | [
"Implements",
"the",
"bigquery",
"cell",
"magic",
"for",
"ipython",
"notebooks",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L840-L860 |
5,048 | googledatalab/pydatalab | google/datalab/bigquery/_query_output.py | QueryOutput.table | def table(name=None, mode='create', use_cache=True, priority='interactive',
allow_large_results=False):
""" Construct a query output object where the result is a table
Args:
name: the result table name as a string or TableName; if None (the default), then a
temporary table will be u... | python | def table(name=None, mode='create', use_cache=True, priority='interactive',
allow_large_results=False):
""" Construct a query output object where the result is a table
Args:
name: the result table name as a string or TableName; if None (the default), then a
temporary table will be u... | [
"def",
"table",
"(",
"name",
"=",
"None",
",",
"mode",
"=",
"'create'",
",",
"use_cache",
"=",
"True",
",",
"priority",
"=",
"'interactive'",
",",
"allow_large_results",
"=",
"False",
")",
":",
"output",
"=",
"QueryOutput",
"(",
")",
"output",
".",
"_out... | Construct a query output object where the result is a table
Args:
name: the result table name as a string or TableName; if None (the default), then a
temporary table will be used.
table_mode: one of 'create', 'overwrite' or 'append'. If 'create' (the default), the request
will fail ... | [
"Construct",
"a",
"query",
"output",
"object",
"where",
"the",
"result",
"is",
"a",
"table"
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_query_output.py#L19-L43 |
5,049 | googledatalab/pydatalab | google/datalab/bigquery/_query_output.py | QueryOutput.file | def file(path, format='csv', csv_delimiter=',', csv_header=True, compress=False,
use_cache=True):
""" Construct a query output object where the result is either a local file or a GCS path
Note that there are two jobs that may need to be run sequentially, one to run the query,
and the second to e... | python | def file(path, format='csv', csv_delimiter=',', csv_header=True, compress=False,
use_cache=True):
""" Construct a query output object where the result is either a local file or a GCS path
Note that there are two jobs that may need to be run sequentially, one to run the query,
and the second to e... | [
"def",
"file",
"(",
"path",
",",
"format",
"=",
"'csv'",
",",
"csv_delimiter",
"=",
"','",
",",
"csv_header",
"=",
"True",
",",
"compress",
"=",
"False",
",",
"use_cache",
"=",
"True",
")",
":",
"output",
"=",
"QueryOutput",
"(",
")",
"output",
".",
... | Construct a query output object where the result is either a local file or a GCS path
Note that there are two jobs that may need to be run sequentially, one to run the query,
and the second to extract the resulting table. These are wrapped by a single outer Job.
If the query has already been executed and ... | [
"Construct",
"a",
"query",
"output",
"object",
"where",
"the",
"result",
"is",
"either",
"a",
"local",
"file",
"or",
"a",
"GCS",
"path"
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_query_output.py#L46-L73 |
5,050 | googledatalab/pydatalab | google/datalab/bigquery/_query_output.py | QueryOutput.dataframe | def dataframe(start_row=0, max_rows=None, use_cache=True):
""" Construct a query output object where the result is a dataframe
Args:
start_row: the row of the table at which to start the export (default 0).
max_rows: an upper limit on the number of rows to export (default None).
use_cache: wh... | python | def dataframe(start_row=0, max_rows=None, use_cache=True):
""" Construct a query output object where the result is a dataframe
Args:
start_row: the row of the table at which to start the export (default 0).
max_rows: an upper limit on the number of rows to export (default None).
use_cache: wh... | [
"def",
"dataframe",
"(",
"start_row",
"=",
"0",
",",
"max_rows",
"=",
"None",
",",
"use_cache",
"=",
"True",
")",
":",
"output",
"=",
"QueryOutput",
"(",
")",
"output",
".",
"_output_type",
"=",
"'dataframe'",
"output",
".",
"_dataframe_start_row",
"=",
"s... | Construct a query output object where the result is a dataframe
Args:
start_row: the row of the table at which to start the export (default 0).
max_rows: an upper limit on the number of rows to export (default None).
use_cache: whether to use cached results or not (default True). | [
"Construct",
"a",
"query",
"output",
"object",
"where",
"the",
"result",
"is",
"a",
"dataframe"
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_query_output.py#L76-L89 |
5,051 | googledatalab/pydatalab | google/datalab/ml/_tensorboard.py | TensorBoard.list | def list():
"""List running TensorBoard instances."""
running_list = []
parser = argparse.ArgumentParser()
parser.add_argument('--logdir')
parser.add_argument('--port')
for p in psutil.process_iter():
if p.name() != 'tensorboard' or p.status() == psutil.STATUS_ZOMBIE:
continue
... | python | def list():
"""List running TensorBoard instances."""
running_list = []
parser = argparse.ArgumentParser()
parser.add_argument('--logdir')
parser.add_argument('--port')
for p in psutil.process_iter():
if p.name() != 'tensorboard' or p.status() == psutil.STATUS_ZOMBIE:
continue
... | [
"def",
"list",
"(",
")",
":",
"running_list",
"=",
"[",
"]",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"'--logdir'",
")",
"parser",
".",
"add_argument",
"(",
"'--port'",
")",
"for",
"p",
"in",
"psutil... | List running TensorBoard instances. | [
"List",
"running",
"TensorBoard",
"instances",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_tensorboard.py#L33-L47 |
5,052 | googledatalab/pydatalab | google/datalab/ml/_tensorboard.py | TensorBoard.start | def start(logdir):
"""Start a TensorBoard instance.
Args:
logdir: the logdir to run TensorBoard on.
Raises:
Exception if the instance cannot be started.
"""
if logdir.startswith('gs://'):
# Check user does have access. TensorBoard will start successfully regardless
# the use... | python | def start(logdir):
"""Start a TensorBoard instance.
Args:
logdir: the logdir to run TensorBoard on.
Raises:
Exception if the instance cannot be started.
"""
if logdir.startswith('gs://'):
# Check user does have access. TensorBoard will start successfully regardless
# the use... | [
"def",
"start",
"(",
"logdir",
")",
":",
"if",
"logdir",
".",
"startswith",
"(",
"'gs://'",
")",
":",
"# Check user does have access. TensorBoard will start successfully regardless",
"# the user has read permissions or not so we check permissions here to",
"# give user alerts if need... | Start a TensorBoard instance.
Args:
logdir: the logdir to run TensorBoard on.
Raises:
Exception if the instance cannot be started. | [
"Start",
"a",
"TensorBoard",
"instance",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_tensorboard.py#L50-L79 |
5,053 | googledatalab/pydatalab | google/datalab/ml/_tensorboard.py | TensorBoard.stop | def stop(pid):
"""Shut down a specific process.
Args:
pid: the pid of the process to shutdown.
"""
if psutil.pid_exists(pid):
try:
p = psutil.Process(pid)
p.kill()
except Exception:
pass | python | def stop(pid):
"""Shut down a specific process.
Args:
pid: the pid of the process to shutdown.
"""
if psutil.pid_exists(pid):
try:
p = psutil.Process(pid)
p.kill()
except Exception:
pass | [
"def",
"stop",
"(",
"pid",
")",
":",
"if",
"psutil",
".",
"pid_exists",
"(",
"pid",
")",
":",
"try",
":",
"p",
"=",
"psutil",
".",
"Process",
"(",
"pid",
")",
"p",
".",
"kill",
"(",
")",
"except",
"Exception",
":",
"pass"
] | Shut down a specific process.
Args:
pid: the pid of the process to shutdown. | [
"Shut",
"down",
"a",
"specific",
"process",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_tensorboard.py#L82-L93 |
5,054 | googledatalab/pydatalab | solutionbox/image_classification/mltoolbox/image/classification/_preprocess.py | EmbeddingsGraph.build_graph | def build_graph(self):
"""Forms the core by building a wrapper around the inception graph.
Here we add the necessary input & output tensors, to decode jpegs,
serialize embeddings, restore from checkpoint etc.
To use other Inception models modify this file. Note that to use other
models bes... | python | def build_graph(self):
"""Forms the core by building a wrapper around the inception graph.
Here we add the necessary input & output tensors, to decode jpegs,
serialize embeddings, restore from checkpoint etc.
To use other Inception models modify this file. Note that to use other
models bes... | [
"def",
"build_graph",
"(",
"self",
")",
":",
"import",
"tensorflow",
"as",
"tf",
"input_jpeg",
"=",
"tf",
".",
"placeholder",
"(",
"tf",
".",
"string",
",",
"shape",
"=",
"None",
")",
"image",
"=",
"tf",
".",
"image",
".",
"decode_jpeg",
"(",
"input_jp... | Forms the core by building a wrapper around the inception graph.
Here we add the necessary input & output tensors, to decode jpegs,
serialize embeddings, restore from checkpoint etc.
To use other Inception models modify this file. Note that to use other
models beside Inception, you should make... | [
"Forms",
"the",
"core",
"by",
"building",
"a",
"wrapper",
"around",
"the",
"inception",
"graph",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_preprocess.py#L126-L167 |
5,055 | googledatalab/pydatalab | solutionbox/image_classification/mltoolbox/image/classification/_preprocess.py | EmbeddingsGraph.restore_from_checkpoint | def restore_from_checkpoint(self, checkpoint_path):
"""To restore inception model variables from the checkpoint file.
Some variables might be missing in the checkpoint file, so it only
loads the ones that are avialable, assuming the rest would be
initialized later.
Args:
checkpoint_p... | python | def restore_from_checkpoint(self, checkpoint_path):
"""To restore inception model variables from the checkpoint file.
Some variables might be missing in the checkpoint file, so it only
loads the ones that are avialable, assuming the rest would be
initialized later.
Args:
checkpoint_p... | [
"def",
"restore_from_checkpoint",
"(",
"self",
",",
"checkpoint_path",
")",
":",
"import",
"tensorflow",
"as",
"tf",
"# Get all variables to restore. Exclude Logits and AuxLogits because they",
"# depend on the input data and we do not need to intialize them from",
"# checkpoint.",
"al... | To restore inception model variables from the checkpoint file.
Some variables might be missing in the checkpoint file, so it only
loads the ones that are avialable, assuming the rest would be
initialized later.
Args:
checkpoint_path: Path to the checkpoint file for the Inception graph. | [
"To",
"restore",
"inception",
"model",
"variables",
"from",
"the",
"checkpoint",
"file",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_preprocess.py#L169-L186 |
5,056 | googledatalab/pydatalab | solutionbox/image_classification/mltoolbox/image/classification/_preprocess.py | EmbeddingsGraph.calculate_embedding | def calculate_embedding(self, batch_image_bytes):
"""Get the embeddings for a given JPEG image.
Args:
batch_image_bytes: As if returned from [ff.read() for ff in file_list].
Returns:
The Inception embeddings (bottleneck layer output)
"""
return self.tf_session.run(
self.embeddi... | python | def calculate_embedding(self, batch_image_bytes):
"""Get the embeddings for a given JPEG image.
Args:
batch_image_bytes: As if returned from [ff.read() for ff in file_list].
Returns:
The Inception embeddings (bottleneck layer output)
"""
return self.tf_session.run(
self.embeddi... | [
"def",
"calculate_embedding",
"(",
"self",
",",
"batch_image_bytes",
")",
":",
"return",
"self",
".",
"tf_session",
".",
"run",
"(",
"self",
".",
"embedding",
",",
"feed_dict",
"=",
"{",
"self",
".",
"input_jpeg",
":",
"batch_image_bytes",
"}",
")"
] | Get the embeddings for a given JPEG image.
Args:
batch_image_bytes: As if returned from [ff.read() for ff in file_list].
Returns:
The Inception embeddings (bottleneck layer output) | [
"Get",
"the",
"embeddings",
"for",
"a",
"given",
"JPEG",
"image",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_preprocess.py#L188-L198 |
5,057 | googledatalab/pydatalab | solutionbox/image_classification/mltoolbox/image/classification/_model.py | Model.add_final_training_ops | def add_final_training_ops(self,
embeddings,
all_labels_count,
bottleneck_tensor_size,
hidden_layer_size=BOTTLENECK_TENSOR_SIZE / 4,
dropout_keep_prob=None):
"""Adds a new... | python | def add_final_training_ops(self,
embeddings,
all_labels_count,
bottleneck_tensor_size,
hidden_layer_size=BOTTLENECK_TENSOR_SIZE / 4,
dropout_keep_prob=None):
"""Adds a new... | [
"def",
"add_final_training_ops",
"(",
"self",
",",
"embeddings",
",",
"all_labels_count",
",",
"bottleneck_tensor_size",
",",
"hidden_layer_size",
"=",
"BOTTLENECK_TENSOR_SIZE",
"/",
"4",
",",
"dropout_keep_prob",
"=",
"None",
")",
":",
"with",
"tf",
".",
"name_scop... | Adds a new softmax and fully-connected layer for training.
The set up for the softmax and fully-connected layers is based on:
https://tensorflow.org/versions/master/tutorials/mnist/beginners/index.html
This function can be customized to add arbitrary layers for
application-specific requirements.
... | [
"Adds",
"a",
"new",
"softmax",
"and",
"fully",
"-",
"connected",
"layer",
"for",
"training",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_model.py#L71-L112 |
5,058 | googledatalab/pydatalab | solutionbox/image_classification/mltoolbox/image/classification/_model.py | Model.build_inception_graph | def build_inception_graph(self):
"""Builds an inception graph and add the necessary input & output tensors.
To use other Inception models modify this file. Also preprocessing must be
modified accordingly.
See tensorflow/contrib/slim/python/slim/nets/inception_v3.py for
details about Incept... | python | def build_inception_graph(self):
"""Builds an inception graph and add the necessary input & output tensors.
To use other Inception models modify this file. Also preprocessing must be
modified accordingly.
See tensorflow/contrib/slim/python/slim/nets/inception_v3.py for
details about Incept... | [
"def",
"build_inception_graph",
"(",
"self",
")",
":",
"image_str_tensor",
"=",
"tf",
".",
"placeholder",
"(",
"tf",
".",
"string",
",",
"shape",
"=",
"[",
"None",
"]",
")",
"# The CloudML Prediction API always \"feeds\" the Tensorflow graph with",
"# dynamic batch size... | Builds an inception graph and add the necessary input & output tensors.
To use other Inception models modify this file. Also preprocessing must be
modified accordingly.
See tensorflow/contrib/slim/python/slim/nets/inception_v3.py for
details about InceptionV3.
Returns:
input_jpeg: A... | [
"Builds",
"an",
"inception",
"graph",
"and",
"add",
"the",
"necessary",
"input",
"&",
"output",
"tensors",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_model.py#L114-L152 |
5,059 | googledatalab/pydatalab | solutionbox/image_classification/mltoolbox/image/classification/_model.py | Model.build_graph | def build_graph(self, data_paths, batch_size, graph_mod):
"""Builds generic graph for training or eval."""
tensors = GraphReferences()
is_training = graph_mod == GraphMod.TRAIN
if data_paths:
_, tensors.examples = _util.read_examples(
data_paths,
batch_size,
shuffle=i... | python | def build_graph(self, data_paths, batch_size, graph_mod):
"""Builds generic graph for training or eval."""
tensors = GraphReferences()
is_training = graph_mod == GraphMod.TRAIN
if data_paths:
_, tensors.examples = _util.read_examples(
data_paths,
batch_size,
shuffle=i... | [
"def",
"build_graph",
"(",
"self",
",",
"data_paths",
",",
"batch_size",
",",
"graph_mod",
")",
":",
"tensors",
"=",
"GraphReferences",
"(",
")",
"is_training",
"=",
"graph_mod",
"==",
"GraphMod",
".",
"TRAIN",
"if",
"data_paths",
":",
"_",
",",
"tensors",
... | Builds generic graph for training or eval. | [
"Builds",
"generic",
"graph",
"for",
"training",
"or",
"eval",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_model.py#L154-L237 |
5,060 | googledatalab/pydatalab | solutionbox/image_classification/mltoolbox/image/classification/_model.py | Model.restore_from_checkpoint | def restore_from_checkpoint(self, session, inception_checkpoint_file,
trained_checkpoint_file):
"""To restore model variables from the checkpoint file.
The graph is assumed to consist of an inception model and other
layers including a softmax and a fully connected layer.... | python | def restore_from_checkpoint(self, session, inception_checkpoint_file,
trained_checkpoint_file):
"""To restore model variables from the checkpoint file.
The graph is assumed to consist of an inception model and other
layers including a softmax and a fully connected layer.... | [
"def",
"restore_from_checkpoint",
"(",
"self",
",",
"session",
",",
"inception_checkpoint_file",
",",
"trained_checkpoint_file",
")",
":",
"inception_exclude_scopes",
"=",
"[",
"'InceptionV3/AuxLogits'",
",",
"'InceptionV3/Logits'",
",",
"'global_step'",
",",
"'final_ops'",... | To restore model variables from the checkpoint file.
The graph is assumed to consist of an inception model and other
layers including a softmax and a fully connected layer. The former is
pre-trained and the latter is trained using the pre-processed data. So
we restore this from two checkpoi... | [
"To",
"restore",
"model",
"variables",
"from",
"the",
"checkpoint",
"file",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_model.py#L245-L284 |
5,061 | googledatalab/pydatalab | solutionbox/image_classification/mltoolbox/image/classification/_model.py | Model.build_prediction_graph | def build_prediction_graph(self):
"""Builds prediction graph and registers appropriate endpoints."""
tensors = self.build_graph(None, 1, GraphMod.PREDICT)
keys_placeholder = tf.placeholder(tf.string, shape=[None])
inputs = {
'key': keys_placeholder,
'image_bytes': tensors.input_jpeg
... | python | def build_prediction_graph(self):
"""Builds prediction graph and registers appropriate endpoints."""
tensors = self.build_graph(None, 1, GraphMod.PREDICT)
keys_placeholder = tf.placeholder(tf.string, shape=[None])
inputs = {
'key': keys_placeholder,
'image_bytes': tensors.input_jpeg
... | [
"def",
"build_prediction_graph",
"(",
"self",
")",
":",
"tensors",
"=",
"self",
".",
"build_graph",
"(",
"None",
",",
"1",
",",
"GraphMod",
".",
"PREDICT",
")",
"keys_placeholder",
"=",
"tf",
".",
"placeholder",
"(",
"tf",
".",
"string",
",",
"shape",
"=... | Builds prediction graph and registers appropriate endpoints. | [
"Builds",
"prediction",
"graph",
"and",
"registers",
"appropriate",
"endpoints",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_model.py#L286-L317 |
5,062 | googledatalab/pydatalab | solutionbox/image_classification/mltoolbox/image/classification/_model.py | Model.export | def export(self, last_checkpoint, output_dir):
"""Builds a prediction graph and xports the model.
Args:
last_checkpoint: Path to the latest checkpoint file from training.
output_dir: Path to the folder to be used to output the model.
"""
logging.info('Exporting prediction graph to %s', outp... | python | def export(self, last_checkpoint, output_dir):
"""Builds a prediction graph and xports the model.
Args:
last_checkpoint: Path to the latest checkpoint file from training.
output_dir: Path to the folder to be used to output the model.
"""
logging.info('Exporting prediction graph to %s', outp... | [
"def",
"export",
"(",
"self",
",",
"last_checkpoint",
",",
"output_dir",
")",
":",
"logging",
".",
"info",
"(",
"'Exporting prediction graph to %s'",
",",
"output_dir",
")",
"with",
"tf",
".",
"Session",
"(",
"graph",
"=",
"tf",
".",
"Graph",
"(",
")",
")"... | Builds a prediction graph and xports the model.
Args:
last_checkpoint: Path to the latest checkpoint file from training.
output_dir: Path to the folder to be used to output the model. | [
"Builds",
"a",
"prediction",
"graph",
"and",
"xports",
"the",
"model",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_model.py#L319-L346 |
5,063 | googledatalab/pydatalab | solutionbox/image_classification/mltoolbox/image/classification/_model.py | Model.format_metric_values | def format_metric_values(self, metric_values):
"""Formats metric values - used for logging purpose."""
# Early in training, metric_values may actually be None.
loss_str = 'N/A'
accuracy_str = 'N/A'
try:
loss_str = 'loss: %.3f' % metric_values[0]
accuracy_str = 'accuracy: %.3f' % metric_... | python | def format_metric_values(self, metric_values):
"""Formats metric values - used for logging purpose."""
# Early in training, metric_values may actually be None.
loss_str = 'N/A'
accuracy_str = 'N/A'
try:
loss_str = 'loss: %.3f' % metric_values[0]
accuracy_str = 'accuracy: %.3f' % metric_... | [
"def",
"format_metric_values",
"(",
"self",
",",
"metric_values",
")",
":",
"# Early in training, metric_values may actually be None.",
"loss_str",
"=",
"'N/A'",
"accuracy_str",
"=",
"'N/A'",
"try",
":",
"loss_str",
"=",
"'loss: %.3f'",
"%",
"metric_values",
"[",
"0",
... | Formats metric values - used for logging purpose. | [
"Formats",
"metric",
"values",
"-",
"used",
"for",
"logging",
"purpose",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_model.py#L348-L360 |
5,064 | googledatalab/pydatalab | google/datalab/ml/_util.py | package_and_copy | def package_and_copy(package_root_dir, setup_py, output_tar_path):
"""Repackage an CloudML package and copy it to a staging dir.
Args:
package_root_dir: the root dir to install package from. Usually you can get the path
from inside your module using a relative path to __file__.
setup_py: the path t... | python | def package_and_copy(package_root_dir, setup_py, output_tar_path):
"""Repackage an CloudML package and copy it to a staging dir.
Args:
package_root_dir: the root dir to install package from. Usually you can get the path
from inside your module using a relative path to __file__.
setup_py: the path t... | [
"def",
"package_and_copy",
"(",
"package_root_dir",
",",
"setup_py",
",",
"output_tar_path",
")",
":",
"if",
"not",
"output_tar_path",
".",
"startswith",
"(",
"'gs://'",
")",
":",
"raise",
"ValueError",
"(",
"'output_tar_path needs to be a GCS path.'",
")",
"if",
"n... | Repackage an CloudML package and copy it to a staging dir.
Args:
package_root_dir: the root dir to install package from. Usually you can get the path
from inside your module using a relative path to __file__.
setup_py: the path to setup.py.
output_tar_path: the GCS path of the output tarball pack... | [
"Repackage",
"an",
"CloudML",
"package",
"and",
"copy",
"it",
"to",
"a",
"staging",
"dir",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_util.py#L45-L88 |
5,065 | googledatalab/pydatalab | google/datalab/ml/_util.py | read_file_to_string | def read_file_to_string(path):
"""Read a file into a string."""
bytes_string = tf.gfile.Open(path, 'r').read()
return dlutils.python_portable_string(bytes_string) | python | def read_file_to_string(path):
"""Read a file into a string."""
bytes_string = tf.gfile.Open(path, 'r').read()
return dlutils.python_portable_string(bytes_string) | [
"def",
"read_file_to_string",
"(",
"path",
")",
":",
"bytes_string",
"=",
"tf",
".",
"gfile",
".",
"Open",
"(",
"path",
",",
"'r'",
")",
".",
"read",
"(",
")",
"return",
"dlutils",
".",
"python_portable_string",
"(",
"bytes_string",
")"
] | Read a file into a string. | [
"Read",
"a",
"file",
"into",
"a",
"string",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_util.py#L91-L94 |
5,066 | googledatalab/pydatalab | datalab/data/commands/_sql.py | _date | def _date(val, offset=None):
""" A special pseudo-type for pipeline arguments.
This allows us to parse dates as Python datetimes, including special values like 'now'
and 'today', as well as apply offsets to the datetime.
Args:
val: a string containing the value for the datetime. This can be 'now', 'today'... | python | def _date(val, offset=None):
""" A special pseudo-type for pipeline arguments.
This allows us to parse dates as Python datetimes, including special values like 'now'
and 'today', as well as apply offsets to the datetime.
Args:
val: a string containing the value for the datetime. This can be 'now', 'today'... | [
"def",
"_date",
"(",
"val",
",",
"offset",
"=",
"None",
")",
":",
"if",
"val",
"is",
"None",
":",
"return",
"val",
"if",
"val",
"==",
"''",
"or",
"val",
"==",
"'now'",
":",
"when",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
"elif"... | A special pseudo-type for pipeline arguments.
This allows us to parse dates as Python datetimes, including special values like 'now'
and 'today', as well as apply offsets to the datetime.
Args:
val: a string containing the value for the datetime. This can be 'now', 'today' (midnight at
start of day)... | [
"A",
"special",
"pseudo",
"-",
"type",
"for",
"pipeline",
"arguments",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/data/commands/_sql.py#L119-L177 |
5,067 | googledatalab/pydatalab | datalab/data/commands/_sql.py | _make_string_formatter | def _make_string_formatter(f, offset=None):
""" A closure-izer for string arguments that include a format and possibly an offset. """
format = f
delta = offset
return lambda v: time.strftime(format, (_date(v, delta)).timetuple()) | python | def _make_string_formatter(f, offset=None):
""" A closure-izer for string arguments that include a format and possibly an offset. """
format = f
delta = offset
return lambda v: time.strftime(format, (_date(v, delta)).timetuple()) | [
"def",
"_make_string_formatter",
"(",
"f",
",",
"offset",
"=",
"None",
")",
":",
"format",
"=",
"f",
"delta",
"=",
"offset",
"return",
"lambda",
"v",
":",
"time",
".",
"strftime",
"(",
"format",
",",
"(",
"_date",
"(",
"v",
",",
"delta",
")",
")",
... | A closure-izer for string arguments that include a format and possibly an offset. | [
"A",
"closure",
"-",
"izer",
"for",
"string",
"arguments",
"that",
"include",
"a",
"format",
"and",
"possibly",
"an",
"offset",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/data/commands/_sql.py#L189-L193 |
5,068 | googledatalab/pydatalab | datalab/data/commands/_sql.py | _make_table_formatter | def _make_table_formatter(f, offset=None):
""" A closure-izer for table arguments that include a format and possibly an offset. """
format = f
delta = offset
return lambda v: _resolve_table(v, format, delta) | python | def _make_table_formatter(f, offset=None):
""" A closure-izer for table arguments that include a format and possibly an offset. """
format = f
delta = offset
return lambda v: _resolve_table(v, format, delta) | [
"def",
"_make_table_formatter",
"(",
"f",
",",
"offset",
"=",
"None",
")",
":",
"format",
"=",
"f",
"delta",
"=",
"offset",
"return",
"lambda",
"v",
":",
"_resolve_table",
"(",
"v",
",",
"format",
",",
"delta",
")"
] | A closure-izer for table arguments that include a format and possibly an offset. | [
"A",
"closure",
"-",
"izer",
"for",
"table",
"arguments",
"that",
"include",
"a",
"format",
"and",
"possibly",
"an",
"offset",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/data/commands/_sql.py#L196-L200 |
5,069 | googledatalab/pydatalab | datalab/data/commands/_sql.py | _arguments | def _arguments(code, module):
"""Define pipeline arguments.
Args:
code: the Python code to execute that defines the arguments.
"""
arg_parser = CommandParser.create('')
try:
# Define our special argument 'types' and add them to the environment.
builtins = {'source': _table, 'datestring': _datest... | python | def _arguments(code, module):
"""Define pipeline arguments.
Args:
code: the Python code to execute that defines the arguments.
"""
arg_parser = CommandParser.create('')
try:
# Define our special argument 'types' and add them to the environment.
builtins = {'source': _table, 'datestring': _datest... | [
"def",
"_arguments",
"(",
"code",
",",
"module",
")",
":",
"arg_parser",
"=",
"CommandParser",
".",
"create",
"(",
"''",
")",
"try",
":",
"# Define our special argument 'types' and add them to the environment.",
"builtins",
"=",
"{",
"'source'",
":",
"_table",
",",
... | Define pipeline arguments.
Args:
code: the Python code to execute that defines the arguments. | [
"Define",
"pipeline",
"arguments",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/data/commands/_sql.py#L215-L281 |
5,070 | googledatalab/pydatalab | datalab/data/commands/_sql.py | _split_cell | def _split_cell(cell, module):
""" Split a hybrid %%sql cell into the Python code and the queries.
Populates a module with the queries.
Args:
cell: the contents of the %%sql cell.
module: the module that the contents will populate.
Returns:
The default (last) query for the module.
"""
line... | python | def _split_cell(cell, module):
""" Split a hybrid %%sql cell into the Python code and the queries.
Populates a module with the queries.
Args:
cell: the contents of the %%sql cell.
module: the module that the contents will populate.
Returns:
The default (last) query for the module.
"""
line... | [
"def",
"_split_cell",
"(",
"cell",
",",
"module",
")",
":",
"lines",
"=",
"cell",
".",
"split",
"(",
"'\\n'",
")",
"code",
"=",
"None",
"last_def",
"=",
"-",
"1",
"name",
"=",
"None",
"define_wild_re",
"=",
"re",
".",
"compile",
"(",
"'^DEFINE\\s+.*$'"... | Split a hybrid %%sql cell into the Python code and the queries.
Populates a module with the queries.
Args:
cell: the contents of the %%sql cell.
module: the module that the contents will populate.
Returns:
The default (last) query for the module. | [
"Split",
"a",
"hybrid",
"%%sql",
"cell",
"into",
"the",
"Python",
"code",
"and",
"the",
"queries",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/data/commands/_sql.py#L284-L367 |
5,071 | googledatalab/pydatalab | datalab/data/commands/_sql.py | sql_cell | def sql_cell(args, cell):
"""Implements the SQL cell magic for ipython notebooks.
The supported syntax is:
%%sql [--module <modulename>]
[<optional Python code for default argument values>]
[<optional named queries>]
[<optional unnamed query>]
At least one query should be present. Named... | python | def sql_cell(args, cell):
"""Implements the SQL cell magic for ipython notebooks.
The supported syntax is:
%%sql [--module <modulename>]
[<optional Python code for default argument values>]
[<optional named queries>]
[<optional unnamed query>]
At least one query should be present. Named... | [
"def",
"sql_cell",
"(",
"args",
",",
"cell",
")",
":",
"name",
"=",
"args",
"[",
"'module'",
"]",
"if",
"args",
"[",
"'module'",
"]",
"else",
"'_sql_cell'",
"module",
"=",
"imp",
".",
"new_module",
"(",
"name",
")",
"query",
"=",
"_split_cell",
"(",
... | Implements the SQL cell magic for ipython notebooks.
The supported syntax is:
%%sql [--module <modulename>]
[<optional Python code for default argument values>]
[<optional named queries>]
[<optional unnamed query>]
At least one query should be present. Named queries should start with:
... | [
"Implements",
"the",
"SQL",
"cell",
"magic",
"for",
"ipython",
"notebooks",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/data/commands/_sql.py#L370-L402 |
5,072 | googledatalab/pydatalab | solutionbox/structured_data/mltoolbox/_structured_data/trainer/task.py | get_reader_input_fn | def get_reader_input_fn(train_config, preprocess_output_dir, model_type,
data_paths, batch_size, shuffle, num_epochs=None):
"""Builds input layer for training."""
def get_input_features():
"""Read the input features from the given data paths."""
_, examples = util.read_examples(
... | python | def get_reader_input_fn(train_config, preprocess_output_dir, model_type,
data_paths, batch_size, shuffle, num_epochs=None):
"""Builds input layer for training."""
def get_input_features():
"""Read the input features from the given data paths."""
_, examples = util.read_examples(
... | [
"def",
"get_reader_input_fn",
"(",
"train_config",
",",
"preprocess_output_dir",
",",
"model_type",
",",
"data_paths",
",",
"batch_size",
",",
"shuffle",
",",
"num_epochs",
"=",
"None",
")",
":",
"def",
"get_input_features",
"(",
")",
":",
"\"\"\"Read the input feat... | Builds input layer for training. | [
"Builds",
"input",
"layer",
"for",
"training",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/structured_data/mltoolbox/_structured_data/trainer/task.py#L30-L57 |
5,073 | googledatalab/pydatalab | solutionbox/structured_data/mltoolbox/_structured_data/trainer/task.py | main | def main(argv=None):
"""Run a Tensorflow model on the Iris dataset."""
args = parse_arguments(sys.argv if argv is None else argv)
tf.logging.set_verbosity(tf.logging.INFO)
learn_runner.run(
experiment_fn=get_experiment_fn(args),
output_dir=args.job_dir) | python | def main(argv=None):
"""Run a Tensorflow model on the Iris dataset."""
args = parse_arguments(sys.argv if argv is None else argv)
tf.logging.set_verbosity(tf.logging.INFO)
learn_runner.run(
experiment_fn=get_experiment_fn(args),
output_dir=args.job_dir) | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"args",
"=",
"parse_arguments",
"(",
"sys",
".",
"argv",
"if",
"argv",
"is",
"None",
"else",
"argv",
")",
"tf",
".",
"logging",
".",
"set_verbosity",
"(",
"tf",
".",
"logging",
".",
"INFO",
")",
"l... | Run a Tensorflow model on the Iris dataset. | [
"Run",
"a",
"Tensorflow",
"model",
"on",
"the",
"Iris",
"dataset",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/structured_data/mltoolbox/_structured_data/trainer/task.py#L231-L238 |
5,074 | googledatalab/pydatalab | google/datalab/stackdriver/commands/_monitoring.py | sd | def sd(line, cell=None):
"""Implements the stackdriver cell magic for ipython notebooks.
Args:
line: the contents of the storage line.
Returns:
The results of executing the cell.
"""
parser = google.datalab.utils.commands.CommandParser(prog='%sd', description=(
'Execute various Stackdriver rela... | python | def sd(line, cell=None):
"""Implements the stackdriver cell magic for ipython notebooks.
Args:
line: the contents of the storage line.
Returns:
The results of executing the cell.
"""
parser = google.datalab.utils.commands.CommandParser(prog='%sd', description=(
'Execute various Stackdriver rela... | [
"def",
"sd",
"(",
"line",
",",
"cell",
"=",
"None",
")",
":",
"parser",
"=",
"google",
".",
"datalab",
".",
"utils",
".",
"commands",
".",
"CommandParser",
"(",
"prog",
"=",
"'%sd'",
",",
"description",
"=",
"(",
"'Execute various Stackdriver related operati... | Implements the stackdriver cell magic for ipython notebooks.
Args:
line: the contents of the storage line.
Returns:
The results of executing the cell. | [
"Implements",
"the",
"stackdriver",
"cell",
"magic",
"for",
"ipython",
"notebooks",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/stackdriver/commands/_monitoring.py#L28-L42 |
5,075 | googledatalab/pydatalab | solutionbox/ml_workbench/xgboost/trainer/task.py | make_prediction_output_tensors | def make_prediction_output_tensors(args, features, input_ops, model_fn_ops,
keep_target):
"""Makes the final prediction output layer."""
target_name = feature_transforms.get_target_name(features)
key_names = get_key_names(features)
outputs = {}
outputs.update({key_name: tf.... | python | def make_prediction_output_tensors(args, features, input_ops, model_fn_ops,
keep_target):
"""Makes the final prediction output layer."""
target_name = feature_transforms.get_target_name(features)
key_names = get_key_names(features)
outputs = {}
outputs.update({key_name: tf.... | [
"def",
"make_prediction_output_tensors",
"(",
"args",
",",
"features",
",",
"input_ops",
",",
"model_fn_ops",
",",
"keep_target",
")",
":",
"target_name",
"=",
"feature_transforms",
".",
"get_target_name",
"(",
"features",
")",
"key_names",
"=",
"get_key_names",
"("... | Makes the final prediction output layer. | [
"Makes",
"the",
"final",
"prediction",
"output",
"layer",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/xgboost/trainer/task.py#L377-L456 |
5,076 | googledatalab/pydatalab | solutionbox/ml_workbench/xgboost/trainer/task.py | read_vocab | def read_vocab(args, column_name):
"""Reads a vocab file if it exists.
Args:
args: command line flags
column_name: name of column to that has a vocab file.
Returns:
List of vocab words or [] if the vocab file is not found.
"""
vocab_path = os.path.join(args.analysis,
... | python | def read_vocab(args, column_name):
"""Reads a vocab file if it exists.
Args:
args: command line flags
column_name: name of column to that has a vocab file.
Returns:
List of vocab words or [] if the vocab file is not found.
"""
vocab_path = os.path.join(args.analysis,
... | [
"def",
"read_vocab",
"(",
"args",
",",
"column_name",
")",
":",
"vocab_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"args",
".",
"analysis",
",",
"feature_transforms",
".",
"VOCAB_ANALYSIS_FILE",
"%",
"column_name",
")",
"if",
"not",
"file_io",
".",
"f... | Reads a vocab file if it exists.
Args:
args: command line flags
column_name: name of column to that has a vocab file.
Returns:
List of vocab words or [] if the vocab file is not found. | [
"Reads",
"a",
"vocab",
"file",
"if",
"it",
"exists",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/xgboost/trainer/task.py#L642-L659 |
5,077 | googledatalab/pydatalab | datalab/utils/_utils.py | get_item | def get_item(env, name, default=None):
""" Get an item from a dictionary, handling nested lookups with dotted notation.
Args:
env: the environment (dictionary) to use to look up the name.
name: the name to look up, in dotted notation.
default: the value to return if the name if not found.
Returns:
... | python | def get_item(env, name, default=None):
""" Get an item from a dictionary, handling nested lookups with dotted notation.
Args:
env: the environment (dictionary) to use to look up the name.
name: the name to look up, in dotted notation.
default: the value to return if the name if not found.
Returns:
... | [
"def",
"get_item",
"(",
"env",
",",
"name",
",",
"default",
"=",
"None",
")",
":",
"# TODO: handle attributes",
"for",
"key",
"in",
"name",
".",
"split",
"(",
"'.'",
")",
":",
"if",
"isinstance",
"(",
"env",
",",
"dict",
")",
"and",
"key",
"in",
"env... | Get an item from a dictionary, handling nested lookups with dotted notation.
Args:
env: the environment (dictionary) to use to look up the name.
name: the name to look up, in dotted notation.
default: the value to return if the name if not found.
Returns:
The result of looking up the name, if foun... | [
"Get",
"an",
"item",
"from",
"a",
"dictionary",
"handling",
"nested",
"lookups",
"with",
"dotted",
"notation",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/utils/_utils.py#L41-L60 |
5,078 | googledatalab/pydatalab | solutionbox/image_classification/mltoolbox/image/classification/_predictor.py | predict | def predict(model_dir, images):
"""Local instant prediction."""
results = _tf_predict(model_dir, images)
predicted_and_scores = [(predicted, label_scores[list(labels).index(predicted)])
for predicted, labels, label_scores in results]
return predicted_and_scores | python | def predict(model_dir, images):
"""Local instant prediction."""
results = _tf_predict(model_dir, images)
predicted_and_scores = [(predicted, label_scores[list(labels).index(predicted)])
for predicted, labels, label_scores in results]
return predicted_and_scores | [
"def",
"predict",
"(",
"model_dir",
",",
"images",
")",
":",
"results",
"=",
"_tf_predict",
"(",
"model_dir",
",",
"images",
")",
"predicted_and_scores",
"=",
"[",
"(",
"predicted",
",",
"label_scores",
"[",
"list",
"(",
"labels",
")",
".",
"index",
"(",
... | Local instant prediction. | [
"Local",
"instant",
"prediction",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_predictor.py#L58-L64 |
5,079 | googledatalab/pydatalab | solutionbox/image_classification/mltoolbox/image/classification/_predictor.py | configure_pipeline | def configure_pipeline(p, dataset, model_dir, output_csv, output_bq_table):
"""Configures a dataflow pipeline for batch prediction."""
data = _util.get_sources_from_dataset(p, dataset, 'predict')
if len(dataset.schema) == 2:
output_schema = [
{'name': 'image_url', 'type': 'STRING'},
{'name': ... | python | def configure_pipeline(p, dataset, model_dir, output_csv, output_bq_table):
"""Configures a dataflow pipeline for batch prediction."""
data = _util.get_sources_from_dataset(p, dataset, 'predict')
if len(dataset.schema) == 2:
output_schema = [
{'name': 'image_url', 'type': 'STRING'},
{'name': ... | [
"def",
"configure_pipeline",
"(",
"p",
",",
"dataset",
",",
"model_dir",
",",
"output_csv",
",",
"output_bq_table",
")",
":",
"data",
"=",
"_util",
".",
"get_sources_from_dataset",
"(",
"p",
",",
"dataset",
",",
"'predict'",
")",
"if",
"len",
"(",
"dataset",... | Configures a dataflow pipeline for batch prediction. | [
"Configures",
"a",
"dataflow",
"pipeline",
"for",
"batch",
"prediction",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_predictor.py#L187-L228 |
5,080 | googledatalab/pydatalab | datalab/bigquery/_query.py | Query.sampling_query | def sampling_query(sql, context, fields=None, count=5, sampling=None, udfs=None,
data_sources=None):
"""Returns a sampling Query for the SQL object.
Args:
sql: the SQL statement (string) or Query object to sample.
context: a Context object providing project_id and credentials.
... | python | def sampling_query(sql, context, fields=None, count=5, sampling=None, udfs=None,
data_sources=None):
"""Returns a sampling Query for the SQL object.
Args:
sql: the SQL statement (string) or Query object to sample.
context: a Context object providing project_id and credentials.
... | [
"def",
"sampling_query",
"(",
"sql",
",",
"context",
",",
"fields",
"=",
"None",
",",
"count",
"=",
"5",
",",
"sampling",
"=",
"None",
",",
"udfs",
"=",
"None",
",",
"data_sources",
"=",
"None",
")",
":",
"return",
"Query",
"(",
"_sampling",
".",
"Sa... | Returns a sampling Query for the SQL object.
Args:
sql: the SQL statement (string) or Query object to sample.
context: a Context object providing project_id and credentials.
fields: an optional list of field names to retrieve.
count: an optional count of rows to retrieve which is used if a ... | [
"Returns",
"a",
"sampling",
"Query",
"for",
"the",
"SQL",
"object",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_query.py#L37-L54 |
5,081 | googledatalab/pydatalab | datalab/bigquery/_query.py | Query.results | def results(self, use_cache=True, dialect=None, billing_tier=None):
"""Retrieves table of results for the query. May block if the query must be executed first.
Args:
use_cache: whether to use cached results or not. Ignored if append is specified.
dialect : {'legacy', 'standard'}, default 'legacy'
... | python | def results(self, use_cache=True, dialect=None, billing_tier=None):
"""Retrieves table of results for the query. May block if the query must be executed first.
Args:
use_cache: whether to use cached results or not. Ignored if append is specified.
dialect : {'legacy', 'standard'}, default 'legacy'
... | [
"def",
"results",
"(",
"self",
",",
"use_cache",
"=",
"True",
",",
"dialect",
"=",
"None",
",",
"billing_tier",
"=",
"None",
")",
":",
"if",
"not",
"use_cache",
"or",
"(",
"self",
".",
"_results",
"is",
"None",
")",
":",
"self",
".",
"execute",
"(",
... | Retrieves table of results for the query. May block if the query must be executed first.
Args:
use_cache: whether to use cached results or not. Ignored if append is specified.
dialect : {'legacy', 'standard'}, default 'legacy'
'legacy' : Use BigQuery's legacy SQL dialect.
'standard'... | [
"Retrieves",
"table",
"of",
"results",
"for",
"the",
"query",
".",
"May",
"block",
"if",
"the",
"query",
"must",
"be",
"executed",
"first",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_query.py#L209-L229 |
5,082 | googledatalab/pydatalab | datalab/bigquery/_query.py | Query.extract | def extract(self, storage_uris, format='csv', csv_delimiter=',', csv_header=True,
compress=False, use_cache=True, dialect=None, billing_tier=None):
"""Exports the query results to GCS.
Args:
storage_uris: the destination URI(s). Can be a single URI or a list.
format: the format to use... | python | def extract(self, storage_uris, format='csv', csv_delimiter=',', csv_header=True,
compress=False, use_cache=True, dialect=None, billing_tier=None):
"""Exports the query results to GCS.
Args:
storage_uris: the destination URI(s). Can be a single URI or a list.
format: the format to use... | [
"def",
"extract",
"(",
"self",
",",
"storage_uris",
",",
"format",
"=",
"'csv'",
",",
"csv_delimiter",
"=",
"','",
",",
"csv_header",
"=",
"True",
",",
"compress",
"=",
"False",
",",
"use_cache",
"=",
"True",
",",
"dialect",
"=",
"None",
",",
"billing_ti... | Exports the query results to GCS.
Args:
storage_uris: the destination URI(s). Can be a single URI or a list.
format: the format to use for the exported data; one of 'csv', 'json', or 'avro'
(default 'csv').
csv_delimiter: for csv exports, the field delimiter to use (default ',').
... | [
"Exports",
"the",
"query",
"results",
"to",
"GCS",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_query.py#L231-L261 |
5,083 | googledatalab/pydatalab | datalab/bigquery/_query.py | Query.to_dataframe | def to_dataframe(self, start_row=0, max_rows=None, use_cache=True, dialect=None,
billing_tier=None):
""" Exports the query results to a Pandas dataframe.
Args:
start_row: the row of the table at which to start the export (default 0).
max_rows: an upper limit on the number of rows... | python | def to_dataframe(self, start_row=0, max_rows=None, use_cache=True, dialect=None,
billing_tier=None):
""" Exports the query results to a Pandas dataframe.
Args:
start_row: the row of the table at which to start the export (default 0).
max_rows: an upper limit on the number of rows... | [
"def",
"to_dataframe",
"(",
"self",
",",
"start_row",
"=",
"0",
",",
"max_rows",
"=",
"None",
",",
"use_cache",
"=",
"True",
",",
"dialect",
"=",
"None",
",",
"billing_tier",
"=",
"None",
")",
":",
"return",
"self",
".",
"results",
"(",
"use_cache",
"=... | Exports the query results to a Pandas dataframe.
Args:
start_row: the row of the table at which to start the export (default 0).
max_rows: an upper limit on the number of rows to export (default None).
use_cache: whether to use cached results or not (default True).
dialect : {'legacy', 'sta... | [
"Exports",
"the",
"query",
"results",
"to",
"a",
"Pandas",
"dataframe",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_query.py#L303-L323 |
5,084 | googledatalab/pydatalab | datalab/bigquery/_query.py | Query.sample | def sample(self, count=5, fields=None, sampling=None, use_cache=True, dialect=None,
billing_tier=None):
"""Retrieves a sampling of rows for the query.
Args:
count: an optional count of rows to retrieve which is used if a specific
sampling is not specified (default 5).
fields:... | python | def sample(self, count=5, fields=None, sampling=None, use_cache=True, dialect=None,
billing_tier=None):
"""Retrieves a sampling of rows for the query.
Args:
count: an optional count of rows to retrieve which is used if a specific
sampling is not specified (default 5).
fields:... | [
"def",
"sample",
"(",
"self",
",",
"count",
"=",
"5",
",",
"fields",
"=",
"None",
",",
"sampling",
"=",
"None",
",",
"use_cache",
"=",
"True",
",",
"dialect",
"=",
"None",
",",
"billing_tier",
"=",
"None",
")",
":",
"return",
"Query",
".",
"sampling_... | Retrieves a sampling of rows for the query.
Args:
count: an optional count of rows to retrieve which is used if a specific
sampling is not specified (default 5).
fields: the list of fields to sample (default None implies all).
sampling: an optional sampling strategy to apply to the tabl... | [
"Retrieves",
"a",
"sampling",
"of",
"rows",
"for",
"the",
"query",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_query.py#L379-L406 |
5,085 | googledatalab/pydatalab | datalab/bigquery/_query.py | Query.execute | def execute(self, table_name=None, table_mode='create', use_cache=True, priority='interactive',
allow_large_results=False, dialect=None, billing_tier=None):
""" Initiate the query, blocking until complete and then return the results.
Args:
table_name: the result table name as a string or Ta... | python | def execute(self, table_name=None, table_mode='create', use_cache=True, priority='interactive',
allow_large_results=False, dialect=None, billing_tier=None):
""" Initiate the query, blocking until complete and then return the results.
Args:
table_name: the result table name as a string or Ta... | [
"def",
"execute",
"(",
"self",
",",
"table_name",
"=",
"None",
",",
"table_mode",
"=",
"'create'",
",",
"use_cache",
"=",
"True",
",",
"priority",
"=",
"'interactive'",
",",
"allow_large_results",
"=",
"False",
",",
"dialect",
"=",
"None",
",",
"billing_tier... | Initiate the query, blocking until complete and then return the results.
Args:
table_name: the result table name as a string or TableName; if None (the default), then a
temporary table will be used.
table_mode: one of 'create', 'overwrite' or 'append'. If 'create' (the default), the request
... | [
"Initiate",
"the",
"query",
"blocking",
"until",
"complete",
"and",
"then",
"return",
"the",
"results",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_query.py#L496-L529 |
5,086 | googledatalab/pydatalab | datalab/bigquery/_query.py | Query.to_view | def to_view(self, view_name):
""" Create a View from this Query.
Args:
view_name: the name of the View either as a string or a 3-part tuple
(projectid, datasetid, name).
Returns:
A View for the Query.
"""
# Do the import here to avoid circular dependencies at top-level.
f... | python | def to_view(self, view_name):
""" Create a View from this Query.
Args:
view_name: the name of the View either as a string or a 3-part tuple
(projectid, datasetid, name).
Returns:
A View for the Query.
"""
# Do the import here to avoid circular dependencies at top-level.
f... | [
"def",
"to_view",
"(",
"self",
",",
"view_name",
")",
":",
"# Do the import here to avoid circular dependencies at top-level.",
"from",
".",
"import",
"_view",
"return",
"_view",
".",
"View",
"(",
"view_name",
",",
"self",
".",
"_context",
")",
".",
"create",
"(",... | Create a View from this Query.
Args:
view_name: the name of the View either as a string or a 3-part tuple
(projectid, datasetid, name).
Returns:
A View for the Query. | [
"Create",
"a",
"View",
"from",
"this",
"Query",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_query.py#L531-L543 |
5,087 | googledatalab/pydatalab | google/datalab/utils/commands/_commands.py | CommandParser.format_help | def format_help(self):
"""Override help doc to add cell args. """
if not self._cell_args:
return super(CommandParser, self).format_help()
else:
# Print the standard argparse info, the cell arg block, and then the epilog
# If we don't remove epilog before calling the super, then epilog wil... | python | def format_help(self):
"""Override help doc to add cell args. """
if not self._cell_args:
return super(CommandParser, self).format_help()
else:
# Print the standard argparse info, the cell arg block, and then the epilog
# If we don't remove epilog before calling the super, then epilog wil... | [
"def",
"format_help",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_cell_args",
":",
"return",
"super",
"(",
"CommandParser",
",",
"self",
")",
".",
"format_help",
"(",
")",
"else",
":",
"# Print the standard argparse info, the cell arg block, and then the epil... | Override help doc to add cell args. | [
"Override",
"help",
"doc",
"to",
"add",
"cell",
"args",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_commands.py#L56-L77 |
5,088 | googledatalab/pydatalab | google/datalab/utils/commands/_commands.py | CommandParser._get_subparsers | def _get_subparsers(self):
"""Recursively get subparsers."""
subparsers = []
for action in self._actions:
if isinstance(action, argparse._SubParsersAction):
for _, subparser in action.choices.items():
subparsers.append(subparser)
ret = subparsers
for sp in subparsers:
... | python | def _get_subparsers(self):
"""Recursively get subparsers."""
subparsers = []
for action in self._actions:
if isinstance(action, argparse._SubParsersAction):
for _, subparser in action.choices.items():
subparsers.append(subparser)
ret = subparsers
for sp in subparsers:
... | [
"def",
"_get_subparsers",
"(",
"self",
")",
":",
"subparsers",
"=",
"[",
"]",
"for",
"action",
"in",
"self",
".",
"_actions",
":",
"if",
"isinstance",
"(",
"action",
",",
"argparse",
".",
"_SubParsersAction",
")",
":",
"for",
"_",
",",
"subparser",
"in",... | Recursively get subparsers. | [
"Recursively",
"get",
"subparsers",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_commands.py#L101-L113 |
5,089 | googledatalab/pydatalab | google/datalab/utils/commands/_commands.py | CommandParser._get_subparser_line_args | def _get_subparser_line_args(self, subparser_prog):
""" Get line args of a specified subparser by its prog."""
subparsers = self._get_subparsers()
for subparser in subparsers:
if subparser_prog == subparser.prog:
# Found the subparser.
args_to_parse = []
for action in subparse... | python | def _get_subparser_line_args(self, subparser_prog):
""" Get line args of a specified subparser by its prog."""
subparsers = self._get_subparsers()
for subparser in subparsers:
if subparser_prog == subparser.prog:
# Found the subparser.
args_to_parse = []
for action in subparse... | [
"def",
"_get_subparser_line_args",
"(",
"self",
",",
"subparser_prog",
")",
":",
"subparsers",
"=",
"self",
".",
"_get_subparsers",
"(",
")",
"for",
"subparser",
"in",
"subparsers",
":",
"if",
"subparser_prog",
"==",
"subparser",
".",
"prog",
":",
"# Found the s... | Get line args of a specified subparser by its prog. | [
"Get",
"line",
"args",
"of",
"a",
"specified",
"subparser",
"by",
"its",
"prog",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_commands.py#L115-L130 |
5,090 | googledatalab/pydatalab | google/datalab/utils/commands/_commands.py | CommandParser._get_subparser_cell_args | def _get_subparser_cell_args(self, subparser_prog):
""" Get cell args of a specified subparser by its prog."""
subparsers = self._get_subparsers()
for subparser in subparsers:
if subparser_prog == subparser.prog:
return subparser._cell_args
return None | python | def _get_subparser_cell_args(self, subparser_prog):
""" Get cell args of a specified subparser by its prog."""
subparsers = self._get_subparsers()
for subparser in subparsers:
if subparser_prog == subparser.prog:
return subparser._cell_args
return None | [
"def",
"_get_subparser_cell_args",
"(",
"self",
",",
"subparser_prog",
")",
":",
"subparsers",
"=",
"self",
".",
"_get_subparsers",
"(",
")",
"for",
"subparser",
"in",
"subparsers",
":",
"if",
"subparser_prog",
"==",
"subparser",
".",
"prog",
":",
"return",
"s... | Get cell args of a specified subparser by its prog. | [
"Get",
"cell",
"args",
"of",
"a",
"specified",
"subparser",
"by",
"its",
"prog",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_commands.py#L132-L140 |
5,091 | googledatalab/pydatalab | google/datalab/utils/commands/_commands.py | CommandParser.add_cell_argument | def add_cell_argument(self, name, help, required=False):
""" Add a cell only argument.
Args:
name: name of the argument. No need to start with "-" or "--".
help: the help string of the argument.
required: Whether it is required in cell content.
"""
for action in self._actions:
... | python | def add_cell_argument(self, name, help, required=False):
""" Add a cell only argument.
Args:
name: name of the argument. No need to start with "-" or "--".
help: the help string of the argument.
required: Whether it is required in cell content.
"""
for action in self._actions:
... | [
"def",
"add_cell_argument",
"(",
"self",
",",
"name",
",",
"help",
",",
"required",
"=",
"False",
")",
":",
"for",
"action",
"in",
"self",
".",
"_actions",
":",
"if",
"action",
".",
"dest",
"==",
"name",
":",
"raise",
"ValueError",
"(",
"'Arg \"%s\" was ... | Add a cell only argument.
Args:
name: name of the argument. No need to start with "-" or "--".
help: the help string of the argument.
required: Whether it is required in cell content. | [
"Add",
"a",
"cell",
"only",
"argument",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_commands.py#L142-L155 |
5,092 | googledatalab/pydatalab | google/datalab/utils/commands/_commands.py | CommandParser.parse | def parse(self, line, cell, namespace=None):
"""Parses a line and cell into a dictionary of arguments, expanding variables from a namespace.
For each line parameters beginning with --, it also checks the cell content and see if it exists
there. For example, if "--config1" is a line parameter, it checks to ... | python | def parse(self, line, cell, namespace=None):
"""Parses a line and cell into a dictionary of arguments, expanding variables from a namespace.
For each line parameters beginning with --, it also checks the cell content and see if it exists
there. For example, if "--config1" is a line parameter, it checks to ... | [
"def",
"parse",
"(",
"self",
",",
"line",
",",
"cell",
",",
"namespace",
"=",
"None",
")",
":",
"if",
"namespace",
"is",
"None",
":",
"ipy",
"=",
"IPython",
".",
"get_ipython",
"(",
")",
"namespace",
"=",
"ipy",
".",
"user_ns",
"# Find which subcommand i... | Parses a line and cell into a dictionary of arguments, expanding variables from a namespace.
For each line parameters beginning with --, it also checks the cell content and see if it exists
there. For example, if "--config1" is a line parameter, it checks to see if cell dict contains
"config1" item, and if... | [
"Parses",
"a",
"line",
"and",
"cell",
"into",
"a",
"dictionary",
"of",
"arguments",
"expanding",
"variables",
"from",
"a",
"namespace",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_commands.py#L157-L257 |
5,093 | googledatalab/pydatalab | google/datalab/ml/_summary.py | Summary._glob_events_files | def _glob_events_files(self, paths, recursive):
"""Find all tf events files under a list of paths recursively. """
event_files = []
for path in paths:
dirs = tf.gfile.Glob(path)
dirs = filter(lambda x: tf.gfile.IsDirectory(x), dirs)
for dir in dirs:
if recursive:
dir_fil... | python | def _glob_events_files(self, paths, recursive):
"""Find all tf events files under a list of paths recursively. """
event_files = []
for path in paths:
dirs = tf.gfile.Glob(path)
dirs = filter(lambda x: tf.gfile.IsDirectory(x), dirs)
for dir in dirs:
if recursive:
dir_fil... | [
"def",
"_glob_events_files",
"(",
"self",
",",
"paths",
",",
"recursive",
")",
":",
"event_files",
"=",
"[",
"]",
"for",
"path",
"in",
"paths",
":",
"dirs",
"=",
"tf",
".",
"gfile",
".",
"Glob",
"(",
"path",
")",
"dirs",
"=",
"filter",
"(",
"lambda",... | Find all tf events files under a list of paths recursively. | [
"Find",
"all",
"tf",
"events",
"files",
"under",
"a",
"list",
"of",
"paths",
"recursively",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_summary.py#L44-L62 |
5,094 | googledatalab/pydatalab | google/datalab/ml/_summary.py | Summary.list_events | def list_events(self):
"""List all scalar events in the directory.
Returns:
A dictionary. Key is the name of a event. Value is a set of dirs that contain that event.
"""
event_dir_dict = collections.defaultdict(set)
for event_file in self._glob_events_files(self._paths, recursive=True):
... | python | def list_events(self):
"""List all scalar events in the directory.
Returns:
A dictionary. Key is the name of a event. Value is a set of dirs that contain that event.
"""
event_dir_dict = collections.defaultdict(set)
for event_file in self._glob_events_files(self._paths, recursive=True):
... | [
"def",
"list_events",
"(",
"self",
")",
":",
"event_dir_dict",
"=",
"collections",
".",
"defaultdict",
"(",
"set",
")",
"for",
"event_file",
"in",
"self",
".",
"_glob_events_files",
"(",
"self",
".",
"_paths",
",",
"recursive",
"=",
"True",
")",
":",
"dir"... | List all scalar events in the directory.
Returns:
A dictionary. Key is the name of a event. Value is a set of dirs that contain that event. | [
"List",
"all",
"scalar",
"events",
"in",
"the",
"directory",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_summary.py#L64-L87 |
5,095 | googledatalab/pydatalab | datalab/bigquery/_federated_table.py | FederatedTable.from_storage | def from_storage(source, source_format='csv', csv_options=None, ignore_unknown_values=False,
max_bad_records=0, compressed=False, schema=None):
""" Create an external table for a GCS object.
Args:
source: the URL of the source objects(s). Can include a wildcard '*' at the end of the i... | python | def from_storage(source, source_format='csv', csv_options=None, ignore_unknown_values=False,
max_bad_records=0, compressed=False, schema=None):
""" Create an external table for a GCS object.
Args:
source: the URL of the source objects(s). Can include a wildcard '*' at the end of the i... | [
"def",
"from_storage",
"(",
"source",
",",
"source_format",
"=",
"'csv'",
",",
"csv_options",
"=",
"None",
",",
"ignore_unknown_values",
"=",
"False",
",",
"max_bad_records",
"=",
"0",
",",
"compressed",
"=",
"False",
",",
"schema",
"=",
"None",
")",
":",
... | Create an external table for a GCS object.
Args:
source: the URL of the source objects(s). Can include a wildcard '*' at the end of the item
name. Can be a single source or a list.
source_format: the format of the data, 'csv' or 'json'; default 'csv'.
csv_options: For CSV files, the opti... | [
"Create",
"an",
"external",
"table",
"for",
"a",
"GCS",
"object",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_federated_table.py#L24-L64 |
5,096 | googledatalab/pydatalab | google/datalab/bigquery/commands/_bigquery.py | get_query_parameters | def get_query_parameters(args, cell_body, date_time=datetime.datetime.now()):
"""Extract query parameters from cell body if provided
Also validates the cell body schema using jsonschema to catch errors before sending the http
request. This validation isn't complete, however; it does not validate recursive schemas... | python | def get_query_parameters(args, cell_body, date_time=datetime.datetime.now()):
"""Extract query parameters from cell body if provided
Also validates the cell body schema using jsonschema to catch errors before sending the http
request. This validation isn't complete, however; it does not validate recursive schemas... | [
"def",
"get_query_parameters",
"(",
"args",
",",
"cell_body",
",",
"date_time",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
")",
":",
"env",
"=",
"google",
".",
"datalab",
".",
"utils",
".",
"commands",
".",
"notebook_environment",
"(",
")",
... | Extract query parameters from cell body if provided
Also validates the cell body schema using jsonschema to catch errors before sending the http
request. This validation isn't complete, however; it does not validate recursive schemas,
but it acts as a good filter against most simple schemas
Args:
args: arg... | [
"Extract",
"query",
"parameters",
"from",
"cell",
"body",
"if",
"provided",
"Also",
"validates",
"the",
"cell",
"body",
"schema",
"using",
"jsonschema",
"to",
"catch",
"errors",
"before",
"sending",
"the",
"http",
"request",
".",
"This",
"validation",
"isn",
"... | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/commands/_bigquery.py#L355-L382 |
5,097 | googledatalab/pydatalab | google/datalab/bigquery/commands/_bigquery.py | _udf_cell | def _udf_cell(args, cell_body):
"""Implements the Bigquery udf cell magic for ipython notebooks.
The supported syntax is:
%%bq udf --name <var> --language <lang>
// @param <name> <type>
// @returns <type>
// @import <gcs_path>
<js function>
Args:
args: the optional arguments following '%%bq udf'.
... | python | def _udf_cell(args, cell_body):
"""Implements the Bigquery udf cell magic for ipython notebooks.
The supported syntax is:
%%bq udf --name <var> --language <lang>
// @param <name> <type>
// @returns <type>
// @import <gcs_path>
<js function>
Args:
args: the optional arguments following '%%bq udf'.
... | [
"def",
"_udf_cell",
"(",
"args",
",",
"cell_body",
")",
":",
"udf_name",
"=",
"args",
"[",
"'name'",
"]",
"if",
"not",
"udf_name",
":",
"raise",
"Exception",
"(",
"'Declaration must be of the form %%bq udf --name <variable name>'",
")",
"# Parse out parameters, return t... | Implements the Bigquery udf cell magic for ipython notebooks.
The supported syntax is:
%%bq udf --name <var> --language <lang>
// @param <name> <type>
// @returns <type>
// @import <gcs_path>
<js function>
Args:
args: the optional arguments following '%%bq udf'.
cell_body: the UDF declaration (i... | [
"Implements",
"the",
"Bigquery",
"udf",
"cell",
"magic",
"for",
"ipython",
"notebooks",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/commands/_bigquery.py#L480-L516 |
5,098 | googledatalab/pydatalab | google/datalab/bigquery/commands/_bigquery.py | _datasource_cell | def _datasource_cell(args, cell_body):
"""Implements the BigQuery datasource cell magic for ipython notebooks.
The supported syntax is
%%bq datasource --name <var> --paths <url> [--format <CSV|JSON>]
<schema>
Args:
args: the optional arguments following '%%bq datasource'
cell_body: the datasource's ... | python | def _datasource_cell(args, cell_body):
"""Implements the BigQuery datasource cell magic for ipython notebooks.
The supported syntax is
%%bq datasource --name <var> --paths <url> [--format <CSV|JSON>]
<schema>
Args:
args: the optional arguments following '%%bq datasource'
cell_body: the datasource's ... | [
"def",
"_datasource_cell",
"(",
"args",
",",
"cell_body",
")",
":",
"name",
"=",
"args",
"[",
"'name'",
"]",
"paths",
"=",
"args",
"[",
"'paths'",
"]",
"data_format",
"=",
"(",
"args",
"[",
"'format'",
"]",
"or",
"'CSV'",
")",
".",
"lower",
"(",
")",... | Implements the BigQuery datasource cell magic for ipython notebooks.
The supported syntax is
%%bq datasource --name <var> --paths <url> [--format <CSV|JSON>]
<schema>
Args:
args: the optional arguments following '%%bq datasource'
cell_body: the datasource's schema in json/yaml | [
"Implements",
"the",
"BigQuery",
"datasource",
"cell",
"magic",
"for",
"ipython",
"notebooks",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/commands/_bigquery.py#L519-L545 |
5,099 | googledatalab/pydatalab | google/datalab/bigquery/commands/_bigquery.py | _query_cell | def _query_cell(args, cell_body):
"""Implements the BigQuery cell magic for used to build SQL objects.
The supported syntax is:
%%bq query <args>
[<inline SQL>]
Args:
args: the optional arguments following '%%bql query'.
cell_body: the contents of the cell
"""
name = args['name']
udfs... | python | def _query_cell(args, cell_body):
"""Implements the BigQuery cell magic for used to build SQL objects.
The supported syntax is:
%%bq query <args>
[<inline SQL>]
Args:
args: the optional arguments following '%%bql query'.
cell_body: the contents of the cell
"""
name = args['name']
udfs... | [
"def",
"_query_cell",
"(",
"args",
",",
"cell_body",
")",
":",
"name",
"=",
"args",
"[",
"'name'",
"]",
"udfs",
"=",
"args",
"[",
"'udfs'",
"]",
"datasources",
"=",
"args",
"[",
"'datasources'",
"]",
"subqueries",
"=",
"args",
"[",
"'subqueries'",
"]",
... | Implements the BigQuery cell magic for used to build SQL objects.
The supported syntax is:
%%bq query <args>
[<inline SQL>]
Args:
args: the optional arguments following '%%bql query'.
cell_body: the contents of the cell | [
"Implements",
"the",
"BigQuery",
"cell",
"magic",
"for",
"used",
"to",
"build",
"SQL",
"objects",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/commands/_bigquery.py#L548-L573 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.