repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/xgboost/trainer/feature_analysis.py#L114-L167 |
googledatalab/pydatalab | solutionbox/ml_workbench/xgboost/trainer/feature_analysis.py | invert_features | def invert_features(features):
"""Make a dict in the form source column : set of transforms.
Note that the key transform is removed.
"""
inverted_features = collections.defaultdict(list)
for transform in six.itervalues(features):
source_column = transform['source_column']
inverted_features[source_col... | python | def invert_features(features):
"""Make a dict in the form source column : set of transforms.
Note that the key transform is removed.
"""
inverted_features = collections.defaultdict(list)
for transform in six.itervalues(features):
source_column = transform['source_column']
inverted_features[source_col... | [
"def",
"invert_features",
"(",
"features",
")",
":",
"inverted_features",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"for",
"transform",
"in",
"six",
".",
"itervalues",
"(",
"features",
")",
":",
"source_column",
"=",
"transform",
"[",
"'source_... | Make a dict in the form source column : set of transforms.
Note that the key transform is removed. | [
"Make",
"a",
"dict",
"in",
"the",
"form",
"source",
"column",
":",
"set",
"of",
"transforms",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/xgboost/trainer/feature_analysis.py#L172-L182 |
googledatalab/pydatalab | solutionbox/ml_workbench/xgboost/trainer/feature_analysis.py | run_local_analysis | def run_local_analysis(output_dir, csv_file_pattern, schema, features):
"""Use pandas to analyze csv files.
Produces a stats file and vocab files.
Args:
output_dir: output folder
csv_file_pattern: list of csv file paths, may contain wildcards
schema: CSV schema list
features: features config
... | python | def run_local_analysis(output_dir, csv_file_pattern, schema, features):
"""Use pandas to analyze csv files.
Produces a stats file and vocab files.
Args:
output_dir: output folder
csv_file_pattern: list of csv file paths, may contain wildcards
schema: CSV schema list
features: features config
... | [
"def",
"run_local_analysis",
"(",
"output_dir",
",",
"csv_file_pattern",
",",
"schema",
",",
"features",
")",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"'Expanding any file patterns...\\n'",
")",
"sys",
".",
"stdout",
".",
"flush",
"(",
")",
"header",
"=",... | Use pandas to analyze csv files.
Produces a stats file and vocab files.
Args:
output_dir: output folder
csv_file_pattern: list of csv file paths, may contain wildcards
schema: CSV schema list
features: features config
Raises:
ValueError: on unknown transfrorms/schemas | [
"Use",
"pandas",
"to",
"analyze",
"csv",
"files",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/xgboost/trainer/feature_analysis.py#L185-L318 |
googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | _get_query_argument | def _get_query_argument(args, cell, env):
""" Get a query argument to a cell magic.
The query is specified with args['query']. We look that up and if it is a BQ query
just return it. If it is instead a SqlModule or SqlStatement it may have variable
references. We resolve those using the arg parser for the SqlM... | python | def _get_query_argument(args, cell, env):
""" Get a query argument to a cell magic.
The query is specified with args['query']. We look that up and if it is a BQ query
just return it. If it is instead a SqlModule or SqlStatement it may have variable
references. We resolve those using the arg parser for the SqlM... | [
"def",
"_get_query_argument",
"(",
"args",
",",
"cell",
",",
"env",
")",
":",
"sql_arg",
"=",
"args",
".",
"get",
"(",
"'query'",
",",
"None",
")",
"if",
"sql_arg",
"is",
"None",
":",
"# Assume we have inline SQL in the cell",
"if",
"not",
"isinstance",
"(",... | Get a query argument to a cell magic.
The query is specified with args['query']. We look that up and if it is a BQ query
just return it. If it is instead a SqlModule or SqlStatement it may have variable
references. We resolve those using the arg parser for the SqlModule, then override
the resulting defaults wi... | [
"Get",
"a",
"query",
"argument",
"to",
"a",
"cell",
"magic",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L248-L282 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L285-L339 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L342-L375 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L378-L403 |
googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | _dryrun_cell | def _dryrun_cell(args, cell_body):
"""Implements the BigQuery cell magic used to dry run BQ queries.
The supported syntax is:
%%bigquery dryrun [-q|--sql <query identifier>]
[<YAML or JSON cell_body or inline SQL>]
Args:
args: the argument following '%bigquery dryrun'.
cell_body: optional content... | python | def _dryrun_cell(args, cell_body):
"""Implements the BigQuery cell magic used to dry run BQ queries.
The supported syntax is:
%%bigquery dryrun [-q|--sql <query identifier>]
[<YAML or JSON cell_body or inline SQL>]
Args:
args: the argument following '%bigquery dryrun'.
cell_body: optional content... | [
"def",
"_dryrun_cell",
"(",
"args",
",",
"cell_body",
")",
":",
"query",
"=",
"_get_query_argument",
"(",
"args",
",",
"cell_body",
",",
"datalab",
".",
"utils",
".",
"commands",
".",
"notebook_environment",
"(",
")",
")",
"if",
"args",
"[",
"'verbose'",
"... | Implements the BigQuery cell magic used to dry run BQ queries.
The supported syntax is:
%%bigquery dryrun [-q|--sql <query identifier>]
[<YAML or JSON cell_body or inline SQL>]
Args:
args: the argument following '%bigquery dryrun'.
cell_body: optional contents of the cell interpreted as YAML or JSO... | [
"Implements",
"the",
"BigQuery",
"cell",
"magic",
"used",
"to",
"dry",
"run",
"BQ",
"queries",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L406-L425 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L428-L492 |
googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | _execute_cell | def _execute_cell(args, cell_body):
"""Implements the BigQuery cell magic used to execute BQ queries.
The supported syntax is:
%%bigquery execute [-q|--sql <query identifier>] <other args>
[<YAML or JSON cell_body or inline SQL>]
Args:
args: the arguments following '%bigquery execute'.
cell_body:... | python | def _execute_cell(args, cell_body):
"""Implements the BigQuery cell magic used to execute BQ queries.
The supported syntax is:
%%bigquery execute [-q|--sql <query identifier>] <other args>
[<YAML or JSON cell_body or inline SQL>]
Args:
args: the arguments following '%bigquery execute'.
cell_body:... | [
"def",
"_execute_cell",
"(",
"args",
",",
"cell_body",
")",
":",
"query",
"=",
"_get_query_argument",
"(",
"args",
",",
"cell_body",
",",
"datalab",
".",
"utils",
".",
"commands",
".",
"notebook_environment",
"(",
")",
")",
"if",
"args",
"[",
"'verbose'",
... | Implements the BigQuery cell magic used to execute BQ queries.
The supported syntax is:
%%bigquery execute [-q|--sql <query identifier>] <other args>
[<YAML or JSON cell_body or inline SQL>]
Args:
args: the arguments following '%bigquery execute'.
cell_body: optional contents of the cell interprete... | [
"Implements",
"the",
"BigQuery",
"cell",
"magic",
"used",
"to",
"execute",
"BQ",
"queries",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L495-L513 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L516-L548 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L551-L571 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L574-L584 |
googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | _schema_line | def _schema_line(args):
"""Implements the BigQuery schema magic used to display table/view schemas.
Args:
args: the arguments following '%bigquery schema'.
Returns:
The HTML rendering for the schema.
"""
# TODO(gram): surely we could just return the schema itself?
name = args['table'] if args['tabl... | python | def _schema_line(args):
"""Implements the BigQuery schema magic used to display table/view schemas.
Args:
args: the arguments following '%bigquery schema'.
Returns:
The HTML rendering for the schema.
"""
# TODO(gram): surely we could just return the schema itself?
name = args['table'] if args['tabl... | [
"def",
"_schema_line",
"(",
"args",
")",
":",
"# TODO(gram): surely we could just return the schema itself?",
"name",
"=",
"args",
"[",
"'table'",
"]",
"if",
"args",
"[",
"'table'",
"]",
"else",
"args",
"[",
"'view'",
"]",
"if",
"name",
"is",
"None",
":",
"rai... | Implements the BigQuery schema magic used to display table/view schemas.
Args:
args: the arguments following '%bigquery schema'.
Returns:
The HTML rendering for the schema. | [
"Implements",
"the",
"BigQuery",
"schema",
"magic",
"used",
"to",
"display",
"table",
"/",
"view",
"schemas",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L615-L633 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L636-L638 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L646-L660 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L663-L688 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L691-L722 |
googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | _load_cell | def _load_cell(args, schema):
"""Implements the BigQuery load magic used to load data from GCS to a table.
The supported syntax is:
%bigquery load -S|--source <source> -D|--destination <table> <other_args>
Args:
args: the arguments following '%bigquery load'.
schema: a JSON schema for the dest... | python | def _load_cell(args, schema):
"""Implements the BigQuery load magic used to load data from GCS to a table.
The supported syntax is:
%bigquery load -S|--source <source> -D|--destination <table> <other_args>
Args:
args: the arguments following '%bigquery load'.
schema: a JSON schema for the dest... | [
"def",
"_load_cell",
"(",
"args",
",",
"schema",
")",
":",
"name",
"=",
"args",
"[",
"'destination'",
"]",
"table",
"=",
"_get_table",
"(",
"name",
")",
"if",
"not",
"table",
":",
"table",
"=",
"datalab",
".",
"bigquery",
".",
"Table",
"(",
"name",
"... | Implements the BigQuery load magic used to load data from GCS to a table.
The supported syntax is:
%bigquery load -S|--source <source> -D|--destination <table> <other_args>
Args:
args: the arguments following '%bigquery load'.
schema: a JSON schema for the destination table.
Returns:
A mes... | [
"Implements",
"the",
"BigQuery",
"load",
"magic",
"used",
"to",
"load",
"data",
"from",
"GCS",
"to",
"a",
"table",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L725-L767 |
googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | _create_bigquery_parser | def _create_bigquery_parser():
""" Create the parser for the %bigquery magics.
Note that because we use the func default handler dispatch mechanism of argparse,
our handlers can take only one argument which is the parsed args. So we must create closures
for the handlers that bind the cell contents and thus mus... | python | def _create_bigquery_parser():
""" Create the parser for the %bigquery magics.
Note that because we use the func default handler dispatch mechanism of argparse,
our handlers can take only one argument which is the parsed args. So we must create closures
for the handlers that bind the cell contents and thus mus... | [
"def",
"_create_bigquery_parser",
"(",
")",
":",
"parser",
"=",
"datalab",
".",
"utils",
".",
"commands",
".",
"CommandParser",
"(",
"prog",
"=",
"'bigquery'",
",",
"description",
"=",
"\"\"\"\nExecute various BigQuery-related operations. Use \"%bigquery <command> -h\"\nfor... | Create the parser for the %bigquery magics.
Note that because we use the func default handler dispatch mechanism of argparse,
our handlers can take only one argument which is the parsed args. So we must create closures
for the handlers that bind the cell contents and thus must recreate this parser for each
cel... | [
"Create",
"the",
"parser",
"for",
"the",
"%bigquery",
"magics",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L777-L833 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L840-L860 |
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"
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_query_output.py#L19-L43 |
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"
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_query_output.py#L46-L73 |
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"
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_query_output.py#L76-L89 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_tensorboard.py#L33-L47 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_tensorboard.py#L50-L79 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_tensorboard.py#L82-L93 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_preprocess.py#L126-L167 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_preprocess.py#L169-L186 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_preprocess.py#L188-L198 |
googledatalab/pydatalab | solutionbox/image_classification/mltoolbox/image/classification/_model.py | loss | def loss(logits, labels):
"""Calculates the loss from the logits and the labels.
Args:
logits: Logits tensor, float - [batch_size, NUM_CLASSES].
labels: Labels tensor, int32 - [batch_size].
Returns:
loss: Loss tensor of type float.
"""
labels = tf.to_int64(labels)
cross_entropy = tf.nn.sparse_s... | python | def loss(logits, labels):
"""Calculates the loss from the logits and the labels.
Args:
logits: Logits tensor, float - [batch_size, NUM_CLASSES].
labels: Labels tensor, int32 - [batch_size].
Returns:
loss: Loss tensor of type float.
"""
labels = tf.to_int64(labels)
cross_entropy = tf.nn.sparse_s... | [
"def",
"loss",
"(",
"logits",
",",
"labels",
")",
":",
"labels",
"=",
"tf",
".",
"to_int64",
"(",
"labels",
")",
"cross_entropy",
"=",
"tf",
".",
"nn",
".",
"sparse_softmax_cross_entropy_with_logits",
"(",
"logits",
"=",
"logits",
",",
"labels",
"=",
"labe... | Calculates the loss from the logits and the labels.
Args:
logits: Logits tensor, float - [batch_size, NUM_CLASSES].
labels: Labels tensor, int32 - [batch_size].
Returns:
loss: Loss tensor of type float. | [
"Calculates",
"the",
"loss",
"from",
"the",
"logits",
"and",
"the",
"labels",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_model.py#L367-L379 |
googledatalab/pydatalab | solutionbox/image_classification/mltoolbox/image/classification/_model.py | training | def training(loss_op):
"""Calculates the loss from the logits and the labels.
Args:
logits: Logits tensor, float - [batch_size, NUM_CLASSES].
labels: Labels tensor, int32 - [batch_size].
Returns:
loss: Loss tensor of type float.
"""
global_step = tf.Variable(0, name='global_step', trainable=False... | python | def training(loss_op):
"""Calculates the loss from the logits and the labels.
Args:
logits: Logits tensor, float - [batch_size, NUM_CLASSES].
labels: Labels tensor, int32 - [batch_size].
Returns:
loss: Loss tensor of type float.
"""
global_step = tf.Variable(0, name='global_step', trainable=False... | [
"def",
"training",
"(",
"loss_op",
")",
":",
"global_step",
"=",
"tf",
".",
"Variable",
"(",
"0",
",",
"name",
"=",
"'global_step'",
",",
"trainable",
"=",
"False",
")",
"with",
"tf",
".",
"name_scope",
"(",
"'train'",
")",
":",
"optimizer",
"=",
"tf",... | Calculates the loss from the logits and the labels.
Args:
logits: Logits tensor, float - [batch_size, NUM_CLASSES].
labels: Labels tensor, int32 - [batch_size].
Returns:
loss: Loss tensor of type float. | [
"Calculates",
"the",
"loss",
"from",
"the",
"logits",
"and",
"the",
"labels",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_model.py#L382-L395 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_model.py#L71-L112 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_model.py#L114-L152 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_model.py#L154-L237 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_model.py#L245-L284 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_model.py#L286-L317 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_model.py#L319-L346 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_model.py#L348-L360 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_util.py#L45-L88 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_util.py#L91-L94 |
googledatalab/pydatalab | datalab/data/commands/_sql.py | sql | def sql(line, cell=None):
""" Create a SQL module with one or more queries. Use %sql --help for more details.
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 pr... | python | def sql(line, cell=None):
""" Create a SQL module with one or more queries. Use %sql --help for more details.
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 pr... | [
"def",
"sql",
"(",
"line",
",",
"cell",
"=",
"None",
")",
":",
"if",
"cell",
"is",
"None",
":",
"_sql_parser",
".",
"print_help",
"(",
")",
"else",
":",
"return",
"handle_magic_line",
"(",
"line",
",",
"cell",
",",
"_sql_parser",
")"
] | Create a SQL module with one or more queries. Use %sql --help for more details.
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 star... | [
"Create",
"a",
"SQL",
"module",
"with",
"one",
"or",
"more",
"queries",
".",
"Use",
"%sql",
"--",
"help",
"for",
"more",
"details",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/data/commands/_sql.py#L93-L116 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/data/commands/_sql.py#L119-L177 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/data/commands/_sql.py#L189-L193 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/data/commands/_sql.py#L196-L200 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/data/commands/_sql.py#L215-L281 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/data/commands/_sql.py#L284-L367 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/data/commands/_sql.py#L370-L402 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/structured_data/mltoolbox/_structured_data/trainer/task.py#L30-L57 |
googledatalab/pydatalab | solutionbox/structured_data/mltoolbox/_structured_data/trainer/task.py | get_experiment_fn | def get_experiment_fn(args):
"""Builds the experiment function for learn_runner.run.
Args:
args: the command line args
Returns:
A function that returns a tf.learn experiment object.
"""
def get_experiment(output_dir):
# Merge schema, input features, and transforms.
train_config = util.merge... | python | def get_experiment_fn(args):
"""Builds the experiment function for learn_runner.run.
Args:
args: the command line args
Returns:
A function that returns a tf.learn experiment object.
"""
def get_experiment(output_dir):
# Merge schema, input features, and transforms.
train_config = util.merge... | [
"def",
"get_experiment_fn",
"(",
"args",
")",
":",
"def",
"get_experiment",
"(",
"output_dir",
")",
":",
"# Merge schema, input features, and transforms.",
"train_config",
"=",
"util",
".",
"merge_metadata",
"(",
"args",
".",
"preprocess_output_dir",
",",
"args",
".",... | Builds the experiment function for learn_runner.run.
Args:
args: the command line args
Returns:
A function that returns a tf.learn experiment object. | [
"Builds",
"the",
"experiment",
"function",
"for",
"learn_runner",
".",
"run",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/structured_data/mltoolbox/_structured_data/trainer/task.py#L60-L132 |
googledatalab/pydatalab | solutionbox/structured_data/mltoolbox/_structured_data/trainer/task.py | parse_arguments | def parse_arguments(argv):
"""Parse the command line arguments."""
parser = argparse.ArgumentParser(
description=('Train a regression or classification model. Note that if '
'using a DNN model, --layer-size1=NUM, --layer-size2=NUM, '
'should be used. '))
# I/O file par... | python | def parse_arguments(argv):
"""Parse the command line arguments."""
parser = argparse.ArgumentParser(
description=('Train a regression or classification model. Note that if '
'using a DNN model, --layer-size1=NUM, --layer-size2=NUM, '
'should be used. '))
# I/O file par... | [
"def",
"parse_arguments",
"(",
"argv",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"(",
"'Train a regression or classification model. Note that if '",
"'using a DNN model, --layer-size1=NUM, --layer-size2=NUM, '",
"'should be used. '",
")"... | Parse the command line arguments. | [
"Parse",
"the",
"command",
"line",
"arguments",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/structured_data/mltoolbox/_structured_data/trainer/task.py#L135-L228 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/structured_data/mltoolbox/_structured_data/trainer/task.py#L231-L238 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/stackdriver/commands/_monitoring.py#L28-L42 |
googledatalab/pydatalab | google/datalab/stackdriver/commands/_monitoring.py | _monitoring_metrics_list | def _monitoring_metrics_list(args, _):
"""Lists the metric descriptors in the project."""
project_id = args['project']
pattern = args['type'] or '*'
descriptors = gcm.MetricDescriptors(context=_make_context(project_id))
dataframe = descriptors.as_dataframe(pattern=pattern)
return _render_dataframe(dataframe... | python | def _monitoring_metrics_list(args, _):
"""Lists the metric descriptors in the project."""
project_id = args['project']
pattern = args['type'] or '*'
descriptors = gcm.MetricDescriptors(context=_make_context(project_id))
dataframe = descriptors.as_dataframe(pattern=pattern)
return _render_dataframe(dataframe... | [
"def",
"_monitoring_metrics_list",
"(",
"args",
",",
"_",
")",
":",
"project_id",
"=",
"args",
"[",
"'project'",
"]",
"pattern",
"=",
"args",
"[",
"'type'",
"]",
"or",
"'*'",
"descriptors",
"=",
"gcm",
".",
"MetricDescriptors",
"(",
"context",
"=",
"_make_... | Lists the metric descriptors in the project. | [
"Lists",
"the",
"metric",
"descriptors",
"in",
"the",
"project",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/stackdriver/commands/_monitoring.py#L84-L90 |
googledatalab/pydatalab | google/datalab/stackdriver/commands/_monitoring.py | _monitoring_resource_types_list | def _monitoring_resource_types_list(args, _):
"""Lists the resource descriptors in the project."""
project_id = args['project']
pattern = args['type'] or '*'
descriptors = gcm.ResourceDescriptors(context=_make_context(project_id))
dataframe = descriptors.as_dataframe(pattern=pattern)
return _render_datafram... | python | def _monitoring_resource_types_list(args, _):
"""Lists the resource descriptors in the project."""
project_id = args['project']
pattern = args['type'] or '*'
descriptors = gcm.ResourceDescriptors(context=_make_context(project_id))
dataframe = descriptors.as_dataframe(pattern=pattern)
return _render_datafram... | [
"def",
"_monitoring_resource_types_list",
"(",
"args",
",",
"_",
")",
":",
"project_id",
"=",
"args",
"[",
"'project'",
"]",
"pattern",
"=",
"args",
"[",
"'type'",
"]",
"or",
"'*'",
"descriptors",
"=",
"gcm",
".",
"ResourceDescriptors",
"(",
"context",
"=",
... | Lists the resource descriptors in the project. | [
"Lists",
"the",
"resource",
"descriptors",
"in",
"the",
"project",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/stackdriver/commands/_monitoring.py#L93-L99 |
googledatalab/pydatalab | google/datalab/stackdriver/commands/_monitoring.py | _monitoring_groups_list | def _monitoring_groups_list(args, _):
"""Lists the groups in the project."""
project_id = args['project']
pattern = args['name'] or '*'
groups = gcm.Groups(context=_make_context(project_id))
dataframe = groups.as_dataframe(pattern=pattern)
return _render_dataframe(dataframe) | python | def _monitoring_groups_list(args, _):
"""Lists the groups in the project."""
project_id = args['project']
pattern = args['name'] or '*'
groups = gcm.Groups(context=_make_context(project_id))
dataframe = groups.as_dataframe(pattern=pattern)
return _render_dataframe(dataframe) | [
"def",
"_monitoring_groups_list",
"(",
"args",
",",
"_",
")",
":",
"project_id",
"=",
"args",
"[",
"'project'",
"]",
"pattern",
"=",
"args",
"[",
"'name'",
"]",
"or",
"'*'",
"groups",
"=",
"gcm",
".",
"Groups",
"(",
"context",
"=",
"_make_context",
"(",
... | Lists the groups in the project. | [
"Lists",
"the",
"groups",
"in",
"the",
"project",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/stackdriver/commands/_monitoring.py#L102-L108 |
googledatalab/pydatalab | solutionbox/ml_workbench/xgboost/trainer/task.py | parse_arguments | def parse_arguments(argv):
"""Parse the command line arguments."""
parser = DatalabParser(
epilog=('Note that if using a DNN model, --hidden-layer-size1=NUM, '
'--hidden-layer-size2=NUM, ..., is also required. '),
datalab_epilog=("""
Note that if using a DNN model,
hidden-layer-size1: ... | python | def parse_arguments(argv):
"""Parse the command line arguments."""
parser = DatalabParser(
epilog=('Note that if using a DNN model, --hidden-layer-size1=NUM, '
'--hidden-layer-size2=NUM, ..., is also required. '),
datalab_epilog=("""
Note that if using a DNN model,
hidden-layer-size1: ... | [
"def",
"parse_arguments",
"(",
"argv",
")",
":",
"parser",
"=",
"DatalabParser",
"(",
"epilog",
"=",
"(",
"'Note that if using a DNN model, --hidden-layer-size1=NUM, '",
"'--hidden-layer-size2=NUM, ..., is also required. '",
")",
",",
"datalab_epilog",
"=",
"(",
"\"\"\"\n No... | Parse the command line arguments. | [
"Parse",
"the",
"command",
"line",
"arguments",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/xgboost/trainer/task.py#L155-L261 |
googledatalab/pydatalab | solutionbox/ml_workbench/xgboost/trainer/task.py | recursive_copy | def recursive_copy(src_dir, dest_dir):
"""Copy the contents of src_dir into the folder dest_dir.
Args:
src_dir: gsc or local path.
dest_dir: gcs or local path.
"""
file_io.recursive_create_dir(dest_dir)
for file_name in file_io.list_directory(src_dir):
old_path = os.path.join(src_dir, file_name)
... | python | def recursive_copy(src_dir, dest_dir):
"""Copy the contents of src_dir into the folder dest_dir.
Args:
src_dir: gsc or local path.
dest_dir: gcs or local path.
"""
file_io.recursive_create_dir(dest_dir)
for file_name in file_io.list_directory(src_dir):
old_path = os.path.join(src_dir, file_name)
... | [
"def",
"recursive_copy",
"(",
"src_dir",
",",
"dest_dir",
")",
":",
"file_io",
".",
"recursive_create_dir",
"(",
"dest_dir",
")",
"for",
"file_name",
"in",
"file_io",
".",
"list_directory",
"(",
"src_dir",
")",
":",
"old_path",
"=",
"os",
".",
"path",
".",
... | Copy the contents of src_dir into the folder dest_dir.
Args:
src_dir: gsc or local path.
dest_dir: gcs or local path. | [
"Copy",
"the",
"contents",
"of",
"src_dir",
"into",
"the",
"folder",
"dest_dir",
".",
"Args",
":",
"src_dir",
":",
"gsc",
"or",
"local",
"path",
".",
"dest_dir",
":",
"gcs",
"or",
"local",
"path",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/xgboost/trainer/task.py#L359-L374 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/xgboost/trainer/task.py#L377-L456 |
googledatalab/pydatalab | solutionbox/ml_workbench/xgboost/trainer/task.py | make_export_strategy | def make_export_strategy(
args,
keep_target,
assets_extra,
features,
schema,
stats):
"""Makes prediction graph that takes json input.
Args:
args: command line args
keep_target: If ture, target column is returned in prediction graph. Target
column must... | python | def make_export_strategy(
args,
keep_target,
assets_extra,
features,
schema,
stats):
"""Makes prediction graph that takes json input.
Args:
args: command line args
keep_target: If ture, target column is returned in prediction graph. Target
column must... | [
"def",
"make_export_strategy",
"(",
"args",
",",
"keep_target",
",",
"assets_extra",
",",
"features",
",",
"schema",
",",
"stats",
")",
":",
"target_name",
"=",
"feature_transforms",
".",
"get_target_name",
"(",
"features",
")",
"csv_header",
"=",
"[",
"col",
... | Makes prediction graph that takes json input.
Args:
args: command line args
keep_target: If ture, target column is returned in prediction graph. Target
column must also exist in input data
assets_extra: other fiels to copy to the output folder
job_dir: root job folder
features: features d... | [
"Makes",
"prediction",
"graph",
"that",
"takes",
"json",
"input",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/xgboost/trainer/task.py#L462-L582 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/xgboost/trainer/task.py#L642-L659 |
googledatalab/pydatalab | solutionbox/ml_workbench/xgboost/trainer/task.py | get_experiment_fn | def get_experiment_fn(args):
"""Builds the experiment function for learn_runner.run.
Args:
args: the command line args
Returns:
A function that returns a tf.learn experiment object.
"""
def get_experiment(output_dir):
# Read schema, input features, and transforms.
schema_path_with_target = ... | python | def get_experiment_fn(args):
"""Builds the experiment function for learn_runner.run.
Args:
args: the command line args
Returns:
A function that returns a tf.learn experiment object.
"""
def get_experiment(output_dir):
# Read schema, input features, and transforms.
schema_path_with_target = ... | [
"def",
"get_experiment_fn",
"(",
"args",
")",
":",
"def",
"get_experiment",
"(",
"output_dir",
")",
":",
"# Read schema, input features, and transforms.",
"schema_path_with_target",
"=",
"os",
".",
"path",
".",
"join",
"(",
"args",
".",
"analysis",
",",
"feature_tra... | Builds the experiment function for learn_runner.run.
Args:
args: the command line args
Returns:
A function that returns a tf.learn experiment object. | [
"Builds",
"the",
"experiment",
"function",
"for",
"learn_runner",
".",
"run",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/xgboost/trainer/task.py#L676-L814 |
googledatalab/pydatalab | solutionbox/ml_workbench/xgboost/trainer/task.py | DatalabParser.make_datalab_help_action | def make_datalab_help_action(self):
"""Custom action for --datalab-help.
The action output the package specific parameters and will be part of "%%ml train"
help string.
"""
datalab_help = self.datalab_help
epilog = self.datalab_epilog
class _CustomAction(argparse.Action):
def __init... | python | def make_datalab_help_action(self):
"""Custom action for --datalab-help.
The action output the package specific parameters and will be part of "%%ml train"
help string.
"""
datalab_help = self.datalab_help
epilog = self.datalab_epilog
class _CustomAction(argparse.Action):
def __init... | [
"def",
"make_datalab_help_action",
"(",
"self",
")",
":",
"datalab_help",
"=",
"self",
".",
"datalab_help",
"epilog",
"=",
"self",
".",
"datalab_epilog",
"class",
"_CustomAction",
"(",
"argparse",
".",
"Action",
")",
":",
"def",
"__init__",
"(",
"self",
",",
... | Custom action for --datalab-help.
The action output the package specific parameters and will be part of "%%ml train"
help string. | [
"Custom",
"action",
"for",
"--",
"datalab",
"-",
"help",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/xgboost/trainer/task.py#L107-L130 |
googledatalab/pydatalab | google/datalab/data/_csv_file.py | CsvFile.browse | def browse(self, max_lines=None, headers=None):
"""Try reading specified number of lines from the CSV object.
Args:
max_lines: max number of lines to read. If None, the whole file is read
headers: a list of strings as column names. If None, it will use "col0, col1..."
Returns:
A pandas Dat... | python | def browse(self, max_lines=None, headers=None):
"""Try reading specified number of lines from the CSV object.
Args:
max_lines: max number of lines to read. If None, the whole file is read
headers: a list of strings as column names. If None, it will use "col0, col1..."
Returns:
A pandas Dat... | [
"def",
"browse",
"(",
"self",
",",
"max_lines",
"=",
"None",
",",
"headers",
"=",
"None",
")",
":",
"if",
"self",
".",
"path",
".",
"startswith",
"(",
"'gs://'",
")",
":",
"lines",
"=",
"CsvFile",
".",
"_read_gcs_lines",
"(",
"self",
".",
"path",
","... | Try reading specified number of lines from the CSV object.
Args:
max_lines: max number of lines to read. If None, the whole file is read
headers: a list of strings as column names. If None, it will use "col0, col1..."
Returns:
A pandas DataFrame with the schema inferred from the data.
Rais... | [
"Try",
"reading",
"specified",
"number",
"of",
"lines",
"from",
"the",
"CSV",
"object",
".",
"Args",
":",
"max_lines",
":",
"max",
"number",
"of",
"lines",
"to",
"read",
".",
"If",
"None",
"the",
"whole",
"file",
"is",
"read",
"headers",
":",
"a",
"lis... | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/data/_csv_file.py#L79-L110 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/utils/_utils.py#L41-L60 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_predictor.py#L58-L64 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_predictor.py#L187-L228 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_query.py#L37-L54 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_query.py#L209-L229 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_query.py#L231-L261 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_query.py#L303-L323 |
googledatalab/pydatalab | datalab/bigquery/_query.py | Query.to_file | def to_file(self, path, format='csv', csv_delimiter=',', csv_header=True, use_cache=True,
dialect=None, billing_tier=None):
"""Save the results to a local file in CSV format.
Args:
path: path on the local filesystem for the saved results.
format: the format to use for the exported dat... | python | def to_file(self, path, format='csv', csv_delimiter=',', csv_header=True, use_cache=True,
dialect=None, billing_tier=None):
"""Save the results to a local file in CSV format.
Args:
path: path on the local filesystem for the saved results.
format: the format to use for the exported dat... | [
"def",
"to_file",
"(",
"self",
",",
"path",
",",
"format",
"=",
"'csv'",
",",
"csv_delimiter",
"=",
"','",
",",
"csv_header",
"=",
"True",
",",
"use_cache",
"=",
"True",
",",
"dialect",
"=",
"None",
",",
"billing_tier",
"=",
"None",
")",
":",
"self",
... | Save the results to a local file in CSV format.
Args:
path: 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 use. Defaults to ','
csv_header: for CSV... | [
"Save",
"the",
"results",
"to",
"a",
"local",
"file",
"in",
"CSV",
"format",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_query.py#L325-L350 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_query.py#L379-L406 |
googledatalab/pydatalab | datalab/bigquery/_query.py | Query.execute_dry_run | def execute_dry_run(self, dialect=None, billing_tier=None):
"""Dry run a query, to check the validity of the query and return some useful statistics.
Args:
dialect : {'legacy', 'standard'}, default 'legacy'
'legacy' : Use BigQuery's legacy SQL dialect.
'standard' : Use BigQuery's stan... | python | def execute_dry_run(self, dialect=None, billing_tier=None):
"""Dry run a query, to check the validity of the query and return some useful statistics.
Args:
dialect : {'legacy', 'standard'}, default 'legacy'
'legacy' : Use BigQuery's legacy SQL dialect.
'standard' : Use BigQuery's stan... | [
"def",
"execute_dry_run",
"(",
"self",
",",
"dialect",
"=",
"None",
",",
"billing_tier",
"=",
"None",
")",
":",
"try",
":",
"query_result",
"=",
"self",
".",
"_api",
".",
"jobs_insert_query",
"(",
"self",
".",
"_sql",
",",
"self",
".",
"_code",
",",
"s... | Dry run a query, to check the validity of the query and return some useful statistics.
Args:
dialect : {'legacy', 'standard'}, default 'legacy'
'legacy' : Use BigQuery's legacy SQL dialect.
'standard' : Use BigQuery's standard SQL (beta), which is
compliant with the SQL 2011 sta... | [
"Dry",
"run",
"a",
"query",
"to",
"check",
"the",
"validity",
"of",
"the",
"query",
"and",
"return",
"some",
"useful",
"statistics",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_query.py#L408-L432 |
googledatalab/pydatalab | datalab/bigquery/_query.py | Query.execute_async | def execute_async(self, table_name=None, table_mode='create', use_cache=True,
priority='interactive', allow_large_results=False, dialect=None,
billing_tier=None):
""" Initiate the query and return a QueryJob.
Args:
table_name: the result table name as a string or T... | python | def execute_async(self, table_name=None, table_mode='create', use_cache=True,
priority='interactive', allow_large_results=False, dialect=None,
billing_tier=None):
""" Initiate the query and return a QueryJob.
Args:
table_name: the result table name as a string or T... | [
"def",
"execute_async",
"(",
"self",
",",
"table_name",
"=",
"None",
",",
"table_mode",
"=",
"'create'",
",",
"use_cache",
"=",
"True",
",",
"priority",
"=",
"'interactive'",
",",
"allow_large_results",
"=",
"False",
",",
"dialect",
"=",
"None",
",",
"billin... | Initiate the query and return a QueryJob.
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
will fail if the table... | [
"Initiate",
"the",
"query",
"and",
"return",
"a",
"QueryJob",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_query.py#L434-L494 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_query.py#L496-L529 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_query.py#L531-L543 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_commands.py#L56-L77 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_commands.py#L101-L113 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_commands.py#L115-L130 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_commands.py#L132-L140 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_commands.py#L142-L155 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_commands.py#L157-L257 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_summary.py#L44-L62 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_summary.py#L64-L87 |
googledatalab/pydatalab | google/datalab/ml/_summary.py | Summary.get_events | def get_events(self, event_names):
"""Get all events as pandas DataFrames given a list of names.
Args:
event_names: A list of events to get.
Returns:
A list with the same length and order as event_names. Each element is a dictionary
{dir1: DataFrame1, dir2: DataFrame2, ...}.
... | python | def get_events(self, event_names):
"""Get all events as pandas DataFrames given a list of names.
Args:
event_names: A list of events to get.
Returns:
A list with the same length and order as event_names. Each element is a dictionary
{dir1: DataFrame1, dir2: DataFrame2, ...}.
... | [
"def",
"get_events",
"(",
"self",
",",
"event_names",
")",
":",
"if",
"isinstance",
"(",
"event_names",
",",
"six",
".",
"string_types",
")",
":",
"event_names",
"=",
"[",
"event_names",
"]",
"all_events",
"=",
"self",
".",
"list_events",
"(",
")",
"dirs_t... | Get all events as pandas DataFrames given a list of names.
Args:
event_names: A list of events to get.
Returns:
A list with the same length and order as event_names. Each element is a dictionary
{dir1: DataFrame1, dir2: DataFrame2, ...}.
Multiple directories may contain events wi... | [
"Get",
"all",
"events",
"as",
"pandas",
"DataFrames",
"given",
"a",
"list",
"of",
"names",
".",
"Args",
":",
"event_names",
":",
"A",
"list",
"of",
"events",
"to",
"get",
".",
"Returns",
":",
"A",
"list",
"with",
"the",
"same",
"length",
"and",
"order"... | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_summary.py#L89-L139 |
googledatalab/pydatalab | google/datalab/ml/_summary.py | Summary.plot | def plot(self, event_names, x_axis='step'):
"""Plots a list of events. Each event (a dir+event_name) is represetented as a line
in the graph.
Args:
event_names: A list of events to plot. Each event_name may correspond to multiple events,
each in a different directory.
x_axis: whethe... | python | def plot(self, event_names, x_axis='step'):
"""Plots a list of events. Each event (a dir+event_name) is represetented as a line
in the graph.
Args:
event_names: A list of events to plot. Each event_name may correspond to multiple events,
each in a different directory.
x_axis: whethe... | [
"def",
"plot",
"(",
"self",
",",
"event_names",
",",
"x_axis",
"=",
"'step'",
")",
":",
"if",
"isinstance",
"(",
"event_names",
",",
"six",
".",
"string_types",
")",
":",
"event_names",
"=",
"[",
"event_names",
"]",
"events_list",
"=",
"self",
".",
"get_... | Plots a list of events. Each event (a dir+event_name) is represetented as a line
in the graph.
Args:
event_names: A list of events to plot. Each event_name may correspond to multiple events,
each in a different directory.
x_axis: whether to use step or time as x axis. | [
"Plots",
"a",
"list",
"of",
"events",
".",
"Each",
"event",
"(",
"a",
"dir",
"+",
"event_name",
")",
"is",
"represetented",
"as",
"a",
"line",
"in",
"the",
"graph",
".",
"Args",
":",
"event_names",
":",
"A",
"list",
"of",
"events",
"to",
"plot",
".",... | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_summary.py#L141-L160 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_federated_table.py#L24-L64 |
googledatalab/pydatalab | google/datalab/bigquery/commands/_bigquery.py | _get_query_argument | def _get_query_argument(args, cell, env):
""" Get a query argument to a cell magic.
The query is specified with args['query']. We look that up and if it is a BQ query
object, just return it. If it is a string, build a query object out of it and return
that
Args:
args: the dictionary of magic arguments.
... | python | def _get_query_argument(args, cell, env):
""" Get a query argument to a cell magic.
The query is specified with args['query']. We look that up and if it is a BQ query
object, just return it. If it is a string, build a query object out of it and return
that
Args:
args: the dictionary of magic arguments.
... | [
"def",
"_get_query_argument",
"(",
"args",
",",
"cell",
",",
"env",
")",
":",
"sql_arg",
"=",
"args",
".",
"get",
"(",
"'query'",
",",
"None",
")",
"if",
"sql_arg",
"is",
"None",
":",
"# Assume we have inline SQL in the cell",
"if",
"not",
"isinstance",
"(",... | Get a query argument to a cell magic.
The query is specified with args['query']. We look that up and if it is a BQ query
object, just return it. If it is a string, build a query object out of it and return
that
Args:
args: the dictionary of magic arguments.
cell: the cell contents which can be variabl... | [
"Get",
"a",
"query",
"argument",
"to",
"a",
"cell",
"magic",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/commands/_bigquery.py#L325-L352 |
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",
"... | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/commands/_bigquery.py#L355-L382 |
googledatalab/pydatalab | google/datalab/bigquery/commands/_bigquery.py | _sample_cell | def _sample_cell(args, cell_body):
"""Implements the BigQuery sample magic for sampling queries
The supported sytanx is:
%%bq sample <args>
[<inline SQL>]
Args:
args: the optional arguments following '%%bq sample'.
cell_body: optional contents of the cell
Returns:
The results of executing t... | python | def _sample_cell(args, cell_body):
"""Implements the BigQuery sample magic for sampling queries
The supported sytanx is:
%%bq sample <args>
[<inline SQL>]
Args:
args: the optional arguments following '%%bq sample'.
cell_body: optional contents of the cell
Returns:
The results of executing t... | [
"def",
"_sample_cell",
"(",
"args",
",",
"cell_body",
")",
":",
"env",
"=",
"google",
".",
"datalab",
".",
"utils",
".",
"commands",
".",
"notebook_environment",
"(",
")",
"config",
"=",
"google",
".",
"datalab",
".",
"utils",
".",
"commands",
".",
"pars... | Implements the BigQuery sample magic for sampling queries
The supported sytanx is:
%%bq sample <args>
[<inline SQL>]
Args:
args: the optional arguments following '%%bq sample'.
cell_body: optional contents of the cell
Returns:
The results of executing the sampling query, or a profile of the s... | [
"Implements",
"the",
"BigQuery",
"sample",
"magic",
"for",
"sampling",
"queries",
"The",
"supported",
"sytanx",
"is",
":",
"%%bq",
"sample",
"<args",
">",
"[",
"<inline",
"SQL",
">",
"]",
"Args",
":",
"args",
":",
"the",
"optional",
"arguments",
"following",... | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/commands/_bigquery.py#L385-L453 |
googledatalab/pydatalab | google/datalab/bigquery/commands/_bigquery.py | _dryrun_cell | def _dryrun_cell(args, cell_body):
"""Implements the BigQuery cell magic used to dry run BQ queries.
The supported syntax is:
%%bq dryrun [-q|--sql <query identifier>]
[<YAML or JSON cell_body or inline SQL>]
Args:
args: the argument following '%bq dryrun'.
cell_body: optional contents of the cel... | python | def _dryrun_cell(args, cell_body):
"""Implements the BigQuery cell magic used to dry run BQ queries.
The supported syntax is:
%%bq dryrun [-q|--sql <query identifier>]
[<YAML or JSON cell_body or inline SQL>]
Args:
args: the argument following '%bq dryrun'.
cell_body: optional contents of the cel... | [
"def",
"_dryrun_cell",
"(",
"args",
",",
"cell_body",
")",
":",
"query",
"=",
"_get_query_argument",
"(",
"args",
",",
"cell_body",
",",
"google",
".",
"datalab",
".",
"utils",
".",
"commands",
".",
"notebook_environment",
"(",
")",
")",
"if",
"args",
"[",... | Implements the BigQuery cell magic used to dry run BQ queries.
The supported syntax is:
%%bq dryrun [-q|--sql <query identifier>]
[<YAML or JSON cell_body or inline SQL>]
Args:
args: the argument following '%bq dryrun'.
cell_body: optional contents of the cell interpreted as YAML or JSON.
Returns... | [
"Implements",
"the",
"BigQuery",
"cell",
"magic",
"used",
"to",
"dry",
"run",
"BQ",
"queries",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/commands/_bigquery.py#L456-L477 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/commands/_bigquery.py#L480-L516 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/commands/_bigquery.py#L519-L545 |
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",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/commands/_bigquery.py#L548-L573 |
googledatalab/pydatalab | google/datalab/bigquery/commands/_bigquery.py | _execute_cell | def _execute_cell(args, cell_body):
"""Implements the BigQuery cell magic used to execute BQ queries.
The supported syntax is:
%%bq execute <args>
[<inline SQL>]
Args:
args: the optional arguments following '%%bq execute'.
cell_body: optional contents of the cell
Returns:
QueryResultsTa... | python | def _execute_cell(args, cell_body):
"""Implements the BigQuery cell magic used to execute BQ queries.
The supported syntax is:
%%bq execute <args>
[<inline SQL>]
Args:
args: the optional arguments following '%%bq execute'.
cell_body: optional contents of the cell
Returns:
QueryResultsTa... | [
"def",
"_execute_cell",
"(",
"args",
",",
"cell_body",
")",
":",
"env",
"=",
"google",
".",
"datalab",
".",
"utils",
".",
"commands",
".",
"notebook_environment",
"(",
")",
"config",
"=",
"google",
".",
"datalab",
".",
"utils",
".",
"commands",
".",
"par... | Implements the BigQuery cell magic used to execute BQ queries.
The supported syntax is:
%%bq execute <args>
[<inline SQL>]
Args:
args: the optional arguments following '%%bq execute'.
cell_body: optional contents of the cell
Returns:
QueryResultsTable containing query result | [
"Implements",
"the",
"BigQuery",
"cell",
"magic",
"used",
"to",
"execute",
"BQ",
"queries",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/commands/_bigquery.py#L576-L614 |
googledatalab/pydatalab | google/datalab/bigquery/commands/_bigquery.py | _get_table | def _get_table(name):
""" Given a variable or table name, get a Table if it exists.
Args:
name: the name of the Table or a variable referencing the Table.
Returns:
The Table, if found.
"""
# If name is a variable referencing a table, use that.
item = google.datalab.utils.commands.get_notebook_item(... | python | def _get_table(name):
""" Given a variable or table name, get a Table if it exists.
Args:
name: the name of the Table or a variable referencing the Table.
Returns:
The Table, if found.
"""
# If name is a variable referencing a table, use that.
item = google.datalab.utils.commands.get_notebook_item(... | [
"def",
"_get_table",
"(",
"name",
")",
":",
"# If name is a variable referencing a table, use that.",
"item",
"=",
"google",
".",
"datalab",
".",
"utils",
".",
"commands",
".",
"get_notebook_item",
"(",
"name",
")",
"if",
"isinstance",
"(",
"item",
",",
"bigquery"... | Given a variable or table name, get a Table if it exists.
Args:
name: the name of the Table or a variable referencing the Table.
Returns:
The Table, if found. | [
"Given",
"a",
"variable",
"or",
"table",
"name",
"get",
"a",
"Table",
"if",
"it",
"exists",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/commands/_bigquery.py#L622-L642 |
googledatalab/pydatalab | google/datalab/bigquery/commands/_bigquery.py | _render_list | def _render_list(data):
""" Helper to render a list of objects as an HTML list object. """
return IPython.core.display.HTML(google.datalab.utils.commands.HtmlBuilder.render_list(data)) | python | def _render_list(data):
""" Helper to render a list of objects as an HTML list object. """
return IPython.core.display.HTML(google.datalab.utils.commands.HtmlBuilder.render_list(data)) | [
"def",
"_render_list",
"(",
"data",
")",
":",
"return",
"IPython",
".",
"core",
".",
"display",
".",
"HTML",
"(",
"google",
".",
"datalab",
".",
"utils",
".",
"commands",
".",
"HtmlBuilder",
".",
"render_list",
"(",
"data",
")",
")"
] | Helper to render a list of objects as an HTML list object. | [
"Helper",
"to",
"render",
"a",
"list",
"of",
"objects",
"as",
"an",
"HTML",
"list",
"object",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/commands/_bigquery.py#L645-L647 |
googledatalab/pydatalab | google/datalab/bigquery/commands/_bigquery.py | _dataset_line | def _dataset_line(args):
"""Implements the BigQuery dataset magic subcommand used to operate on datasets
The supported syntax is:
%bq datasets <command> <args>
Commands:
{list, create, delete}
Args:
args: the optional arguments following '%bq datasets command'.
"""
if args['command'] == 'list... | python | def _dataset_line(args):
"""Implements the BigQuery dataset magic subcommand used to operate on datasets
The supported syntax is:
%bq datasets <command> <args>
Commands:
{list, create, delete}
Args:
args: the optional arguments following '%bq datasets command'.
"""
if args['command'] == 'list... | [
"def",
"_dataset_line",
"(",
"args",
")",
":",
"if",
"args",
"[",
"'command'",
"]",
"==",
"'list'",
":",
"filter_",
"=",
"args",
"[",
"'filter'",
"]",
"if",
"args",
"[",
"'filter'",
"]",
"else",
"'*'",
"context",
"=",
"google",
".",
"datalab",
".",
"... | Implements the BigQuery dataset magic subcommand used to operate on datasets
The supported syntax is:
%bq datasets <command> <args>
Commands:
{list, create, delete}
Args:
args: the optional arguments following '%bq datasets command'. | [
"Implements",
"the",
"BigQuery",
"dataset",
"magic",
"subcommand",
"used",
"to",
"operate",
"on",
"datasets"
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/commands/_bigquery.py#L650-L680 |
googledatalab/pydatalab | google/datalab/bigquery/commands/_bigquery.py | _table_cell | def _table_cell(args, cell_body):
"""Implements the BigQuery table magic subcommand used to operate on tables
The supported syntax is:
%%bq tables <command> <args>
Commands:
{list, create, delete, describe, view}
Args:
args: the optional arguments following '%%bq tables command'.
cell_body: o... | python | def _table_cell(args, cell_body):
"""Implements the BigQuery table magic subcommand used to operate on tables
The supported syntax is:
%%bq tables <command> <args>
Commands:
{list, create, delete, describe, view}
Args:
args: the optional arguments following '%%bq tables command'.
cell_body: o... | [
"def",
"_table_cell",
"(",
"args",
",",
"cell_body",
")",
":",
"if",
"args",
"[",
"'command'",
"]",
"==",
"'list'",
":",
"filter_",
"=",
"args",
"[",
"'filter'",
"]",
"if",
"args",
"[",
"'filter'",
"]",
"else",
"'*'",
"if",
"args",
"[",
"'dataset'",
... | Implements the BigQuery table magic subcommand used to operate on tables
The supported syntax is:
%%bq tables <command> <args>
Commands:
{list, create, delete, describe, view}
Args:
args: the optional arguments following '%%bq tables command'.
cell_body: optional contents of the cell interprete... | [
"Implements",
"the",
"BigQuery",
"table",
"magic",
"subcommand",
"used",
"to",
"operate",
"on",
"tables"
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/commands/_bigquery.py#L683-L754 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.