repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
googledatalab/pydatalab | google/datalab/contrib/mlworkbench/_prediction_explainer.py | PredictionExplainer._make_tabular_predict_fn | def _make_tabular_predict_fn(self, labels, instance, categories):
"""Create a predict_fn that can be used by LIME tabular explainer. """
def _predict_fn(np_instance):
df = pd.DataFrame(
np_instance,
columns=(self._categorical_columns + self._numeric_columns)... | python | def _make_tabular_predict_fn(self, labels, instance, categories):
"""Create a predict_fn that can be used by LIME tabular explainer. """
def _predict_fn(np_instance):
df = pd.DataFrame(
np_instance,
columns=(self._categorical_columns + self._numeric_columns)... | [
"def",
"_make_tabular_predict_fn",
"(",
"self",
",",
"labels",
",",
"instance",
",",
"categories",
")",
":",
"def",
"_predict_fn",
"(",
"np_instance",
")",
":",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
"np_instance",
",",
"columns",
"=",
"(",
"self",
".",
... | Create a predict_fn that can be used by LIME tabular explainer. | [
"Create",
"a",
"predict_fn",
"that",
"can",
"be",
"used",
"by",
"LIME",
"tabular",
"explainer",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/mlworkbench/_prediction_explainer.py#L130-L155 | train |
googledatalab/pydatalab | google/datalab/contrib/mlworkbench/_prediction_explainer.py | PredictionExplainer.explain_tabular | def explain_tabular(self, trainset, labels, instance, num_features=5, kernel_width=3):
"""Explain categorical and numeric features for a prediction.
It analyze the prediction by LIME, and returns a report of the most impactful tabular
features contributing to certain labels.
Args:
... | python | def explain_tabular(self, trainset, labels, instance, num_features=5, kernel_width=3):
"""Explain categorical and numeric features for a prediction.
It analyze the prediction by LIME, and returns a report of the most impactful tabular
features contributing to certain labels.
Args:
... | [
"def",
"explain_tabular",
"(",
"self",
",",
"trainset",
",",
"labels",
",",
"instance",
",",
"num_features",
"=",
"5",
",",
"kernel_width",
"=",
"3",
")",
":",
"from",
"lime",
".",
"lime_tabular",
"import",
"LimeTabularExplainer",
"if",
"isinstance",
"(",
"i... | Explain categorical and numeric features for a prediction.
It analyze the prediction by LIME, and returns a report of the most impactful tabular
features contributing to certain labels.
Args:
trainset: a DataFrame representing the training features that LIME can use to decide
... | [
"Explain",
"categorical",
"and",
"numeric",
"features",
"for",
"a",
"prediction",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/mlworkbench/_prediction_explainer.py#L157-L199 | train |
googledatalab/pydatalab | google/datalab/contrib/mlworkbench/_prediction_explainer.py | PredictionExplainer.explain_text | def explain_text(self, labels, instance, column_name=None, num_features=10, num_samples=5000):
"""Explain a text field of a prediction.
It analyze the prediction by LIME, and returns a report of which words are most impactful
in contributing to certain labels.
Args:
labels: a... | python | def explain_text(self, labels, instance, column_name=None, num_features=10, num_samples=5000):
"""Explain a text field of a prediction.
It analyze the prediction by LIME, and returns a report of which words are most impactful
in contributing to certain labels.
Args:
labels: a... | [
"def",
"explain_text",
"(",
"self",
",",
"labels",
",",
"instance",
",",
"column_name",
"=",
"None",
",",
"num_features",
"=",
"10",
",",
"num_samples",
"=",
"5000",
")",
":",
"from",
"lime",
".",
"lime_text",
"import",
"LimeTextExplainer",
"if",
"len",
"(... | Explain a text field of a prediction.
It analyze the prediction by LIME, and returns a report of which words are most impactful
in contributing to certain labels.
Args:
labels: a list of labels to explain.
instance: the prediction instance. It needs to conform to model's in... | [
"Explain",
"a",
"text",
"field",
"of",
"a",
"prediction",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/mlworkbench/_prediction_explainer.py#L201-L244 | train |
googledatalab/pydatalab | google/datalab/contrib/mlworkbench/_prediction_explainer.py | PredictionExplainer.explain_image | def explain_image(self, labels, instance, column_name=None, num_features=100000,
num_samples=300, batch_size=200, hide_color=0):
"""Explain an image of a prediction.
It analyze the prediction by LIME, and returns a report of which words are most impactful
in contributing t... | python | def explain_image(self, labels, instance, column_name=None, num_features=100000,
num_samples=300, batch_size=200, hide_color=0):
"""Explain an image of a prediction.
It analyze the prediction by LIME, and returns a report of which words are most impactful
in contributing t... | [
"def",
"explain_image",
"(",
"self",
",",
"labels",
",",
"instance",
",",
"column_name",
"=",
"None",
",",
"num_features",
"=",
"100000",
",",
"num_samples",
"=",
"300",
",",
"batch_size",
"=",
"200",
",",
"hide_color",
"=",
"0",
")",
":",
"from",
"lime"... | Explain an image of a prediction.
It analyze the prediction by LIME, and returns a report of which words are most impactful
in contributing to certain labels.
Args:
labels: a list of labels to explain.
instance: the prediction instance. It needs to conform to model's input.... | [
"Explain",
"an",
"image",
"of",
"a",
"prediction",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/mlworkbench/_prediction_explainer.py#L246-L299 | train |
googledatalab/pydatalab | google/datalab/contrib/mlworkbench/_prediction_explainer.py | PredictionExplainer.probe_image | def probe_image(self, labels, instance, column_name=None, num_scaled_images=50,
top_percent=10):
""" Get pixel importance of the image.
It performs pixel sensitivity analysis by showing only the most important pixels to a
certain label in the image. It uses integrated gradie... | python | def probe_image(self, labels, instance, column_name=None, num_scaled_images=50,
top_percent=10):
""" Get pixel importance of the image.
It performs pixel sensitivity analysis by showing only the most important pixels to a
certain label in the image. It uses integrated gradie... | [
"def",
"probe_image",
"(",
"self",
",",
"labels",
",",
"instance",
",",
"column_name",
"=",
"None",
",",
"num_scaled_images",
"=",
"50",
",",
"top_percent",
"=",
"10",
")",
":",
"if",
"len",
"(",
"self",
".",
"_image_columns",
")",
">",
"1",
"and",
"no... | Get pixel importance of the image.
It performs pixel sensitivity analysis by showing only the most important pixels to a
certain label in the image. It uses integrated gradients to measure the
importance of each pixel.
Args:
labels: labels to compute gradients from.
... | [
"Get",
"pixel",
"importance",
"of",
"the",
"image",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/mlworkbench/_prediction_explainer.py#L334-L414 | train |
googledatalab/pydatalab | google/datalab/ml/_cloud_models.py | Models.get_model_details | def get_model_details(self, model_name):
"""Get details of the specified model from CloudML Service.
Args:
model_name: the name of the model. It can be a model full name
("projects/[project_id]/models/[model_name]") or just [model_name].
Returns: a dictionary of the model details.
"""... | python | def get_model_details(self, model_name):
"""Get details of the specified model from CloudML Service.
Args:
model_name: the name of the model. It can be a model full name
("projects/[project_id]/models/[model_name]") or just [model_name].
Returns: a dictionary of the model details.
"""... | [
"def",
"get_model_details",
"(",
"self",
",",
"model_name",
")",
":",
"full_name",
"=",
"model_name",
"if",
"not",
"model_name",
".",
"startswith",
"(",
"'projects/'",
")",
":",
"full_name",
"=",
"(",
"'projects/%s/models/%s'",
"%",
"(",
"self",
".",
"_project... | Get details of the specified model from CloudML Service.
Args:
model_name: the name of the model. It can be a model full name
("projects/[project_id]/models/[model_name]") or just [model_name].
Returns: a dictionary of the model details. | [
"Get",
"details",
"of",
"the",
"specified",
"model",
"from",
"CloudML",
"Service",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_cloud_models.py#L53-L64 | train |
googledatalab/pydatalab | google/datalab/ml/_cloud_models.py | Models.create | def create(self, model_name):
"""Create a model.
Args:
model_name: the short name of the model, such as "iris".
Returns:
If successful, returns informaiton of the model, such as
{u'regions': [u'us-central1'], u'name': u'projects/myproject/models/mymodel'}
Raises:
If the model cr... | python | def create(self, model_name):
"""Create a model.
Args:
model_name: the short name of the model, such as "iris".
Returns:
If successful, returns informaiton of the model, such as
{u'regions': [u'us-central1'], u'name': u'projects/myproject/models/mymodel'}
Raises:
If the model cr... | [
"def",
"create",
"(",
"self",
",",
"model_name",
")",
":",
"body",
"=",
"{",
"'name'",
":",
"model_name",
"}",
"parent",
"=",
"'projects/'",
"+",
"self",
".",
"_project_id",
"return",
"self",
".",
"_api",
".",
"projects",
"(",
")",
".",
"models",
"(",
... | Create a model.
Args:
model_name: the short name of the model, such as "iris".
Returns:
If successful, returns informaiton of the model, such as
{u'regions': [u'us-central1'], u'name': u'projects/myproject/models/mymodel'}
Raises:
If the model creation failed. | [
"Create",
"a",
"model",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_cloud_models.py#L66-L80 | train |
googledatalab/pydatalab | google/datalab/ml/_cloud_models.py | Models.list | def list(self, count=10):
"""List models under the current project in a table view.
Args:
count: upper limit of the number of models to list.
Raises:
Exception if it is called in a non-IPython environment.
"""
import IPython
data = []
# Add range(count) to loop so it will stop e... | python | def list(self, count=10):
"""List models under the current project in a table view.
Args:
count: upper limit of the number of models to list.
Raises:
Exception if it is called in a non-IPython environment.
"""
import IPython
data = []
# Add range(count) to loop so it will stop e... | [
"def",
"list",
"(",
"self",
",",
"count",
"=",
"10",
")",
":",
"import",
"IPython",
"data",
"=",
"[",
"]",
"for",
"_",
",",
"model",
"in",
"zip",
"(",
"range",
"(",
"count",
")",
",",
"self",
".",
"get_iterator",
"(",
")",
")",
":",
"element",
... | List models under the current project in a table view.
Args:
count: upper limit of the number of models to list.
Raises:
Exception if it is called in a non-IPython environment. | [
"List",
"models",
"under",
"the",
"current",
"project",
"in",
"a",
"table",
"view",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_cloud_models.py#L97-L117 | train |
googledatalab/pydatalab | google/datalab/ml/_cloud_models.py | ModelVersions.get_version_details | def get_version_details(self, version_name):
"""Get details of a version.
Args:
version: the name of the version in short form, such as "v1".
Returns: a dictionary containing the version details.
"""
name = ('%s/versions/%s' % (self._full_model_name, version_name))
return self._api.projec... | python | def get_version_details(self, version_name):
"""Get details of a version.
Args:
version: the name of the version in short form, such as "v1".
Returns: a dictionary containing the version details.
"""
name = ('%s/versions/%s' % (self._full_model_name, version_name))
return self._api.projec... | [
"def",
"get_version_details",
"(",
"self",
",",
"version_name",
")",
":",
"name",
"=",
"(",
"'%s/versions/%s'",
"%",
"(",
"self",
".",
"_full_model_name",
",",
"version_name",
")",
")",
"return",
"self",
".",
"_api",
".",
"projects",
"(",
")",
".",
"models... | Get details of a version.
Args:
version: the name of the version in short form, such as "v1".
Returns: a dictionary containing the version details. | [
"Get",
"details",
"of",
"a",
"version",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_cloud_models.py#L166-L174 | train |
googledatalab/pydatalab | google/datalab/ml/_cloud_models.py | ModelVersions.deploy | def deploy(self, version_name, path, runtime_version=None):
"""Deploy a model version to the cloud.
Args:
version_name: the name of the version in short form, such as "v1".
path: the Google Cloud Storage path (gs://...) which contains the model files.
runtime_version: the ML Engine runtime ve... | python | def deploy(self, version_name, path, runtime_version=None):
"""Deploy a model version to the cloud.
Args:
version_name: the name of the version in short form, such as "v1".
path: the Google Cloud Storage path (gs://...) which contains the model files.
runtime_version: the ML Engine runtime ve... | [
"def",
"deploy",
"(",
"self",
",",
"version_name",
",",
"path",
",",
"runtime_version",
"=",
"None",
")",
":",
"if",
"not",
"path",
".",
"startswith",
"(",
"'gs://'",
")",
":",
"raise",
"Exception",
"(",
"'Invalid path. Only Google Cloud Storage path (gs://...) is... | Deploy a model version to the cloud.
Args:
version_name: the name of the version in short form, such as "v1".
path: the Google Cloud Storage path (gs://...) which contains the model files.
runtime_version: the ML Engine runtime version as a string, example '1.2'.
See https://cloud.googl... | [
"Deploy",
"a",
"model",
"version",
"to",
"the",
"cloud",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_cloud_models.py#L176-L222 | train |
googledatalab/pydatalab | google/datalab/ml/_cloud_models.py | ModelVersions.delete | def delete(self, version_name):
"""Delete a version of model.
Args:
version_name: the name of the version in short form, such as "v1".
"""
name = ('%s/versions/%s' % (self._full_model_name, version_name))
response = self._api.projects().models().versions().delete(name=name).execute()
if '... | python | def delete(self, version_name):
"""Delete a version of model.
Args:
version_name: the name of the version in short form, such as "v1".
"""
name = ('%s/versions/%s' % (self._full_model_name, version_name))
response = self._api.projects().models().versions().delete(name=name).execute()
if '... | [
"def",
"delete",
"(",
"self",
",",
"version_name",
")",
":",
"name",
"=",
"(",
"'%s/versions/%s'",
"%",
"(",
"self",
".",
"_full_model_name",
",",
"version_name",
")",
")",
"response",
"=",
"self",
".",
"_api",
".",
"projects",
"(",
")",
".",
"models",
... | Delete a version of model.
Args:
version_name: the name of the version in short form, such as "v1". | [
"Delete",
"a",
"version",
"of",
"model",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_cloud_models.py#L224-L234 | train |
googledatalab/pydatalab | google/datalab/ml/_cloud_models.py | ModelVersions.predict | def predict(self, version_name, data):
"""Get prediction results from features instances.
Args:
version_name: the name of the version used for prediction.
data: typically a list of instance to be submitted for prediction. The format of the
instance depends on the model. For example, struc... | python | def predict(self, version_name, data):
"""Get prediction results from features instances.
Args:
version_name: the name of the version used for prediction.
data: typically a list of instance to be submitted for prediction. The format of the
instance depends on the model. For example, struc... | [
"def",
"predict",
"(",
"self",
",",
"version_name",
",",
"data",
")",
":",
"full_version_name",
"=",
"(",
"'%s/versions/%s'",
"%",
"(",
"self",
".",
"_full_model_name",
",",
"version_name",
")",
")",
"request",
"=",
"self",
".",
"_api",
".",
"projects",
"(... | Get prediction results from features instances.
Args:
version_name: the name of the version used for prediction.
data: typically a list of instance to be submitted for prediction. The format of the
instance depends on the model. For example, structured data model may require
a csv l... | [
"Get",
"prediction",
"results",
"from",
"features",
"instances",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_cloud_models.py#L236-L261 | train |
googledatalab/pydatalab | google/datalab/ml/_cloud_models.py | ModelVersions.list | def list(self):
"""List versions under the current model in a table view.
Raises:
Exception if it is called in a non-IPython environment.
"""
import IPython
# "self" is iterable (see __iter__() method).
data = [{'name': version['name'].split()[-1],
'deploymentUri': version['... | python | def list(self):
"""List versions under the current model in a table view.
Raises:
Exception if it is called in a non-IPython environment.
"""
import IPython
# "self" is iterable (see __iter__() method).
data = [{'name': version['name'].split()[-1],
'deploymentUri': version['... | [
"def",
"list",
"(",
"self",
")",
":",
"import",
"IPython",
"data",
"=",
"[",
"{",
"'name'",
":",
"version",
"[",
"'name'",
"]",
".",
"split",
"(",
")",
"[",
"-",
"1",
"]",
",",
"'deploymentUri'",
":",
"version",
"[",
"'deploymentUri'",
"]",
",",
"'... | List versions under the current model in a table view.
Raises:
Exception if it is called in a non-IPython environment. | [
"List",
"versions",
"under",
"the",
"current",
"model",
"in",
"a",
"table",
"view",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_cloud_models.py#L273-L286 | train |
googledatalab/pydatalab | solutionbox/ml_workbench/xgboost/trainer/feature_transforms.py | create_feature_map | def create_feature_map(features, feature_indices, output_dir):
"""Returns feature_map about the transformed features.
feature_map includes information such as:
1, cat1=0
2, cat1=1
3, numeric1
...
Returns:
List in the from
[(index, feature_description)]
"""
feature_map = []
for name,... | python | def create_feature_map(features, feature_indices, output_dir):
"""Returns feature_map about the transformed features.
feature_map includes information such as:
1, cat1=0
2, cat1=1
3, numeric1
...
Returns:
List in the from
[(index, feature_description)]
"""
feature_map = []
for name,... | [
"def",
"create_feature_map",
"(",
"features",
",",
"feature_indices",
",",
"output_dir",
")",
":",
"feature_map",
"=",
"[",
"]",
"for",
"name",
",",
"info",
"in",
"feature_indices",
":",
"transform_name",
"=",
"features",
"[",
"name",
"]",
"[",
"'transform'",
... | Returns feature_map about the transformed features.
feature_map includes information such as:
1, cat1=0
2, cat1=1
3, numeric1
...
Returns:
List in the from
[(index, feature_description)] | [
"Returns",
"feature_map",
"about",
"the",
"transformed",
"features",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/xgboost/trainer/feature_transforms.py#L447-L477 | train |
googledatalab/pydatalab | datalab/bigquery/_view.py | View.create | def create(self, query):
""" Creates the view with the specified query.
Args:
query: the query to use to for the View; either a string containing a SQL query or
a Query object.
Returns:
The View instance.
Raises:
Exception if the view couldn't be created or already exists an... | python | def create(self, query):
""" Creates the view with the specified query.
Args:
query: the query to use to for the View; either a string containing a SQL query or
a Query object.
Returns:
The View instance.
Raises:
Exception if the view couldn't be created or already exists an... | [
"def",
"create",
"(",
"self",
",",
"query",
")",
":",
"if",
"isinstance",
"(",
"query",
",",
"_query",
".",
"Query",
")",
":",
"query",
"=",
"query",
".",
"sql",
"try",
":",
"response",
"=",
"self",
".",
"_table",
".",
"_api",
".",
"tables_insert",
... | Creates the view with the specified query.
Args:
query: the query to use to for the View; either a string containing a SQL query or
a Query object.
Returns:
The View instance.
Raises:
Exception if the view couldn't be created or already exists and overwrite was False. | [
"Creates",
"the",
"view",
"with",
"the",
"specified",
"query",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_view.py#L91-L110 | train |
googledatalab/pydatalab | datalab/bigquery/_view.py | View.sample | def sample(self, fields=None, count=5, sampling=None, use_cache=True, dialect=None,
billing_tier=None):
"""Retrieves a sampling of data from the view.
Args:
fields: an optional list of field names to retrieve.
count: an optional count of rows to retrieve which is used if a specific
... | python | def sample(self, fields=None, count=5, sampling=None, use_cache=True, dialect=None,
billing_tier=None):
"""Retrieves a sampling of data from the view.
Args:
fields: an optional list of field names to retrieve.
count: an optional count of rows to retrieve which is used if a specific
... | [
"def",
"sample",
"(",
"self",
",",
"fields",
"=",
"None",
",",
"count",
"=",
"5",
",",
"sampling",
"=",
"None",
",",
"use_cache",
"=",
"True",
",",
"dialect",
"=",
"None",
",",
"billing_tier",
"=",
"None",
")",
":",
"return",
"self",
".",
"_table",
... | Retrieves a sampling of data from the view.
Args:
fields: an optional list of field names to retrieve.
count: an optional count of rows to retrieve which is used if a specific
sampling is not specified.
sampling: an optional sampling strategy to apply to the view.
use_cache: wheth... | [
"Retrieves",
"a",
"sampling",
"of",
"data",
"from",
"the",
"view",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_view.py#L112-L136 | train |
googledatalab/pydatalab | datalab/bigquery/_view.py | View.update | def update(self, friendly_name=None, description=None, query=None):
""" Selectively updates View information.
Any parameters that are None (the default) are not applied in the update.
Args:
friendly_name: if not None, the new friendly name.
description: if not None, the new description.
... | python | def update(self, friendly_name=None, description=None, query=None):
""" Selectively updates View information.
Any parameters that are None (the default) are not applied in the update.
Args:
friendly_name: if not None, the new friendly name.
description: if not None, the new description.
... | [
"def",
"update",
"(",
"self",
",",
"friendly_name",
"=",
"None",
",",
"description",
"=",
"None",
",",
"query",
"=",
"None",
")",
":",
"self",
".",
"_table",
".",
"_load_info",
"(",
")",
"if",
"query",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(... | Selectively updates View information.
Any parameters that are None (the default) are not applied in the update.
Args:
friendly_name: if not None, the new friendly name.
description: if not None, the new description.
query: if not None, a new query string for the View. | [
"Selectively",
"updates",
"View",
"information",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_view.py#L149-L164 | train |
googledatalab/pydatalab | datalab/bigquery/_view.py | View.results | def results(self, use_cache=True, dialect=None, billing_tier=None):
"""Materialize the view synchronously.
If you require more control over the execution, use execute() or execute_async().
Args:
use_cache: whether to use cached results or not.
dialect : {'legacy', 'standard'}, default 'legacy'... | python | def results(self, use_cache=True, dialect=None, billing_tier=None):
"""Materialize the view synchronously.
If you require more control over the execution, use execute() or execute_async().
Args:
use_cache: whether to use cached results or not.
dialect : {'legacy', 'standard'}, default 'legacy'... | [
"def",
"results",
"(",
"self",
",",
"use_cache",
"=",
"True",
",",
"dialect",
"=",
"None",
",",
"billing_tier",
"=",
"None",
")",
":",
"return",
"self",
".",
"_materialization",
".",
"results",
"(",
"use_cache",
"=",
"use_cache",
",",
"dialect",
"=",
"di... | Materialize the view synchronously.
If you require more control over the execution, use execute() or execute_async().
Args:
use_cache: whether to use cached results or not.
dialect : {'legacy', 'standard'}, default 'legacy'
'legacy' : Use BigQuery's legacy SQL dialect.
'standar... | [
"Materialize",
"the",
"view",
"synchronously",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_view.py#L166-L187 | train |
googledatalab/pydatalab | datalab/bigquery/_view.py | View.execute_async | def execute_async(self, table_name=None, table_mode='create', use_cache=True, priority='high',
allow_large_results=False, dialect=None, billing_tier=None):
"""Materialize the View asynchronously.
Args:
table_name: the result table name; if None, then a temporary table will be used.
... | python | def execute_async(self, table_name=None, table_mode='create', use_cache=True, priority='high',
allow_large_results=False, dialect=None, billing_tier=None):
"""Materialize the View asynchronously.
Args:
table_name: the result table name; if None, then a temporary table will be used.
... | [
"def",
"execute_async",
"(",
"self",
",",
"table_name",
"=",
"None",
",",
"table_mode",
"=",
"'create'",
",",
"use_cache",
"=",
"True",
",",
"priority",
"=",
"'high'",
",",
"allow_large_results",
"=",
"False",
",",
"dialect",
"=",
"None",
",",
"billing_tier"... | Materialize the View asynchronously.
Args:
table_name: the result table name; if None, 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 exists.
use_cache: whether to use past query re... | [
"Materialize",
"the",
"View",
"asynchronously",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_view.py#L189-L219 | train |
googledatalab/pydatalab | google/datalab/utils/commands/_utils.py | get_notebook_item | def get_notebook_item(name):
""" Get an item from the IPython environment. """
env = notebook_environment()
return google.datalab.utils.get_item(env, name) | python | def get_notebook_item(name):
""" Get an item from the IPython environment. """
env = notebook_environment()
return google.datalab.utils.get_item(env, name) | [
"def",
"get_notebook_item",
"(",
"name",
")",
":",
"env",
"=",
"notebook_environment",
"(",
")",
"return",
"google",
".",
"datalab",
".",
"utils",
".",
"get_item",
"(",
"env",
",",
"name",
")"
] | Get an item from the IPython environment. | [
"Get",
"an",
"item",
"from",
"the",
"IPython",
"environment",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_utils.py#L50-L53 | train |
googledatalab/pydatalab | google/datalab/utils/commands/_utils.py | _get_data_from_list_of_dicts | def _get_data_from_list_of_dicts(source, fields='*', first_row=0, count=-1, schema=None):
""" Helper function for _get_data that handles lists of dicts. """
if schema is None:
schema = google.datalab.bigquery.Schema.from_data(source)
fields = get_field_list(fields, schema)
gen = source[first_row:first_row +... | python | def _get_data_from_list_of_dicts(source, fields='*', first_row=0, count=-1, schema=None):
""" Helper function for _get_data that handles lists of dicts. """
if schema is None:
schema = google.datalab.bigquery.Schema.from_data(source)
fields = get_field_list(fields, schema)
gen = source[first_row:first_row +... | [
"def",
"_get_data_from_list_of_dicts",
"(",
"source",
",",
"fields",
"=",
"'*'",
",",
"first_row",
"=",
"0",
",",
"count",
"=",
"-",
"1",
",",
"schema",
"=",
"None",
")",
":",
"if",
"schema",
"is",
"None",
":",
"schema",
"=",
"google",
".",
"datalab",
... | Helper function for _get_data that handles lists of dicts. | [
"Helper",
"function",
"for",
"_get_data",
"that",
"handles",
"lists",
"of",
"dicts",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_utils.py#L144-L151 | train |
googledatalab/pydatalab | google/datalab/utils/commands/_utils.py | _get_data_from_list_of_lists | def _get_data_from_list_of_lists(source, fields='*', first_row=0, count=-1, schema=None):
""" Helper function for _get_data that handles lists of lists. """
if schema is None:
schema = google.datalab.bigquery.Schema.from_data(source)
fields = get_field_list(fields, schema)
gen = source[first_row:first_row +... | python | def _get_data_from_list_of_lists(source, fields='*', first_row=0, count=-1, schema=None):
""" Helper function for _get_data that handles lists of lists. """
if schema is None:
schema = google.datalab.bigquery.Schema.from_data(source)
fields = get_field_list(fields, schema)
gen = source[first_row:first_row +... | [
"def",
"_get_data_from_list_of_lists",
"(",
"source",
",",
"fields",
"=",
"'*'",
",",
"first_row",
"=",
"0",
",",
"count",
"=",
"-",
"1",
",",
"schema",
"=",
"None",
")",
":",
"if",
"schema",
"is",
"None",
":",
"schema",
"=",
"google",
".",
"datalab",
... | Helper function for _get_data that handles lists of lists. | [
"Helper",
"function",
"for",
"_get_data",
"that",
"handles",
"lists",
"of",
"lists",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_utils.py#L154-L162 | train |
googledatalab/pydatalab | google/datalab/utils/commands/_utils.py | _get_data_from_dataframe | def _get_data_from_dataframe(source, fields='*', first_row=0, count=-1, schema=None):
""" Helper function for _get_data that handles Pandas DataFrames. """
if schema is None:
schema = google.datalab.bigquery.Schema.from_data(source)
fields = get_field_list(fields, schema)
rows = []
if count < 0:
count... | python | def _get_data_from_dataframe(source, fields='*', first_row=0, count=-1, schema=None):
""" Helper function for _get_data that handles Pandas DataFrames. """
if schema is None:
schema = google.datalab.bigquery.Schema.from_data(source)
fields = get_field_list(fields, schema)
rows = []
if count < 0:
count... | [
"def",
"_get_data_from_dataframe",
"(",
"source",
",",
"fields",
"=",
"'*'",
",",
"first_row",
"=",
"0",
",",
"count",
"=",
"-",
"1",
",",
"schema",
"=",
"None",
")",
":",
"if",
"schema",
"is",
"None",
":",
"schema",
"=",
"google",
".",
"datalab",
".... | Helper function for _get_data that handles Pandas DataFrames. | [
"Helper",
"function",
"for",
"_get_data",
"that",
"handles",
"Pandas",
"DataFrames",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_utils.py#L165-L183 | train |
googledatalab/pydatalab | google/datalab/utils/commands/_utils.py | parse_config_for_selected_keys | def parse_config_for_selected_keys(content, keys):
""" Parse a config from a magic cell body for selected config keys.
For example, if 'content' is:
config_item1: value1
config_item2: value2
config_item3: value3
and 'keys' are: [config_item1, config_item3]
The results will be a tuple of
1. The p... | python | def parse_config_for_selected_keys(content, keys):
""" Parse a config from a magic cell body for selected config keys.
For example, if 'content' is:
config_item1: value1
config_item2: value2
config_item3: value3
and 'keys' are: [config_item1, config_item3]
The results will be a tuple of
1. The p... | [
"def",
"parse_config_for_selected_keys",
"(",
"content",
",",
"keys",
")",
":",
"config_items",
"=",
"{",
"key",
":",
"None",
"for",
"key",
"in",
"keys",
"}",
"if",
"not",
"content",
":",
"return",
"config_items",
",",
"content",
"stripped",
"=",
"content",
... | Parse a config from a magic cell body for selected config keys.
For example, if 'content' is:
config_item1: value1
config_item2: value2
config_item3: value3
and 'keys' are: [config_item1, config_item3]
The results will be a tuple of
1. The parsed config items (dict): {config_item1: value1, config_... | [
"Parse",
"a",
"config",
"from",
"a",
"magic",
"cell",
"body",
"for",
"selected",
"config",
"keys",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_utils.py#L341-L393 | train |
googledatalab/pydatalab | google/datalab/utils/commands/_utils.py | chart_html | def chart_html(driver_name, chart_type, source, chart_options=None, fields='*', refresh_interval=0,
refresh_data=None, control_defaults=None, control_ids=None, schema=None):
""" Return HTML for a chart.
Args:
driver_name: the name of the chart driver. Currently we support 'plotly' or 'gcharts'.
... | python | def chart_html(driver_name, chart_type, source, chart_options=None, fields='*', refresh_interval=0,
refresh_data=None, control_defaults=None, control_ids=None, schema=None):
""" Return HTML for a chart.
Args:
driver_name: the name of the chart driver. Currently we support 'plotly' or 'gcharts'.
... | [
"def",
"chart_html",
"(",
"driver_name",
",",
"chart_type",
",",
"source",
",",
"chart_options",
"=",
"None",
",",
"fields",
"=",
"'*'",
",",
"refresh_interval",
"=",
"0",
",",
"refresh_data",
"=",
"None",
",",
"control_defaults",
"=",
"None",
",",
"control_... | Return HTML for a chart.
Args:
driver_name: the name of the chart driver. Currently we support 'plotly' or 'gcharts'.
chart_type: string specifying type of chart.
source: the data source for the chart. Can be actual data (e.g. list) or the name of
a data source (e.g. the name of a query module).
... | [
"Return",
"HTML",
"for",
"a",
"chart",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_utils.py#L614-L727 | train |
googledatalab/pydatalab | google/datalab/bigquery/_sampling.py | Sampling.default | def default(fields=None, count=5):
"""Provides a simple default sampling strategy which limits the result set by a count.
Args:
fields: an optional list of field names to retrieve.
count: optional number of rows to limit the sampled results to.
Returns:
A sampling function that can be app... | python | def default(fields=None, count=5):
"""Provides a simple default sampling strategy which limits the result set by a count.
Args:
fields: an optional list of field names to retrieve.
count: optional number of rows to limit the sampled results to.
Returns:
A sampling function that can be app... | [
"def",
"default",
"(",
"fields",
"=",
"None",
",",
"count",
"=",
"5",
")",
":",
"projection",
"=",
"Sampling",
".",
"_create_projection",
"(",
"fields",
")",
"return",
"lambda",
"sql",
":",
"'SELECT %s FROM (%s) LIMIT %d'",
"%",
"(",
"projection",
",",
"sql"... | Provides a simple default sampling strategy which limits the result set by a count.
Args:
fields: an optional list of field names to retrieve.
count: optional number of rows to limit the sampled results to.
Returns:
A sampling function that can be applied to get a random sampling. | [
"Provides",
"a",
"simple",
"default",
"sampling",
"strategy",
"which",
"limits",
"the",
"result",
"set",
"by",
"a",
"count",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_sampling.py#L44-L54 | train |
googledatalab/pydatalab | google/datalab/bigquery/_sampling.py | Sampling.sorted | def sorted(field_name, ascending=True, fields=None, count=5):
"""Provides a sampling strategy that picks from an ordered set of rows.
Args:
field_name: the name of the field to sort the rows by.
ascending: whether to sort in ascending direction or not.
fields: an optional list of field names ... | python | def sorted(field_name, ascending=True, fields=None, count=5):
"""Provides a sampling strategy that picks from an ordered set of rows.
Args:
field_name: the name of the field to sort the rows by.
ascending: whether to sort in ascending direction or not.
fields: an optional list of field names ... | [
"def",
"sorted",
"(",
"field_name",
",",
"ascending",
"=",
"True",
",",
"fields",
"=",
"None",
",",
"count",
"=",
"5",
")",
":",
"if",
"field_name",
"is",
"None",
":",
"raise",
"Exception",
"(",
"'Sort field must be specified'",
")",
"direction",
"=",
"''"... | Provides a sampling strategy that picks from an ordered set of rows.
Args:
field_name: the name of the field to sort the rows by.
ascending: whether to sort in ascending direction or not.
fields: an optional list of field names to retrieve.
count: optional number of rows to limit the sample... | [
"Provides",
"a",
"sampling",
"strategy",
"that",
"picks",
"from",
"an",
"ordered",
"set",
"of",
"rows",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_sampling.py#L57-L73 | train |
googledatalab/pydatalab | google/datalab/bigquery/_sampling.py | Sampling.hashed | def hashed(field_name, percent, fields=None, count=0):
"""Provides a sampling strategy based on hashing and selecting a percentage of data.
Args:
field_name: the name of the field to hash.
percent: the percentage of the resulting hashes to select.
fields: an optional list of field names to re... | python | def hashed(field_name, percent, fields=None, count=0):
"""Provides a sampling strategy based on hashing and selecting a percentage of data.
Args:
field_name: the name of the field to hash.
percent: the percentage of the resulting hashes to select.
fields: an optional list of field names to re... | [
"def",
"hashed",
"(",
"field_name",
",",
"percent",
",",
"fields",
"=",
"None",
",",
"count",
"=",
"0",
")",
":",
"if",
"field_name",
"is",
"None",
":",
"raise",
"Exception",
"(",
"'Hash field must be specified'",
")",
"def",
"_hashed_sampling",
"(",
"sql",
... | Provides a sampling strategy based on hashing and selecting a percentage of data.
Args:
field_name: the name of the field to hash.
percent: the percentage of the resulting hashes to select.
fields: an optional list of field names to retrieve.
count: optional maximum count of rows to pick.
... | [
"Provides",
"a",
"sampling",
"strategy",
"based",
"on",
"hashing",
"and",
"selecting",
"a",
"percentage",
"of",
"data",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_sampling.py#L76-L97 | train |
googledatalab/pydatalab | google/datalab/bigquery/_sampling.py | Sampling.random | def random(percent, fields=None, count=0):
"""Provides a sampling strategy that picks a semi-random set of rows.
Args:
percent: the percentage of the resulting hashes to select.
fields: an optional list of field names to retrieve.
count: maximum number of rows to limit the sampled results to ... | python | def random(percent, fields=None, count=0):
"""Provides a sampling strategy that picks a semi-random set of rows.
Args:
percent: the percentage of the resulting hashes to select.
fields: an optional list of field names to retrieve.
count: maximum number of rows to limit the sampled results to ... | [
"def",
"random",
"(",
"percent",
",",
"fields",
"=",
"None",
",",
"count",
"=",
"0",
")",
":",
"def",
"_random_sampling",
"(",
"sql",
")",
":",
"projection",
"=",
"Sampling",
".",
"_create_projection",
"(",
"fields",
")",
"sql",
"=",
"'SELECT %s FROM (%s) ... | Provides a sampling strategy that picks a semi-random set of rows.
Args:
percent: the percentage of the resulting hashes to select.
fields: an optional list of field names to retrieve.
count: maximum number of rows to limit the sampled results to (default 5).
Returns:
A sampling functio... | [
"Provides",
"a",
"sampling",
"strategy",
"that",
"picks",
"a",
"semi",
"-",
"random",
"set",
"of",
"rows",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_sampling.py#L100-L119 | train |
googledatalab/pydatalab | google/datalab/bigquery/_sampling.py | Sampling._auto | def _auto(method, fields, count, percent, key_field, ascending):
"""Construct a sampling function according to the provided sampling technique, provided all
its needed fields are passed as arguments
Args:
method: one of the supported sampling methods: {limit,random,hashed,sorted}
fields: an opt... | python | def _auto(method, fields, count, percent, key_field, ascending):
"""Construct a sampling function according to the provided sampling technique, provided all
its needed fields are passed as arguments
Args:
method: one of the supported sampling methods: {limit,random,hashed,sorted}
fields: an opt... | [
"def",
"_auto",
"(",
"method",
",",
"fields",
",",
"count",
",",
"percent",
",",
"key_field",
",",
"ascending",
")",
":",
"if",
"method",
"==",
"'limit'",
":",
"return",
"Sampling",
".",
"default",
"(",
"fields",
"=",
"fields",
",",
"count",
"=",
"coun... | Construct a sampling function according to the provided sampling technique, provided all
its needed fields are passed as arguments
Args:
method: one of the supported sampling methods: {limit,random,hashed,sorted}
fields: an optional list of field names to retrieve.
count: maximum number of ro... | [
"Construct",
"a",
"sampling",
"function",
"according",
"to",
"the",
"provided",
"sampling",
"technique",
"provided",
"all",
"its",
"needed",
"fields",
"are",
"passed",
"as",
"arguments"
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_sampling.py#L122-L147 | train |
googledatalab/pydatalab | google/datalab/bigquery/_csv_options.py | CSVOptions._to_query_json | def _to_query_json(self):
""" Return the options as a dictionary to be used as JSON in a query job. """
return {
'quote': self._quote,
'fieldDelimiter': self._delimiter,
'encoding': self._encoding.upper(),
'skipLeadingRows': self._skip_leading_rows,
'allowQuotedNewlines': self._all... | python | def _to_query_json(self):
""" Return the options as a dictionary to be used as JSON in a query job. """
return {
'quote': self._quote,
'fieldDelimiter': self._delimiter,
'encoding': self._encoding.upper(),
'skipLeadingRows': self._skip_leading_rows,
'allowQuotedNewlines': self._all... | [
"def",
"_to_query_json",
"(",
"self",
")",
":",
"return",
"{",
"'quote'",
":",
"self",
".",
"_quote",
",",
"'fieldDelimiter'",
":",
"self",
".",
"_delimiter",
",",
"'encoding'",
":",
"self",
".",
"_encoding",
".",
"upper",
"(",
")",
",",
"'skipLeadingRows'... | Return the options as a dictionary to be used as JSON in a query job. | [
"Return",
"the",
"options",
"as",
"a",
"dictionary",
"to",
"be",
"used",
"as",
"JSON",
"in",
"a",
"query",
"job",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_csv_options.py#L75-L84 | train |
googledatalab/pydatalab | datalab/bigquery/_api.py | Api.jobs_insert_load | def jobs_insert_load(self, source, table_name, append=False, overwrite=False, create=False,
source_format='CSV', field_delimiter=',', allow_jagged_rows=False,
allow_quoted_newlines=False, encoding='UTF-8', ignore_unknown_values=False,
max_bad_records=... | python | def jobs_insert_load(self, source, table_name, append=False, overwrite=False, create=False,
source_format='CSV', field_delimiter=',', allow_jagged_rows=False,
allow_quoted_newlines=False, encoding='UTF-8', ignore_unknown_values=False,
max_bad_records=... | [
"def",
"jobs_insert_load",
"(",
"self",
",",
"source",
",",
"table_name",
",",
"append",
"=",
"False",
",",
"overwrite",
"=",
"False",
",",
"create",
"=",
"False",
",",
"source_format",
"=",
"'CSV'",
",",
"field_delimiter",
"=",
"','",
",",
"allow_jagged_row... | Issues a request to load data from GCS to a BQ table
Args:
source: the URL of the source bucket(s). Can include wildcards, and can be a single
string argument or a list.
table_name: a tuple representing the full name of the destination table.
append: if True append onto existing table c... | [
"Issues",
"a",
"request",
"to",
"load",
"data",
"from",
"GCS",
"to",
"a",
"BQ",
"table"
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_api.py#L50-L123 | train |
googledatalab/pydatalab | datalab/bigquery/_api.py | Api.jobs_get | def jobs_get(self, job_id, project_id=None):
"""Issues a request to retrieve information about a job.
Args:
job_id: the id of the job
project_id: the project id to use to fetch the results; use None for the default project.
Returns:
A parsed result object.
Raises:
Exception if t... | python | def jobs_get(self, job_id, project_id=None):
"""Issues a request to retrieve information about a job.
Args:
job_id: the id of the job
project_id: the project id to use to fetch the results; use None for the default project.
Returns:
A parsed result object.
Raises:
Exception if t... | [
"def",
"jobs_get",
"(",
"self",
",",
"job_id",
",",
"project_id",
"=",
"None",
")",
":",
"if",
"project_id",
"is",
"None",
":",
"project_id",
"=",
"self",
".",
"_project_id",
"url",
"=",
"Api",
".",
"_ENDPOINT",
"+",
"(",
"Api",
".",
"_JOBS_PATH",
"%",... | Issues a request to retrieve information about a job.
Args:
job_id: the id of the job
project_id: the project id to use to fetch the results; use None for the default project.
Returns:
A parsed result object.
Raises:
Exception if there is an error performing the operation. | [
"Issues",
"a",
"request",
"to",
"retrieve",
"information",
"about",
"a",
"job",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_api.py#L239-L253 | train |
googledatalab/pydatalab | datalab/bigquery/_api.py | Api.datasets_insert | def datasets_insert(self, dataset_name, friendly_name=None, description=None):
"""Issues a request to create a dataset.
Args:
dataset_name: the name of the dataset to create.
friendly_name: (optional) the friendly name for the dataset
description: (optional) a description for the dataset
... | python | def datasets_insert(self, dataset_name, friendly_name=None, description=None):
"""Issues a request to create a dataset.
Args:
dataset_name: the name of the dataset to create.
friendly_name: (optional) the friendly name for the dataset
description: (optional) a description for the dataset
... | [
"def",
"datasets_insert",
"(",
"self",
",",
"dataset_name",
",",
"friendly_name",
"=",
"None",
",",
"description",
"=",
"None",
")",
":",
"url",
"=",
"Api",
".",
"_ENDPOINT",
"+",
"(",
"Api",
".",
"_DATASETS_PATH",
"%",
"(",
"dataset_name",
".",
"project_i... | Issues a request to create a dataset.
Args:
dataset_name: the name of the dataset to create.
friendly_name: (optional) the friendly name for the dataset
description: (optional) a description for the dataset
Returns:
A parsed result object.
Raises:
Exception if there is an erro... | [
"Issues",
"a",
"request",
"to",
"create",
"a",
"dataset",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_api.py#L255-L279 | train |
googledatalab/pydatalab | datalab/bigquery/_api.py | Api.datasets_delete | def datasets_delete(self, dataset_name, delete_contents):
"""Issues a request to delete a dataset.
Args:
dataset_name: the name of the dataset to delete.
delete_contents: if True, any tables in the dataset will be deleted. If False and the
dataset is non-empty an exception will be raised.... | python | def datasets_delete(self, dataset_name, delete_contents):
"""Issues a request to delete a dataset.
Args:
dataset_name: the name of the dataset to delete.
delete_contents: if True, any tables in the dataset will be deleted. If False and the
dataset is non-empty an exception will be raised.... | [
"def",
"datasets_delete",
"(",
"self",
",",
"dataset_name",
",",
"delete_contents",
")",
":",
"url",
"=",
"Api",
".",
"_ENDPOINT",
"+",
"(",
"Api",
".",
"_DATASETS_PATH",
"%",
"dataset_name",
")",
"args",
"=",
"{",
"}",
"if",
"delete_contents",
":",
"args"... | Issues a request to delete a dataset.
Args:
dataset_name: the name of the dataset to delete.
delete_contents: if True, any tables in the dataset will be deleted. If False and the
dataset is non-empty an exception will be raised.
Returns:
A parsed result object.
Raises:
Exc... | [
"Issues",
"a",
"request",
"to",
"delete",
"a",
"dataset",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_api.py#L281-L298 | train |
googledatalab/pydatalab | datalab/bigquery/_api.py | Api.datasets_update | def datasets_update(self, dataset_name, dataset_info):
"""Updates the Dataset info.
Args:
dataset_name: the name of the dataset to update as a tuple of components.
dataset_info: the Dataset resource with updated fields.
"""
url = Api._ENDPOINT + (Api._DATASETS_PATH % dataset_name)
retur... | python | def datasets_update(self, dataset_name, dataset_info):
"""Updates the Dataset info.
Args:
dataset_name: the name of the dataset to update as a tuple of components.
dataset_info: the Dataset resource with updated fields.
"""
url = Api._ENDPOINT + (Api._DATASETS_PATH % dataset_name)
retur... | [
"def",
"datasets_update",
"(",
"self",
",",
"dataset_name",
",",
"dataset_info",
")",
":",
"url",
"=",
"Api",
".",
"_ENDPOINT",
"+",
"(",
"Api",
".",
"_DATASETS_PATH",
"%",
"dataset_name",
")",
"return",
"datalab",
".",
"utils",
".",
"Http",
".",
"request"... | Updates the Dataset info.
Args:
dataset_name: the name of the dataset to update as a tuple of components.
dataset_info: the Dataset resource with updated fields. | [
"Updates",
"the",
"Dataset",
"info",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_api.py#L300-L309 | train |
googledatalab/pydatalab | datalab/bigquery/_api.py | Api.datasets_get | def datasets_get(self, dataset_name):
"""Issues a request to retrieve information about a dataset.
Args:
dataset_name: the name of the dataset
Returns:
A parsed result object.
Raises:
Exception if there is an error performing the operation.
"""
url = Api._ENDPOINT + (Api._DATA... | python | def datasets_get(self, dataset_name):
"""Issues a request to retrieve information about a dataset.
Args:
dataset_name: the name of the dataset
Returns:
A parsed result object.
Raises:
Exception if there is an error performing the operation.
"""
url = Api._ENDPOINT + (Api._DATA... | [
"def",
"datasets_get",
"(",
"self",
",",
"dataset_name",
")",
":",
"url",
"=",
"Api",
".",
"_ENDPOINT",
"+",
"(",
"Api",
".",
"_DATASETS_PATH",
"%",
"dataset_name",
")",
"return",
"datalab",
".",
"utils",
".",
"Http",
".",
"request",
"(",
"url",
",",
"... | Issues a request to retrieve information about a dataset.
Args:
dataset_name: the name of the dataset
Returns:
A parsed result object.
Raises:
Exception if there is an error performing the operation. | [
"Issues",
"a",
"request",
"to",
"retrieve",
"information",
"about",
"a",
"dataset",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_api.py#L311-L322 | train |
googledatalab/pydatalab | datalab/bigquery/_api.py | Api.datasets_list | def datasets_list(self, project_id=None, max_results=0, page_token=None):
"""Issues a request to list the datasets in the project.
Args:
project_id: the project id to use to fetch the results; use None for the default project.
max_results: an optional maximum number of tables to retrieve.
pag... | python | def datasets_list(self, project_id=None, max_results=0, page_token=None):
"""Issues a request to list the datasets in the project.
Args:
project_id: the project id to use to fetch the results; use None for the default project.
max_results: an optional maximum number of tables to retrieve.
pag... | [
"def",
"datasets_list",
"(",
"self",
",",
"project_id",
"=",
"None",
",",
"max_results",
"=",
"0",
",",
"page_token",
"=",
"None",
")",
":",
"if",
"project_id",
"is",
"None",
":",
"project_id",
"=",
"self",
".",
"_project_id",
"url",
"=",
"Api",
".",
"... | Issues a request to list the datasets in the project.
Args:
project_id: the project id to use to fetch the results; use None for the default project.
max_results: an optional maximum number of tables to retrieve.
page_token: an optional token to continue the retrieval.
Returns:
A parsed... | [
"Issues",
"a",
"request",
"to",
"list",
"the",
"datasets",
"in",
"the",
"project",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_api.py#L324-L346 | train |
googledatalab/pydatalab | datalab/bigquery/_api.py | Api.tables_get | def tables_get(self, table_name):
"""Issues a request to retrieve information about a table.
Args:
table_name: a tuple representing the full name of the table.
Returns:
A parsed result object.
Raises:
Exception if there is an error performing the operation.
"""
url = Api._ENDP... | python | def tables_get(self, table_name):
"""Issues a request to retrieve information about a table.
Args:
table_name: a tuple representing the full name of the table.
Returns:
A parsed result object.
Raises:
Exception if there is an error performing the operation.
"""
url = Api._ENDP... | [
"def",
"tables_get",
"(",
"self",
",",
"table_name",
")",
":",
"url",
"=",
"Api",
".",
"_ENDPOINT",
"+",
"(",
"Api",
".",
"_TABLES_PATH",
"%",
"table_name",
")",
"return",
"datalab",
".",
"utils",
".",
"Http",
".",
"request",
"(",
"url",
",",
"credenti... | Issues a request to retrieve information about a table.
Args:
table_name: a tuple representing the full name of the table.
Returns:
A parsed result object.
Raises:
Exception if there is an error performing the operation. | [
"Issues",
"a",
"request",
"to",
"retrieve",
"information",
"about",
"a",
"table",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_api.py#L348-L359 | train |
googledatalab/pydatalab | datalab/bigquery/_api.py | Api.tables_insert | def tables_insert(self, table_name, schema=None, query=None, friendly_name=None,
description=None):
"""Issues a request to create a table or view in the specified dataset with the specified id.
A schema must be provided to create a Table, or a query must be provided to create a View.
... | python | def tables_insert(self, table_name, schema=None, query=None, friendly_name=None,
description=None):
"""Issues a request to create a table or view in the specified dataset with the specified id.
A schema must be provided to create a Table, or a query must be provided to create a View.
... | [
"def",
"tables_insert",
"(",
"self",
",",
"table_name",
",",
"schema",
"=",
"None",
",",
"query",
"=",
"None",
",",
"friendly_name",
"=",
"None",
",",
"description",
"=",
"None",
")",
":",
"url",
"=",
"Api",
".",
"_ENDPOINT",
"+",
"(",
"Api",
".",
"_... | Issues a request to create a table or view in the specified dataset with the specified id.
A schema must be provided to create a Table, or a query must be provided to create a View.
Args:
table_name: the name of the table as a tuple of components.
schema: the schema, if this is a Table creation.... | [
"Issues",
"a",
"request",
"to",
"create",
"a",
"table",
"or",
"view",
"in",
"the",
"specified",
"dataset",
"with",
"the",
"specified",
"id",
".",
"A",
"schema",
"must",
"be",
"provided",
"to",
"create",
"a",
"Table",
"or",
"a",
"query",
"must",
"be",
"... | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_api.py#L384-L420 | train |
googledatalab/pydatalab | datalab/bigquery/_api.py | Api.tabledata_insert_all | def tabledata_insert_all(self, table_name, rows):
"""Issues a request to insert data into a table.
Args:
table_name: the name of the table as a tuple of components.
rows: the data to populate the table, as a list of dictionaries.
Returns:
A parsed result object.
Raises:
Exceptio... | python | def tabledata_insert_all(self, table_name, rows):
"""Issues a request to insert data into a table.
Args:
table_name: the name of the table as a tuple of components.
rows: the data to populate the table, as a list of dictionaries.
Returns:
A parsed result object.
Raises:
Exceptio... | [
"def",
"tabledata_insert_all",
"(",
"self",
",",
"table_name",
",",
"rows",
")",
":",
"url",
"=",
"Api",
".",
"_ENDPOINT",
"+",
"(",
"Api",
".",
"_TABLES_PATH",
"%",
"table_name",
")",
"+",
"\"/insertAll\"",
"data",
"=",
"{",
"'kind'",
":",
"'bigquery#tabl... | Issues a request to insert data into a table.
Args:
table_name: the name of the table as a tuple of components.
rows: the data to populate the table, as a list of dictionaries.
Returns:
A parsed result object.
Raises:
Exception if there is an error performing the operation. | [
"Issues",
"a",
"request",
"to",
"insert",
"data",
"into",
"a",
"table",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_api.py#L422-L440 | train |
googledatalab/pydatalab | datalab/bigquery/_api.py | Api.tabledata_list | def tabledata_list(self, table_name, start_index=None, max_results=None, page_token=None):
""" Retrieves the contents of a table.
Args:
table_name: the name of the table as a tuple of components.
start_index: the index of the row at which to start retrieval.
max_results: an optional maximum n... | python | def tabledata_list(self, table_name, start_index=None, max_results=None, page_token=None):
""" Retrieves the contents of a table.
Args:
table_name: the name of the table as a tuple of components.
start_index: the index of the row at which to start retrieval.
max_results: an optional maximum n... | [
"def",
"tabledata_list",
"(",
"self",
",",
"table_name",
",",
"start_index",
"=",
"None",
",",
"max_results",
"=",
"None",
",",
"page_token",
"=",
"None",
")",
":",
"url",
"=",
"Api",
".",
"_ENDPOINT",
"+",
"(",
"Api",
".",
"_TABLEDATA_PATH",
"%",
"table... | Retrieves the contents of a table.
Args:
table_name: the name of the table as a tuple of components.
start_index: the index of the row at which to start retrieval.
max_results: an optional maximum number of rows to retrieve.
page_token: an optional token to continue the retrieval.
Retur... | [
"Retrieves",
"the",
"contents",
"of",
"a",
"table",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_api.py#L442-L463 | train |
googledatalab/pydatalab | datalab/bigquery/_api.py | Api.table_delete | def table_delete(self, table_name):
"""Issues a request to delete a table.
Args:
table_name: the name of the table as a tuple of components.
Returns:
A parsed result object.
Raises:
Exception if there is an error performing the operation.
"""
url = Api._ENDPOINT + (Api._TABLES... | python | def table_delete(self, table_name):
"""Issues a request to delete a table.
Args:
table_name: the name of the table as a tuple of components.
Returns:
A parsed result object.
Raises:
Exception if there is an error performing the operation.
"""
url = Api._ENDPOINT + (Api._TABLES... | [
"def",
"table_delete",
"(",
"self",
",",
"table_name",
")",
":",
"url",
"=",
"Api",
".",
"_ENDPOINT",
"+",
"(",
"Api",
".",
"_TABLES_PATH",
"%",
"table_name",
")",
"return",
"datalab",
".",
"utils",
".",
"Http",
".",
"request",
"(",
"url",
",",
"method... | Issues a request to delete a table.
Args:
table_name: the name of the table as a tuple of components.
Returns:
A parsed result object.
Raises:
Exception if there is an error performing the operation. | [
"Issues",
"a",
"request",
"to",
"delete",
"a",
"table",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_api.py#L465-L477 | train |
googledatalab/pydatalab | datalab/bigquery/_api.py | Api.table_extract | def table_extract(self, table_name, destination, format='CSV', compress=True,
field_delimiter=',', print_header=True):
"""Exports the table to GCS.
Args:
table_name: the name of the table as a tuple of components.
destination: the destination URI(s). Can be a single URI or a lis... | python | def table_extract(self, table_name, destination, format='CSV', compress=True,
field_delimiter=',', print_header=True):
"""Exports the table to GCS.
Args:
table_name: the name of the table as a tuple of components.
destination: the destination URI(s). Can be a single URI or a lis... | [
"def",
"table_extract",
"(",
"self",
",",
"table_name",
",",
"destination",
",",
"format",
"=",
"'CSV'",
",",
"compress",
"=",
"True",
",",
"field_delimiter",
"=",
"','",
",",
"print_header",
"=",
"True",
")",
":",
"url",
"=",
"Api",
".",
"_ENDPOINT",
"+... | Exports the table to GCS.
Args:
table_name: the name of the table as a tuple of components.
destination: the destination URI(s). Can be a single URI or a list.
format: the format to use for the exported data; one of CSV, NEWLINE_DELIMITED_JSON or AVRO.
Defaults to CSV.
compress: w... | [
"Exports",
"the",
"table",
"to",
"GCS",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_api.py#L479-L519 | train |
googledatalab/pydatalab | datalab/bigquery/_api.py | Api.table_update | def table_update(self, table_name, table_info):
"""Updates the Table info.
Args:
table_name: the name of the table to update as a tuple of components.
table_info: the Table resource with updated fields.
"""
url = Api._ENDPOINT + (Api._TABLES_PATH % table_name)
return datalab.utils.Http.... | python | def table_update(self, table_name, table_info):
"""Updates the Table info.
Args:
table_name: the name of the table to update as a tuple of components.
table_info: the Table resource with updated fields.
"""
url = Api._ENDPOINT + (Api._TABLES_PATH % table_name)
return datalab.utils.Http.... | [
"def",
"table_update",
"(",
"self",
",",
"table_name",
",",
"table_info",
")",
":",
"url",
"=",
"Api",
".",
"_ENDPOINT",
"+",
"(",
"Api",
".",
"_TABLES_PATH",
"%",
"table_name",
")",
"return",
"datalab",
".",
"utils",
".",
"Http",
".",
"request",
"(",
... | Updates the Table info.
Args:
table_name: the name of the table to update as a tuple of components.
table_info: the Table resource with updated fields. | [
"Updates",
"the",
"Table",
"info",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_api.py#L521-L530 | train |
googledatalab/pydatalab | google/datalab/contrib/mlworkbench/_archive.py | extract_archive | def extract_archive(archive_path, dest):
"""Extract a local or GCS archive file to a folder.
Args:
archive_path: local or gcs path to a *.tar.gz or *.tar file
dest: local folder the archive will be extracted to
"""
# Make the dest folder if it does not exist
if not os.path.isdir(dest):
os.makedir... | python | def extract_archive(archive_path, dest):
"""Extract a local or GCS archive file to a folder.
Args:
archive_path: local or gcs path to a *.tar.gz or *.tar file
dest: local folder the archive will be extracted to
"""
# Make the dest folder if it does not exist
if not os.path.isdir(dest):
os.makedir... | [
"def",
"extract_archive",
"(",
"archive_path",
",",
"dest",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"dest",
")",
":",
"os",
".",
"makedirs",
"(",
"dest",
")",
"try",
":",
"tmpfolder",
"=",
"None",
"if",
"(",
"not",
"tf",
".",
... | Extract a local or GCS archive file to a folder.
Args:
archive_path: local or gcs path to a *.tar.gz or *.tar file
dest: local folder the archive will be extracted to | [
"Extract",
"a",
"local",
"or",
"GCS",
"archive",
"file",
"to",
"a",
"folder",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/mlworkbench/_archive.py#L27-L62 | train |
googledatalab/pydatalab | solutionbox/image_classification/mltoolbox/image/classification/_cloud.py | Cloud.preprocess | def preprocess(train_dataset, output_dir, eval_dataset, checkpoint, pipeline_option):
"""Preprocess data in Cloud with DataFlow."""
import apache_beam as beam
import google.datalab.utils
from . import _preprocess
if checkpoint is None:
checkpoint = _util._DEFAULT_CHECKPOINT_GSURL
job_na... | python | def preprocess(train_dataset, output_dir, eval_dataset, checkpoint, pipeline_option):
"""Preprocess data in Cloud with DataFlow."""
import apache_beam as beam
import google.datalab.utils
from . import _preprocess
if checkpoint is None:
checkpoint = _util._DEFAULT_CHECKPOINT_GSURL
job_na... | [
"def",
"preprocess",
"(",
"train_dataset",
",",
"output_dir",
",",
"eval_dataset",
",",
"checkpoint",
",",
"pipeline_option",
")",
":",
"import",
"apache_beam",
"as",
"beam",
"import",
"google",
".",
"datalab",
".",
"utils",
"from",
".",
"import",
"_preprocess",... | Preprocess data in Cloud with DataFlow. | [
"Preprocess",
"data",
"in",
"Cloud",
"with",
"DataFlow",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_cloud.py#L40-L96 | train |
googledatalab/pydatalab | solutionbox/image_classification/mltoolbox/image/classification/_cloud.py | Cloud.train | def train(input_dir, batch_size, max_steps, output_dir, checkpoint, cloud_train_config):
"""Train model in the cloud with CloudML trainer service."""
import google.datalab.ml as ml
if checkpoint is None:
checkpoint = _util._DEFAULT_CHECKPOINT_GSURL
staging_package_url = _util.repackage_to_staging... | python | def train(input_dir, batch_size, max_steps, output_dir, checkpoint, cloud_train_config):
"""Train model in the cloud with CloudML trainer service."""
import google.datalab.ml as ml
if checkpoint is None:
checkpoint = _util._DEFAULT_CHECKPOINT_GSURL
staging_package_url = _util.repackage_to_staging... | [
"def",
"train",
"(",
"input_dir",
",",
"batch_size",
",",
"max_steps",
",",
"output_dir",
",",
"checkpoint",
",",
"cloud_train_config",
")",
":",
"import",
"google",
".",
"datalab",
".",
"ml",
"as",
"ml",
"if",
"checkpoint",
"is",
"None",
":",
"checkpoint",
... | Train model in the cloud with CloudML trainer service. | [
"Train",
"model",
"in",
"the",
"cloud",
"with",
"CloudML",
"trainer",
"service",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_cloud.py#L99-L132 | train |
googledatalab/pydatalab | google/datalab/bigquery/_query.py | Query.from_table | def from_table(table, fields=None):
""" Return a Query for the given Table object
Args:
table: the Table object to construct a Query out of
fields: the fields to return. If None, all fields will be returned. This can be a string
which will be injected into the Query after SELECT, or a lis... | python | def from_table(table, fields=None):
""" Return a Query for the given Table object
Args:
table: the Table object to construct a Query out of
fields: the fields to return. If None, all fields will be returned. This can be a string
which will be injected into the Query after SELECT, or a lis... | [
"def",
"from_table",
"(",
"table",
",",
"fields",
"=",
"None",
")",
":",
"if",
"fields",
"is",
"None",
":",
"fields",
"=",
"'*'",
"elif",
"isinstance",
"(",
"fields",
",",
"list",
")",
":",
"fields",
"=",
"','",
".",
"join",
"(",
"fields",
")",
"re... | Return a Query for the given Table object
Args:
table: the Table object to construct a Query out of
fields: the fields to return. If None, all fields will be returned. This can be a string
which will be injected into the Query after SELECT, or a list of field names.
Returns:
A Quer... | [
"Return",
"a",
"Query",
"for",
"the",
"given",
"Table",
"object"
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_query.py#L105-L120 | train |
googledatalab/pydatalab | google/datalab/bigquery/_query.py | Query._expanded_sql | def _expanded_sql(self, sampling=None):
"""Get the expanded SQL of this object, including all subqueries, UDFs, and external datasources
Returns:
The expanded SQL string of this object
"""
# use lists to preserve the order of subqueries, bigquery will not like listing subqueries
# out of ord... | python | def _expanded_sql(self, sampling=None):
"""Get the expanded SQL of this object, including all subqueries, UDFs, and external datasources
Returns:
The expanded SQL string of this object
"""
# use lists to preserve the order of subqueries, bigquery will not like listing subqueries
# out of ord... | [
"def",
"_expanded_sql",
"(",
"self",
",",
"sampling",
"=",
"None",
")",
":",
"udfs",
"=",
"[",
"]",
"subqueries",
"=",
"[",
"]",
"expanded_sql",
"=",
"''",
"def",
"_recurse_subqueries",
"(",
"query",
")",
":",
"if",
"query",
".",
"_subqueries",
":",
"f... | Get the expanded SQL of this object, including all subqueries, UDFs, and external datasources
Returns:
The expanded SQL string of this object | [
"Get",
"the",
"expanded",
"SQL",
"of",
"this",
"object",
"including",
"all",
"subqueries",
"UDFs",
"and",
"external",
"datasources"
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_query.py#L122-L167 | train |
googledatalab/pydatalab | google/datalab/contrib/mlworkbench/_shell_process.py | run_and_monitor | def run_and_monitor(args, pid_to_wait, std_out_filter_fn=None, cwd=None):
""" Start a process, and have it depend on another specified process.
Args:
args: the args of the process to start and monitor.
pid_to_wait: the process to wait on. If the process ends, also kill the started process.
std_out_filt... | python | def run_and_monitor(args, pid_to_wait, std_out_filter_fn=None, cwd=None):
""" Start a process, and have it depend on another specified process.
Args:
args: the args of the process to start and monitor.
pid_to_wait: the process to wait on. If the process ends, also kill the started process.
std_out_filt... | [
"def",
"run_and_monitor",
"(",
"args",
",",
"pid_to_wait",
",",
"std_out_filter_fn",
"=",
"None",
",",
"cwd",
"=",
"None",
")",
":",
"monitor_process",
"=",
"None",
"try",
":",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"args",
",",
"cwd",
"=",
"cwd",
... | Start a process, and have it depend on another specified process.
Args:
args: the args of the process to start and monitor.
pid_to_wait: the process to wait on. If the process ends, also kill the started process.
std_out_filter_fn: a filter function which takes a string content from the stdout of the
... | [
"Start",
"a",
"process",
"and",
"have",
"it",
"depend",
"on",
"another",
"specified",
"process",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/mlworkbench/_shell_process.py#L43-L77 | train |
googledatalab/pydatalab | google/datalab/bigquery/_table.py | TableMetadata.created_on | def created_on(self):
"""The creation timestamp."""
timestamp = self._info.get('creationTime')
return _parser.Parser.parse_timestamp(timestamp) | python | def created_on(self):
"""The creation timestamp."""
timestamp = self._info.get('creationTime')
return _parser.Parser.parse_timestamp(timestamp) | [
"def",
"created_on",
"(",
"self",
")",
":",
"timestamp",
"=",
"self",
".",
"_info",
".",
"get",
"(",
"'creationTime'",
")",
"return",
"_parser",
".",
"Parser",
".",
"parse_timestamp",
"(",
"timestamp",
")"
] | The creation timestamp. | [
"The",
"creation",
"timestamp",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L56-L59 | train |
googledatalab/pydatalab | google/datalab/bigquery/_table.py | TableMetadata.expires_on | def expires_on(self):
"""The timestamp for when the table will expire, or None if unknown."""
timestamp = self._info.get('expirationTime', None)
if timestamp is None:
return None
return _parser.Parser.parse_timestamp(timestamp) | python | def expires_on(self):
"""The timestamp for when the table will expire, or None if unknown."""
timestamp = self._info.get('expirationTime', None)
if timestamp is None:
return None
return _parser.Parser.parse_timestamp(timestamp) | [
"def",
"expires_on",
"(",
"self",
")",
":",
"timestamp",
"=",
"self",
".",
"_info",
".",
"get",
"(",
"'expirationTime'",
",",
"None",
")",
"if",
"timestamp",
"is",
"None",
":",
"return",
"None",
"return",
"_parser",
".",
"Parser",
".",
"parse_timestamp",
... | The timestamp for when the table will expire, or None if unknown. | [
"The",
"timestamp",
"for",
"when",
"the",
"table",
"will",
"expire",
"or",
"None",
"if",
"unknown",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L67-L72 | train |
googledatalab/pydatalab | google/datalab/bigquery/_table.py | TableMetadata.modified_on | def modified_on(self):
"""The timestamp for when the table was last modified."""
timestamp = self._info.get('lastModifiedTime')
return _parser.Parser.parse_timestamp(timestamp) | python | def modified_on(self):
"""The timestamp for when the table was last modified."""
timestamp = self._info.get('lastModifiedTime')
return _parser.Parser.parse_timestamp(timestamp) | [
"def",
"modified_on",
"(",
"self",
")",
":",
"timestamp",
"=",
"self",
".",
"_info",
".",
"get",
"(",
"'lastModifiedTime'",
")",
"return",
"_parser",
".",
"Parser",
".",
"parse_timestamp",
"(",
"timestamp",
")"
] | The timestamp for when the table was last modified. | [
"The",
"timestamp",
"for",
"when",
"the",
"table",
"was",
"last",
"modified",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L80-L83 | train |
googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table._load_info | def _load_info(self):
"""Loads metadata about this table."""
if self._info is None:
try:
self._info = self._api.tables_get(self._name_parts)
except Exception as e:
raise e | python | def _load_info(self):
"""Loads metadata about this table."""
if self._info is None:
try:
self._info = self._api.tables_get(self._name_parts)
except Exception as e:
raise e | [
"def",
"_load_info",
"(",
"self",
")",
":",
"if",
"self",
".",
"_info",
"is",
"None",
":",
"try",
":",
"self",
".",
"_info",
"=",
"self",
".",
"_api",
".",
"tables_get",
"(",
"self",
".",
"_name_parts",
")",
"except",
"Exception",
"as",
"e",
":",
"... | Loads metadata about this table. | [
"Loads",
"metadata",
"about",
"this",
"table",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L161-L167 | train |
googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table.exists | def exists(self):
"""Checks if the table exists.
Returns:
True if the table exists; False otherwise.
Raises:
Exception if there was an error requesting information about the table.
"""
try:
info = self._api.tables_get(self._name_parts)
except google.datalab.utils.RequestExcept... | python | def exists(self):
"""Checks if the table exists.
Returns:
True if the table exists; False otherwise.
Raises:
Exception if there was an error requesting information about the table.
"""
try:
info = self._api.tables_get(self._name_parts)
except google.datalab.utils.RequestExcept... | [
"def",
"exists",
"(",
"self",
")",
":",
"try",
":",
"info",
"=",
"self",
".",
"_api",
".",
"tables_get",
"(",
"self",
".",
"_name_parts",
")",
"except",
"google",
".",
"datalab",
".",
"utils",
".",
"RequestException",
"as",
"e",
":",
"if",
"e",
".",
... | Checks if the table exists.
Returns:
True if the table exists; False otherwise.
Raises:
Exception if there was an error requesting information about the table. | [
"Checks",
"if",
"the",
"table",
"exists",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L181-L198 | train |
googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table.delete | def delete(self):
""" Delete the table.
Returns:
True if the Table no longer exists; False otherwise.
"""
try:
self._api.table_delete(self._name_parts)
except google.datalab.utils.RequestException:
# TODO(gram): May want to check the error reasons here and if it is not
# bec... | python | def delete(self):
""" Delete the table.
Returns:
True if the Table no longer exists; False otherwise.
"""
try:
self._api.table_delete(self._name_parts)
except google.datalab.utils.RequestException:
# TODO(gram): May want to check the error reasons here and if it is not
# bec... | [
"def",
"delete",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_api",
".",
"table_delete",
"(",
"self",
".",
"_name_parts",
")",
"except",
"google",
".",
"datalab",
".",
"utils",
".",
"RequestException",
":",
"pass",
"except",
"Exception",
"as",
"e",
... | Delete the table.
Returns:
True if the Table no longer exists; False otherwise. | [
"Delete",
"the",
"table",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L209-L223 | train |
googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table.create | def create(self, schema, overwrite=False):
""" Create the table with the specified schema.
Args:
schema: the schema to use to create the table. Should be a list of dictionaries, each
containing at least a pair of entries, 'name' and 'type'.
See https://cloud.google.com/bigquery/docs/r... | python | def create(self, schema, overwrite=False):
""" Create the table with the specified schema.
Args:
schema: the schema to use to create the table. Should be a list of dictionaries, each
containing at least a pair of entries, 'name' and 'type'.
See https://cloud.google.com/bigquery/docs/r... | [
"def",
"create",
"(",
"self",
",",
"schema",
",",
"overwrite",
"=",
"False",
")",
":",
"if",
"overwrite",
"and",
"self",
".",
"exists",
"(",
")",
":",
"self",
".",
"delete",
"(",
")",
"if",
"not",
"isinstance",
"(",
"schema",
",",
"_schema",
".",
"... | Create the table with the specified schema.
Args:
schema: the schema to use to create the table. Should be a list of dictionaries, each
containing at least a pair of entries, 'name' and 'type'.
See https://cloud.google.com/bigquery/docs/reference/v2/tables#resource
overwrite: if Tru... | [
"Create",
"the",
"table",
"with",
"the",
"specified",
"schema",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L225-L251 | train |
googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table._init_job_from_response | def _init_job_from_response(self, response):
""" Helper function to create a Job instance from a response. """
job = None
if response and 'jobReference' in response:
job = _job.Job(job_id=response['jobReference']['jobId'], context=self._context)
return job | python | def _init_job_from_response(self, response):
""" Helper function to create a Job instance from a response. """
job = None
if response and 'jobReference' in response:
job = _job.Job(job_id=response['jobReference']['jobId'], context=self._context)
return job | [
"def",
"_init_job_from_response",
"(",
"self",
",",
"response",
")",
":",
"job",
"=",
"None",
"if",
"response",
"and",
"'jobReference'",
"in",
"response",
":",
"job",
"=",
"_job",
".",
"Job",
"(",
"job_id",
"=",
"response",
"[",
"'jobReference'",
"]",
"[",... | Helper function to create a Job instance from a response. | [
"Helper",
"function",
"to",
"create",
"a",
"Job",
"instance",
"from",
"a",
"response",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L393-L398 | train |
googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table.extract_async | def extract_async(self, destination, format='csv', csv_delimiter=None, csv_header=True,
compress=False):
"""Starts a job to export the table to GCS.
Args:
destination: the destination URI(s). Can be a single URI or a list.
format: the format to use for the exported data; one of ... | python | def extract_async(self, destination, format='csv', csv_delimiter=None, csv_header=True,
compress=False):
"""Starts a job to export the table to GCS.
Args:
destination: the destination URI(s). Can be a single URI or a list.
format: the format to use for the exported data; one of ... | [
"def",
"extract_async",
"(",
"self",
",",
"destination",
",",
"format",
"=",
"'csv'",
",",
"csv_delimiter",
"=",
"None",
",",
"csv_header",
"=",
"True",
",",
"compress",
"=",
"False",
")",
":",
"format",
"=",
"format",
".",
"upper",
"(",
")",
"if",
"fo... | Starts a job to export the table to GCS.
Args:
destination: the destination URI(s). Can be a single URI or a list.
format: the format to use for the exported data; one of 'csv', 'json', or 'avro'
(default 'csv').
csv_delimiter: for CSV exports, the field delimiter to use. Defaults to ',... | [
"Starts",
"a",
"job",
"to",
"export",
"the",
"table",
"to",
"GCS",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L400-L426 | train |
googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table.extract | def extract(self, destination, format='csv', csv_delimiter=None, csv_header=True, compress=False):
"""Exports the table to GCS; blocks until complete.
Args:
destination: the destination URI(s). Can be a single URI or a list.
format: the format to use for the exported data; one of 'csv', 'json', or ... | python | def extract(self, destination, format='csv', csv_delimiter=None, csv_header=True, compress=False):
"""Exports the table to GCS; blocks until complete.
Args:
destination: the destination URI(s). Can be a single URI or a list.
format: the format to use for the exported data; one of 'csv', 'json', or ... | [
"def",
"extract",
"(",
"self",
",",
"destination",
",",
"format",
"=",
"'csv'",
",",
"csv_delimiter",
"=",
"None",
",",
"csv_header",
"=",
"True",
",",
"compress",
"=",
"False",
")",
":",
"job",
"=",
"self",
".",
"extract_async",
"(",
"destination",
",",... | Exports the table to GCS; blocks until complete.
Args:
destination: the destination URI(s). Can be a single URI or a list.
format: the format to use for the exported data; one of 'csv', 'json', or 'avro'
(default 'csv').
csv_delimiter: for CSV exports, the field delimiter to use. Defaul... | [
"Exports",
"the",
"table",
"to",
"GCS",
";",
"blocks",
"until",
"complete",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L428-L446 | train |
googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table.load_async | def load_async(self, source, mode='create', source_format='csv', csv_options=None,
ignore_unknown_values=False, max_bad_records=0):
""" Starts importing a table from GCS and return a Future.
Args:
source: the URL of the source objects(s). Can include a wildcard '*' at the end of the item... | python | def load_async(self, source, mode='create', source_format='csv', csv_options=None,
ignore_unknown_values=False, max_bad_records=0):
""" Starts importing a table from GCS and return a Future.
Args:
source: the URL of the source objects(s). Can include a wildcard '*' at the end of the item... | [
"def",
"load_async",
"(",
"self",
",",
"source",
",",
"mode",
"=",
"'create'",
",",
"source_format",
"=",
"'csv'",
",",
"csv_options",
"=",
"None",
",",
"ignore_unknown_values",
"=",
"False",
",",
"max_bad_records",
"=",
"0",
")",
":",
"if",
"source_format",... | Starts importing a table from GCS and return a Future.
Args:
source: the URL of the source objects(s). Can include a wildcard '*' at the end of the item
name. Can be a single source or a list.
mode: one of 'create', 'append', or 'overwrite'. 'append' or 'overwrite' will fail if the
t... | [
"Starts",
"importing",
"a",
"table",
"from",
"GCS",
"and",
"return",
"a",
"Future",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L448-L499 | train |
googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table.load | def load(self, source, mode='create', source_format='csv', csv_options=None,
ignore_unknown_values=False, max_bad_records=0):
""" Load the table from GCS.
Args:
source: the URL of the source objects(s). Can include a wildcard '*' at the end of the item
name. Can be a single source or ... | python | def load(self, source, mode='create', source_format='csv', csv_options=None,
ignore_unknown_values=False, max_bad_records=0):
""" Load the table from GCS.
Args:
source: the URL of the source objects(s). Can include a wildcard '*' at the end of the item
name. Can be a single source or ... | [
"def",
"load",
"(",
"self",
",",
"source",
",",
"mode",
"=",
"'create'",
",",
"source_format",
"=",
"'csv'",
",",
"csv_options",
"=",
"None",
",",
"ignore_unknown_values",
"=",
"False",
",",
"max_bad_records",
"=",
"0",
")",
":",
"job",
"=",
"self",
".",... | Load the table from GCS.
Args:
source: the URL of the source objects(s). Can include a wildcard '*' at the end of the item
name. Can be a single source or a list.
mode: one of 'create', 'append', or 'overwrite'. 'append' or 'overwrite' will fail if the
table does not already exist, w... | [
"Load",
"the",
"table",
"from",
"GCS",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L501-L529 | train |
googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table._get_row_fetcher | def _get_row_fetcher(self, start_row=0, max_rows=None, page_size=_DEFAULT_PAGE_SIZE):
""" Get a function that can retrieve a page of rows.
The function returned is a closure so that it can have a signature suitable for use
by Iterator.
Args:
start_row: the row to start fetching from; default 0.
... | python | def _get_row_fetcher(self, start_row=0, max_rows=None, page_size=_DEFAULT_PAGE_SIZE):
""" Get a function that can retrieve a page of rows.
The function returned is a closure so that it can have a signature suitable for use
by Iterator.
Args:
start_row: the row to start fetching from; default 0.
... | [
"def",
"_get_row_fetcher",
"(",
"self",
",",
"start_row",
"=",
"0",
",",
"max_rows",
"=",
"None",
",",
"page_size",
"=",
"_DEFAULT_PAGE_SIZE",
")",
":",
"if",
"not",
"start_row",
":",
"start_row",
"=",
"0",
"elif",
"start_row",
"<",
"0",
":",
"if",
"self... | Get a function that can retrieve a page of rows.
The function returned is a closure so that it can have a signature suitable for use
by Iterator.
Args:
start_row: the row to start fetching from; default 0.
max_rows: the maximum number of rows to fetch (across all calls, not per-call). Default
... | [
"Get",
"a",
"function",
"that",
"can",
"retrieve",
"a",
"page",
"of",
"rows",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L531-L588 | train |
googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table.schema | def schema(self):
"""Retrieves the schema of the table.
Returns:
A Schema object containing a list of schema fields and associated metadata.
Raises
Exception if the request could not be executed or the response was malformed.
"""
if not self._schema:
try:
self._load_info()... | python | def schema(self):
"""Retrieves the schema of the table.
Returns:
A Schema object containing a list of schema fields and associated metadata.
Raises
Exception if the request could not be executed or the response was malformed.
"""
if not self._schema:
try:
self._load_info()... | [
"def",
"schema",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_schema",
":",
"try",
":",
"self",
".",
"_load_info",
"(",
")",
"self",
".",
"_schema",
"=",
"_schema",
".",
"Schema",
"(",
"self",
".",
"_info",
"[",
"'schema'",
"]",
"[",
"'fields... | Retrieves the schema of the table.
Returns:
A Schema object containing a list of schema fields and associated metadata.
Raises
Exception if the request could not be executed or the response was malformed. | [
"Retrieves",
"the",
"schema",
"of",
"the",
"table",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L662-L676 | train |
googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table.snapshot | def snapshot(self, at):
""" Return a new Table which is a snapshot of this table at the specified time.
Args:
at: the time of the snapshot. This can be a Python datetime (absolute) or timedelta
(relative to current time). The result must be after the table was created and no more
than... | python | def snapshot(self, at):
""" Return a new Table which is a snapshot of this table at the specified time.
Args:
at: the time of the snapshot. This can be a Python datetime (absolute) or timedelta
(relative to current time). The result must be after the table was created and no more
than... | [
"def",
"snapshot",
"(",
"self",
",",
"at",
")",
":",
"if",
"self",
".",
"_name_parts",
".",
"decorator",
"!=",
"''",
":",
"raise",
"Exception",
"(",
"\"Cannot use snapshot() on an already decorated table\"",
")",
"value",
"=",
"Table",
".",
"_convert_decorator_tim... | Return a new Table which is a snapshot of this table at the specified time.
Args:
at: the time of the snapshot. This can be a Python datetime (absolute) or timedelta
(relative to current time). The result must be after the table was created and no more
than seven days in the past. Passing... | [
"Return",
"a",
"new",
"Table",
"which",
"is",
"a",
"snapshot",
"of",
"this",
"table",
"at",
"the",
"specified",
"time",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L803-L826 | train |
googledatalab/pydatalab | google/datalab/bigquery/_table.py | Table.window | def window(self, begin, end=None):
""" Return a new Table limited to the rows added to this Table during the specified time range.
Args:
begin: the start time of the window. This can be a Python datetime (absolute) or timedelta
(relative to current time). The result must be after the table was ... | python | def window(self, begin, end=None):
""" Return a new Table limited to the rows added to this Table during the specified time range.
Args:
begin: the start time of the window. This can be a Python datetime (absolute) or timedelta
(relative to current time). The result must be after the table was ... | [
"def",
"window",
"(",
"self",
",",
"begin",
",",
"end",
"=",
"None",
")",
":",
"if",
"self",
".",
"_name_parts",
".",
"decorator",
"!=",
"''",
":",
"raise",
"Exception",
"(",
"\"Cannot use window() on an already decorated table\"",
")",
"start",
"=",
"Table",
... | Return a new Table limited to the rows added to this Table during the specified time range.
Args:
begin: the start time of the window. This can be a Python datetime (absolute) or timedelta
(relative to current time). The result must be after the table was created and no more
than seven da... | [
"Return",
"a",
"new",
"Table",
"limited",
"to",
"the",
"rows",
"added",
"to",
"this",
"Table",
"during",
"the",
"specified",
"time",
"range",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_table.py#L828-L870 | train |
googledatalab/pydatalab | solutionbox/ml_workbench/xgboost/transform.py | serialize_example | def serialize_example(transformed_json_data, features, feature_indices, target_name):
"""Makes an instance of data in libsvm format.
Args:
transformed_json_data: dict of transformed data.
features: features config.
feature_indices: output of feature_transforms.get_transformed_feature_indices()
Retur... | python | def serialize_example(transformed_json_data, features, feature_indices, target_name):
"""Makes an instance of data in libsvm format.
Args:
transformed_json_data: dict of transformed data.
features: features config.
feature_indices: output of feature_transforms.get_transformed_feature_indices()
Retur... | [
"def",
"serialize_example",
"(",
"transformed_json_data",
",",
"features",
",",
"feature_indices",
",",
"target_name",
")",
":",
"import",
"six",
"import",
"tensorflow",
"as",
"tf",
"from",
"trainer",
"import",
"feature_transforms",
"line",
"=",
"str",
"(",
"trans... | Makes an instance of data in libsvm format.
Args:
transformed_json_data: dict of transformed data.
features: features config.
feature_indices: output of feature_transforms.get_transformed_feature_indices()
Returns:
The text line representation of an instance in libsvm format. | [
"Makes",
"an",
"instance",
"of",
"data",
"in",
"libsvm",
"format",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/xgboost/transform.py#L392-L421 | train |
googledatalab/pydatalab | datalab/bigquery/_dataset.py | Dataset.delete | def delete(self, delete_contents=False):
"""Issues a request to delete the dataset.
Args:
delete_contents: if True, any tables and views in the dataset will be deleted. If False
and the dataset is non-empty an exception will be raised.
Returns:
None on success.
Raises:
Excep... | python | def delete(self, delete_contents=False):
"""Issues a request to delete the dataset.
Args:
delete_contents: if True, any tables and views in the dataset will be deleted. If False
and the dataset is non-empty an exception will be raised.
Returns:
None on success.
Raises:
Excep... | [
"def",
"delete",
"(",
"self",
",",
"delete_contents",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"exists",
"(",
")",
":",
"raise",
"Exception",
"(",
"'Cannot delete non-existent dataset %s'",
"%",
"self",
".",
"_full_name",
")",
"try",
":",
"self",
... | Issues a request to delete the dataset.
Args:
delete_contents: if True, any tables and views in the dataset will be deleted. If False
and the dataset is non-empty an exception will be raised.
Returns:
None on success.
Raises:
Exception if the delete fails (including if table was... | [
"Issues",
"a",
"request",
"to",
"delete",
"the",
"dataset",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_dataset.py#L101-L119 | train |
googledatalab/pydatalab | datalab/bigquery/_dataset.py | Dataset.create | def create(self, friendly_name=None, description=None):
"""Creates the Dataset with the specified friendly name and description.
Args:
friendly_name: (optional) the friendly name for the dataset if it is being created.
description: (optional) a description for the dataset if it is being created.
... | python | def create(self, friendly_name=None, description=None):
"""Creates the Dataset with the specified friendly name and description.
Args:
friendly_name: (optional) the friendly name for the dataset if it is being created.
description: (optional) a description for the dataset if it is being created.
... | [
"def",
"create",
"(",
"self",
",",
"friendly_name",
"=",
"None",
",",
"description",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"exists",
"(",
")",
":",
"try",
":",
"response",
"=",
"self",
".",
"_api",
".",
"datasets_insert",
"(",
"self",
".",... | Creates the Dataset with the specified friendly name and description.
Args:
friendly_name: (optional) the friendly name for the dataset if it is being created.
description: (optional) a description for the dataset if it is being created.
Returns:
The Dataset.
Raises:
Exception if th... | [
"Creates",
"the",
"Dataset",
"with",
"the",
"specified",
"friendly",
"name",
"and",
"description",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_dataset.py#L121-L141 | train |
googledatalab/pydatalab | datalab/bigquery/_dataset.py | Dataset.update | def update(self, friendly_name=None, description=None):
""" Selectively updates Dataset information.
Args:
friendly_name: if not None, the new friendly name.
description: if not None, the new description.
Returns:
"""
self._get_info()
if self._info:
if friendly_name:
... | python | def update(self, friendly_name=None, description=None):
""" Selectively updates Dataset information.
Args:
friendly_name: if not None, the new friendly name.
description: if not None, the new description.
Returns:
"""
self._get_info()
if self._info:
if friendly_name:
... | [
"def",
"update",
"(",
"self",
",",
"friendly_name",
"=",
"None",
",",
"description",
"=",
"None",
")",
":",
"self",
".",
"_get_info",
"(",
")",
"if",
"self",
".",
"_info",
":",
"if",
"friendly_name",
":",
"self",
".",
"_info",
"[",
"'friendlyName'",
"]... | Selectively updates Dataset information.
Args:
friendly_name: if not None, the new friendly name.
description: if not None, the new description.
Returns: | [
"Selectively",
"updates",
"Dataset",
"information",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_dataset.py#L143-L164 | train |
googledatalab/pydatalab | google/datalab/bigquery/_view.py | View.query | def query(self):
"""The Query that defines the view."""
if not self.exists():
return None
self._table._load_info()
if 'view' in self._table._info and 'query' in self._table._info['view']:
return _query.Query(self._table._info['view']['query'])
return None | python | def query(self):
"""The Query that defines the view."""
if not self.exists():
return None
self._table._load_info()
if 'view' in self._table._info and 'query' in self._table._info['view']:
return _query.Query(self._table._info['view']['query'])
return None | [
"def",
"query",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"exists",
"(",
")",
":",
"return",
"None",
"self",
".",
"_table",
".",
"_load_info",
"(",
")",
"if",
"'view'",
"in",
"self",
".",
"_table",
".",
"_info",
"and",
"'query'",
"in",
"self... | The Query that defines the view. | [
"The",
"Query",
"that",
"defines",
"the",
"view",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_view.py#L70-L77 | train |
googledatalab/pydatalab | solutionbox/structured_data/mltoolbox/_structured_data/preprocess/local_preprocess.py | run_numerical_categorical_analysis | def run_numerical_categorical_analysis(args, schema_list):
"""Makes the numerical and categorical analysis files.
Args:
args: the command line args
schema_list: python object of the schema json file.
Raises:
ValueError: if schema contains unknown column types.
"""
header = [column['name'] for co... | python | def run_numerical_categorical_analysis(args, schema_list):
"""Makes the numerical and categorical analysis files.
Args:
args: the command line args
schema_list: python object of the schema json file.
Raises:
ValueError: if schema contains unknown column types.
"""
header = [column['name'] for co... | [
"def",
"run_numerical_categorical_analysis",
"(",
"args",
",",
"schema_list",
")",
":",
"header",
"=",
"[",
"column",
"[",
"'name'",
"]",
"for",
"column",
"in",
"schema_list",
"]",
"input_files",
"=",
"file_io",
".",
"get_matching_files",
"(",
"args",
".",
"in... | Makes the numerical and categorical analysis files.
Args:
args: the command line args
schema_list: python object of the schema json file.
Raises:
ValueError: if schema contains unknown column types. | [
"Makes",
"the",
"numerical",
"and",
"categorical",
"analysis",
"files",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/structured_data/mltoolbox/_structured_data/preprocess/local_preprocess.py#L69-L144 | train |
googledatalab/pydatalab | solutionbox/structured_data/mltoolbox/_structured_data/preprocess/local_preprocess.py | run_analysis | def run_analysis(args):
"""Builds an analysis files for training."""
# Read the schema and input feature types
schema_list = json.loads(
file_io.read_file_to_string(args.schema_file))
run_numerical_categorical_analysis(args, schema_list)
# Also save a copy of the schema in the output folder.
file_i... | python | def run_analysis(args):
"""Builds an analysis files for training."""
# Read the schema and input feature types
schema_list = json.loads(
file_io.read_file_to_string(args.schema_file))
run_numerical_categorical_analysis(args, schema_list)
# Also save a copy of the schema in the output folder.
file_i... | [
"def",
"run_analysis",
"(",
"args",
")",
":",
"schema_list",
"=",
"json",
".",
"loads",
"(",
"file_io",
".",
"read_file_to_string",
"(",
"args",
".",
"schema_file",
")",
")",
"run_numerical_categorical_analysis",
"(",
"args",
",",
"schema_list",
")",
"file_io",
... | Builds an analysis files for training. | [
"Builds",
"an",
"analysis",
"files",
"for",
"training",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/structured_data/mltoolbox/_structured_data/preprocess/local_preprocess.py#L147-L159 | train |
googledatalab/pydatalab | google/datalab/utils/commands/_html.py | Html._repr_html_ | def _repr_html_(self):
"""Generates the HTML representation.
"""
parts = []
if self._class:
parts.append('<div id="hh_%s" class="%s">%s</div>' % (self._id, self._class, self._markup))
else:
parts.append('<div id="hh_%s">%s</div>' % (self._id, self._markup))
if len(self._script) != 0... | python | def _repr_html_(self):
"""Generates the HTML representation.
"""
parts = []
if self._class:
parts.append('<div id="hh_%s" class="%s">%s</div>' % (self._id, self._class, self._markup))
else:
parts.append('<div id="hh_%s">%s</div>' % (self._id, self._markup))
if len(self._script) != 0... | [
"def",
"_repr_html_",
"(",
"self",
")",
":",
"parts",
"=",
"[",
"]",
"if",
"self",
".",
"_class",
":",
"parts",
".",
"append",
"(",
"'<div id=\"hh_%s\" class=\"%s\">%s</div>'",
"%",
"(",
"self",
".",
"_id",
",",
"self",
".",
"_class",
",",
"self",
".",
... | Generates the HTML representation. | [
"Generates",
"the",
"HTML",
"representation",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_html.py#L64-L84 | train |
googledatalab/pydatalab | google/datalab/utils/commands/_html.py | HtmlBuilder._render_objects | def _render_objects(self, items, attributes=None, datatype='object'):
"""Renders an HTML table with the specified list of objects.
Args:
items: the iterable collection of objects to render.
attributes: the optional list of properties or keys to render.
datatype: the type of data; one of 'obje... | python | def _render_objects(self, items, attributes=None, datatype='object'):
"""Renders an HTML table with the specified list of objects.
Args:
items: the iterable collection of objects to render.
attributes: the optional list of properties or keys to render.
datatype: the type of data; one of 'obje... | [
"def",
"_render_objects",
"(",
"self",
",",
"items",
",",
"attributes",
"=",
"None",
",",
"datatype",
"=",
"'object'",
")",
":",
"if",
"not",
"items",
":",
"return",
"if",
"datatype",
"==",
"'chartdata'",
":",
"if",
"not",
"attributes",
":",
"attributes",
... | Renders an HTML table with the specified list of objects.
Args:
items: the iterable collection of objects to render.
attributes: the optional list of properties or keys to render.
datatype: the type of data; one of 'object' for Python objects, 'dict' for a list
of dictionaries, or 'char... | [
"Renders",
"an",
"HTML",
"table",
"with",
"the",
"specified",
"list",
"of",
"objects",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_html.py#L96-L149 | train |
googledatalab/pydatalab | google/datalab/utils/commands/_html.py | HtmlBuilder._render_list | def _render_list(self, items, empty='<pre><empty></pre>'):
"""Renders an HTML list with the specified list of strings.
Args:
items: the iterable collection of objects to render.
empty: what to render if the list is None or empty.
"""
if not items or len(items) == 0:
self._segmen... | python | def _render_list(self, items, empty='<pre><empty></pre>'):
"""Renders an HTML list with the specified list of strings.
Args:
items: the iterable collection of objects to render.
empty: what to render if the list is None or empty.
"""
if not items or len(items) == 0:
self._segmen... | [
"def",
"_render_list",
"(",
"self",
",",
"items",
",",
"empty",
"=",
"'<pre><empty></pre>'",
")",
":",
"if",
"not",
"items",
"or",
"len",
"(",
"items",
")",
"==",
"0",
":",
"self",
".",
"_segments",
".",
"append",
"(",
"empty",
")",
"return",
"se... | Renders an HTML list with the specified list of strings.
Args:
items: the iterable collection of objects to render.
empty: what to render if the list is None or empty. | [
"Renders",
"an",
"HTML",
"list",
"with",
"the",
"specified",
"list",
"of",
"strings",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_html.py#L161-L176 | train |
googledatalab/pydatalab | datalab/bigquery/_table.py | Table.sample | def sample(self, fields=None, count=5, sampling=None, use_cache=True, dialect=None,
billing_tier=None):
"""Retrieves a sampling of data from the table.
Args:
fields: an optional list of field names to retrieve.
count: an optional count of rows to retrieve which is used if a specific
... | python | def sample(self, fields=None, count=5, sampling=None, use_cache=True, dialect=None,
billing_tier=None):
"""Retrieves a sampling of data from the table.
Args:
fields: an optional list of field names to retrieve.
count: an optional count of rows to retrieve which is used if a specific
... | [
"def",
"sample",
"(",
"self",
",",
"fields",
"=",
"None",
",",
"count",
"=",
"5",
",",
"sampling",
"=",
"None",
",",
"use_cache",
"=",
"True",
",",
"dialect",
"=",
"None",
",",
"billing_tier",
"=",
"None",
")",
":",
"from",
".",
"import",
"_query",
... | Retrieves a sampling of data from the table.
Args:
fields: an optional list of field names to retrieve.
count: an optional count of rows to retrieve which is used if a specific
sampling is not specified.
sampling: an optional sampling strategy to apply to the table.
use_cache: whe... | [
"Retrieves",
"a",
"sampling",
"of",
"data",
"from",
"the",
"table",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_table.py#L248-L277 | train |
googledatalab/pydatalab | datalab/bigquery/_table.py | Table._encode_dict_as_row | def _encode_dict_as_row(record, column_name_map):
""" Encode a dictionary representing a table row in a form suitable for streaming to BQ.
This includes encoding timestamps as ISO-compatible strings and removing invalid
characters from column names.
Args:
record: a Python dictionary represen... | python | def _encode_dict_as_row(record, column_name_map):
""" Encode a dictionary representing a table row in a form suitable for streaming to BQ.
This includes encoding timestamps as ISO-compatible strings and removing invalid
characters from column names.
Args:
record: a Python dictionary represen... | [
"def",
"_encode_dict_as_row",
"(",
"record",
",",
"column_name_map",
")",
":",
"for",
"k",
"in",
"list",
"(",
"record",
".",
"keys",
"(",
")",
")",
":",
"v",
"=",
"record",
"[",
"k",
"]",
"if",
"isinstance",
"(",
"v",
",",
"pandas",
".",
"Timestamp",... | Encode a dictionary representing a table row in a form suitable for streaming to BQ.
This includes encoding timestamps as ISO-compatible strings and removing invalid
characters from column names.
Args:
record: a Python dictionary representing the table row.
column_name_map: a dictionary ma... | [
"Encode",
"a",
"dictionary",
"representing",
"a",
"table",
"row",
"in",
"a",
"form",
"suitable",
"for",
"streaming",
"to",
"BQ",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_table.py#L280-L307 | train |
googledatalab/pydatalab | datalab/bigquery/_table.py | Table.insert_data | def insert_data(self, data, include_index=False, index_name=None):
""" Insert the contents of a Pandas DataFrame or a list of dictionaries into the table.
The insertion will be performed using at most 500 rows per POST, and at most 10 POSTs per
second, as BigQuery has some limits on streaming rates.
A... | python | def insert_data(self, data, include_index=False, index_name=None):
""" Insert the contents of a Pandas DataFrame or a list of dictionaries into the table.
The insertion will be performed using at most 500 rows per POST, and at most 10 POSTs per
second, as BigQuery has some limits on streaming rates.
A... | [
"def",
"insert_data",
"(",
"self",
",",
"data",
",",
"include_index",
"=",
"False",
",",
"index_name",
"=",
"None",
")",
":",
"max_rows_per_post",
"=",
"500",
"post_interval",
"=",
"0.05",
"if",
"not",
"self",
".",
"exists",
"(",
")",
":",
"raise",
"Exce... | Insert the contents of a Pandas DataFrame or a list of dictionaries into the table.
The insertion will be performed using at most 500 rows per POST, and at most 10 POSTs per
second, as BigQuery has some limits on streaming rates.
Args:
data: the DataFrame or list to insert.
include_index: whet... | [
"Insert",
"the",
"contents",
"of",
"a",
"Pandas",
"DataFrame",
"or",
"a",
"list",
"of",
"dictionaries",
"into",
"the",
"table",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_table.py#L309-L417 | train |
googledatalab/pydatalab | datalab/bigquery/_table.py | Table.range | def range(self, start_row=0, max_rows=None):
""" Get an iterator to iterate through a set of table rows.
Args:
start_row: the row of the table at which to start the iteration (default 0)
max_rows: an upper limit on the number of rows to iterate through (default None)
Returns:
A row itera... | python | def range(self, start_row=0, max_rows=None):
""" Get an iterator to iterate through a set of table rows.
Args:
start_row: the row of the table at which to start the iteration (default 0)
max_rows: an upper limit on the number of rows to iterate through (default None)
Returns:
A row itera... | [
"def",
"range",
"(",
"self",
",",
"start_row",
"=",
"0",
",",
"max_rows",
"=",
"None",
")",
":",
"fetcher",
"=",
"self",
".",
"_get_row_fetcher",
"(",
"start_row",
"=",
"start_row",
",",
"max_rows",
"=",
"max_rows",
")",
"return",
"iter",
"(",
"datalab",... | Get an iterator to iterate through a set of table rows.
Args:
start_row: the row of the table at which to start the iteration (default 0)
max_rows: an upper limit on the number of rows to iterate through (default None)
Returns:
A row iterator. | [
"Get",
"an",
"iterator",
"to",
"iterate",
"through",
"a",
"set",
"of",
"table",
"rows",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_table.py#L614-L625 | train |
googledatalab/pydatalab | datalab/bigquery/_table.py | Table.to_file_async | def to_file_async(self, destination, format='csv', csv_delimiter=',', csv_header=True):
"""Start saving the results to a local file in CSV format and return a Job for completion.
Args:
destination: path on the local filesystem for the saved results.
format: the format to use for the exported data; ... | python | def to_file_async(self, destination, format='csv', csv_delimiter=',', csv_header=True):
"""Start saving the results to a local file in CSV format and return a Job for completion.
Args:
destination: path on the local filesystem for the saved results.
format: the format to use for the exported data; ... | [
"def",
"to_file_async",
"(",
"self",
",",
"destination",
",",
"format",
"=",
"'csv'",
",",
"csv_delimiter",
"=",
"','",
",",
"csv_header",
"=",
"True",
")",
":",
"self",
".",
"to_file",
"(",
"destination",
",",
"format",
"=",
"format",
",",
"csv_delimiter"... | Start saving the results to a local file in CSV format and return a Job for completion.
Args:
destination: path on the local filesystem for the saved results.
format: the format to use for the exported data; currently only 'csv' is supported.
csv_delimiter: for CSV exports, the field delimiter to... | [
"Start",
"saving",
"the",
"results",
"to",
"a",
"local",
"file",
"in",
"CSV",
"format",
"and",
"return",
"a",
"Job",
"for",
"completion",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_table.py#L680-L693 | train |
googledatalab/pydatalab | datalab/bigquery/_table.py | Table.update | def update(self, friendly_name=None, description=None, expiry=None, schema=None):
""" Selectively updates Table information.
Any parameters that are omitted or None are not updated.
Args:
friendly_name: if not None, the new friendly name.
description: if not None, the new description.
ex... | python | def update(self, friendly_name=None, description=None, expiry=None, schema=None):
""" Selectively updates Table information.
Any parameters that are omitted or None are not updated.
Args:
friendly_name: if not None, the new friendly name.
description: if not None, the new description.
ex... | [
"def",
"update",
"(",
"self",
",",
"friendly_name",
"=",
"None",
",",
"description",
"=",
"None",
",",
"expiry",
"=",
"None",
",",
"schema",
"=",
"None",
")",
":",
"self",
".",
"_load_info",
"(",
")",
"if",
"friendly_name",
"is",
"not",
"None",
":",
... | Selectively updates Table information.
Any parameters that are omitted or None are not updated.
Args:
friendly_name: if not None, the new friendly name.
description: if not None, the new description.
expiry: if not None, the new expiry time, either as a DateTime or milliseconds since epoch.
... | [
"Selectively",
"updates",
"Table",
"information",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_table.py#L712-L742 | train |
googledatalab/pydatalab | datalab/bigquery/_table.py | Table.to_query | def to_query(self, fields=None):
""" Return a Query for this Table.
Args:
fields: the fields to return. If None, all fields will be returned. This can be a string
which will be injected into the Query after SELECT, or a list of field names.
Returns:
A Query object that will return th... | python | def to_query(self, fields=None):
""" Return a Query for this Table.
Args:
fields: the fields to return. If None, all fields will be returned. This can be a string
which will be injected into the Query after SELECT, or a list of field names.
Returns:
A Query object that will return th... | [
"def",
"to_query",
"(",
"self",
",",
"fields",
"=",
"None",
")",
":",
"from",
".",
"import",
"_query",
"if",
"fields",
"is",
"None",
":",
"fields",
"=",
"'*'",
"elif",
"isinstance",
"(",
"fields",
",",
"list",
")",
":",
"fields",
"=",
"','",
".",
"... | Return a Query for this Table.
Args:
fields: the fields to return. If None, all fields will be returned. This can be a string
which will be injected into the Query after SELECT, or a list of field names.
Returns:
A Query object that will return the specified fields from the records in th... | [
"Return",
"a",
"Query",
"for",
"this",
"Table",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_table.py#L914-L930 | train |
googledatalab/pydatalab | datalab/storage/_item.py | Item.copy_to | def copy_to(self, new_key, bucket=None):
"""Copies this item to the specified new key.
Args:
new_key: the new key to copy this item to.
bucket: the bucket of the new item; if None (the default) use the same bucket.
Returns:
An Item corresponding to new key.
Raises:
Exception if ... | python | def copy_to(self, new_key, bucket=None):
"""Copies this item to the specified new key.
Args:
new_key: the new key to copy this item to.
bucket: the bucket of the new item; if None (the default) use the same bucket.
Returns:
An Item corresponding to new key.
Raises:
Exception if ... | [
"def",
"copy_to",
"(",
"self",
",",
"new_key",
",",
"bucket",
"=",
"None",
")",
":",
"if",
"bucket",
"is",
"None",
":",
"bucket",
"=",
"self",
".",
"_bucket",
"try",
":",
"new_info",
"=",
"self",
".",
"_api",
".",
"objects_copy",
"(",
"self",
".",
... | Copies this item to the specified new key.
Args:
new_key: the new key to copy this item to.
bucket: the bucket of the new item; if None (the default) use the same bucket.
Returns:
An Item corresponding to new key.
Raises:
Exception if there was an error copying the item. | [
"Copies",
"this",
"item",
"to",
"the",
"specified",
"new",
"key",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/storage/_item.py#L111-L128 | train |
googledatalab/pydatalab | datalab/storage/_item.py | Item.exists | def exists(self):
""" Checks if the item exists. """
try:
return self.metadata is not None
except datalab.utils.RequestException:
return False
except Exception as e:
raise e | python | def exists(self):
""" Checks if the item exists. """
try:
return self.metadata is not None
except datalab.utils.RequestException:
return False
except Exception as e:
raise e | [
"def",
"exists",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"metadata",
"is",
"not",
"None",
"except",
"datalab",
".",
"utils",
".",
"RequestException",
":",
"return",
"False",
"except",
"Exception",
"as",
"e",
":",
"raise",
"e"
] | Checks if the item exists. | [
"Checks",
"if",
"the",
"item",
"exists",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/storage/_item.py#L130-L137 | train |
googledatalab/pydatalab | datalab/storage/_item.py | Item.delete | def delete(self):
"""Deletes this item from its bucket.
Raises:
Exception if there was an error deleting the item.
"""
if self.exists():
try:
self._api.objects_delete(self._bucket, self._key)
except Exception as e:
raise e | python | def delete(self):
"""Deletes this item from its bucket.
Raises:
Exception if there was an error deleting the item.
"""
if self.exists():
try:
self._api.objects_delete(self._bucket, self._key)
except Exception as e:
raise e | [
"def",
"delete",
"(",
"self",
")",
":",
"if",
"self",
".",
"exists",
"(",
")",
":",
"try",
":",
"self",
".",
"_api",
".",
"objects_delete",
"(",
"self",
".",
"_bucket",
",",
"self",
".",
"_key",
")",
"except",
"Exception",
"as",
"e",
":",
"raise",
... | Deletes this item from its bucket.
Raises:
Exception if there was an error deleting the item. | [
"Deletes",
"this",
"item",
"from",
"its",
"bucket",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/storage/_item.py#L139-L149 | train |
googledatalab/pydatalab | datalab/storage/_item.py | Item.write_to | def write_to(self, content, content_type):
"""Writes text content to this item.
Args:
content: the text content to be written.
content_type: the type of text content.
Raises:
Exception if there was an error requesting the item's content.
"""
try:
self._api.object_upload(self... | python | def write_to(self, content, content_type):
"""Writes text content to this item.
Args:
content: the text content to be written.
content_type: the type of text content.
Raises:
Exception if there was an error requesting the item's content.
"""
try:
self._api.object_upload(self... | [
"def",
"write_to",
"(",
"self",
",",
"content",
",",
"content_type",
")",
":",
"try",
":",
"self",
".",
"_api",
".",
"object_upload",
"(",
"self",
".",
"_bucket",
",",
"self",
".",
"_key",
",",
"content",
",",
"content_type",
")",
"except",
"Exception",
... | Writes text content to this item.
Args:
content: the text content to be written.
content_type: the type of text content.
Raises:
Exception if there was an error requesting the item's content. | [
"Writes",
"text",
"content",
"to",
"this",
"item",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/storage/_item.py#L212-L224 | train |
googledatalab/pydatalab | datalab/storage/_item.py | Items.contains | def contains(self, key):
"""Checks if the specified item exists.
Args:
key: the key of the item to lookup.
Returns:
True if the item exists; False otherwise.
Raises:
Exception if there was an error requesting information about the item.
"""
try:
self._api.objects_get(sel... | python | def contains(self, key):
"""Checks if the specified item exists.
Args:
key: the key of the item to lookup.
Returns:
True if the item exists; False otherwise.
Raises:
Exception if there was an error requesting information about the item.
"""
try:
self._api.objects_get(sel... | [
"def",
"contains",
"(",
"self",
",",
"key",
")",
":",
"try",
":",
"self",
".",
"_api",
".",
"objects_get",
"(",
"self",
".",
"_bucket",
",",
"key",
")",
"except",
"datalab",
".",
"utils",
".",
"RequestException",
"as",
"e",
":",
"if",
"e",
".",
"st... | Checks if the specified item exists.
Args:
key: the key of the item to lookup.
Returns:
True if the item exists; False otherwise.
Raises:
Exception if there was an error requesting information about the item. | [
"Checks",
"if",
"the",
"specified",
"item",
"exists",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/storage/_item.py#L252-L270 | train |
googledatalab/pydatalab | google/datalab/utils/_http.py | Http.request | def request(url, args=None, data=None, headers=None, method=None,
credentials=None, raw_response=False, stats=None):
"""Issues HTTP requests.
Args:
url: the URL to request.
args: optional query string arguments.
data: optional data to be sent within the request.
headers: o... | python | def request(url, args=None, data=None, headers=None, method=None,
credentials=None, raw_response=False, stats=None):
"""Issues HTTP requests.
Args:
url: the URL to request.
args: optional query string arguments.
data: optional data to be sent within the request.
headers: o... | [
"def",
"request",
"(",
"url",
",",
"args",
"=",
"None",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"method",
"=",
"None",
",",
"credentials",
"=",
"None",
",",
"raw_response",
"=",
"False",
",",
"stats",
"=",
"None",
")",
":",
"if"... | Issues HTTP requests.
Args:
url: the URL to request.
args: optional query string arguments.
data: optional data to be sent within the request.
headers: optional headers to include in the request.
method: optional HTTP method to use. If unspecified this is inferred
(GET or PO... | [
"Issues",
"HTTP",
"requests",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/_http.py#L81-L167 | train |
googledatalab/pydatalab | google/datalab/contrib/pipeline/commands/_pipeline.py | _add_command | def _add_command(parser, subparser_fn, handler, cell_required=False,
cell_prohibited=False):
""" Create and initialize a pipeline subcommand handler. """
sub_parser = subparser_fn(parser)
sub_parser.set_defaults(func=lambda args, cell: _dispatch_handler(
args, cell, sub_parser, handler, cel... | python | def _add_command(parser, subparser_fn, handler, cell_required=False,
cell_prohibited=False):
""" Create and initialize a pipeline subcommand handler. """
sub_parser = subparser_fn(parser)
sub_parser.set_defaults(func=lambda args, cell: _dispatch_handler(
args, cell, sub_parser, handler, cel... | [
"def",
"_add_command",
"(",
"parser",
",",
"subparser_fn",
",",
"handler",
",",
"cell_required",
"=",
"False",
",",
"cell_prohibited",
"=",
"False",
")",
":",
"sub_parser",
"=",
"subparser_fn",
"(",
"parser",
")",
"sub_parser",
".",
"set_defaults",
"(",
"func"... | Create and initialize a pipeline subcommand handler. | [
"Create",
"and",
"initialize",
"a",
"pipeline",
"subcommand",
"handler",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/pipeline/commands/_pipeline.py#L57-L63 | train |
googledatalab/pydatalab | google/datalab/contrib/pipeline/commands/_pipeline.py | pipeline | def pipeline(line, cell=None):
"""Implements the pipeline cell magic for ipython notebooks.
The supported syntax is:
%%pipeline <command> [<args>]
<cell>
or:
%pipeline <command> [<args>]
Use %pipeline --help for a list of commands, or %pipeline <command> --help for
help on a specific command.... | python | def pipeline(line, cell=None):
"""Implements the pipeline cell magic for ipython notebooks.
The supported syntax is:
%%pipeline <command> [<args>]
<cell>
or:
%pipeline <command> [<args>]
Use %pipeline --help for a list of commands, or %pipeline <command> --help for
help on a specific command.... | [
"def",
"pipeline",
"(",
"line",
",",
"cell",
"=",
"None",
")",
":",
"return",
"google",
".",
"datalab",
".",
"utils",
".",
"commands",
".",
"handle_magic_line",
"(",
"line",
",",
"cell",
",",
"_pipeline_parser",
")"
] | Implements the pipeline cell magic for ipython notebooks.
The supported syntax is:
%%pipeline <command> [<args>]
<cell>
or:
%pipeline <command> [<args>]
Use %pipeline --help for a list of commands, or %pipeline <command> --help for
help on a specific command. | [
"Implements",
"the",
"pipeline",
"cell",
"magic",
"for",
"ipython",
"notebooks",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/pipeline/commands/_pipeline.py#L90-L105 | train |
googledatalab/pydatalab | google/datalab/contrib/pipeline/commands/_pipeline.py | _dispatch_handler | def _dispatch_handler(args, cell, parser, handler, cell_required=False,
cell_prohibited=False):
""" Makes sure cell magics include cell and line magics don't, before
dispatching to handler.
Args:
args: the parsed arguments from the magic line.
cell: the contents of the cell, if an... | python | def _dispatch_handler(args, cell, parser, handler, cell_required=False,
cell_prohibited=False):
""" Makes sure cell magics include cell and line magics don't, before
dispatching to handler.
Args:
args: the parsed arguments from the magic line.
cell: the contents of the cell, if an... | [
"def",
"_dispatch_handler",
"(",
"args",
",",
"cell",
",",
"parser",
",",
"handler",
",",
"cell_required",
"=",
"False",
",",
"cell_prohibited",
"=",
"False",
")",
":",
"if",
"cell_prohibited",
":",
"if",
"cell",
"and",
"len",
"(",
"cell",
".",
"strip",
... | Makes sure cell magics include cell and line magics don't, before
dispatching to handler.
Args:
args: the parsed arguments from the magic line.
cell: the contents of the cell, if any.
parser: the argument parser for <cmd>; used for error message.
handler: the handler to call if the cell present/a... | [
"Makes",
"sure",
"cell",
"magics",
"include",
"cell",
"and",
"line",
"magics",
"don",
"t",
"before",
"dispatching",
"to",
"handler",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/pipeline/commands/_pipeline.py#L108-L138 | train |
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",
"]",
"for",
"name",
",",
"transform",
"in",
"six",
".",
"iteritems",
"(",
"features",
")",
":",
"if",
"... | Add to features any default transformations.
Not every column in the schema has an explicit feature transformation listed
in the featurs file. For these columns, add a default transformation based on
the schema's type. The features dict is modified by this function call.
After this function call, every column... | [
"Add",
"to",
"features",
"any",
"default",
"transformations",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/ml_workbench/xgboost/trainer/feature_analysis.py#L114-L167 | train |
googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | _sample_cell | def _sample_cell(args, cell_body):
"""Implements the bigquery sample cell magic for ipython notebooks.
Args:
args: the optional arguments following '%%bigquery sample'.
cell_body: optional contents of the cell interpreted as SQL, YAML or JSON.
Returns:
The results of executing the sampling query, or ... | python | def _sample_cell(args, cell_body):
"""Implements the bigquery sample cell magic for ipython notebooks.
Args:
args: the optional arguments following '%%bigquery sample'.
cell_body: optional contents of the cell interpreted as SQL, YAML or JSON.
Returns:
The results of executing the sampling query, or ... | [
"def",
"_sample_cell",
"(",
"args",
",",
"cell_body",
")",
":",
"env",
"=",
"datalab",
".",
"utils",
".",
"commands",
".",
"notebook_environment",
"(",
")",
"query",
"=",
"None",
"table",
"=",
"None",
"view",
"=",
"None",
"if",
"args",
"[",
"'query'",
... | Implements the bigquery sample cell magic for ipython notebooks.
Args:
args: the optional arguments following '%%bigquery sample'.
cell_body: optional contents of the cell interpreted as SQL, YAML or JSON.
Returns:
The results of executing the sampling query, or a profile of the sample data. | [
"Implements",
"the",
"bigquery",
"sample",
"cell",
"magic",
"for",
"ipython",
"notebooks",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L285-L339 | train |
googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | _create_cell | def _create_cell(args, cell_body):
"""Implements the BigQuery cell magic used to create datasets and tables.
The supported syntax is:
%%bigquery create dataset -n|--name <name> [-f|--friendly <friendlyname>]
[<description>]
or:
%%bigquery create table -n|--name <tablename> [--overwrite]
... | python | def _create_cell(args, cell_body):
"""Implements the BigQuery cell magic used to create datasets and tables.
The supported syntax is:
%%bigquery create dataset -n|--name <name> [-f|--friendly <friendlyname>]
[<description>]
or:
%%bigquery create table -n|--name <tablename> [--overwrite]
... | [
"def",
"_create_cell",
"(",
"args",
",",
"cell_body",
")",
":",
"if",
"args",
"[",
"'command'",
"]",
"==",
"'dataset'",
":",
"try",
":",
"datalab",
".",
"bigquery",
".",
"Dataset",
"(",
"args",
"[",
"'name'",
"]",
")",
".",
"create",
"(",
"friendly_nam... | Implements the BigQuery cell magic used to create datasets and tables.
The supported syntax is:
%%bigquery create dataset -n|--name <name> [-f|--friendly <friendlyname>]
[<description>]
or:
%%bigquery create table -n|--name <tablename> [--overwrite]
[<YAML or JSON cell_body defining schema... | [
"Implements",
"the",
"BigQuery",
"cell",
"magic",
"used",
"to",
"create",
"datasets",
"and",
"tables",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L342-L375 | train |
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",
",",
"_",
")",
":",
"if",
"args",
"[",
"'command'",
"]",
"==",
"'dataset'",
":",
"try",
":",
"datalab",
".",
"bigquery",
".",
"Dataset",
"(",
"args",
"[",
"'name'",
"]",
")",
".",
"delete",
"(",
")",
"except",
"E... | Implements the BigQuery cell magic used to delete datasets and tables.
The supported syntax is:
%%bigquery delete dataset -n|--name <name>
or:
%%bigquery delete table -n|--name <name>
Args:
args: the argument following '%bigquery delete <command>'. | [
"Implements",
"the",
"BigQuery",
"cell",
"magic",
"used",
"to",
"delete",
"datasets",
"and",
"tables",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L378-L403 | train |
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>'",
")",
"spec_pattern",
"=... | Implements the bigquery_udf cell magic for ipython notebooks.
The supported syntax is:
%%bigquery udf --module <var>
<js function>
Args:
args: the optional arguments following '%%bigquery udf'.
js: the UDF declaration (inputs and outputs) and implementation in javascript.
Returns:
The results of... | [
"Implements",
"the",
"bigquery_udf",
"cell",
"magic",
"for",
"ipython",
"notebooks",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L428-L492 | train |
googledatalab/pydatalab | datalab/bigquery/commands/_bigquery.py | _pipeline_cell | def _pipeline_cell(args, cell_body):
"""Implements the BigQuery cell magic used to validate, execute or deploy BQ pipelines.
The supported syntax is:
%%bigquery pipeline [-q|--sql <query identifier>] <other args> <action>
[<YAML or JSON cell_body or inline SQL>]
Args:
args: the arguments following '%... | python | def _pipeline_cell(args, cell_body):
"""Implements the BigQuery cell magic used to validate, execute or deploy BQ pipelines.
The supported syntax is:
%%bigquery pipeline [-q|--sql <query identifier>] <other args> <action>
[<YAML or JSON cell_body or inline SQL>]
Args:
args: the arguments following '%... | [
"def",
"_pipeline_cell",
"(",
"args",
",",
"cell_body",
")",
":",
"if",
"args",
"[",
"'action'",
"]",
"==",
"'deploy'",
":",
"raise",
"Exception",
"(",
"'Deploying a pipeline is not yet supported'",
")",
"env",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in"... | Implements the BigQuery cell magic used to validate, execute or deploy BQ pipelines.
The supported syntax is:
%%bigquery pipeline [-q|--sql <query identifier>] <other args> <action>
[<YAML or JSON cell_body or inline SQL>]
Args:
args: the arguments following '%bigquery pipeline'.
cell_body: optiona... | [
"Implements",
"the",
"BigQuery",
"cell",
"magic",
"used",
"to",
"validate",
"execute",
"or",
"deploy",
"BQ",
"pipelines",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L516-L548 | train |
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",
")",
":",
"name",
"=",
"args",
"[",
"'table'",
"]",
"table",
"=",
"_get_table",
"(",
"name",
")",
"if",
"table",
"and",
"table",
".",
"exists",
"(",
")",
":",
"fields",
"=",
"args",
"[",
"'cols'",
"]",
".",
"split... | Implements the BigQuery table magic used to display tables.
The supported syntax is:
%bigquery table -t|--table <name> <other args>
Args:
args: the arguments following '%bigquery table'.
Returns:
The HTML rendering for the table. | [
"Implements",
"the",
"BigQuery",
"table",
"magic",
"used",
"to",
"display",
"tables",
"."
] | d9031901d5bca22fe0d5925d204e6698df9852e1 | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L551-L571 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.