partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | DrawingClassifier.evaluate | Evaluate the model by making predictions of target values and comparing
these to actual values.
Parameters
----------
dataset : SFrame
Dataset of new observations. Must include columns with the same
names as the feature and target columns used for model t... | src/unity/python/turicreate/toolkits/drawing_classifier/drawing_classifier.py | def evaluate(self, dataset, metric='auto', batch_size=None, verbose=True):
"""
Evaluate the model by making predictions of target values and comparing
these to actual values.
Parameters
----------
dataset : SFrame
Dataset of new observations. Must inc... | def evaluate(self, dataset, metric='auto', batch_size=None, verbose=True):
"""
Evaluate the model by making predictions of target values and comparing
these to actual values.
Parameters
----------
dataset : SFrame
Dataset of new observations. Must inc... | [
"Evaluate",
"the",
"model",
"by",
"making",
"predictions",
"of",
"target",
"values",
"and",
"comparing",
"these",
"to",
"actual",
"values",
".",
"Parameters",
"----------",
"dataset",
":",
"SFrame",
"Dataset",
"of",
"new",
"observations",
".",
"Must",
"include",... | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/drawing_classifier/drawing_classifier.py#L603-L690 | [
"def",
"evaluate",
"(",
"self",
",",
"dataset",
",",
"metric",
"=",
"'auto'",
",",
"batch_size",
"=",
"None",
",",
"verbose",
"=",
"True",
")",
":",
"if",
"self",
".",
"target",
"not",
"in",
"dataset",
".",
"column_names",
"(",
")",
":",
"raise",
"_T... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | DrawingClassifier.predict_topk | Return top-k predictions for the ``dataset``, using the trained model.
Predictions are returned as an SFrame with three columns: `id`,
`class`, and `probability` or `rank`, depending on the ``output_type``
parameter.
Parameters
----------
dataset : SFrame | SArray | turi... | src/unity/python/turicreate/toolkits/drawing_classifier/drawing_classifier.py | def predict_topk(self, dataset, output_type="probability", k=3,
batch_size=None):
"""
Return top-k predictions for the ``dataset``, using the trained model.
Predictions are returned as an SFrame with three columns: `id`,
`class`, and `probability` or `rank`, depending on the ``ou... | def predict_topk(self, dataset, output_type="probability", k=3,
batch_size=None):
"""
Return top-k predictions for the ``dataset``, using the trained model.
Predictions are returned as an SFrame with three columns: `id`,
`class`, and `probability` or `rank`, depending on the ``ou... | [
"Return",
"top",
"-",
"k",
"predictions",
"for",
"the",
"dataset",
"using",
"the",
"trained",
"model",
".",
"Predictions",
"are",
"returned",
"as",
"an",
"SFrame",
"with",
"three",
"columns",
":",
"id",
"class",
"and",
"probability",
"or",
"rank",
"depending... | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/drawing_classifier/drawing_classifier.py#L692-L785 | [
"def",
"predict_topk",
"(",
"self",
",",
"dataset",
",",
"output_type",
"=",
"\"probability\"",
",",
"k",
"=",
"3",
",",
"batch_size",
"=",
"None",
")",
":",
"_tkutl",
".",
"_check_categorical_option_type",
"(",
"\"output_type\"",
",",
"output_type",
",",
"[",... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | DrawingClassifier.predict | Predict on an SFrame or SArray of drawings, or on a single drawing.
Parameters
----------
data : SFrame | SArray | tc.Image | list
The drawing(s) on which to perform drawing classification.
If dataset is an SFrame, it must have a column with the same name
as ... | src/unity/python/turicreate/toolkits/drawing_classifier/drawing_classifier.py | def predict(self, data, output_type='class', batch_size=None, verbose=True):
"""
Predict on an SFrame or SArray of drawings, or on a single drawing.
Parameters
----------
data : SFrame | SArray | tc.Image | list
The drawing(s) on which to perform drawing classificati... | def predict(self, data, output_type='class', batch_size=None, verbose=True):
"""
Predict on an SFrame or SArray of drawings, or on a single drawing.
Parameters
----------
data : SFrame | SArray | tc.Image | list
The drawing(s) on which to perform drawing classificati... | [
"Predict",
"on",
"an",
"SFrame",
"or",
"SArray",
"of",
"drawings",
"or",
"on",
"a",
"single",
"drawing",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/drawing_classifier/drawing_classifier.py#L788-L879 | [
"def",
"predict",
"(",
"self",
",",
"data",
",",
"output_type",
"=",
"'class'",
",",
"batch_size",
"=",
"None",
",",
"verbose",
"=",
"True",
")",
":",
"_tkutl",
".",
"_check_categorical_option_type",
"(",
"\"output_type\"",
",",
"output_type",
",",
"[",
"\"p... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | MXFeatureExtractor.extract_features | Parameters
----------
dataset: SFrame
SFrame of images | src/unity/python/turicreate/toolkits/_image_feature_extractor.py | def extract_features(self, dataset, feature, batch_size=64, verbose=False):
"""
Parameters
----------
dataset: SFrame
SFrame of images
"""
from ._mxnet._mx_sframe_iter import SFrameImageIter as _SFrameImageIter
from six.moves.queue import Queue as _Que... | def extract_features(self, dataset, feature, batch_size=64, verbose=False):
"""
Parameters
----------
dataset: SFrame
SFrame of images
"""
from ._mxnet._mx_sframe_iter import SFrameImageIter as _SFrameImageIter
from six.moves.queue import Queue as _Que... | [
"Parameters",
"----------",
"dataset",
":",
"SFrame",
"SFrame",
"of",
"images"
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_image_feature_extractor.py#L106-L183 | [
"def",
"extract_features",
"(",
"self",
",",
"dataset",
",",
"feature",
",",
"batch_size",
"=",
"64",
",",
"verbose",
"=",
"False",
")",
":",
"from",
".",
"_mxnet",
".",
"_mx_sframe_iter",
"import",
"SFrameImageIter",
"as",
"_SFrameImageIter",
"from",
"six",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | MXFeatureExtractor.get_coreml_model | Parameters
----------
mode: str ('classifier', 'regressor' or None)
Mode of the converted coreml model.
When mode = 'classifier', a NeuralNetworkClassifier spec will be constructed.
When mode = 'regressor', a NeuralNetworkRegressor spec will be constructed.
R... | src/unity/python/turicreate/toolkits/_image_feature_extractor.py | def get_coreml_model(self, mode = 'classifier'):
"""
Parameters
----------
mode: str ('classifier', 'regressor' or None)
Mode of the converted coreml model.
When mode = 'classifier', a NeuralNetworkClassifier spec will be constructed.
When mode = 'regr... | def get_coreml_model(self, mode = 'classifier'):
"""
Parameters
----------
mode: str ('classifier', 'regressor' or None)
Mode of the converted coreml model.
When mode = 'classifier', a NeuralNetworkClassifier spec will be constructed.
When mode = 'regr... | [
"Parameters",
"----------",
"mode",
":",
"str",
"(",
"classifier",
"regressor",
"or",
"None",
")",
"Mode",
"of",
"the",
"converted",
"coreml",
"model",
".",
"When",
"mode",
"=",
"classifier",
"a",
"NeuralNetworkClassifier",
"spec",
"will",
"be",
"constructed",
... | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_image_feature_extractor.py#L185-L224 | [
"def",
"get_coreml_model",
"(",
"self",
",",
"mode",
"=",
"'classifier'",
")",
":",
"import",
"mxnet",
"as",
"_mx",
"from",
".",
"_mxnet",
"import",
"_mxnet_utils",
"from",
".",
"_mxnet",
".",
"_mxnet_to_coreml",
"import",
"_mxnet_converter",
"(",
"sym",
",",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | DarkNetObjectDetectorBase.available_parameters_subset | Takes an mxnet parameter collect (from Block.collect_params()) and
subsets it with the parameters available in this base network. | src/unity/python/turicreate/toolkits/_pre_trained_models.py | def available_parameters_subset(self, mx_params):
"""
Takes an mxnet parameter collect (from Block.collect_params()) and
subsets it with the parameters available in this base network.
"""
from copy import copy
from collections import OrderedDict
subset_params = co... | def available_parameters_subset(self, mx_params):
"""
Takes an mxnet parameter collect (from Block.collect_params()) and
subsets it with the parameters available in this base network.
"""
from copy import copy
from collections import OrderedDict
subset_params = co... | [
"Takes",
"an",
"mxnet",
"parameter",
"collect",
"(",
"from",
"Block",
".",
"collect_params",
"()",
")",
"and",
"subsets",
"it",
"with",
"the",
"parameters",
"available",
"in",
"this",
"base",
"network",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_pre_trained_models.py#L166-L177 | [
"def",
"available_parameters_subset",
"(",
"self",
",",
"mx_params",
")",
":",
"from",
"copy",
"import",
"copy",
"from",
"collections",
"import",
"OrderedDict",
"subset_params",
"=",
"copy",
"(",
"mx_params",
")",
"subset_params",
".",
"_params",
"=",
"OrderedDict... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _BOW_FEATURE_EXTRACTOR | Return an SFrame containing a bag of words representation of each column. | src/unity/python/turicreate/toolkits/text_classifier/_text_classifier.py | def _BOW_FEATURE_EXTRACTOR(sf, target=None):
"""
Return an SFrame containing a bag of words representation of each column.
"""
if isinstance(sf, dict):
out = _tc.SArray([sf]).unpack('')
elif isinstance(sf, _tc.SFrame):
out = sf.__copy__()
else:
raise ValueError("Unrecogni... | def _BOW_FEATURE_EXTRACTOR(sf, target=None):
"""
Return an SFrame containing a bag of words representation of each column.
"""
if isinstance(sf, dict):
out = _tc.SArray([sf]).unpack('')
elif isinstance(sf, _tc.SFrame):
out = sf.__copy__()
else:
raise ValueError("Unrecogni... | [
"Return",
"an",
"SFrame",
"containing",
"a",
"bag",
"of",
"words",
"representation",
"of",
"each",
"column",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/text_classifier/_text_classifier.py#L18-L31 | [
"def",
"_BOW_FEATURE_EXTRACTOR",
"(",
"sf",
",",
"target",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"sf",
",",
"dict",
")",
":",
"out",
"=",
"_tc",
".",
"SArray",
"(",
"[",
"sf",
"]",
")",
".",
"unpack",
"(",
"''",
")",
"elif",
"isinstance",... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | create | Create a model that trains a classifier to classify text from a
collection of documents. The model is a
:class:`~turicreate.logistic_classifier.LogisticClassifier` model trained
using a bag-of-words representation of the text dataset.
Parameters
----------
dataset : SFrame
Contains one or... | src/unity/python/turicreate/toolkits/text_classifier/_text_classifier.py | def create(dataset, target, features = None, drop_stop_words = True,
word_count_threshold = 2, method = 'auto', validation_set = 'auto',
max_iterations = 10):
"""
Create a model that trains a classifier to classify text from a
collection of documents. The model is a
:class:`~turicr... | def create(dataset, target, features = None, drop_stop_words = True,
word_count_threshold = 2, method = 'auto', validation_set = 'auto',
max_iterations = 10):
"""
Create a model that trains a classifier to classify text from a
collection of documents. The model is a
:class:`~turicr... | [
"Create",
"a",
"model",
"that",
"trains",
"a",
"classifier",
"to",
"classify",
"text",
"from",
"a",
"collection",
"of",
"documents",
".",
"The",
"model",
"is",
"a",
":",
"class",
":",
"~turicreate",
".",
"logistic_classifier",
".",
"LogisticClassifier",
"model... | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/text_classifier/_text_classifier.py#L33-L151 | [
"def",
"create",
"(",
"dataset",
",",
"target",
",",
"features",
"=",
"None",
",",
"drop_stop_words",
"=",
"True",
",",
"word_count_threshold",
"=",
"2",
",",
"method",
"=",
"'auto'",
",",
"validation_set",
"=",
"'auto'",
",",
"max_iterations",
"=",
"10",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _get_str_columns | Returns a list of names of columns that are string type. | src/unity/python/turicreate/toolkits/text_classifier/_text_classifier.py | def _get_str_columns(sf):
"""
Returns a list of names of columns that are string type.
"""
return [name for name in sf.column_names() if sf[name].dtype == str] | def _get_str_columns(sf):
"""
Returns a list of names of columns that are string type.
"""
return [name for name in sf.column_names() if sf[name].dtype == str] | [
"Returns",
"a",
"list",
"of",
"names",
"of",
"columns",
"that",
"are",
"string",
"type",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/text_classifier/_text_classifier.py#L372-L376 | [
"def",
"_get_str_columns",
"(",
"sf",
")",
":",
"return",
"[",
"name",
"for",
"name",
"in",
"sf",
".",
"column_names",
"(",
")",
"if",
"sf",
"[",
"name",
"]",
".",
"dtype",
"==",
"str",
"]"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | TextClassifier.predict | Return predictions for ``dataset``, using the trained model.
Parameters
----------
dataset : SFrame
dataset of new observations. Must include columns with the same
names as the features used for model training, but does not require
a target column. Additional... | src/unity/python/turicreate/toolkits/text_classifier/_text_classifier.py | def predict(self, dataset, output_type='class'):
"""
Return predictions for ``dataset``, using the trained model.
Parameters
----------
dataset : SFrame
dataset of new observations. Must include columns with the same
names as the features used for model t... | def predict(self, dataset, output_type='class'):
"""
Return predictions for ``dataset``, using the trained model.
Parameters
----------
dataset : SFrame
dataset of new observations. Must include columns with the same
names as the features used for model t... | [
"Return",
"predictions",
"for",
"dataset",
"using",
"the",
"trained",
"model",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/text_classifier/_text_classifier.py#L182-L224 | [
"def",
"predict",
"(",
"self",
",",
"dataset",
",",
"output_type",
"=",
"'class'",
")",
":",
"m",
"=",
"self",
".",
"__proxy__",
"[",
"'classifier'",
"]",
"target",
"=",
"self",
".",
"__proxy__",
"[",
"'target'",
"]",
"f",
"=",
"_BOW_FEATURE_EXTRACTOR",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | TextClassifier.classify | Return a classification, for each example in the ``dataset``, using the
trained model. The output SFrame contains predictions as both class
labels as well as probabilities that the predicted value is the
associated label.
Parameters
----------
dataset : SFrame
... | src/unity/python/turicreate/toolkits/text_classifier/_text_classifier.py | def classify(self, dataset):
"""
Return a classification, for each example in the ``dataset``, using the
trained model. The output SFrame contains predictions as both class
labels as well as probabilities that the predicted value is the
associated label.
Parameters
... | def classify(self, dataset):
"""
Return a classification, for each example in the ``dataset``, using the
trained model. The output SFrame contains predictions as both class
labels as well as probabilities that the predicted value is the
associated label.
Parameters
... | [
"Return",
"a",
"classification",
"for",
"each",
"example",
"in",
"the",
"dataset",
"using",
"the",
"trained",
"model",
".",
"The",
"output",
"SFrame",
"contains",
"predictions",
"as",
"both",
"class",
"labels",
"as",
"well",
"as",
"probabilities",
"that",
"the... | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/text_classifier/_text_classifier.py#L226-L260 | [
"def",
"classify",
"(",
"self",
",",
"dataset",
")",
":",
"m",
"=",
"self",
".",
"__proxy__",
"[",
"'classifier'",
"]",
"target",
"=",
"self",
".",
"__proxy__",
"[",
"'target'",
"]",
"f",
"=",
"_BOW_FEATURE_EXTRACTOR",
"return",
"m",
".",
"classify",
"("... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | TextClassifier.evaluate | Evaluate the model by making predictions of target values and comparing
these to actual values.
Parameters
----------
dataset : SFrame
An SFrame having the same feature columns as provided when creating
the model.
metric : str, optional
Name ... | src/unity/python/turicreate/toolkits/text_classifier/_text_classifier.py | def evaluate(self, dataset, metric='auto', **kwargs):
"""
Evaluate the model by making predictions of target values and comparing
these to actual values.
Parameters
----------
dataset : SFrame
An SFrame having the same feature columns as provided when creatin... | def evaluate(self, dataset, metric='auto', **kwargs):
"""
Evaluate the model by making predictions of target values and comparing
these to actual values.
Parameters
----------
dataset : SFrame
An SFrame having the same feature columns as provided when creatin... | [
"Evaluate",
"the",
"model",
"by",
"making",
"predictions",
"of",
"target",
"values",
"and",
"comparing",
"these",
"to",
"actual",
"values",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/text_classifier/_text_classifier.py#L289-L332 | [
"def",
"evaluate",
"(",
"self",
",",
"dataset",
",",
"metric",
"=",
"'auto'",
",",
"*",
"*",
"kwargs",
")",
":",
"m",
"=",
"self",
".",
"__proxy__",
"[",
"'classifier'",
"]",
"target",
"=",
"self",
".",
"__proxy__",
"[",
"'target'",
"]",
"f",
"=",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _generate_base_svm_regression_spec | Takes an SVM regression model produces a starting spec using the parts.
that are shared between all SVMs. | src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_SVR.py | def _generate_base_svm_regression_spec(model):
"""
Takes an SVM regression model produces a starting spec using the parts.
that are shared between all SVMs.
"""
if not(_HAS_SKLEARN):
raise RuntimeError('scikit-learn not found. scikit-learn conversion API is disabled.')
spec = _Model_pb... | def _generate_base_svm_regression_spec(model):
"""
Takes an SVM regression model produces a starting spec using the parts.
that are shared between all SVMs.
"""
if not(_HAS_SKLEARN):
raise RuntimeError('scikit-learn not found. scikit-learn conversion API is disabled.')
spec = _Model_pb... | [
"Takes",
"an",
"SVM",
"regression",
"model",
"produces",
"a",
"starting",
"spec",
"using",
"the",
"parts",
".",
"that",
"are",
"shared",
"between",
"all",
"SVMs",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_SVR.py#L23-L46 | [
"def",
"_generate_base_svm_regression_spec",
"(",
"model",
")",
":",
"if",
"not",
"(",
"_HAS_SKLEARN",
")",
":",
"raise",
"RuntimeError",
"(",
"'scikit-learn not found. scikit-learn conversion API is disabled.'",
")",
"spec",
"=",
"_Model_pb2",
".",
"Model",
"(",
")",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | convert | Convert a Support Vector Regressor (SVR) model to the protobuf spec.
Parameters
----------
model: SVR
A trained SVR encoder model.
feature_names: [str]
Name of the input columns.
target: str
Name of the output column.
Returns
-------
model_spec: An object of ty... | src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_SVR.py | def convert(model, features, target):
"""Convert a Support Vector Regressor (SVR) model to the protobuf spec.
Parameters
----------
model: SVR
A trained SVR encoder model.
feature_names: [str]
Name of the input columns.
target: str
Name of the output column.
Return... | def convert(model, features, target):
"""Convert a Support Vector Regressor (SVR) model to the protobuf spec.
Parameters
----------
model: SVR
A trained SVR encoder model.
feature_names: [str]
Name of the input columns.
target: str
Name of the output column.
Return... | [
"Convert",
"a",
"Support",
"Vector",
"Regressor",
"(",
"SVR",
")",
"model",
"to",
"the",
"protobuf",
"spec",
".",
"Parameters",
"----------",
"model",
":",
"SVR",
"A",
"trained",
"SVR",
"encoder",
"model",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_SVR.py#L48-L68 | [
"def",
"convert",
"(",
"model",
",",
"features",
",",
"target",
")",
":",
"spec",
"=",
"_generate_base_svm_regression_spec",
"(",
"model",
")",
"spec",
"=",
"set_regressor_interface_params",
"(",
"spec",
",",
"features",
",",
"target",
")",
"return",
"_MLModel",... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _VerifyExtensionHandle | Verify that the given extension handle is valid. | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _VerifyExtensionHandle(message, extension_handle):
"""Verify that the given extension handle is valid."""
if not isinstance(extension_handle, _FieldDescriptor):
raise KeyError('HasExtension() expects an extension handle, got: %s' %
extension_handle)
if not extension_handle.is_extensio... | def _VerifyExtensionHandle(message, extension_handle):
"""Verify that the given extension handle is valid."""
if not isinstance(extension_handle, _FieldDescriptor):
raise KeyError('HasExtension() expects an extension handle, got: %s' %
extension_handle)
if not extension_handle.is_extensio... | [
"Verify",
"that",
"the",
"given",
"extension",
"handle",
"is",
"valid",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L213-L232 | [
"def",
"_VerifyExtensionHandle",
"(",
"message",
",",
"extension_handle",
")",
":",
"if",
"not",
"isinstance",
"(",
"extension_handle",
",",
"_FieldDescriptor",
")",
":",
"raise",
"KeyError",
"(",
"'HasExtension() expects an extension handle, got: %s'",
"%",
"extension_ha... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddEnumValues | Sets class-level attributes for all enum fields defined in this message.
Also exporting a class-level object that can name enum values.
Args:
descriptor: Descriptor object for this message type.
cls: Class we're constructing for this message type. | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddEnumValues(descriptor, cls):
"""Sets class-level attributes for all enum fields defined in this message.
Also exporting a class-level object that can name enum values.
Args:
descriptor: Descriptor object for this message type.
cls: Class we're constructing for this message type.
"""
for enum... | def _AddEnumValues(descriptor, cls):
"""Sets class-level attributes for all enum fields defined in this message.
Also exporting a class-level object that can name enum values.
Args:
descriptor: Descriptor object for this message type.
cls: Class we're constructing for this message type.
"""
for enum... | [
"Sets",
"class",
"-",
"level",
"attributes",
"for",
"all",
"enum",
"fields",
"defined",
"in",
"this",
"message",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L347-L359 | [
"def",
"_AddEnumValues",
"(",
"descriptor",
",",
"cls",
")",
":",
"for",
"enum_type",
"in",
"descriptor",
".",
"enum_types",
":",
"setattr",
"(",
"cls",
",",
"enum_type",
".",
"name",
",",
"enum_type_wrapper",
".",
"EnumTypeWrapper",
"(",
"enum_type",
")",
"... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _DefaultValueConstructorForField | Returns a function which returns a default value for a field.
Args:
field: FieldDescriptor object for this field.
The returned function has one argument:
message: Message instance containing this field, or a weakref proxy
of same.
That function in turn returns a default value for this field. The... | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _DefaultValueConstructorForField(field):
"""Returns a function which returns a default value for a field.
Args:
field: FieldDescriptor object for this field.
The returned function has one argument:
message: Message instance containing this field, or a weakref proxy
of same.
That function in... | def _DefaultValueConstructorForField(field):
"""Returns a function which returns a default value for a field.
Args:
field: FieldDescriptor object for this field.
The returned function has one argument:
message: Message instance containing this field, or a weakref proxy
of same.
That function in... | [
"Returns",
"a",
"function",
"which",
"returns",
"a",
"default",
"value",
"for",
"a",
"field",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L384-L436 | [
"def",
"_DefaultValueConstructorForField",
"(",
"field",
")",
":",
"if",
"_IsMapField",
"(",
"field",
")",
":",
"return",
"_GetInitializeDefaultForMap",
"(",
"field",
")",
"if",
"field",
".",
"label",
"==",
"_FieldDescriptor",
".",
"LABEL_REPEATED",
":",
"if",
"... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _ReraiseTypeErrorWithFieldName | Re-raise the currently-handled TypeError with the field name added. | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _ReraiseTypeErrorWithFieldName(message_name, field_name):
"""Re-raise the currently-handled TypeError with the field name added."""
exc = sys.exc_info()[1]
if len(exc.args) == 1 and type(exc) is TypeError:
# simple TypeError; add field name to exception message
exc = TypeError('%s for field %s.%s' % (... | def _ReraiseTypeErrorWithFieldName(message_name, field_name):
"""Re-raise the currently-handled TypeError with the field name added."""
exc = sys.exc_info()[1]
if len(exc.args) == 1 and type(exc) is TypeError:
# simple TypeError; add field name to exception message
exc = TypeError('%s for field %s.%s' % (... | [
"Re",
"-",
"raise",
"the",
"currently",
"-",
"handled",
"TypeError",
"with",
"the",
"field",
"name",
"added",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L439-L447 | [
"def",
"_ReraiseTypeErrorWithFieldName",
"(",
"message_name",
",",
"field_name",
")",
":",
"exc",
"=",
"sys",
".",
"exc_info",
"(",
")",
"[",
"1",
"]",
"if",
"len",
"(",
"exc",
".",
"args",
")",
"==",
"1",
"and",
"type",
"(",
"exc",
")",
"is",
"TypeE... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddInitMethod | Adds an __init__ method to cls. | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddInitMethod(message_descriptor, cls):
"""Adds an __init__ method to cls."""
def _GetIntegerEnumValue(enum_type, value):
"""Convert a string or integer enum value to an integer.
If the value is a string, it is converted to the enum value in
enum_type with the same name. If the value is not a st... | def _AddInitMethod(message_descriptor, cls):
"""Adds an __init__ method to cls."""
def _GetIntegerEnumValue(enum_type, value):
"""Convert a string or integer enum value to an integer.
If the value is a string, it is converted to the enum value in
enum_type with the same name. If the value is not a st... | [
"Adds",
"an",
"__init__",
"method",
"to",
"cls",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L450-L531 | [
"def",
"_AddInitMethod",
"(",
"message_descriptor",
",",
"cls",
")",
":",
"def",
"_GetIntegerEnumValue",
"(",
"enum_type",
",",
"value",
")",
":",
"\"\"\"Convert a string or integer enum value to an integer.\n\n If the value is a string, it is converted to the enum value in\n e... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _GetFieldByName | Returns a field descriptor by field name.
Args:
message_descriptor: A Descriptor describing all fields in message.
field_name: The name of the field to retrieve.
Returns:
The field descriptor associated with the field name. | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _GetFieldByName(message_descriptor, field_name):
"""Returns a field descriptor by field name.
Args:
message_descriptor: A Descriptor describing all fields in message.
field_name: The name of the field to retrieve.
Returns:
The field descriptor associated with the field name.
"""
try:
retu... | def _GetFieldByName(message_descriptor, field_name):
"""Returns a field descriptor by field name.
Args:
message_descriptor: A Descriptor describing all fields in message.
field_name: The name of the field to retrieve.
Returns:
The field descriptor associated with the field name.
"""
try:
retu... | [
"Returns",
"a",
"field",
"descriptor",
"by",
"field",
"name",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L534-L547 | [
"def",
"_GetFieldByName",
"(",
"message_descriptor",
",",
"field_name",
")",
":",
"try",
":",
"return",
"message_descriptor",
".",
"fields_by_name",
"[",
"field_name",
"]",
"except",
"KeyError",
":",
"raise",
"ValueError",
"(",
"'Protocol message %s has no \"%s\" field.... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddPropertiesForFields | Adds properties for all fields in this protocol message type. | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddPropertiesForFields(descriptor, cls):
"""Adds properties for all fields in this protocol message type."""
for field in descriptor.fields:
_AddPropertiesForField(field, cls)
if descriptor.is_extendable:
# _ExtensionDict is just an adaptor with no state so we allocate a new one
# every time it ... | def _AddPropertiesForFields(descriptor, cls):
"""Adds properties for all fields in this protocol message type."""
for field in descriptor.fields:
_AddPropertiesForField(field, cls)
if descriptor.is_extendable:
# _ExtensionDict is just an adaptor with no state so we allocate a new one
# every time it ... | [
"Adds",
"properties",
"for",
"all",
"fields",
"in",
"this",
"protocol",
"message",
"type",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L550-L558 | [
"def",
"_AddPropertiesForFields",
"(",
"descriptor",
",",
"cls",
")",
":",
"for",
"field",
"in",
"descriptor",
".",
"fields",
":",
"_AddPropertiesForField",
"(",
"field",
",",
"cls",
")",
"if",
"descriptor",
".",
"is_extendable",
":",
"# _ExtensionDict is just an ... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddPropertiesForField | Adds a public property for a protocol message field.
Clients can use this property to get and (in the case
of non-repeated scalar fields) directly set the value
of a protocol message field.
Args:
field: A FieldDescriptor for this field.
cls: The class we're constructing. | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddPropertiesForField(field, cls):
"""Adds a public property for a protocol message field.
Clients can use this property to get and (in the case
of non-repeated scalar fields) directly set the value
of a protocol message field.
Args:
field: A FieldDescriptor for this field.
cls: The class we're ... | def _AddPropertiesForField(field, cls):
"""Adds a public property for a protocol message field.
Clients can use this property to get and (in the case
of non-repeated scalar fields) directly set the value
of a protocol message field.
Args:
field: A FieldDescriptor for this field.
cls: The class we're ... | [
"Adds",
"a",
"public",
"property",
"for",
"a",
"protocol",
"message",
"field",
".",
"Clients",
"can",
"use",
"this",
"property",
"to",
"get",
"and",
"(",
"in",
"the",
"case",
"of",
"non",
"-",
"repeated",
"scalar",
"fields",
")",
"directly",
"set",
"the"... | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L561-L583 | [
"def",
"_AddPropertiesForField",
"(",
"field",
",",
"cls",
")",
":",
"# Catch it if we add other types that we should",
"# handle specially here.",
"assert",
"_FieldDescriptor",
".",
"MAX_CPPTYPE",
"==",
"10",
"constant_name",
"=",
"field",
".",
"name",
".",
"upper",
"(... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddPropertiesForRepeatedField | Adds a public property for a "repeated" protocol message field. Clients
can use this property to get the value of the field, which will be either a
_RepeatedScalarFieldContainer or _RepeatedCompositeFieldContainer (see
below).
Note that when clients add values to these containers, we perform
type-checking i... | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddPropertiesForRepeatedField(field, cls):
"""Adds a public property for a "repeated" protocol message field. Clients
can use this property to get the value of the field, which will be either a
_RepeatedScalarFieldContainer or _RepeatedCompositeFieldContainer (see
below).
Note that when clients add val... | def _AddPropertiesForRepeatedField(field, cls):
"""Adds a public property for a "repeated" protocol message field. Clients
can use this property to get the value of the field, which will be either a
_RepeatedScalarFieldContainer or _RepeatedCompositeFieldContainer (see
below).
Note that when clients add val... | [
"Adds",
"a",
"public",
"property",
"for",
"a",
"repeated",
"protocol",
"message",
"field",
".",
"Clients",
"can",
"use",
"this",
"property",
"to",
"get",
"the",
"value",
"of",
"the",
"field",
"which",
"will",
"be",
"either",
"a",
"_RepeatedScalarFieldContainer... | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L586-L627 | [
"def",
"_AddPropertiesForRepeatedField",
"(",
"field",
",",
"cls",
")",
":",
"proto_field_name",
"=",
"field",
".",
"name",
"property_name",
"=",
"_PropertyName",
"(",
"proto_field_name",
")",
"def",
"getter",
"(",
"self",
")",
":",
"field_value",
"=",
"self",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddPropertiesForNonRepeatedScalarField | Adds a public property for a nonrepeated, scalar protocol message field.
Clients can use this property to get and directly set the value of the field.
Note that when the client sets the value of a field by using this property,
all necessary "has" bits are set as a side-effect, and we also perform
type-checking.... | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddPropertiesForNonRepeatedScalarField(field, cls):
"""Adds a public property for a nonrepeated, scalar protocol message field.
Clients can use this property to get and directly set the value of the field.
Note that when the client sets the value of a field by using this property,
all necessary "has" bits ... | def _AddPropertiesForNonRepeatedScalarField(field, cls):
"""Adds a public property for a nonrepeated, scalar protocol message field.
Clients can use this property to get and directly set the value of the field.
Note that when the client sets the value of a field by using this property,
all necessary "has" bits ... | [
"Adds",
"a",
"public",
"property",
"for",
"a",
"nonrepeated",
"scalar",
"protocol",
"message",
"field",
".",
"Clients",
"can",
"use",
"this",
"property",
"to",
"get",
"and",
"directly",
"set",
"the",
"value",
"of",
"the",
"field",
".",
"Note",
"that",
"whe... | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L630-L683 | [
"def",
"_AddPropertiesForNonRepeatedScalarField",
"(",
"field",
",",
"cls",
")",
":",
"proto_field_name",
"=",
"field",
".",
"name",
"property_name",
"=",
"_PropertyName",
"(",
"proto_field_name",
")",
"type_checker",
"=",
"type_checkers",
".",
"GetTypeChecker",
"(",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddPropertiesForExtensions | Adds properties for all fields in this protocol message type. | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddPropertiesForExtensions(descriptor, cls):
"""Adds properties for all fields in this protocol message type."""
extension_dict = descriptor.extensions_by_name
for extension_name, extension_field in extension_dict.items():
constant_name = extension_name.upper() + "_FIELD_NUMBER"
setattr(cls, constant... | def _AddPropertiesForExtensions(descriptor, cls):
"""Adds properties for all fields in this protocol message type."""
extension_dict = descriptor.extensions_by_name
for extension_name, extension_field in extension_dict.items():
constant_name = extension_name.upper() + "_FIELD_NUMBER"
setattr(cls, constant... | [
"Adds",
"properties",
"for",
"all",
"fields",
"in",
"this",
"protocol",
"message",
"type",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L730-L743 | [
"def",
"_AddPropertiesForExtensions",
"(",
"descriptor",
",",
"cls",
")",
":",
"extension_dict",
"=",
"descriptor",
".",
"extensions_by_name",
"for",
"extension_name",
",",
"extension_field",
"in",
"extension_dict",
".",
"items",
"(",
")",
":",
"constant_name",
"=",... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _IsPresent | Given a (FieldDescriptor, value) tuple from _fields, return true if the
value should be included in the list returned by ListFields(). | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _IsPresent(item):
"""Given a (FieldDescriptor, value) tuple from _fields, return true if the
value should be included in the list returned by ListFields()."""
if item[0].label == _FieldDescriptor.LABEL_REPEATED:
return bool(item[1])
elif item[0].cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
return ... | def _IsPresent(item):
"""Given a (FieldDescriptor, value) tuple from _fields, return true if the
value should be included in the list returned by ListFields()."""
if item[0].label == _FieldDescriptor.LABEL_REPEATED:
return bool(item[1])
elif item[0].cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
return ... | [
"Given",
"a",
"(",
"FieldDescriptor",
"value",
")",
"tuple",
"from",
"_fields",
"return",
"true",
"if",
"the",
"value",
"should",
"be",
"included",
"in",
"the",
"list",
"returned",
"by",
"ListFields",
"()",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L761-L770 | [
"def",
"_IsPresent",
"(",
"item",
")",
":",
"if",
"item",
"[",
"0",
"]",
".",
"label",
"==",
"_FieldDescriptor",
".",
"LABEL_REPEATED",
":",
"return",
"bool",
"(",
"item",
"[",
"1",
"]",
")",
"elif",
"item",
"[",
"0",
"]",
".",
"cpp_type",
"==",
"_... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddListFieldsMethod | Helper for _AddMessageMethods(). | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddListFieldsMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
def ListFields(self):
all_fields = [item for item in self._fields.items() if _IsPresent(item)]
all_fields.sort(key = lambda item: item[0].number)
return all_fields
cls.ListFields = ListFields | def _AddListFieldsMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
def ListFields(self):
all_fields = [item for item in self._fields.items() if _IsPresent(item)]
all_fields.sort(key = lambda item: item[0].number)
return all_fields
cls.ListFields = ListFields | [
"Helper",
"for",
"_AddMessageMethods",
"()",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L773-L781 | [
"def",
"_AddListFieldsMethod",
"(",
"message_descriptor",
",",
"cls",
")",
":",
"def",
"ListFields",
"(",
"self",
")",
":",
"all_fields",
"=",
"[",
"item",
"for",
"item",
"in",
"self",
".",
"_fields",
".",
"items",
"(",
")",
"if",
"_IsPresent",
"(",
"ite... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddHasFieldMethod | Helper for _AddMessageMethods(). | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddHasFieldMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
is_proto3 = (message_descriptor.syntax == "proto3")
error_msg = _Proto3HasError if is_proto3 else _Proto2HasError
hassable_fields = {}
for field in message_descriptor.fields:
if field.label == _FieldDescriptor.LABEL_... | def _AddHasFieldMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
is_proto3 = (message_descriptor.syntax == "proto3")
error_msg = _Proto3HasError if is_proto3 else _Proto2HasError
hassable_fields = {}
for field in message_descriptor.fields:
if field.label == _FieldDescriptor.LABEL_... | [
"Helper",
"for",
"_AddMessageMethods",
"()",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L786-L825 | [
"def",
"_AddHasFieldMethod",
"(",
"message_descriptor",
",",
"cls",
")",
":",
"is_proto3",
"=",
"(",
"message_descriptor",
".",
"syntax",
"==",
"\"proto3\"",
")",
"error_msg",
"=",
"_Proto3HasError",
"if",
"is_proto3",
"else",
"_Proto2HasError",
"hassable_fields",
"... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddClearFieldMethod | Helper for _AddMessageMethods(). | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddClearFieldMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
def ClearField(self, field_name):
try:
field = message_descriptor.fields_by_name[field_name]
except KeyError:
try:
field = message_descriptor.oneofs_by_name[field_name]
if field in self._one... | def _AddClearFieldMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
def ClearField(self, field_name):
try:
field = message_descriptor.fields_by_name[field_name]
except KeyError:
try:
field = message_descriptor.oneofs_by_name[field_name]
if field in self._one... | [
"Helper",
"for",
"_AddMessageMethods",
"()",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L828-L863 | [
"def",
"_AddClearFieldMethod",
"(",
"message_descriptor",
",",
"cls",
")",
":",
"def",
"ClearField",
"(",
"self",
",",
"field_name",
")",
":",
"try",
":",
"field",
"=",
"message_descriptor",
".",
"fields_by_name",
"[",
"field_name",
"]",
"except",
"KeyError",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddClearExtensionMethod | Helper for _AddMessageMethods(). | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddClearExtensionMethod(cls):
"""Helper for _AddMessageMethods()."""
def ClearExtension(self, extension_handle):
_VerifyExtensionHandle(self, extension_handle)
# Similar to ClearField(), above.
if extension_handle in self._fields:
del self._fields[extension_handle]
self._Modified()
cls... | def _AddClearExtensionMethod(cls):
"""Helper for _AddMessageMethods()."""
def ClearExtension(self, extension_handle):
_VerifyExtensionHandle(self, extension_handle)
# Similar to ClearField(), above.
if extension_handle in self._fields:
del self._fields[extension_handle]
self._Modified()
cls... | [
"Helper",
"for",
"_AddMessageMethods",
"()",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L866-L875 | [
"def",
"_AddClearExtensionMethod",
"(",
"cls",
")",
":",
"def",
"ClearExtension",
"(",
"self",
",",
"extension_handle",
")",
":",
"_VerifyExtensionHandle",
"(",
"self",
",",
"extension_handle",
")",
"# Similar to ClearField(), above.",
"if",
"extension_handle",
"in",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddHasExtensionMethod | Helper for _AddMessageMethods(). | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddHasExtensionMethod(cls):
"""Helper for _AddMessageMethods()."""
def HasExtension(self, extension_handle):
_VerifyExtensionHandle(self, extension_handle)
if extension_handle.label == _FieldDescriptor.LABEL_REPEATED:
raise KeyError('"%s" is repeated.' % extension_handle.full_name)
if extens... | def _AddHasExtensionMethod(cls):
"""Helper for _AddMessageMethods()."""
def HasExtension(self, extension_handle):
_VerifyExtensionHandle(self, extension_handle)
if extension_handle.label == _FieldDescriptor.LABEL_REPEATED:
raise KeyError('"%s" is repeated.' % extension_handle.full_name)
if extens... | [
"Helper",
"for",
"_AddMessageMethods",
"()",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L878-L890 | [
"def",
"_AddHasExtensionMethod",
"(",
"cls",
")",
":",
"def",
"HasExtension",
"(",
"self",
",",
"extension_handle",
")",
":",
"_VerifyExtensionHandle",
"(",
"self",
",",
"extension_handle",
")",
"if",
"extension_handle",
".",
"label",
"==",
"_FieldDescriptor",
"."... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _InternalUnpackAny | Unpacks Any message and returns the unpacked message.
This internal method is different from public Any Unpack method which takes
the target message as argument. _InternalUnpackAny method does not have
target message type and need to find the message type in descriptor pool.
Args:
msg: An Any message to b... | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _InternalUnpackAny(msg):
"""Unpacks Any message and returns the unpacked message.
This internal method is different from public Any Unpack method which takes
the target message as argument. _InternalUnpackAny method does not have
target message type and need to find the message type in descriptor pool.
... | def _InternalUnpackAny(msg):
"""Unpacks Any message and returns the unpacked message.
This internal method is different from public Any Unpack method which takes
the target message as argument. _InternalUnpackAny method does not have
target message type and need to find the message type in descriptor pool.
... | [
"Unpacks",
"Any",
"message",
"and",
"returns",
"the",
"unpacked",
"message",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L892-L929 | [
"def",
"_InternalUnpackAny",
"(",
"msg",
")",
":",
"# TODO(amauryfa): Don't use the factory of generated messages.",
"# To make Any work with custom factories, use the message factory of the",
"# parent message.",
"# pylint: disable=g-import-not-at-top",
"from",
"google",
".",
"protobuf",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddEqualsMethod | Helper for _AddMessageMethods(). | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddEqualsMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
def __eq__(self, other):
if (not isinstance(other, message_mod.Message) or
other.DESCRIPTOR != self.DESCRIPTOR):
return False
if self is other:
return True
if self.DESCRIPTOR.full_name == _AnyFull... | def _AddEqualsMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
def __eq__(self, other):
if (not isinstance(other, message_mod.Message) or
other.DESCRIPTOR != self.DESCRIPTOR):
return False
if self is other:
return True
if self.DESCRIPTOR.full_name == _AnyFull... | [
"Helper",
"for",
"_AddMessageMethods",
"()",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L932-L959 | [
"def",
"_AddEqualsMethod",
"(",
"message_descriptor",
",",
"cls",
")",
":",
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"if",
"(",
"not",
"isinstance",
"(",
"other",
",",
"message_mod",
".",
"Message",
")",
"or",
"other",
".",
"DESCRIPTOR",
"!=... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddStrMethod | Helper for _AddMessageMethods(). | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddStrMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
def __str__(self):
return text_format.MessageToString(self)
cls.__str__ = __str__ | def _AddStrMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
def __str__(self):
return text_format.MessageToString(self)
cls.__str__ = __str__ | [
"Helper",
"for",
"_AddMessageMethods",
"()",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L962-L966 | [
"def",
"_AddStrMethod",
"(",
"message_descriptor",
",",
"cls",
")",
":",
"def",
"__str__",
"(",
"self",
")",
":",
"return",
"text_format",
".",
"MessageToString",
"(",
"self",
")",
"cls",
".",
"__str__",
"=",
"__str__"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddReprMethod | Helper for _AddMessageMethods(). | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddReprMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
def __repr__(self):
return text_format.MessageToString(self)
cls.__repr__ = __repr__ | def _AddReprMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
def __repr__(self):
return text_format.MessageToString(self)
cls.__repr__ = __repr__ | [
"Helper",
"for",
"_AddMessageMethods",
"()",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L969-L973 | [
"def",
"_AddReprMethod",
"(",
"message_descriptor",
",",
"cls",
")",
":",
"def",
"__repr__",
"(",
"self",
")",
":",
"return",
"text_format",
".",
"MessageToString",
"(",
"self",
")",
"cls",
".",
"__repr__",
"=",
"__repr__"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddUnicodeMethod | Helper for _AddMessageMethods(). | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddUnicodeMethod(unused_message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
def __unicode__(self):
return text_format.MessageToString(self, as_utf8=True).decode('utf-8')
cls.__unicode__ = __unicode__ | def _AddUnicodeMethod(unused_message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
def __unicode__(self):
return text_format.MessageToString(self, as_utf8=True).decode('utf-8')
cls.__unicode__ = __unicode__ | [
"Helper",
"for",
"_AddMessageMethods",
"()",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L976-L981 | [
"def",
"_AddUnicodeMethod",
"(",
"unused_message_descriptor",
",",
"cls",
")",
":",
"def",
"__unicode__",
"(",
"self",
")",
":",
"return",
"text_format",
".",
"MessageToString",
"(",
"self",
",",
"as_utf8",
"=",
"True",
")",
".",
"decode",
"(",
"'utf-8'",
")... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _BytesForNonRepeatedElement | Returns the number of bytes needed to serialize a non-repeated element.
The returned byte count includes space for tag information and any
other additional space associated with serializing value.
Args:
value: Value we're serializing.
field_number: Field number of this value. (Since the field number
... | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _BytesForNonRepeatedElement(value, field_number, field_type):
"""Returns the number of bytes needed to serialize a non-repeated element.
The returned byte count includes space for tag information and any
other additional space associated with serializing value.
Args:
value: Value we're serializing.
... | def _BytesForNonRepeatedElement(value, field_number, field_type):
"""Returns the number of bytes needed to serialize a non-repeated element.
The returned byte count includes space for tag information and any
other additional space associated with serializing value.
Args:
value: Value we're serializing.
... | [
"Returns",
"the",
"number",
"of",
"bytes",
"needed",
"to",
"serialize",
"a",
"non",
"-",
"repeated",
"element",
".",
"The",
"returned",
"byte",
"count",
"includes",
"space",
"for",
"tag",
"information",
"and",
"any",
"other",
"additional",
"space",
"associated... | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L984-L1001 | [
"def",
"_BytesForNonRepeatedElement",
"(",
"value",
",",
"field_number",
",",
"field_type",
")",
":",
"try",
":",
"fn",
"=",
"type_checkers",
".",
"TYPE_TO_BYTE_SIZE_FN",
"[",
"field_type",
"]",
"return",
"fn",
"(",
"field_number",
",",
"value",
")",
"except",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddByteSizeMethod | Helper for _AddMessageMethods(). | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddByteSizeMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
def ByteSize(self):
if not self._cached_byte_size_dirty:
return self._cached_byte_size
size = 0
for field_descriptor, field_value in self.ListFields():
size += field_descriptor._sizer(field_value)
... | def _AddByteSizeMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
def ByteSize(self):
if not self._cached_byte_size_dirty:
return self._cached_byte_size
size = 0
for field_descriptor, field_value in self.ListFields():
size += field_descriptor._sizer(field_value)
... | [
"Helper",
"for",
"_AddMessageMethods",
"()",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L1004-L1023 | [
"def",
"_AddByteSizeMethod",
"(",
"message_descriptor",
",",
"cls",
")",
":",
"def",
"ByteSize",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_cached_byte_size_dirty",
":",
"return",
"self",
".",
"_cached_byte_size",
"size",
"=",
"0",
"for",
"field_descri... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddSerializeToStringMethod | Helper for _AddMessageMethods(). | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddSerializeToStringMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
def SerializeToString(self):
# Check if the message has all of its required fields set.
errors = []
if not self.IsInitialized():
raise message_mod.EncodeError(
'Message %s is missing require... | def _AddSerializeToStringMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
def SerializeToString(self):
# Check if the message has all of its required fields set.
errors = []
if not self.IsInitialized():
raise message_mod.EncodeError(
'Message %s is missing require... | [
"Helper",
"for",
"_AddMessageMethods",
"()",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L1026-L1037 | [
"def",
"_AddSerializeToStringMethod",
"(",
"message_descriptor",
",",
"cls",
")",
":",
"def",
"SerializeToString",
"(",
"self",
")",
":",
"# Check if the message has all of its required fields set.",
"errors",
"=",
"[",
"]",
"if",
"not",
"self",
".",
"IsInitialized",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddSerializePartialToStringMethod | Helper for _AddMessageMethods(). | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddSerializePartialToStringMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
def SerializePartialToString(self):
out = BytesIO()
self._InternalSerialize(out.write)
return out.getvalue()
cls.SerializePartialToString = SerializePartialToString
def InternalSerialize(self, w... | def _AddSerializePartialToStringMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
def SerializePartialToString(self):
out = BytesIO()
self._InternalSerialize(out.write)
return out.getvalue()
cls.SerializePartialToString = SerializePartialToString
def InternalSerialize(self, w... | [
"Helper",
"for",
"_AddMessageMethods",
"()",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L1040-L1055 | [
"def",
"_AddSerializePartialToStringMethod",
"(",
"message_descriptor",
",",
"cls",
")",
":",
"def",
"SerializePartialToString",
"(",
"self",
")",
":",
"out",
"=",
"BytesIO",
"(",
")",
"self",
".",
"_InternalSerialize",
"(",
"out",
".",
"write",
")",
"return",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddMergeFromStringMethod | Helper for _AddMessageMethods(). | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddMergeFromStringMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
def MergeFromString(self, serialized):
length = len(serialized)
try:
if self._InternalParse(serialized, 0, length) != length:
# The only reason _InternalParse would return early is if it
# en... | def _AddMergeFromStringMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
def MergeFromString(self, serialized):
length = len(serialized)
try:
if self._InternalParse(serialized, 0, length) != length:
# The only reason _InternalParse would return early is if it
# en... | [
"Helper",
"for",
"_AddMessageMethods",
"()",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L1058-L1103 | [
"def",
"_AddMergeFromStringMethod",
"(",
"message_descriptor",
",",
"cls",
")",
":",
"def",
"MergeFromString",
"(",
"self",
",",
"serialized",
")",
":",
"length",
"=",
"len",
"(",
"serialized",
")",
"try",
":",
"if",
"self",
".",
"_InternalParse",
"(",
"seri... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddIsInitializedMethod | Adds the IsInitialized and FindInitializationError methods to the
protocol message class. | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddIsInitializedMethod(message_descriptor, cls):
"""Adds the IsInitialized and FindInitializationError methods to the
protocol message class."""
required_fields = [field for field in message_descriptor.fields
if field.label == _FieldDescriptor.LABEL_REQUIRED]
def IsInitialized(... | def _AddIsInitializedMethod(message_descriptor, cls):
"""Adds the IsInitialized and FindInitializationError methods to the
protocol message class."""
required_fields = [field for field in message_descriptor.fields
if field.label == _FieldDescriptor.LABEL_REQUIRED]
def IsInitialized(... | [
"Adds",
"the",
"IsInitialized",
"and",
"FindInitializationError",
"methods",
"to",
"the",
"protocol",
"message",
"class",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L1106-L1198 | [
"def",
"_AddIsInitializedMethod",
"(",
"message_descriptor",
",",
"cls",
")",
":",
"required_fields",
"=",
"[",
"field",
"for",
"field",
"in",
"message_descriptor",
".",
"fields",
"if",
"field",
".",
"label",
"==",
"_FieldDescriptor",
".",
"LABEL_REQUIRED",
"]",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddMessageMethods | Adds implementations of all Message methods to cls. | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddMessageMethods(message_descriptor, cls):
"""Adds implementations of all Message methods to cls."""
_AddListFieldsMethod(message_descriptor, cls)
_AddHasFieldMethod(message_descriptor, cls)
_AddClearFieldMethod(message_descriptor, cls)
if message_descriptor.is_extendable:
_AddClearExtensionMethod(c... | def _AddMessageMethods(message_descriptor, cls):
"""Adds implementations of all Message methods to cls."""
_AddListFieldsMethod(message_descriptor, cls)
_AddHasFieldMethod(message_descriptor, cls)
_AddClearFieldMethod(message_descriptor, cls)
if message_descriptor.is_extendable:
_AddClearExtensionMethod(c... | [
"Adds",
"implementations",
"of",
"all",
"Message",
"methods",
"to",
"cls",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L1295-L1318 | [
"def",
"_AddMessageMethods",
"(",
"message_descriptor",
",",
"cls",
")",
":",
"_AddListFieldsMethod",
"(",
"message_descriptor",
",",
"cls",
")",
"_AddHasFieldMethod",
"(",
"message_descriptor",
",",
"cls",
")",
"_AddClearFieldMethod",
"(",
"message_descriptor",
",",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _AddPrivateHelperMethods | Adds implementation of private helper methods to cls. | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def _AddPrivateHelperMethods(message_descriptor, cls):
"""Adds implementation of private helper methods to cls."""
def Modified(self):
"""Sets the _cached_byte_size_dirty bit to true,
and propagates this to our listener iff this was a state change.
"""
# Note: Some callers check _cached_byte_size... | def _AddPrivateHelperMethods(message_descriptor, cls):
"""Adds implementation of private helper methods to cls."""
def Modified(self):
"""Sets the _cached_byte_size_dirty bit to true,
and propagates this to our listener iff this was a state change.
"""
# Note: Some callers check _cached_byte_size... | [
"Adds",
"implementation",
"of",
"private",
"helper",
"methods",
"to",
"cls",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L1321-L1352 | [
"def",
"_AddPrivateHelperMethods",
"(",
"message_descriptor",
",",
"cls",
")",
":",
"def",
"Modified",
"(",
"self",
")",
":",
"\"\"\"Sets the _cached_byte_size_dirty bit to true,\n and propagates this to our listener iff this was a state change.\n \"\"\"",
"# Note: Some callers ... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _OneofListener.Modified | Also updates the state of the containing oneof in the parent message. | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py | def Modified(self):
"""Also updates the state of the containing oneof in the parent message."""
try:
self._parent_message_weakref._UpdateOneofState(self._field)
super(_OneofListener, self).Modified()
except ReferenceError:
pass | def Modified(self):
"""Also updates the state of the containing oneof in the parent message."""
try:
self._parent_message_weakref._UpdateOneofState(self._field)
super(_OneofListener, self).Modified()
except ReferenceError:
pass | [
"Also",
"updates",
"the",
"state",
"of",
"the",
"containing",
"oneof",
"in",
"the",
"parent",
"message",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L1413-L1419 | [
"def",
"Modified",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_parent_message_weakref",
".",
"_UpdateOneofState",
"(",
"self",
".",
"_field",
")",
"super",
"(",
"_OneofListener",
",",
"self",
")",
".",
"Modified",
"(",
")",
"except",
"ReferenceError",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | EnumTypeWrapper.Name | Returns a string containing the name of an enum value. | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/enum_type_wrapper.py | def Name(self, number):
"""Returns a string containing the name of an enum value."""
if number in self._enum_type.values_by_number:
return self._enum_type.values_by_number[number].name
raise ValueError('Enum %s has no name defined for value %d' % (
self._enum_type.name, number)) | def Name(self, number):
"""Returns a string containing the name of an enum value."""
if number in self._enum_type.values_by_number:
return self._enum_type.values_by_number[number].name
raise ValueError('Enum %s has no name defined for value %d' % (
self._enum_type.name, number)) | [
"Returns",
"a",
"string",
"containing",
"the",
"name",
"of",
"an",
"enum",
"value",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/enum_type_wrapper.py#L51-L56 | [
"def",
"Name",
"(",
"self",
",",
"number",
")",
":",
"if",
"number",
"in",
"self",
".",
"_enum_type",
".",
"values_by_number",
":",
"return",
"self",
".",
"_enum_type",
".",
"values_by_number",
"[",
"number",
"]",
".",
"name",
"raise",
"ValueError",
"(",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | EnumTypeWrapper.Value | Returns the value coresponding to the given enum name. | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/enum_type_wrapper.py | def Value(self, name):
"""Returns the value coresponding to the given enum name."""
if name in self._enum_type.values_by_name:
return self._enum_type.values_by_name[name].number
raise ValueError('Enum %s has no value defined for name %s' % (
self._enum_type.name, name)) | def Value(self, name):
"""Returns the value coresponding to the given enum name."""
if name in self._enum_type.values_by_name:
return self._enum_type.values_by_name[name].number
raise ValueError('Enum %s has no value defined for name %s' % (
self._enum_type.name, name)) | [
"Returns",
"the",
"value",
"coresponding",
"to",
"the",
"given",
"enum",
"name",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/enum_type_wrapper.py#L58-L63 | [
"def",
"Value",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"_enum_type",
".",
"values_by_name",
":",
"return",
"self",
".",
"_enum_type",
".",
"values_by_name",
"[",
"name",
"]",
".",
"number",
"raise",
"ValueError",
"(",
"'Enum... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | EnumTypeWrapper.items | Return a list of the (name, value) pairs of the enum.
These are returned in the order they were defined in the .proto file. | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/enum_type_wrapper.py | def items(self):
"""Return a list of the (name, value) pairs of the enum.
These are returned in the order they were defined in the .proto file.
"""
return [(value_descriptor.name, value_descriptor.number)
for value_descriptor in self._enum_type.values] | def items(self):
"""Return a list of the (name, value) pairs of the enum.
These are returned in the order they were defined in the .proto file.
"""
return [(value_descriptor.name, value_descriptor.number)
for value_descriptor in self._enum_type.values] | [
"Return",
"a",
"list",
"of",
"the",
"(",
"name",
"value",
")",
"pairs",
"of",
"the",
"enum",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/enum_type_wrapper.py#L83-L89 | [
"def",
"items",
"(",
"self",
")",
":",
"return",
"[",
"(",
"value_descriptor",
".",
"name",
",",
"value_descriptor",
".",
"number",
")",
"for",
"value_descriptor",
"in",
"self",
".",
"_enum_type",
".",
"values",
"]"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | _load_tcmps_lib | Load global singleton of tcmps lib handler.
This function is used not used at the top level, so
that the shared library is loaded lazily only when needed. | src/unity/python/turicreate/toolkits/_mps_utils.py | def _load_tcmps_lib():
"""
Load global singleton of tcmps lib handler.
This function is used not used at the top level, so
that the shared library is loaded lazily only when needed.
"""
global _g_TCMPS_LIB
if _g_TCMPS_LIB is None:
# This library requires macOS 10.14 or above
... | def _load_tcmps_lib():
"""
Load global singleton of tcmps lib handler.
This function is used not used at the top level, so
that the shared library is loaded lazily only when needed.
"""
global _g_TCMPS_LIB
if _g_TCMPS_LIB is None:
# This library requires macOS 10.14 or above
... | [
"Load",
"global",
"singleton",
"of",
"tcmps",
"lib",
"handler",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_mps_utils.py#L141-L164 | [
"def",
"_load_tcmps_lib",
"(",
")",
":",
"global",
"_g_TCMPS_LIB",
"if",
"_g_TCMPS_LIB",
"is",
"None",
":",
"# This library requires macOS 10.14 or above",
"if",
"_mac_ver",
"(",
")",
"<",
"(",
"10",
",",
"14",
")",
":",
"return",
"None",
"# The symbols defined in... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | has_fast_mps_support | Returns True if the environment has MPS backend support
and a high-power (fast) device is available. | src/unity/python/turicreate/toolkits/_mps_utils.py | def has_fast_mps_support():
"""
Returns True if the environment has MPS backend support
and a high-power (fast) device is available.
"""
lib = _load_tcmps_lib()
if lib is None:
return False
c_bool = _ctypes.c_bool()
ret = lib.TCMPSHasHighPowerMetalDevice(_ctypes.byref(c_bool))
... | def has_fast_mps_support():
"""
Returns True if the environment has MPS backend support
and a high-power (fast) device is available.
"""
lib = _load_tcmps_lib()
if lib is None:
return False
c_bool = _ctypes.c_bool()
ret = lib.TCMPSHasHighPowerMetalDevice(_ctypes.byref(c_bool))
... | [
"Returns",
"True",
"if",
"the",
"environment",
"has",
"MPS",
"backend",
"support",
"and",
"a",
"high",
"-",
"power",
"(",
"fast",
")",
"device",
"is",
"available",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_mps_utils.py#L167-L178 | [
"def",
"has_fast_mps_support",
"(",
")",
":",
"lib",
"=",
"_load_tcmps_lib",
"(",
")",
"if",
"lib",
"is",
"None",
":",
"return",
"False",
"c_bool",
"=",
"_ctypes",
".",
"c_bool",
"(",
")",
"ret",
"=",
"lib",
".",
"TCMPSHasHighPowerMetalDevice",
"(",
"_ctyp... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | mps_device_name | Returns name of MPS device that will be used, else None. | src/unity/python/turicreate/toolkits/_mps_utils.py | def mps_device_name():
"""
Returns name of MPS device that will be used, else None.
"""
lib = _load_tcmps_lib()
if lib is None:
return None
n = 256
c_name = (_ctypes.c_char * n)()
ret = lib.TCMPSMetalDeviceName(_ctypes.byref(c_name), _ctypes.c_int32(n))
if ret == 0:
... | def mps_device_name():
"""
Returns name of MPS device that will be used, else None.
"""
lib = _load_tcmps_lib()
if lib is None:
return None
n = 256
c_name = (_ctypes.c_char * n)()
ret = lib.TCMPSMetalDeviceName(_ctypes.byref(c_name), _ctypes.c_int32(n))
if ret == 0:
... | [
"Returns",
"name",
"of",
"MPS",
"device",
"that",
"will",
"be",
"used",
"else",
"None",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_mps_utils.py#L188-L202 | [
"def",
"mps_device_name",
"(",
")",
":",
"lib",
"=",
"_load_tcmps_lib",
"(",
")",
"if",
"lib",
"is",
"None",
":",
"return",
"None",
"n",
"=",
"256",
"c_name",
"=",
"(",
"_ctypes",
".",
"c_char",
"*",
"n",
")",
"(",
")",
"ret",
"=",
"lib",
".",
"T... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | mps_device_memory_limit | Returns the memory size in bytes that can be effectively allocated on the
MPS device that will be used, or None if no suitable device is available. | src/unity/python/turicreate/toolkits/_mps_utils.py | def mps_device_memory_limit():
"""
Returns the memory size in bytes that can be effectively allocated on the
MPS device that will be used, or None if no suitable device is available.
"""
lib = _load_tcmps_lib()
if lib is None:
return None
c_size = _ctypes.c_uint64()
ret = lib.TC... | def mps_device_memory_limit():
"""
Returns the memory size in bytes that can be effectively allocated on the
MPS device that will be used, or None if no suitable device is available.
"""
lib = _load_tcmps_lib()
if lib is None:
return None
c_size = _ctypes.c_uint64()
ret = lib.TC... | [
"Returns",
"the",
"memory",
"size",
"in",
"bytes",
"that",
"can",
"be",
"effectively",
"allocated",
"on",
"the",
"MPS",
"device",
"that",
"will",
"be",
"used",
"or",
"None",
"if",
"no",
"suitable",
"device",
"is",
"available",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_mps_utils.py#L205-L216 | [
"def",
"mps_device_memory_limit",
"(",
")",
":",
"lib",
"=",
"_load_tcmps_lib",
"(",
")",
"if",
"lib",
"is",
"None",
":",
"return",
"None",
"c_size",
"=",
"_ctypes",
".",
"c_uint64",
"(",
")",
"ret",
"=",
"lib",
".",
"TCMPSMetalDeviceMemoryLimit",
"(",
"_c... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | MpsFloatArray.shape | Copy the shape from TCMPS as a new numpy ndarray. | src/unity/python/turicreate/toolkits/_mps_utils.py | def shape(self):
"""Copy the shape from TCMPS as a new numpy ndarray."""
# Create C variables that will serve as out parameters for TCMPS.
shape_ptr = _ctypes.POINTER(_ctypes.c_size_t)() # size_t* shape_ptr
dim = _ctypes.c_size_t() # size_t dim
# Obtain... | def shape(self):
"""Copy the shape from TCMPS as a new numpy ndarray."""
# Create C variables that will serve as out parameters for TCMPS.
shape_ptr = _ctypes.POINTER(_ctypes.c_size_t)() # size_t* shape_ptr
dim = _ctypes.c_size_t() # size_t dim
# Obtain... | [
"Copy",
"the",
"shape",
"from",
"TCMPS",
"as",
"a",
"new",
"numpy",
"ndarray",
"."
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_mps_utils.py#L314-L326 | [
"def",
"shape",
"(",
"self",
")",
":",
"# Create C variables that will serve as out parameters for TCMPS.",
"shape_ptr",
"=",
"_ctypes",
".",
"POINTER",
"(",
"_ctypes",
".",
"c_size_t",
")",
"(",
")",
"# size_t* shape_ptr",
"dim",
"=",
"_ctypes",
".",
"c_size_t",
"(... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | MpsFloatArray.asnumpy | Copy the data from TCMPS into a new numpy ndarray | src/unity/python/turicreate/toolkits/_mps_utils.py | def asnumpy(self):
"""Copy the data from TCMPS into a new numpy ndarray"""
# Create C variables that will serve as out parameters for TCMPS.
data_ptr = _ctypes.POINTER(_ctypes.c_float)() # float* data_ptr
shape_ptr = _ctypes.POINTER(_ctypes.c_size_t)() # size_t* shape_ptr
di... | def asnumpy(self):
"""Copy the data from TCMPS into a new numpy ndarray"""
# Create C variables that will serve as out parameters for TCMPS.
data_ptr = _ctypes.POINTER(_ctypes.c_float)() # float* data_ptr
shape_ptr = _ctypes.POINTER(_ctypes.c_size_t)() # size_t* shape_ptr
di... | [
"Copy",
"the",
"data",
"from",
"TCMPS",
"into",
"a",
"new",
"numpy",
"ndarray"
] | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_mps_utils.py#L328-L344 | [
"def",
"asnumpy",
"(",
"self",
")",
":",
"# Create C variables that will serve as out parameters for TCMPS.",
"data_ptr",
"=",
"_ctypes",
".",
"POINTER",
"(",
"_ctypes",
".",
"c_float",
")",
"(",
")",
"# float* data_ptr",
"shape_ptr",
"=",
"_ctypes",
".",
"POINTER",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | MpsGraphAPI.train | Submits an input batch to the model. Returns a MpsFloatArray
representing the batch loss. Calling asnumpy() on this value will wait
for the batch to finish and yield the loss as a numpy array. | src/unity/python/turicreate/toolkits/_mps_utils.py | def train(self, input, label):
"""
Submits an input batch to the model. Returns a MpsFloatArray
representing the batch loss. Calling asnumpy() on this value will wait
for the batch to finish and yield the loss as a numpy array.
"""
assert self._mode == MpsGraphMode.Train... | def train(self, input, label):
"""
Submits an input batch to the model. Returns a MpsFloatArray
representing the batch loss. Calling asnumpy() on this value will wait
for the batch to finish and yield the loss as a numpy array.
"""
assert self._mode == MpsGraphMode.Train... | [
"Submits",
"an",
"input",
"batch",
"to",
"the",
"model",
".",
"Returns",
"a",
"MpsFloatArray",
"representing",
"the",
"batch",
"loss",
".",
"Calling",
"asnumpy",
"()",
"on",
"this",
"value",
"will",
"wait",
"for",
"the",
"batch",
"to",
"finish",
"and",
"yi... | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_mps_utils.py#L463-L490 | [
"def",
"train",
"(",
"self",
",",
"input",
",",
"label",
")",
":",
"assert",
"self",
".",
"_mode",
"==",
"MpsGraphMode",
".",
"Train",
"assert",
"input",
".",
"shape",
"==",
"self",
".",
"_ishape",
"assert",
"label",
".",
"shape",
"==",
"self",
".",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | MpsGraphAPI.predict | Submits an input batch to the model. Returns a MpsFloatArray
representing the model predictions. Calling asnumpy() on this value will
wait for the batch to finish and yield the predictions as a numpy array. | src/unity/python/turicreate/toolkits/_mps_utils.py | def predict(self, input):
"""
Submits an input batch to the model. Returns a MpsFloatArray
representing the model predictions. Calling asnumpy() on this value will
wait for the batch to finish and yield the predictions as a numpy array.
"""
assert self._mode == MpsGraphM... | def predict(self, input):
"""
Submits an input batch to the model. Returns a MpsFloatArray
representing the model predictions. Calling asnumpy() on this value will
wait for the batch to finish and yield the predictions as a numpy array.
"""
assert self._mode == MpsGraphM... | [
"Submits",
"an",
"input",
"batch",
"to",
"the",
"model",
".",
"Returns",
"a",
"MpsFloatArray",
"representing",
"the",
"model",
"predictions",
".",
"Calling",
"asnumpy",
"()",
"on",
"this",
"value",
"will",
"wait",
"for",
"the",
"batch",
"to",
"finish",
"and"... | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_mps_utils.py#L492-L513 | [
"def",
"predict",
"(",
"self",
",",
"input",
")",
":",
"assert",
"self",
".",
"_mode",
"==",
"MpsGraphMode",
".",
"Inference",
"assert",
"input",
".",
"shape",
"==",
"self",
".",
"_ishape",
"input_array",
"=",
"MpsFloatArray",
"(",
"input",
")",
"result_ha... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | MpsGraphAPI.train_return_grad | Performs a forward pass from the input batch, followed by a backward
pass using the provided gradient (in place of a loss function). Returns
a MpsFloatArray representing the output (final gradient) of the backward
pass. Calling asnumpy() on this value will wait for the batch to finish
an... | src/unity/python/turicreate/toolkits/_mps_utils.py | def train_return_grad(self, input, grad):
"""
Performs a forward pass from the input batch, followed by a backward
pass using the provided gradient (in place of a loss function). Returns
a MpsFloatArray representing the output (final gradient) of the backward
pass. Calling asnump... | def train_return_grad(self, input, grad):
"""
Performs a forward pass from the input batch, followed by a backward
pass using the provided gradient (in place of a loss function). Returns
a MpsFloatArray representing the output (final gradient) of the backward
pass. Calling asnump... | [
"Performs",
"a",
"forward",
"pass",
"from",
"the",
"input",
"batch",
"followed",
"by",
"a",
"backward",
"pass",
"using",
"the",
"provided",
"gradient",
"(",
"in",
"place",
"of",
"a",
"loss",
"function",
")",
".",
"Returns",
"a",
"MpsFloatArray",
"representin... | apple/turicreate | python | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_mps_utils.py#L515-L541 | [
"def",
"train_return_grad",
"(",
"self",
",",
"input",
",",
"grad",
")",
":",
"assert",
"self",
".",
"_mode",
"==",
"MpsGraphMode",
".",
"TrainReturnGrad",
"assert",
"input",
".",
"shape",
"==",
"self",
".",
"_ishape",
"assert",
"grad",
".",
"shape",
"==",... | 74514c3f99e25b46f22c6e02977fe3da69221c2e |
train | route_sns_task | Gets SNS Message, deserialises the message,
imports the function, calls the function with args | zappa/asynchronous.py | def route_sns_task(event, context):
"""
Gets SNS Message, deserialises the message,
imports the function, calls the function with args
"""
record = event['Records'][0]
message = json.loads(
record['Sns']['Message']
)
return run_message(message) | def route_sns_task(event, context):
"""
Gets SNS Message, deserialises the message,
imports the function, calls the function with args
"""
record = event['Records'][0]
message = json.loads(
record['Sns']['Message']
)
return run_message(message) | [
"Gets",
"SNS",
"Message",
"deserialises",
"the",
"message",
"imports",
"the",
"function",
"calls",
"the",
"function",
"with",
"args"
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/asynchronous.py#L275-L284 | [
"def",
"route_sns_task",
"(",
"event",
",",
"context",
")",
":",
"record",
"=",
"event",
"[",
"'Records'",
"]",
"[",
"0",
"]",
"message",
"=",
"json",
".",
"loads",
"(",
"record",
"[",
"'Sns'",
"]",
"[",
"'Message'",
"]",
")",
"return",
"run_message",
... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | run_message | Runs a function defined by a message object with keys:
'task_path', 'args', and 'kwargs' used by lambda routing
and a 'command' in handler.py | zappa/asynchronous.py | def run_message(message):
"""
Runs a function defined by a message object with keys:
'task_path', 'args', and 'kwargs' used by lambda routing
and a 'command' in handler.py
"""
if message.get('capture_response', False):
DYNAMODB_CLIENT.put_item(
TableName=ASYNC_RESPONSE_TABLE,... | def run_message(message):
"""
Runs a function defined by a message object with keys:
'task_path', 'args', and 'kwargs' used by lambda routing
and a 'command' in handler.py
"""
if message.get('capture_response', False):
DYNAMODB_CLIENT.put_item(
TableName=ASYNC_RESPONSE_TABLE,... | [
"Runs",
"a",
"function",
"defined",
"by",
"a",
"message",
"object",
"with",
"keys",
":",
"task_path",
"args",
"and",
"kwargs",
"used",
"by",
"lambda",
"routing",
"and",
"a",
"command",
"in",
"handler",
".",
"py"
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/asynchronous.py#L287-L327 | [
"def",
"run_message",
"(",
"message",
")",
":",
"if",
"message",
".",
"get",
"(",
"'capture_response'",
",",
"False",
")",
":",
"DYNAMODB_CLIENT",
".",
"put_item",
"(",
"TableName",
"=",
"ASYNC_RESPONSE_TABLE",
",",
"Item",
"=",
"{",
"'id'",
":",
"{",
"'S'... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | run | Instead of decorating a function with @task, you can just run it directly.
If you were going to do func(*args, **kwargs), then you will call this:
import zappa.asynchronous.run
zappa.asynchronous.run(func, args, kwargs)
If you want to use SNS, then do:
zappa.asynchronous.run(func, args, kwargs, s... | zappa/asynchronous.py | def run(func, args=[], kwargs={}, service='lambda', capture_response=False,
remote_aws_lambda_function_name=None, remote_aws_region=None, **task_kwargs):
"""
Instead of decorating a function with @task, you can just run it directly.
If you were going to do func(*args, **kwargs), then you will call t... | def run(func, args=[], kwargs={}, service='lambda', capture_response=False,
remote_aws_lambda_function_name=None, remote_aws_region=None, **task_kwargs):
"""
Instead of decorating a function with @task, you can just run it directly.
If you were going to do func(*args, **kwargs), then you will call t... | [
"Instead",
"of",
"decorating",
"a",
"function",
"with",
"@task",
"you",
"can",
"just",
"run",
"it",
"directly",
".",
"If",
"you",
"were",
"going",
"to",
"do",
"func",
"(",
"*",
"args",
"**",
"kwargs",
")",
"then",
"you",
"will",
"call",
"this",
":"
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/asynchronous.py#L334-L356 | [
"def",
"run",
"(",
"func",
",",
"args",
"=",
"[",
"]",
",",
"kwargs",
"=",
"{",
"}",
",",
"service",
"=",
"'lambda'",
",",
"capture_response",
"=",
"False",
",",
"remote_aws_lambda_function_name",
"=",
"None",
",",
"remote_aws_region",
"=",
"None",
",",
... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | task | Async task decorator so that running
Args:
func (function): the function to be wrapped
Further requirements:
func must be an independent top-level function.
i.e. not a class method or an anonymous function
service (str): either 'lambda' or 'sns'
remo... | zappa/asynchronous.py | def task(*args, **kwargs):
"""Async task decorator so that running
Args:
func (function): the function to be wrapped
Further requirements:
func must be an independent top-level function.
i.e. not a class method or an anonymous function
service (str): eit... | def task(*args, **kwargs):
"""Async task decorator so that running
Args:
func (function): the function to be wrapped
Further requirements:
func must be an independent top-level function.
i.e. not a class method or an anonymous function
service (str): eit... | [
"Async",
"task",
"decorator",
"so",
"that",
"running"
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/asynchronous.py#L364-L439 | [
"def",
"task",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"func",
"=",
"None",
"if",
"len",
"(",
"args",
")",
"==",
"1",
"and",
"callable",
"(",
"args",
"[",
"0",
"]",
")",
":",
"func",
"=",
"args",
"[",
"0",
"]",
"if",
"not",
"kw... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | import_and_get_task | Given a modular path to a function, import that module
and return the function. | zappa/asynchronous.py | def import_and_get_task(task_path):
"""
Given a modular path to a function, import that module
and return the function.
"""
module, function = task_path.rsplit('.', 1)
app_module = importlib.import_module(module)
app_function = getattr(app_module, function)
return app_function | def import_and_get_task(task_path):
"""
Given a modular path to a function, import that module
and return the function.
"""
module, function = task_path.rsplit('.', 1)
app_module = importlib.import_module(module)
app_function = getattr(app_module, function)
return app_function | [
"Given",
"a",
"modular",
"path",
"to",
"a",
"function",
"import",
"that",
"module",
"and",
"return",
"the",
"function",
"."
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/asynchronous.py#L453-L461 | [
"def",
"import_and_get_task",
"(",
"task_path",
")",
":",
"module",
",",
"function",
"=",
"task_path",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"app_module",
"=",
"importlib",
".",
"import_module",
"(",
"module",
")",
"app_function",
"=",
"getattr",
"(",
... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | get_func_task_path | Format the modular task path for a function via inspection. | zappa/asynchronous.py | def get_func_task_path(func):
"""
Format the modular task path for a function via inspection.
"""
module_path = inspect.getmodule(func).__name__
task_path = '{module_path}.{func_name}'.format(
module_path=module_path,
fu... | def get_func_task_path(func):
"""
Format the modular task path for a function via inspection.
"""
module_path = inspect.getmodule(func).__name__
task_path = '{module_path}.{func_name}'.format(
module_path=module_path,
fu... | [
"Format",
"the",
"modular",
"task",
"path",
"for",
"a",
"function",
"via",
"inspection",
"."
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/asynchronous.py#L464-L473 | [
"def",
"get_func_task_path",
"(",
"func",
")",
":",
"module_path",
"=",
"inspect",
".",
"getmodule",
"(",
"func",
")",
".",
"__name__",
"task_path",
"=",
"'{module_path}.{func_name}'",
".",
"format",
"(",
"module_path",
"=",
"module_path",
",",
"func_name",
"=",... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | get_async_response | Get the response from the async table | zappa/asynchronous.py | def get_async_response(response_id):
"""
Get the response from the async table
"""
response = DYNAMODB_CLIENT.get_item(
TableName=ASYNC_RESPONSE_TABLE,
Key={'id': {'S': str(response_id)}}
)
if 'Item' not in response:
return None
return {
'status': response['I... | def get_async_response(response_id):
"""
Get the response from the async table
"""
response = DYNAMODB_CLIENT.get_item(
TableName=ASYNC_RESPONSE_TABLE,
Key={'id': {'S': str(response_id)}}
)
if 'Item' not in response:
return None
return {
'status': response['I... | [
"Get",
"the",
"response",
"from",
"the",
"async",
"table"
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/asynchronous.py#L476-L490 | [
"def",
"get_async_response",
"(",
"response_id",
")",
":",
"response",
"=",
"DYNAMODB_CLIENT",
".",
"get_item",
"(",
"TableName",
"=",
"ASYNC_RESPONSE_TABLE",
",",
"Key",
"=",
"{",
"'id'",
":",
"{",
"'S'",
":",
"str",
"(",
"response_id",
")",
"}",
"}",
")"... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | LambdaAsyncResponse.send | Create the message object and pass it to the actual sender. | zappa/asynchronous.py | def send(self, task_path, args, kwargs):
"""
Create the message object and pass it to the actual sender.
"""
message = {
'task_path': task_path,
'capture_response': self.capture_response,
'response_id': self.response_id,
'ar... | def send(self, task_path, args, kwargs):
"""
Create the message object and pass it to the actual sender.
"""
message = {
'task_path': task_path,
'capture_response': self.capture_response,
'response_id': self.response_id,
'ar... | [
"Create",
"the",
"message",
"object",
"and",
"pass",
"it",
"to",
"the",
"actual",
"sender",
"."
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/asynchronous.py#L162-L174 | [
"def",
"send",
"(",
"self",
",",
"task_path",
",",
"args",
",",
"kwargs",
")",
":",
"message",
"=",
"{",
"'task_path'",
":",
"task_path",
",",
"'capture_response'",
":",
"self",
".",
"capture_response",
",",
"'response_id'",
":",
"self",
".",
"response_id",
... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | LambdaAsyncResponse._send | Given a message, directly invoke the lamdba function for this task. | zappa/asynchronous.py | def _send(self, message):
"""
Given a message, directly invoke the lamdba function for this task.
"""
message['command'] = 'zappa.asynchronous.route_lambda_task'
payload = json.dumps(message).encode('utf-8')
if len(payload) > LAMBDA_ASYNC_PAYLOAD_LIMIT: # pragma: no cover... | def _send(self, message):
"""
Given a message, directly invoke the lamdba function for this task.
"""
message['command'] = 'zappa.asynchronous.route_lambda_task'
payload = json.dumps(message).encode('utf-8')
if len(payload) > LAMBDA_ASYNC_PAYLOAD_LIMIT: # pragma: no cover... | [
"Given",
"a",
"message",
"directly",
"invoke",
"the",
"lamdba",
"function",
"for",
"this",
"task",
"."
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/asynchronous.py#L176-L189 | [
"def",
"_send",
"(",
"self",
",",
"message",
")",
":",
"message",
"[",
"'command'",
"]",
"=",
"'zappa.asynchronous.route_lambda_task'",
"payload",
"=",
"json",
".",
"dumps",
"(",
"message",
")",
".",
"encode",
"(",
"'utf-8'",
")",
"if",
"len",
"(",
"payloa... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | SnsAsyncResponse._send | Given a message, publish to this topic. | zappa/asynchronous.py | def _send(self, message):
"""
Given a message, publish to this topic.
"""
message['command'] = 'zappa.asynchronous.route_sns_task'
payload = json.dumps(message).encode('utf-8')
if len(payload) > LAMBDA_ASYNC_PAYLOAD_LIMIT: # pragma: no cover
raise AsyncExcepti... | def _send(self, message):
"""
Given a message, publish to this topic.
"""
message['command'] = 'zappa.asynchronous.route_sns_task'
payload = json.dumps(message).encode('utf-8')
if len(payload) > LAMBDA_ASYNC_PAYLOAD_LIMIT: # pragma: no cover
raise AsyncExcepti... | [
"Given",
"a",
"message",
"publish",
"to",
"this",
"topic",
"."
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/asynchronous.py#L242-L254 | [
"def",
"_send",
"(",
"self",
",",
"message",
")",
":",
"message",
"[",
"'command'",
"]",
"=",
"'zappa.asynchronous.route_sns_task'",
"payload",
"=",
"json",
".",
"dumps",
"(",
"message",
")",
".",
"encode",
"(",
"'utf-8'",
")",
"if",
"len",
"(",
"payload",... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | parse_s3_url | Parses S3 URL.
Returns bucket (domain) and file (full path). | zappa/utilities.py | def parse_s3_url(url):
"""
Parses S3 URL.
Returns bucket (domain) and file (full path).
"""
bucket = ''
path = ''
if url:
result = urlparse(url)
bucket = result.netloc
path = result.path.strip('/')
return bucket, path | def parse_s3_url(url):
"""
Parses S3 URL.
Returns bucket (domain) and file (full path).
"""
bucket = ''
path = ''
if url:
result = urlparse(url)
bucket = result.netloc
path = result.path.strip('/')
return bucket, path | [
"Parses",
"S3",
"URL",
"."
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/utilities.py#L67-L79 | [
"def",
"parse_s3_url",
"(",
"url",
")",
":",
"bucket",
"=",
"''",
"path",
"=",
"''",
"if",
"url",
":",
"result",
"=",
"urlparse",
"(",
"url",
")",
"bucket",
"=",
"result",
".",
"netloc",
"path",
"=",
"result",
".",
"path",
".",
"strip",
"(",
"'/'",... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | string_to_timestamp | Accepts a str, returns an int timestamp. | zappa/utilities.py | def string_to_timestamp(timestring):
"""
Accepts a str, returns an int timestamp.
"""
ts = None
# Uses an extended version of Go's duration string.
try:
delta = durationpy.from_str(timestring);
past = datetime.datetime.utcnow() - delta
ts = calendar.timegm(past.timetupl... | def string_to_timestamp(timestring):
"""
Accepts a str, returns an int timestamp.
"""
ts = None
# Uses an extended version of Go's duration string.
try:
delta = durationpy.from_str(timestring);
past = datetime.datetime.utcnow() - delta
ts = calendar.timegm(past.timetupl... | [
"Accepts",
"a",
"str",
"returns",
"an",
"int",
"timestamp",
"."
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/utilities.py#L91-L111 | [
"def",
"string_to_timestamp",
"(",
"timestring",
")",
":",
"ts",
"=",
"None",
"# Uses an extended version of Go's duration string.",
"try",
":",
"delta",
"=",
"durationpy",
".",
"from_str",
"(",
"timestring",
")",
"past",
"=",
"datetime",
".",
"datetime",
".",
"ut... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | detect_django_settings | Automatically try to discover Django settings files,
return them as relative module paths. | zappa/utilities.py | def detect_django_settings():
"""
Automatically try to discover Django settings files,
return them as relative module paths.
"""
matches = []
for root, dirnames, filenames in os.walk(os.getcwd()):
for filename in fnmatch.filter(filenames, '*settings.py'):
full = os.path.join... | def detect_django_settings():
"""
Automatically try to discover Django settings files,
return them as relative module paths.
"""
matches = []
for root, dirnames, filenames in os.walk(os.getcwd()):
for filename in fnmatch.filter(filenames, '*settings.py'):
full = os.path.join... | [
"Automatically",
"try",
"to",
"discover",
"Django",
"settings",
"files",
"return",
"them",
"as",
"relative",
"module",
"paths",
"."
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/utilities.py#L117-L134 | [
"def",
"detect_django_settings",
"(",
")",
":",
"matches",
"=",
"[",
"]",
"for",
"root",
",",
"dirnames",
",",
"filenames",
"in",
"os",
".",
"walk",
"(",
"os",
".",
"getcwd",
"(",
")",
")",
":",
"for",
"filename",
"in",
"fnmatch",
".",
"filter",
"(",... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | detect_flask_apps | Automatically try to discover Flask apps files,
return them as relative module paths. | zappa/utilities.py | def detect_flask_apps():
"""
Automatically try to discover Flask apps files,
return them as relative module paths.
"""
matches = []
for root, dirnames, filenames in os.walk(os.getcwd()):
for filename in fnmatch.filter(filenames, '*.py'):
full = os.path.join(root, filename)
... | def detect_flask_apps():
"""
Automatically try to discover Flask apps files,
return them as relative module paths.
"""
matches = []
for root, dirnames, filenames in os.walk(os.getcwd()):
for filename in fnmatch.filter(filenames, '*.py'):
full = os.path.join(root, filename)
... | [
"Automatically",
"try",
"to",
"discover",
"Flask",
"apps",
"files",
"return",
"them",
"as",
"relative",
"module",
"paths",
"."
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/utilities.py#L136-L171 | [
"def",
"detect_flask_apps",
"(",
")",
":",
"matches",
"=",
"[",
"]",
"for",
"root",
",",
"dirnames",
",",
"filenames",
"in",
"os",
".",
"walk",
"(",
"os",
".",
"getcwd",
"(",
")",
")",
":",
"for",
"filename",
"in",
"fnmatch",
".",
"filter",
"(",
"f... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | add_event_source | Given an event_source dictionary, create the object and add the event source. | zappa/utilities.py | def add_event_source(event_source, lambda_arn, target_function, boto_session, dry=False):
"""
Given an event_source dictionary, create the object and add the event source.
"""
event_source_obj, ctx, funk = get_event_source(event_source, lambda_arn, target_function, boto_session, dry=False)
# TODO: ... | def add_event_source(event_source, lambda_arn, target_function, boto_session, dry=False):
"""
Given an event_source dictionary, create the object and add the event source.
"""
event_source_obj, ctx, funk = get_event_source(event_source, lambda_arn, target_function, boto_session, dry=False)
# TODO: ... | [
"Given",
"an",
"event_source",
"dictionary",
"create",
"the",
"object",
"and",
"add",
"the",
"event",
"source",
"."
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/utilities.py#L399-L413 | [
"def",
"add_event_source",
"(",
"event_source",
",",
"lambda_arn",
",",
"target_function",
",",
"boto_session",
",",
"dry",
"=",
"False",
")",
":",
"event_source_obj",
",",
"ctx",
",",
"funk",
"=",
"get_event_source",
"(",
"event_source",
",",
"lambda_arn",
",",... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | remove_event_source | Given an event_source dictionary, create the object and remove the event source. | zappa/utilities.py | def remove_event_source(event_source, lambda_arn, target_function, boto_session, dry=False):
"""
Given an event_source dictionary, create the object and remove the event source.
"""
event_source_obj, ctx, funk = get_event_source(event_source, lambda_arn, target_function, boto_session, dry=False)
#... | def remove_event_source(event_source, lambda_arn, target_function, boto_session, dry=False):
"""
Given an event_source dictionary, create the object and remove the event source.
"""
event_source_obj, ctx, funk = get_event_source(event_source, lambda_arn, target_function, boto_session, dry=False)
#... | [
"Given",
"an",
"event_source",
"dictionary",
"create",
"the",
"object",
"and",
"remove",
"the",
"event",
"source",
"."
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/utilities.py#L415-L428 | [
"def",
"remove_event_source",
"(",
"event_source",
",",
"lambda_arn",
",",
"target_function",
",",
"boto_session",
",",
"dry",
"=",
"False",
")",
":",
"event_source_obj",
",",
"ctx",
",",
"funk",
"=",
"get_event_source",
"(",
"event_source",
",",
"lambda_arn",
"... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | get_event_source_status | Given an event_source dictionary, create the object and get the event source status. | zappa/utilities.py | def get_event_source_status(event_source, lambda_arn, target_function, boto_session, dry=False):
"""
Given an event_source dictionary, create the object and get the event source status.
"""
event_source_obj, ctx, funk = get_event_source(event_source, lambda_arn, target_function, boto_session, dry=False... | def get_event_source_status(event_source, lambda_arn, target_function, boto_session, dry=False):
"""
Given an event_source dictionary, create the object and get the event source status.
"""
event_source_obj, ctx, funk = get_event_source(event_source, lambda_arn, target_function, boto_session, dry=False... | [
"Given",
"an",
"event_source",
"dictionary",
"create",
"the",
"object",
"and",
"get",
"the",
"event",
"source",
"status",
"."
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/utilities.py#L430-L436 | [
"def",
"get_event_source_status",
"(",
"event_source",
",",
"lambda_arn",
",",
"target_function",
",",
"boto_session",
",",
"dry",
"=",
"False",
")",
":",
"event_source_obj",
",",
"ctx",
",",
"funk",
"=",
"get_event_source",
"(",
"event_source",
",",
"lambda_arn",... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | check_new_version_available | Checks if a newer version of Zappa is available.
Returns True is updateable, else False. | zappa/utilities.py | def check_new_version_available(this_version):
"""
Checks if a newer version of Zappa is available.
Returns True is updateable, else False.
"""
import requests
pypi_url = 'https://pypi.python.org/pypi/Zappa/json'
resp = requests.get(pypi_url, timeout=1.5)
top_version = resp.json()['in... | def check_new_version_available(this_version):
"""
Checks if a newer version of Zappa is available.
Returns True is updateable, else False.
"""
import requests
pypi_url = 'https://pypi.python.org/pypi/Zappa/json'
resp = requests.get(pypi_url, timeout=1.5)
top_version = resp.json()['in... | [
"Checks",
"if",
"a",
"newer",
"version",
"of",
"Zappa",
"is",
"available",
"."
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/utilities.py#L442-L455 | [
"def",
"check_new_version_available",
"(",
"this_version",
")",
":",
"import",
"requests",
"pypi_url",
"=",
"'https://pypi.python.org/pypi/Zappa/json'",
"resp",
"=",
"requests",
".",
"get",
"(",
"pypi_url",
",",
"timeout",
"=",
"1.5",
")",
"top_version",
"=",
"resp"... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | validate_name | Validate name for AWS Lambda function.
name: actual name (without `arn:aws:lambda:...:` prefix and without
`:$LATEST`, alias or version suffix.
maxlen: max allowed length for name without prefix and suffix.
The value 80 was calculated from prefix with longest known region name
and assuming that... | zappa/utilities.py | def validate_name(name, maxlen=80):
"""Validate name for AWS Lambda function.
name: actual name (without `arn:aws:lambda:...:` prefix and without
`:$LATEST`, alias or version suffix.
maxlen: max allowed length for name without prefix and suffix.
The value 80 was calculated from prefix with long... | def validate_name(name, maxlen=80):
"""Validate name for AWS Lambda function.
name: actual name (without `arn:aws:lambda:...:` prefix and without
`:$LATEST`, alias or version suffix.
maxlen: max allowed length for name without prefix and suffix.
The value 80 was calculated from prefix with long... | [
"Validate",
"name",
"for",
"AWS",
"Lambda",
"function",
".",
"name",
":",
"actual",
"name",
"(",
"without",
"arn",
":",
"aws",
":",
"lambda",
":",
"...",
":",
"prefix",
"and",
"without",
":",
"$LATEST",
"alias",
"or",
"version",
"suffix",
".",
"maxlen",
... | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/utilities.py#L463-L490 | [
"def",
"validate_name",
"(",
"name",
",",
"maxlen",
"=",
"80",
")",
":",
"if",
"not",
"isinstance",
"(",
"name",
",",
"basestring",
")",
":",
"msg",
"=",
"\"Name must be of type string\"",
"raise",
"InvalidAwsLambdaName",
"(",
"msg",
")",
"if",
"len",
"(",
... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | contains_python_files_or_subdirs | Checks (recursively) if the directory contains .py or .pyc files | zappa/utilities.py | def contains_python_files_or_subdirs(folder):
"""
Checks (recursively) if the directory contains .py or .pyc files
"""
for root, dirs, files in os.walk(folder):
if [filename for filename in files if filename.endswith('.py') or filename.endswith('.pyc')]:
return True
for d in... | def contains_python_files_or_subdirs(folder):
"""
Checks (recursively) if the directory contains .py or .pyc files
"""
for root, dirs, files in os.walk(folder):
if [filename for filename in files if filename.endswith('.py') or filename.endswith('.pyc')]:
return True
for d in... | [
"Checks",
"(",
"recursively",
")",
"if",
"the",
"directory",
"contains",
".",
"py",
"or",
".",
"pyc",
"files"
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/utilities.py#L493-L506 | [
"def",
"contains_python_files_or_subdirs",
"(",
"folder",
")",
":",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"folder",
")",
":",
"if",
"[",
"filename",
"for",
"filename",
"in",
"files",
"if",
"filename",
".",
"endswith",
"(... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | conflicts_with_a_neighbouring_module | Checks if a directory lies in the same directory as a .py file with the same name. | zappa/utilities.py | def conflicts_with_a_neighbouring_module(directory_path):
"""
Checks if a directory lies in the same directory as a .py file with the same name.
"""
parent_dir_path, current_dir_name = os.path.split(os.path.normpath(directory_path))
neighbours = os.listdir(parent_dir_path)
conflicting_neighbour_... | def conflicts_with_a_neighbouring_module(directory_path):
"""
Checks if a directory lies in the same directory as a .py file with the same name.
"""
parent_dir_path, current_dir_name = os.path.split(os.path.normpath(directory_path))
neighbours = os.listdir(parent_dir_path)
conflicting_neighbour_... | [
"Checks",
"if",
"a",
"directory",
"lies",
"in",
"the",
"same",
"directory",
"as",
"a",
".",
"py",
"file",
"with",
"the",
"same",
"name",
"."
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/utilities.py#L509-L516 | [
"def",
"conflicts_with_a_neighbouring_module",
"(",
"directory_path",
")",
":",
"parent_dir_path",
",",
"current_dir_name",
"=",
"os",
".",
"path",
".",
"split",
"(",
"os",
".",
"path",
".",
"normpath",
"(",
"directory_path",
")",
")",
"neighbours",
"=",
"os",
... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | is_valid_bucket_name | Checks if an S3 bucket name is valid according to https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html#bucketnamingrules | zappa/utilities.py | def is_valid_bucket_name(name):
"""
Checks if an S3 bucket name is valid according to https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html#bucketnamingrules
"""
# Bucket names must be at least 3 and no more than 63 characters long.
if (len(name) < 3 or len(name) > 63):
ret... | def is_valid_bucket_name(name):
"""
Checks if an S3 bucket name is valid according to https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html#bucketnamingrules
"""
# Bucket names must be at least 3 and no more than 63 characters long.
if (len(name) < 3 or len(name) > 63):
ret... | [
"Checks",
"if",
"an",
"S3",
"bucket",
"name",
"is",
"valid",
"according",
"to",
"https",
":",
"//",
"docs",
".",
"aws",
".",
"amazon",
".",
"com",
"/",
"AmazonS3",
"/",
"latest",
"/",
"dev",
"/",
"BucketRestrictions",
".",
"html#bucketnamingrules"
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/utilities.py#L528-L561 | [
"def",
"is_valid_bucket_name",
"(",
"name",
")",
":",
"# Bucket names must be at least 3 and no more than 63 characters long.",
"if",
"(",
"len",
"(",
"name",
")",
"<",
"3",
"or",
"len",
"(",
"name",
")",
">",
"63",
")",
":",
"return",
"False",
"# Bucket names mus... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | merge_headers | Merge the values of headers and multiValueHeaders into a single dict.
Opens up support for multivalue headers via API Gateway and ALB.
See: https://github.com/Miserlou/Zappa/pull/1756 | zappa/utilities.py | def merge_headers(event):
"""
Merge the values of headers and multiValueHeaders into a single dict.
Opens up support for multivalue headers via API Gateway and ALB.
See: https://github.com/Miserlou/Zappa/pull/1756
"""
headers = event.get('headers') or {}
multi_headers = (event.get('multiValu... | def merge_headers(event):
"""
Merge the values of headers and multiValueHeaders into a single dict.
Opens up support for multivalue headers via API Gateway and ALB.
See: https://github.com/Miserlou/Zappa/pull/1756
"""
headers = event.get('headers') or {}
multi_headers = (event.get('multiValu... | [
"Merge",
"the",
"values",
"of",
"headers",
"and",
"multiValueHeaders",
"into",
"a",
"single",
"dict",
".",
"Opens",
"up",
"support",
"for",
"multivalue",
"headers",
"via",
"API",
"Gateway",
"and",
"ALB",
".",
"See",
":",
"https",
":",
"//",
"github",
".",
... | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/utilities.py#L564-L577 | [
"def",
"merge_headers",
"(",
"event",
")",
":",
"headers",
"=",
"event",
".",
"get",
"(",
"'headers'",
")",
"or",
"{",
"}",
"multi_headers",
"=",
"(",
"event",
".",
"get",
"(",
"'multiValueHeaders'",
")",
"or",
"{",
"}",
")",
".",
"copy",
"(",
")",
... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | create_wsgi_request | Given some event_info via API Gateway,
create and return a valid WSGI request environ. | zappa/wsgi.py | def create_wsgi_request(event_info,
server_name='zappa',
script_name=None,
trailing_slash=True,
binary_support=False,
base_path=None,
context_header_mappings={},
... | def create_wsgi_request(event_info,
server_name='zappa',
script_name=None,
trailing_slash=True,
binary_support=False,
base_path=None,
context_header_mappings={},
... | [
"Given",
"some",
"event_info",
"via",
"API",
"Gateway",
"create",
"and",
"return",
"a",
"valid",
"WSGI",
"request",
"environ",
"."
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/wsgi.py#L30-L168 | [
"def",
"create_wsgi_request",
"(",
"event_info",
",",
"server_name",
"=",
"'zappa'",
",",
"script_name",
"=",
"None",
",",
"trailing_slash",
"=",
"True",
",",
"binary_support",
"=",
"False",
",",
"base_path",
"=",
"None",
",",
"context_header_mappings",
"=",
"{"... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | common_log | Given the WSGI environ and the response,
log this event in Common Log Format. | zappa/wsgi.py | def common_log(environ, response, response_time=None):
"""
Given the WSGI environ and the response,
log this event in Common Log Format.
"""
logger = logging.getLogger()
if response_time:
formatter = ApacheFormatter(with_response_time=True)
try:
log_entry = formatt... | def common_log(environ, response, response_time=None):
"""
Given the WSGI environ and the response,
log this event in Common Log Format.
"""
logger = logging.getLogger()
if response_time:
formatter = ApacheFormatter(with_response_time=True)
try:
log_entry = formatt... | [
"Given",
"the",
"WSGI",
"environ",
"and",
"the",
"response",
"log",
"this",
"event",
"in",
"Common",
"Log",
"Format",
"."
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/wsgi.py#L171-L196 | [
"def",
"common_log",
"(",
"environ",
",",
"response",
",",
"response_time",
"=",
"None",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
")",
"if",
"response_time",
":",
"formatter",
"=",
"ApacheFormatter",
"(",
"with_response_time",
"=",
"True",
... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | LambdaHandler.load_remote_project_archive | Puts the project files from S3 in /tmp and adds to path | zappa/handler.py | def load_remote_project_archive(self, project_zip_path):
"""
Puts the project files from S3 in /tmp and adds to path
"""
project_folder = '/tmp/{0!s}'.format(self.settings.PROJECT_NAME)
if not os.path.isdir(project_folder):
# The project folder doesn't exist in this c... | def load_remote_project_archive(self, project_zip_path):
"""
Puts the project files from S3 in /tmp and adds to path
"""
project_folder = '/tmp/{0!s}'.format(self.settings.PROJECT_NAME)
if not os.path.isdir(project_folder):
# The project folder doesn't exist in this c... | [
"Puts",
"the",
"project",
"files",
"from",
"S3",
"in",
"/",
"tmp",
"and",
"adds",
"to",
"path"
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/handler.py#L156-L182 | [
"def",
"load_remote_project_archive",
"(",
"self",
",",
"project_zip_path",
")",
":",
"project_folder",
"=",
"'/tmp/{0!s}'",
".",
"format",
"(",
"self",
".",
"settings",
".",
"PROJECT_NAME",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"project_fold... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | LambdaHandler.load_remote_settings | Attempt to read a file from s3 containing a flat json object. Adds each
key->value pair as environment variables. Helpful for keeping
sensitiZve or stage-specific configuration variables in s3 instead of
version control. | zappa/handler.py | def load_remote_settings(self, remote_bucket, remote_file):
"""
Attempt to read a file from s3 containing a flat json object. Adds each
key->value pair as environment variables. Helpful for keeping
sensitiZve or stage-specific configuration variables in s3 instead of
version cont... | def load_remote_settings(self, remote_bucket, remote_file):
"""
Attempt to read a file from s3 containing a flat json object. Adds each
key->value pair as environment variables. Helpful for keeping
sensitiZve or stage-specific configuration variables in s3 instead of
version cont... | [
"Attempt",
"to",
"read",
"a",
"file",
"from",
"s3",
"containing",
"a",
"flat",
"json",
"object",
".",
"Adds",
"each",
"key",
"-",
">",
"value",
"pair",
"as",
"environment",
"variables",
".",
"Helpful",
"for",
"keeping",
"sensitiZve",
"or",
"stage",
"-",
... | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/handler.py#L184-L230 | [
"def",
"load_remote_settings",
"(",
"self",
",",
"remote_bucket",
",",
"remote_file",
")",
":",
"if",
"not",
"self",
".",
"session",
":",
"boto_session",
"=",
"boto3",
".",
"Session",
"(",
")",
"else",
":",
"boto_session",
"=",
"self",
".",
"session",
"s3"... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | LambdaHandler.import_module_and_get_function | Given a modular path to a function, import that module
and return the function. | zappa/handler.py | def import_module_and_get_function(whole_function):
"""
Given a modular path to a function, import that module
and return the function.
"""
module, function = whole_function.rsplit('.', 1)
app_module = importlib.import_module(module)
app_function = getattr(app_mod... | def import_module_and_get_function(whole_function):
"""
Given a modular path to a function, import that module
and return the function.
"""
module, function = whole_function.rsplit('.', 1)
app_module = importlib.import_module(module)
app_function = getattr(app_mod... | [
"Given",
"a",
"modular",
"path",
"to",
"a",
"function",
"import",
"that",
"module",
"and",
"return",
"the",
"function",
"."
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/handler.py#L233-L241 | [
"def",
"import_module_and_get_function",
"(",
"whole_function",
")",
":",
"module",
",",
"function",
"=",
"whole_function",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"app_module",
"=",
"importlib",
".",
"import_module",
"(",
"module",
")",
"app_function",
"=",
... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | LambdaHandler.run_function | Given a function and event context,
detect signature and execute, returning any result. | zappa/handler.py | def run_function(app_function, event, context):
"""
Given a function and event context,
detect signature and execute, returning any result.
"""
# getargspec does not support python 3 method with type hints
# Related issue: https://github.com/Miserlou/Zappa/issues/1452
... | def run_function(app_function, event, context):
"""
Given a function and event context,
detect signature and execute, returning any result.
"""
# getargspec does not support python 3 method with type hints
# Related issue: https://github.com/Miserlou/Zappa/issues/1452
... | [
"Given",
"a",
"function",
"and",
"event",
"context",
"detect",
"signature",
"and",
"execute",
"returning",
"any",
"result",
"."
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/handler.py#L270-L291 | [
"def",
"run_function",
"(",
"app_function",
",",
"event",
",",
"context",
")",
":",
"# getargspec does not support python 3 method with type hints",
"# Related issue: https://github.com/Miserlou/Zappa/issues/1452",
"if",
"hasattr",
"(",
"inspect",
",",
"\"getfullargspec\"",
")",
... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | LambdaHandler.get_function_for_aws_event | Get the associated function to execute for a triggered AWS event
Support S3, SNS, DynamoDB, kinesis and SQS events | zappa/handler.py | def get_function_for_aws_event(self, record):
"""
Get the associated function to execute for a triggered AWS event
Support S3, SNS, DynamoDB, kinesis and SQS events
"""
if 's3' in record:
if ':' in record['s3']['configurationId']:
return record['s3'][... | def get_function_for_aws_event(self, record):
"""
Get the associated function to execute for a triggered AWS event
Support S3, SNS, DynamoDB, kinesis and SQS events
"""
if 's3' in record:
if ':' in record['s3']['configurationId']:
return record['s3'][... | [
"Get",
"the",
"associated",
"function",
"to",
"execute",
"for",
"a",
"triggered",
"AWS",
"event"
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/handler.py#L293-L322 | [
"def",
"get_function_for_aws_event",
"(",
"self",
",",
"record",
")",
":",
"if",
"'s3'",
"in",
"record",
":",
"if",
"':'",
"in",
"record",
"[",
"'s3'",
"]",
"[",
"'configurationId'",
"]",
":",
"return",
"record",
"[",
"'s3'",
"]",
"[",
"'configurationId'",... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | LambdaHandler.get_function_from_bot_intent_trigger | For the given event build ARN and return the configured function | zappa/handler.py | def get_function_from_bot_intent_trigger(self, event):
"""
For the given event build ARN and return the configured function
"""
intent = event.get('currentIntent')
if intent:
intent = intent.get('name')
if intent:
return self.settings.AWS_B... | def get_function_from_bot_intent_trigger(self, event):
"""
For the given event build ARN and return the configured function
"""
intent = event.get('currentIntent')
if intent:
intent = intent.get('name')
if intent:
return self.settings.AWS_B... | [
"For",
"the",
"given",
"event",
"build",
"ARN",
"and",
"return",
"the",
"configured",
"function"
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/handler.py#L324-L334 | [
"def",
"get_function_from_bot_intent_trigger",
"(",
"self",
",",
"event",
")",
":",
"intent",
"=",
"event",
".",
"get",
"(",
"'currentIntent'",
")",
"if",
"intent",
":",
"intent",
"=",
"intent",
".",
"get",
"(",
"'name'",
")",
"if",
"intent",
":",
"return"... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | LambdaHandler.get_function_for_cognito_trigger | Get the associated function to execute for a cognito trigger | zappa/handler.py | def get_function_for_cognito_trigger(self, trigger):
"""
Get the associated function to execute for a cognito trigger
"""
print("get_function_for_cognito_trigger", self.settings.COGNITO_TRIGGER_MAPPING, trigger, self.settings.COGNITO_TRIGGER_MAPPING.get(trigger))
return self.sett... | def get_function_for_cognito_trigger(self, trigger):
"""
Get the associated function to execute for a cognito trigger
"""
print("get_function_for_cognito_trigger", self.settings.COGNITO_TRIGGER_MAPPING, trigger, self.settings.COGNITO_TRIGGER_MAPPING.get(trigger))
return self.sett... | [
"Get",
"the",
"associated",
"function",
"to",
"execute",
"for",
"a",
"cognito",
"trigger"
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/handler.py#L336-L341 | [
"def",
"get_function_for_cognito_trigger",
"(",
"self",
",",
"trigger",
")",
":",
"print",
"(",
"\"get_function_for_cognito_trigger\"",
",",
"self",
".",
"settings",
".",
"COGNITO_TRIGGER_MAPPING",
",",
"trigger",
",",
"self",
".",
"settings",
".",
"COGNITO_TRIGGER_MA... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | LambdaHandler.handler | An AWS Lambda function which parses specific API Gateway input into a
WSGI request, feeds it to our WSGI app, procceses the response, and returns
that back to the API Gateway. | zappa/handler.py | def handler(self, event, context):
"""
An AWS Lambda function which parses specific API Gateway input into a
WSGI request, feeds it to our WSGI app, procceses the response, and returns
that back to the API Gateway.
"""
settings = self.settings
# If in DEBUG mode... | def handler(self, event, context):
"""
An AWS Lambda function which parses specific API Gateway input into a
WSGI request, feeds it to our WSGI app, procceses the response, and returns
that back to the API Gateway.
"""
settings = self.settings
# If in DEBUG mode... | [
"An",
"AWS",
"Lambda",
"function",
"which",
"parses",
"specific",
"API",
"Gateway",
"input",
"into",
"a",
"WSGI",
"request",
"feeds",
"it",
"to",
"our",
"WSGI",
"app",
"procceses",
"the",
"response",
"and",
"returns",
"that",
"back",
"to",
"the",
"API",
"G... | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/handler.py#L343-L598 | [
"def",
"handler",
"(",
"self",
",",
"event",
",",
"context",
")",
":",
"settings",
"=",
"self",
".",
"settings",
"# If in DEBUG mode, log all raw incoming events.",
"if",
"settings",
".",
"DEBUG",
":",
"logger",
".",
"debug",
"(",
"'Zappa Event: {}'",
".",
"form... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | lambda_handler | validate the incoming token | example/authmodule.py | def lambda_handler(event, context):
print("Client token: " + event['authorizationToken'])
print("Method ARN: " + event['methodArn'])
"""validate the incoming token"""
"""and produce the principal user identifier associated with the token"""
"""this could be accomplished in a number of ways:"""
... | def lambda_handler(event, context):
print("Client token: " + event['authorizationToken'])
print("Method ARN: " + event['methodArn'])
"""validate the incoming token"""
"""and produce the principal user identifier associated with the token"""
"""this could be accomplished in a number of ways:"""
... | [
"validate",
"the",
"incoming",
"token"
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/example/authmodule.py#L15-L61 | [
"def",
"lambda_handler",
"(",
"event",
",",
"context",
")",
":",
"print",
"(",
"\"Client token: \"",
"+",
"event",
"[",
"'authorizationToken'",
"]",
")",
"print",
"(",
"\"Method ARN: \"",
"+",
"event",
"[",
"'methodArn'",
"]",
")",
"\"\"\"and produce the principal... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | AuthPolicy._addMethod | Adds a method to the internal lists of allowed or denied methods. Each object in
the internal list contains a resource ARN and a condition statement. The condition
statement can be null. | example/authmodule.py | def _addMethod(self, effect, verb, resource, conditions):
"""Adds a method to the internal lists of allowed or denied methods. Each object in
the internal list contains a resource ARN and a condition statement. The condition
statement can be null."""
if verb != "*" and not hasattr(HttpVe... | def _addMethod(self, effect, verb, resource, conditions):
"""Adds a method to the internal lists of allowed or denied methods. Each object in
the internal list contains a resource ARN and a condition statement. The condition
statement can be null."""
if verb != "*" and not hasattr(HttpVe... | [
"Adds",
"a",
"method",
"to",
"the",
"internal",
"lists",
"of",
"allowed",
"or",
"denied",
"methods",
".",
"Each",
"object",
"in",
"the",
"internal",
"list",
"contains",
"a",
"resource",
"ARN",
"and",
"a",
"condition",
"statement",
".",
"The",
"condition",
... | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/example/authmodule.py#L104-L134 | [
"def",
"_addMethod",
"(",
"self",
",",
"effect",
",",
"verb",
",",
"resource",
",",
"conditions",
")",
":",
"if",
"verb",
"!=",
"\"*\"",
"and",
"not",
"hasattr",
"(",
"HttpVerb",
",",
"verb",
")",
":",
"raise",
"NameError",
"(",
"\"Invalid HTTP verb \"",
... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | AuthPolicy.allowMethodWithConditions | Adds an API Gateway method (Http verb + Resource path) to the list of allowed
methods and includes a condition for the policy statement. More on AWS policy
conditions here: http://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html#Condition | example/authmodule.py | def allowMethodWithConditions(self, verb, resource, conditions):
"""Adds an API Gateway method (Http verb + Resource path) to the list of allowed
methods and includes a condition for the policy statement. More on AWS policy
conditions here: http://docs.aws.amazon.com/IAM/latest/UserGuide/referen... | def allowMethodWithConditions(self, verb, resource, conditions):
"""Adds an API Gateway method (Http verb + Resource path) to the list of allowed
methods and includes a condition for the policy statement. More on AWS policy
conditions here: http://docs.aws.amazon.com/IAM/latest/UserGuide/referen... | [
"Adds",
"an",
"API",
"Gateway",
"method",
"(",
"Http",
"verb",
"+",
"Resource",
"path",
")",
"to",
"the",
"list",
"of",
"allowed",
"methods",
"and",
"includes",
"a",
"condition",
"for",
"the",
"policy",
"statement",
".",
"More",
"on",
"AWS",
"policy",
"c... | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/example/authmodule.py#L186-L190 | [
"def",
"allowMethodWithConditions",
"(",
"self",
",",
"verb",
",",
"resource",
",",
"conditions",
")",
":",
"self",
".",
"_addMethod",
"(",
"\"Allow\"",
",",
"verb",
",",
"resource",
",",
"conditions",
")"
] | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | AuthPolicy.denyMethodWithConditions | Adds an API Gateway method (Http verb + Resource path) to the list of denied
methods and includes a condition for the policy statement. More on AWS policy
conditions here: http://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html#Condition | example/authmodule.py | def denyMethodWithConditions(self, verb, resource, conditions):
"""Adds an API Gateway method (Http verb + Resource path) to the list of denied
methods and includes a condition for the policy statement. More on AWS policy
conditions here: http://docs.aws.amazon.com/IAM/latest/UserGuide/reference... | def denyMethodWithConditions(self, verb, resource, conditions):
"""Adds an API Gateway method (Http verb + Resource path) to the list of denied
methods and includes a condition for the policy statement. More on AWS policy
conditions here: http://docs.aws.amazon.com/IAM/latest/UserGuide/reference... | [
"Adds",
"an",
"API",
"Gateway",
"method",
"(",
"Http",
"verb",
"+",
"Resource",
"path",
")",
"to",
"the",
"list",
"of",
"denied",
"methods",
"and",
"includes",
"a",
"condition",
"for",
"the",
"policy",
"statement",
".",
"More",
"on",
"AWS",
"policy",
"co... | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/example/authmodule.py#L192-L196 | [
"def",
"denyMethodWithConditions",
"(",
"self",
",",
"verb",
",",
"resource",
",",
"conditions",
")",
":",
"self",
".",
"_addMethod",
"(",
"\"Deny\"",
",",
"verb",
",",
"resource",
",",
"conditions",
")"
] | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | AuthPolicy.build | Generates the policy document based on the internal lists of allowed and denied
conditions. This will generate a policy with two main statements for the effect:
one statement for Allow and one statement for Deny.
Methods that includes conditions will have their own statement in the policy. | example/authmodule.py | def build(self):
"""Generates the policy document based on the internal lists of allowed and denied
conditions. This will generate a policy with two main statements for the effect:
one statement for Allow and one statement for Deny.
Methods that includes conditions will have their own st... | def build(self):
"""Generates the policy document based on the internal lists of allowed and denied
conditions. This will generate a policy with two main statements for the effect:
one statement for Allow and one statement for Deny.
Methods that includes conditions will have their own st... | [
"Generates",
"the",
"policy",
"document",
"based",
"on",
"the",
"internal",
"lists",
"of",
"allowed",
"and",
"denied",
"conditions",
".",
"This",
"will",
"generate",
"a",
"policy",
"with",
"two",
"main",
"statements",
"for",
"the",
"effect",
":",
"one",
"sta... | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/example/authmodule.py#L198-L218 | [
"def",
"build",
"(",
"self",
")",
":",
"if",
"(",
"(",
"self",
".",
"allowMethods",
"is",
"None",
"or",
"len",
"(",
"self",
".",
"allowMethods",
")",
"==",
"0",
")",
"and",
"(",
"self",
".",
"denyMethods",
"is",
"None",
"or",
"len",
"(",
"self",
... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | Zappa.configure_boto_session_method_kwargs | Allow for custom endpoint urls for non-AWS (testing and bootleg cloud) deployments | zappa/core.py | def configure_boto_session_method_kwargs(self, service, kw):
"""Allow for custom endpoint urls for non-AWS (testing and bootleg cloud) deployments"""
if service in self.endpoint_urls and not 'endpoint_url' in kw:
kw['endpoint_url'] = self.endpoint_urls[service]
return kw | def configure_boto_session_method_kwargs(self, service, kw):
"""Allow for custom endpoint urls for non-AWS (testing and bootleg cloud) deployments"""
if service in self.endpoint_urls and not 'endpoint_url' in kw:
kw['endpoint_url'] = self.endpoint_urls[service]
return kw | [
"Allow",
"for",
"custom",
"endpoint",
"urls",
"for",
"non",
"-",
"AWS",
"(",
"testing",
"and",
"bootleg",
"cloud",
")",
"deployments"
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L328-L332 | [
"def",
"configure_boto_session_method_kwargs",
"(",
"self",
",",
"service",
",",
"kw",
")",
":",
"if",
"service",
"in",
"self",
".",
"endpoint_urls",
"and",
"not",
"'endpoint_url'",
"in",
"kw",
":",
"kw",
"[",
"'endpoint_url'",
"]",
"=",
"self",
".",
"endpoi... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | Zappa.boto_client | A wrapper to apply configuration options to boto clients | zappa/core.py | def boto_client(self, service, *args, **kwargs):
"""A wrapper to apply configuration options to boto clients"""
return self.boto_session.client(service, *args, **self.configure_boto_session_method_kwargs(service, kwargs)) | def boto_client(self, service, *args, **kwargs):
"""A wrapper to apply configuration options to boto clients"""
return self.boto_session.client(service, *args, **self.configure_boto_session_method_kwargs(service, kwargs)) | [
"A",
"wrapper",
"to",
"apply",
"configuration",
"options",
"to",
"boto",
"clients"
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L334-L336 | [
"def",
"boto_client",
"(",
"self",
",",
"service",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"boto_session",
".",
"client",
"(",
"service",
",",
"*",
"args",
",",
"*",
"*",
"self",
".",
"configure_boto_session_method_kwa... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | Zappa.boto_resource | A wrapper to apply configuration options to boto resources | zappa/core.py | def boto_resource(self, service, *args, **kwargs):
"""A wrapper to apply configuration options to boto resources"""
return self.boto_session.resource(service, *args, **self.configure_boto_session_method_kwargs(service, kwargs)) | def boto_resource(self, service, *args, **kwargs):
"""A wrapper to apply configuration options to boto resources"""
return self.boto_session.resource(service, *args, **self.configure_boto_session_method_kwargs(service, kwargs)) | [
"A",
"wrapper",
"to",
"apply",
"configuration",
"options",
"to",
"boto",
"resources"
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L338-L340 | [
"def",
"boto_resource",
"(",
"self",
",",
"service",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"boto_session",
".",
"resource",
"(",
"service",
",",
"*",
"args",
",",
"*",
"*",
"self",
".",
"configure_boto_session_method... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | Zappa.cache_param | Returns a troposphere Ref to a value cached as a parameter. | zappa/core.py | def cache_param(self, value):
'''Returns a troposphere Ref to a value cached as a parameter.'''
if value not in self.cf_parameters:
keyname = chr(ord('A') + len(self.cf_parameters))
param = self.cf_template.add_parameter(troposphere.Parameter(
keyname, Type="Stri... | def cache_param(self, value):
'''Returns a troposphere Ref to a value cached as a parameter.'''
if value not in self.cf_parameters:
keyname = chr(ord('A') + len(self.cf_parameters))
param = self.cf_template.add_parameter(troposphere.Parameter(
keyname, Type="Stri... | [
"Returns",
"a",
"troposphere",
"Ref",
"to",
"a",
"value",
"cached",
"as",
"a",
"parameter",
"."
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L342-L353 | [
"def",
"cache_param",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"not",
"in",
"self",
".",
"cf_parameters",
":",
"keyname",
"=",
"chr",
"(",
"ord",
"(",
"'A'",
")",
"+",
"len",
"(",
"self",
".",
"cf_parameters",
")",
")",
"param",
"=",
"se... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
train | Zappa.get_deps_list | For a given package, returns a list of required packages. Recursive. | zappa/core.py | def get_deps_list(self, pkg_name, installed_distros=None):
"""
For a given package, returns a list of required packages. Recursive.
"""
# https://github.com/Miserlou/Zappa/issues/1478. Using `pkg_resources`
# instead of `pip` is the recommended approach. The usage is nearly
... | def get_deps_list(self, pkg_name, installed_distros=None):
"""
For a given package, returns a list of required packages. Recursive.
"""
# https://github.com/Miserlou/Zappa/issues/1478. Using `pkg_resources`
# instead of `pip` is the recommended approach. The usage is nearly
... | [
"For",
"a",
"given",
"package",
"returns",
"a",
"list",
"of",
"required",
"packages",
".",
"Recursive",
"."
] | Miserlou/Zappa | python | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L373-L389 | [
"def",
"get_deps_list",
"(",
"self",
",",
"pkg_name",
",",
"installed_distros",
"=",
"None",
")",
":",
"# https://github.com/Miserlou/Zappa/issues/1478. Using `pkg_resources`",
"# instead of `pip` is the recommended approach. The usage is nearly",
"# identical.",
"import",
"pkg_res... | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.