id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
29,600
apple/turicreate
src/external/xgboost/python-package/xgboost/core.py
DMatrix.get_uint_info
def get_uint_info(self, field): """Get unsigned integer property from the DMatrix. Parameters ---------- field: str The field name of the information Returns ------- info : array a numpy array of float information of the data """ ...
python
def get_uint_info(self, field): """Get unsigned integer property from the DMatrix. Parameters ---------- field: str The field name of the information Returns ------- info : array a numpy array of float information of the data """ ...
[ "def", "get_uint_info", "(", "self", ",", "field", ")", ":", "length", "=", "ctypes", ".", "c_ulong", "(", ")", "ret", "=", "ctypes", ".", "POINTER", "(", "ctypes", ".", "c_uint", ")", "(", ")", "_check_call", "(", "_LIB", ".", "XGDMatrixGetUIntInfo", ...
Get unsigned integer property from the DMatrix. Parameters ---------- field: str The field name of the information Returns ------- info : array a numpy array of float information of the data
[ "Get", "unsigned", "integer", "property", "from", "the", "DMatrix", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L298-L317
29,601
apple/turicreate
src/external/xgboost/python-package/xgboost/core.py
DMatrix.save_binary
def save_binary(self, fname, silent=True): """Save DMatrix to an XGBoost buffer. Parameters ---------- fname : string Name of the output buffer file. silent : bool (optional; default: True) If set, the output is suppressed. """ _check_call...
python
def save_binary(self, fname, silent=True): """Save DMatrix to an XGBoost buffer. Parameters ---------- fname : string Name of the output buffer file. silent : bool (optional; default: True) If set, the output is suppressed. """ _check_call...
[ "def", "save_binary", "(", "self", ",", "fname", ",", "silent", "=", "True", ")", ":", "_check_call", "(", "_LIB", ".", "XGDMatrixSaveBinary", "(", "self", ".", "handle", ",", "c_str", "(", "fname", ")", ",", "int", "(", "silent", ")", ")", ")" ]
Save DMatrix to an XGBoost buffer. Parameters ---------- fname : string Name of the output buffer file. silent : bool (optional; default: True) If set, the output is suppressed.
[ "Save", "DMatrix", "to", "an", "XGBoost", "buffer", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L351-L363
29,602
apple/turicreate
src/external/xgboost/python-package/xgboost/core.py
DMatrix.num_row
def num_row(self): """Get the number of rows in the DMatrix. Returns ------- number of rows : int """ ret = ctypes.c_ulong() _check_call(_LIB.XGDMatrixNumRow(self.handle, ctypes.byref(ret))) return ret.value
python
def num_row(self): """Get the number of rows in the DMatrix. Returns ------- number of rows : int """ ret = ctypes.c_ulong() _check_call(_LIB.XGDMatrixNumRow(self.handle, ctypes.byref(ret))) return ret.value
[ "def", "num_row", "(", "self", ")", ":", "ret", "=", "ctypes", ".", "c_ulong", "(", ")", "_check_call", "(", "_LIB", ".", "XGDMatrixNumRow", "(", "self", ".", "handle", ",", "ctypes", ".", "byref", "(", "ret", ")", ")", ")", "return", "ret", ".", "...
Get the number of rows in the DMatrix. Returns ------- number of rows : int
[ "Get", "the", "number", "of", "rows", "in", "the", "DMatrix", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L440-L450
29,603
apple/turicreate
src/external/xgboost/python-package/xgboost/core.py
DMatrix.slice
def slice(self, rindex): """Slice the DMatrix and return a new DMatrix that only contains `rindex`. Parameters ---------- rindex : list List of indices to be selected. Returns ------- res : DMatrix A new DMatrix containing only selected i...
python
def slice(self, rindex): """Slice the DMatrix and return a new DMatrix that only contains `rindex`. Parameters ---------- rindex : list List of indices to be selected. Returns ------- res : DMatrix A new DMatrix containing only selected i...
[ "def", "slice", "(", "self", ",", "rindex", ")", ":", "res", "=", "DMatrix", "(", "None", ",", "feature_names", "=", "self", ".", "feature_names", ")", "res", ".", "handle", "=", "ctypes", ".", "c_void_p", "(", ")", "_check_call", "(", "_LIB", ".", "...
Slice the DMatrix and return a new DMatrix that only contains `rindex`. Parameters ---------- rindex : list List of indices to be selected. Returns ------- res : DMatrix A new DMatrix containing only selected indices.
[ "Slice", "the", "DMatrix", "and", "return", "a", "new", "DMatrix", "that", "only", "contains", "rindex", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L464-L483
29,604
apple/turicreate
src/external/xgboost/python-package/xgboost/core.py
Booster.update
def update(self, dtrain, iteration, fobj=None): """ Update for one iteration, with objective function calculated internally. Parameters ---------- dtrain : DMatrix Training data. iteration : int Current iteration number. fobj : function ...
python
def update(self, dtrain, iteration, fobj=None): """ Update for one iteration, with objective function calculated internally. Parameters ---------- dtrain : DMatrix Training data. iteration : int Current iteration number. fobj : function ...
[ "def", "update", "(", "self", ",", "dtrain", ",", "iteration", ",", "fobj", "=", "None", ")", ":", "if", "not", "isinstance", "(", "dtrain", ",", "DMatrix", ")", ":", "raise", "TypeError", "(", "'invalid training matrix: {}'", ".", "format", "(", "type", ...
Update for one iteration, with objective function calculated internally. Parameters ---------- dtrain : DMatrix Training data. iteration : int Current iteration number. fobj : function Customized objective function.
[ "Update", "for", "one", "iteration", "with", "objective", "function", "calculated", "internally", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L664-L686
29,605
apple/turicreate
src/external/xgboost/python-package/xgboost/core.py
Booster.boost
def boost(self, dtrain, grad, hess): """ Boost the booster for one iteration, with customized gradient statistics. Parameters ---------- dtrain : DMatrix The training DMatrix. grad : list The first order of gradient. hess : list ...
python
def boost(self, dtrain, grad, hess): """ Boost the booster for one iteration, with customized gradient statistics. Parameters ---------- dtrain : DMatrix The training DMatrix. grad : list The first order of gradient. hess : list ...
[ "def", "boost", "(", "self", ",", "dtrain", ",", "grad", ",", "hess", ")", ":", "if", "len", "(", "grad", ")", "!=", "len", "(", "hess", ")", ":", "raise", "ValueError", "(", "'grad / hess length mismatch: {} / {}'", ".", "format", "(", "len", "(", "gr...
Boost the booster for one iteration, with customized gradient statistics. Parameters ---------- dtrain : DMatrix The training DMatrix. grad : list The first order of gradient. hess : list The second order of gradient.
[ "Boost", "the", "booster", "for", "one", "iteration", "with", "customized", "gradient", "statistics", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L688-L710
29,606
apple/turicreate
src/external/xgboost/python-package/xgboost/core.py
Booster.eval_set
def eval_set(self, evals, iteration=0, feval=None): # pylint: disable=invalid-name """Evaluate a set of data. Parameters ---------- evals : list of tuples (DMatrix, string) List of items to be evaluated. iteration : int Current iteration. ...
python
def eval_set(self, evals, iteration=0, feval=None): # pylint: disable=invalid-name """Evaluate a set of data. Parameters ---------- evals : list of tuples (DMatrix, string) List of items to be evaluated. iteration : int Current iteration. ...
[ "def", "eval_set", "(", "self", ",", "evals", ",", "iteration", "=", "0", ",", "feval", "=", "None", ")", ":", "# pylint: disable=invalid-name", "if", "feval", "is", "None", ":", "for", "d", "in", "evals", ":", "if", "not", "isinstance", "(", "d", "[",...
Evaluate a set of data. Parameters ---------- evals : list of tuples (DMatrix, string) List of items to be evaluated. iteration : int Current iteration. feval : function Custom evaluation function. Returns ------- res...
[ "Evaluate", "a", "set", "of", "data", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L712-L750
29,607
apple/turicreate
src/external/xgboost/python-package/xgboost/core.py
Booster.save_raw
def save_raw(self): """ Save the model to a in memory buffer represetation Returns ------- a in memory buffer represetation of the model """ length = ctypes.c_ulong() cptr = ctypes.POINTER(ctypes.c_char)() _check_call(_LIB.XGBoosterGetModelRaw(sel...
python
def save_raw(self): """ Save the model to a in memory buffer represetation Returns ------- a in memory buffer represetation of the model """ length = ctypes.c_ulong() cptr = ctypes.POINTER(ctypes.c_char)() _check_call(_LIB.XGBoosterGetModelRaw(sel...
[ "def", "save_raw", "(", "self", ")", ":", "length", "=", "ctypes", ".", "c_ulong", "(", ")", "cptr", "=", "ctypes", ".", "POINTER", "(", "ctypes", ".", "c_char", ")", "(", ")", "_check_call", "(", "_LIB", ".", "XGBoosterGetModelRaw", "(", "self", ".", ...
Save the model to a in memory buffer represetation Returns ------- a in memory buffer represetation of the model
[ "Save", "the", "model", "to", "a", "in", "memory", "buffer", "represetation" ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L840-L853
29,608
apple/turicreate
src/external/xgboost/python-package/xgboost/core.py
Booster.dump_model
def dump_model(self, fout, fmap='', with_stats=False): """ Dump model into a text file. Parameters ---------- foout : string Output file name. fmap : string, optional Name of the file containing feature map names. with_stats : bool (option...
python
def dump_model(self, fout, fmap='', with_stats=False): """ Dump model into a text file. Parameters ---------- foout : string Output file name. fmap : string, optional Name of the file containing feature map names. with_stats : bool (option...
[ "def", "dump_model", "(", "self", ",", "fout", ",", "fmap", "=", "''", ",", "with_stats", "=", "False", ")", ":", "if", "isinstance", "(", "fout", ",", "STRING_TYPES", ")", ":", "fout", "=", "open", "(", "fout", ",", "'w'", ")", "need_close", "=", ...
Dump model into a text file. Parameters ---------- foout : string Output file name. fmap : string, optional Name of the file containing feature map names. with_stats : bool (optional) Controls whether the split statistics are output.
[ "Dump", "model", "into", "a", "text", "file", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L875-L898
29,609
apple/turicreate
src/external/xgboost/python-package/xgboost/core.py
Booster.get_dump
def get_dump(self, fmap='', with_stats=False): """ Returns the dump the model as a list of strings. """ length = ctypes.c_ulong() sarr = ctypes.POINTER(ctypes.c_char_p)() if self.feature_names is not None and fmap == '': flen = int(len(self.feature_names)) ...
python
def get_dump(self, fmap='', with_stats=False): """ Returns the dump the model as a list of strings. """ length = ctypes.c_ulong() sarr = ctypes.POINTER(ctypes.c_char_p)() if self.feature_names is not None and fmap == '': flen = int(len(self.feature_names)) ...
[ "def", "get_dump", "(", "self", ",", "fmap", "=", "''", ",", "with_stats", "=", "False", ")", ":", "length", "=", "ctypes", ".", "c_ulong", "(", ")", "sarr", "=", "ctypes", ".", "POINTER", "(", "ctypes", ".", "c_char_p", ")", "(", ")", "if", "self"...
Returns the dump the model as a list of strings.
[ "Returns", "the", "dump", "the", "model", "as", "a", "list", "of", "strings", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L900-L934
29,610
apple/turicreate
src/external/xgboost/python-package/xgboost/core.py
Booster.get_fscore
def get_fscore(self, fmap=''): """Get feature importance of each feature. Parameters ---------- fmap: str (optional) The name of feature map file """ trees = self.get_dump(fmap) fmap = {} for tree in trees: for line in tree.split('\...
python
def get_fscore(self, fmap=''): """Get feature importance of each feature. Parameters ---------- fmap: str (optional) The name of feature map file """ trees = self.get_dump(fmap) fmap = {} for tree in trees: for line in tree.split('\...
[ "def", "get_fscore", "(", "self", ",", "fmap", "=", "''", ")", ":", "trees", "=", "self", ".", "get_dump", "(", "fmap", ")", "fmap", "=", "{", "}", "for", "tree", "in", "trees", ":", "for", "line", "in", "tree", ".", "split", "(", "'\\n'", ")", ...
Get feature importance of each feature. Parameters ---------- fmap: str (optional) The name of feature map file
[ "Get", "feature", "importance", "of", "each", "feature", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L936-L957
29,611
apple/turicreate
deps/src/boost_1_68_0/tools/build/src/util/regex.py
transform
def transform (list, pattern, indices = [1]): """ Matches all elements of 'list' agains the 'pattern' and returns a list of the elements indicated by indices of all successfull matches. If 'indices' is omitted returns a list of first paranthethised groups of all successfull matches. ...
python
def transform (list, pattern, indices = [1]): """ Matches all elements of 'list' agains the 'pattern' and returns a list of the elements indicated by indices of all successfull matches. If 'indices' is omitted returns a list of first paranthethised groups of all successfull matches. ...
[ "def", "transform", "(", "list", ",", "pattern", ",", "indices", "=", "[", "1", "]", ")", ":", "result", "=", "[", "]", "for", "e", "in", "list", ":", "m", "=", "re", ".", "match", "(", "pattern", ",", "e", ")", "if", "m", ":", "for", "i", ...
Matches all elements of 'list' agains the 'pattern' and returns a list of the elements indicated by indices of all successfull matches. If 'indices' is omitted returns a list of first paranthethised groups of all successfull matches.
[ "Matches", "all", "elements", "of", "list", "agains", "the", "pattern", "and", "returns", "a", "list", "of", "the", "elements", "indicated", "by", "indices", "of", "all", "successfull", "matches", ".", "If", "indices", "is", "omitted", "returns", "a", "list"...
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/util/regex.py#L11-L27
29,612
apple/turicreate
deps/src/boost_1_68_0/tools/build/src/util/regex.py
replace
def replace(s, pattern, replacement): """Replaces occurrences of a match string in a given string and returns the new string. The match string can be a regex expression. Args: s (str): the string to modify pattern (str): the search expression replacement (str): the...
python
def replace(s, pattern, replacement): """Replaces occurrences of a match string in a given string and returns the new string. The match string can be a regex expression. Args: s (str): the string to modify pattern (str): the search expression replacement (str): the...
[ "def", "replace", "(", "s", ",", "pattern", ",", "replacement", ")", ":", "# the replacement string may contain invalid backreferences (like \\1 or \\g)", "# which will cause python's regex to blow up. Since this should emulate", "# the jam version exactly and the jam version didn't support"...
Replaces occurrences of a match string in a given string and returns the new string. The match string can be a regex expression. Args: s (str): the string to modify pattern (str): the search expression replacement (str): the string to replace each match with
[ "Replaces", "occurrences", "of", "a", "match", "string", "in", "a", "given", "string", "and", "returns", "the", "new", "string", ".", "The", "match", "string", "can", "be", "a", "regex", "expression", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/util/regex.py#L31-L50
29,613
apple/turicreate
deps/src/boost_1_68_0/tools/build/src/util/regex.py
replace_list
def replace_list(items, match, replacement): """Replaces occurrences of a match string in a given list of strings and returns a list of new strings. The match string can be a regex expression. Args: items (list): the list of strings to modify. match (str): the search expression...
python
def replace_list(items, match, replacement): """Replaces occurrences of a match string in a given list of strings and returns a list of new strings. The match string can be a regex expression. Args: items (list): the list of strings to modify. match (str): the search expression...
[ "def", "replace_list", "(", "items", ",", "match", ",", "replacement", ")", ":", "return", "[", "replace", "(", "item", ",", "match", ",", "replacement", ")", "for", "item", "in", "items", "]" ]
Replaces occurrences of a match string in a given list of strings and returns a list of new strings. The match string can be a regex expression. Args: items (list): the list of strings to modify. match (str): the search expression. replacement (str): the string to replace ...
[ "Replaces", "occurrences", "of", "a", "match", "string", "in", "a", "given", "list", "of", "strings", "and", "returns", "a", "list", "of", "new", "strings", ".", "The", "match", "string", "can", "be", "a", "regex", "expression", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/util/regex.py#L54-L63
29,614
apple/turicreate
src/unity/python/turicreate/toolkits/topic_model/topic_model.py
create
def create(dataset, num_topics=10, initial_topics=None, alpha=None, beta=.1, num_iterations=10, num_burnin=5, associations=None, verbose=False, print_interval=10, validation_set=None, method='auto'):...
python
def create(dataset, num_topics=10, initial_topics=None, alpha=None, beta=.1, num_iterations=10, num_burnin=5, associations=None, verbose=False, print_interval=10, validation_set=None, method='auto'):...
[ "def", "create", "(", "dataset", ",", "num_topics", "=", "10", ",", "initial_topics", "=", "None", ",", "alpha", "=", "None", ",", "beta", "=", ".1", ",", "num_iterations", "=", "10", ",", "num_burnin", "=", "5", ",", "associations", "=", "None", ",", ...
Create a topic model from the given data set. A topic model assumes each document is a mixture of a set of topics, where for each topic some words are more likely than others. One statistical approach to do this is called a "topic model". This method learns a topic model for the given document collectio...
[ "Create", "a", "topic", "model", "from", "the", "given", "data", "set", ".", "A", "topic", "model", "assumes", "each", "document", "is", "a", "mixture", "of", "a", "set", "of", "topics", "where", "for", "each", "topic", "some", "words", "are", "more", ...
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/topic_model/topic_model.py#L35-L271
29,615
apple/turicreate
src/unity/python/turicreate/toolkits/topic_model/topic_model.py
perplexity
def perplexity(test_data, predictions, topics, vocabulary): """ Compute the perplexity of a set of test documents given a set of predicted topics. Let theta be the matrix of document-topic probabilities, where theta_ik = p(topic k | document i). Let Phi be the matrix of term-topic probabilities...
python
def perplexity(test_data, predictions, topics, vocabulary): """ Compute the perplexity of a set of test documents given a set of predicted topics. Let theta be the matrix of document-topic probabilities, where theta_ik = p(topic k | document i). Let Phi be the matrix of term-topic probabilities...
[ "def", "perplexity", "(", "test_data", ",", "predictions", ",", "topics", ",", "vocabulary", ")", ":", "test_data", "=", "_check_input", "(", "test_data", ")", "assert", "isinstance", "(", "predictions", ",", "_SArray", ")", ",", "\"Predictions must be an SArray o...
Compute the perplexity of a set of test documents given a set of predicted topics. Let theta be the matrix of document-topic probabilities, where theta_ik = p(topic k | document i). Let Phi be the matrix of term-topic probabilities, where phi_jk = p(word j | topic k). Then for each word in each do...
[ "Compute", "the", "perplexity", "of", "a", "set", "of", "test", "documents", "given", "a", "set", "of", "predicted", "topics", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/topic_model/topic_model.py#L740-L826
29,616
apple/turicreate
src/unity/python/turicreate/toolkits/topic_model/topic_model.py
TopicModel.get_topics
def get_topics(self, topic_ids=None, num_words=5, cdf_cutoff=1.0, output_type='topic_probabilities'): """ Get the words associated with a given topic. The score column is the probability of choosing that word given that you have chosen a particular topic. Par...
python
def get_topics(self, topic_ids=None, num_words=5, cdf_cutoff=1.0, output_type='topic_probabilities'): """ Get the words associated with a given topic. The score column is the probability of choosing that word given that you have chosen a particular topic. Par...
[ "def", "get_topics", "(", "self", ",", "topic_ids", "=", "None", ",", "num_words", "=", "5", ",", "cdf_cutoff", "=", "1.0", ",", "output_type", "=", "'topic_probabilities'", ")", ":", "_check_categorical_option_type", "(", "'output_type'", ",", "output_type", ",...
Get the words associated with a given topic. The score column is the probability of choosing that word given that you have chosen a particular topic. Parameters ---------- topic_ids : list of int, optional The topics to retrieve words. Topic ids are zero-based. ...
[ "Get", "the", "words", "associated", "with", "a", "given", "topic", ".", "The", "score", "column", "is", "the", "probability", "of", "choosing", "that", "word", "given", "that", "you", "have", "chosen", "a", "particular", "topic", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/topic_model/topic_model.py#L430-L568
29,617
apple/turicreate
src/unity/python/turicreate/toolkits/topic_model/topic_model.py
TopicModel.predict
def predict(self, dataset, output_type='assignment', num_burnin=None): """ Use the model to predict topics for each document. The provided `dataset` should be an SArray object where each element is a dict representing a single document in bag-of-words format, where keys are words...
python
def predict(self, dataset, output_type='assignment', num_burnin=None): """ Use the model to predict topics for each document. The provided `dataset` should be an SArray object where each element is a dict representing a single document in bag-of-words format, where keys are words...
[ "def", "predict", "(", "self", ",", "dataset", ",", "output_type", "=", "'assignment'", ",", "num_burnin", "=", "None", ")", ":", "dataset", "=", "_check_input", "(", "dataset", ")", "if", "num_burnin", "is", "None", ":", "num_burnin", "=", "self", ".", ...
Use the model to predict topics for each document. The provided `dataset` should be an SArray object where each element is a dict representing a single document in bag-of-words format, where keys are words and values are their corresponding counts. If `dataset` is an SFrame, then it must...
[ "Use", "the", "model", "to", "predict", "topics", "for", "each", "document", ".", "The", "provided", "dataset", "should", "be", "an", "SArray", "object", "where", "each", "element", "is", "a", "dict", "representing", "a", "single", "document", "in", "bag", ...
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/topic_model/topic_model.py#L570-L660
29,618
apple/turicreate
src/unity/python/turicreate/toolkits/topic_model/topic_model.py
TopicModel.evaluate
def evaluate(self, train_data, test_data=None, metric='perplexity'): """ Estimate the model's ability to predict new data. Imagine you have a corpus of books. One common approach to evaluating topic models is to train on the first half of all of the books and see how well the model ...
python
def evaluate(self, train_data, test_data=None, metric='perplexity'): """ Estimate the model's ability to predict new data. Imagine you have a corpus of books. One common approach to evaluating topic models is to train on the first half of all of the books and see how well the model ...
[ "def", "evaluate", "(", "self", ",", "train_data", ",", "test_data", "=", "None", ",", "metric", "=", "'perplexity'", ")", ":", "train_data", "=", "_check_input", "(", "train_data", ")", "if", "test_data", "is", "None", ":", "test_data", "=", "train_data", ...
Estimate the model's ability to predict new data. Imagine you have a corpus of books. One common approach to evaluating topic models is to train on the first half of all of the books and see how well the model predicts the second half of each book. This method returns a metric called pe...
[ "Estimate", "the", "model", "s", "ability", "to", "predict", "new", "data", ".", "Imagine", "you", "have", "a", "corpus", "of", "books", ".", "One", "common", "approach", "to", "evaluating", "topic", "models", "is", "to", "train", "on", "the", "first", "...
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/topic_model/topic_model.py#L663-L731
29,619
apple/turicreate
src/unity/python/turicreate/toolkits/drawing_classifier/drawing_classifier.py
_raise_error_if_not_drawing_classifier_input_sframe
def _raise_error_if_not_drawing_classifier_input_sframe( dataset, feature, target): """ Performs some sanity checks on the SFrame provided as input to `turicreate.drawing_classifier.create` and raises a ToolkitError if something in the dataset is missing or wrong. """ from turicreate.toolki...
python
def _raise_error_if_not_drawing_classifier_input_sframe( dataset, feature, target): """ Performs some sanity checks on the SFrame provided as input to `turicreate.drawing_classifier.create` and raises a ToolkitError if something in the dataset is missing or wrong. """ from turicreate.toolki...
[ "def", "_raise_error_if_not_drawing_classifier_input_sframe", "(", "dataset", ",", "feature", ",", "target", ")", ":", "from", "turicreate", ".", "toolkits", ".", "_internal_utils", "import", "_raise_error_if_not_sframe", "_raise_error_if_not_sframe", "(", "dataset", ")", ...
Performs some sanity checks on the SFrame provided as input to `turicreate.drawing_classifier.create` and raises a ToolkitError if something in the dataset is missing or wrong.
[ "Performs", "some", "sanity", "checks", "on", "the", "SFrame", "provided", "as", "input", "to", "turicreate", ".", "drawing_classifier", ".", "create", "and", "raises", "a", "ToolkitError", "if", "something", "in", "the", "dataset", "is", "missing", "or", "wro...
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/drawing_classifier/drawing_classifier.py#L22-L45
29,620
apple/turicreate
src/unity/python/turicreate/toolkits/drawing_classifier/drawing_classifier.py
DrawingClassifier._predict_with_probabilities
def _predict_with_probabilities(self, input_dataset, batch_size=None, verbose=True): """ Predict with probabilities. The core prediction part that both `evaluate` and `predict` share. Returns an SFrame with two columns, self.target, and "probabilities". The column wit...
python
def _predict_with_probabilities(self, input_dataset, batch_size=None, verbose=True): """ Predict with probabilities. The core prediction part that both `evaluate` and `predict` share. Returns an SFrame with two columns, self.target, and "probabilities". The column wit...
[ "def", "_predict_with_probabilities", "(", "self", ",", "input_dataset", ",", "batch_size", "=", "None", ",", "verbose", "=", "True", ")", ":", "from", ".", ".", "_mxnet", "import", "_mxnet_utils", "import", "mxnet", "as", "_mx", "from", ".", "_sframe_loader",...
Predict with probabilities. The core prediction part that both `evaluate` and `predict` share. Returns an SFrame with two columns, self.target, and "probabilities". The column with column name, self.target, contains the predictions made by the model for the provided dataset. ...
[ "Predict", "with", "probabilities", ".", "The", "core", "prediction", "part", "that", "both", "evaluate", "and", "predict", "share", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/drawing_classifier/drawing_classifier.py#L522-L601
29,621
apple/turicreate
src/unity/python/turicreate/toolkits/drawing_classifier/drawing_classifier.py
DrawingClassifier.predict
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...
python
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", ")", ":", "_tkutl", ".", "_check_categorical_option_type", "(", "\"output_type\"", ",", "output_type", ",", "[", "\"p...
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 ...
[ "Predict", "on", "an", "SFrame", "or", "SArray", "of", "drawings", "or", "on", "a", "single", "drawing", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/drawing_classifier/drawing_classifier.py#L788-L879
29,622
apple/turicreate
src/unity/python/turicreate/toolkits/text_classifier/_text_classifier.py
_BOW_FEATURE_EXTRACTOR
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...
python
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", ")", ":", "if", "isinstance", "(", "sf", ",", "dict", ")", ":", "out", "=", "_tc", ".", "SArray", "(", "[", "sf", "]", ")", ".", "unpack", "(", "''", ")", "elif", "isinstance",...
Return an SFrame containing a bag of words representation of each column.
[ "Return", "an", "SFrame", "containing", "a", "bag", "of", "words", "representation", "of", "each", "column", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/text_classifier/_text_classifier.py#L18-L31
29,623
apple/turicreate
src/unity/python/turicreate/toolkits/text_classifier/_text_classifier.py
_get_str_columns
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]
python
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", ")", ":", "return", "[", "name", "for", "name", "in", "sf", ".", "column_names", "(", ")", "if", "sf", "[", "name", "]", ".", "dtype", "==", "str", "]" ]
Returns a list of names of columns that are string type.
[ "Returns", "a", "list", "of", "names", "of", "columns", "that", "are", "string", "type", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/text_classifier/_text_classifier.py#L372-L376
29,624
apple/turicreate
src/unity/python/turicreate/toolkits/text_classifier/_text_classifier.py
TextClassifier.predict
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...
python
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'", ")", ":", "m", "=", "self", ".", "__proxy__", "[", "'classifier'", "]", "target", "=", "self", ".", "__proxy__", "[", "'target'", "]", "f", "=", "_BOW_FEATURE_EXTRACTOR", ...
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...
[ "Return", "predictions", "for", "dataset", "using", "the", "trained", "model", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/text_classifier/_text_classifier.py#L182-L224
29,625
apple/turicreate
src/unity/python/turicreate/toolkits/text_classifier/_text_classifier.py
TextClassifier.classify
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 ...
python
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", ")", ":", "m", "=", "self", ".", "__proxy__", "[", "'classifier'", "]", "target", "=", "self", ".", "__proxy__", "[", "'target'", "]", "f", "=", "_BOW_FEATURE_EXTRACTOR", "return", "m", ".", "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 ...
[ "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...
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/text_classifier/_text_classifier.py#L226-L260
29,626
apple/turicreate
src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_SVR.py
_generate_base_svm_regression_spec
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...
python
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", ")", ":", "if", "not", "(", "_HAS_SKLEARN", ")", ":", "raise", "RuntimeError", "(", "'scikit-learn not found. scikit-learn conversion API is disabled.'", ")", "spec", "=", "_Model_pb2", ".", "Model", "(", ")", ...
Takes an SVM regression model produces a starting spec using the parts. that are shared between all SVMs.
[ "Takes", "an", "SVM", "regression", "model", "produces", "a", "starting", "spec", "using", "the", "parts", ".", "that", "are", "shared", "between", "all", "SVMs", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_SVR.py#L23-L46
29,627
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py
_VerifyExtensionHandle
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...
python
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", ")", ":", "if", "not", "isinstance", "(", "extension_handle", ",", "_FieldDescriptor", ")", ":", "raise", "KeyError", "(", "'HasExtension() expects an extension handle, got: %s'", "%", "extension_ha...
Verify that the given extension handle is valid.
[ "Verify", "that", "the", "given", "extension", "handle", "is", "valid", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L213-L232
29,628
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py
_AddEnumValues
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...
python
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", ")", ":", "for", "enum_type", "in", "descriptor", ".", "enum_types", ":", "setattr", "(", "cls", ",", "enum_type", ".", "name", ",", "enum_type_wrapper", ".", "EnumTypeWrapper", "(", "enum_type", ")", "...
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.
[ "Sets", "class", "-", "level", "attributes", "for", "all", "enum", "fields", "defined", "in", "this", "message", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L347-L359
29,629
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py
_DefaultValueConstructorForField
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...
python
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", ")", ":", "if", "_IsMapField", "(", "field", ")", ":", "return", "_GetInitializeDefaultForMap", "(", "field", ")", "if", "field", ".", "label", "==", "_FieldDescriptor", ".", "LABEL_REPEATED", ":", "if", "...
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...
[ "Returns", "a", "function", "which", "returns", "a", "default", "value", "for", "a", "field", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L384-L436
29,630
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py
_ReraiseTypeErrorWithFieldName
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' % (...
python
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", ")", ":", "exc", "=", "sys", ".", "exc_info", "(", ")", "[", "1", "]", "if", "len", "(", "exc", ".", "args", ")", "==", "1", "and", "type", "(", "exc", ")", "is", "TypeE...
Re-raise the currently-handled TypeError with the field name added.
[ "Re", "-", "raise", "the", "currently", "-", "handled", "TypeError", "with", "the", "field", "name", "added", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L439-L447
29,631
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py
_GetFieldByName
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...
python
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", ")", ":", "try", ":", "return", "message_descriptor", ".", "fields_by_name", "[", "field_name", "]", "except", "KeyError", ":", "raise", "ValueError", "(", "'Protocol message %s has no \"%s\" field....
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.
[ "Returns", "a", "field", "descriptor", "by", "field", "name", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L534-L547
29,632
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py
_AddPropertiesForNonRepeatedScalarField
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 ...
python
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", ")", ":", "proto_field_name", "=", "field", ".", "name", "property_name", "=", "_PropertyName", "(", "proto_field_name", ")", "type_checker", "=", "type_checkers", ".", "GetTypeChecker", "(", ...
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....
[ "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...
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L630-L683
29,633
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py
_InternalUnpackAny
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. ...
python
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", ")", ":", "# 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", ...
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...
[ "Unpacks", "Any", "message", "and", "returns", "the", "unpacked", "message", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L892-L929
29,634
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py
_BytesForNonRepeatedElement
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. ...
python
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", ")", ":", "try", ":", "fn", "=", "type_checkers", ".", "TYPE_TO_BYTE_SIZE_FN", "[", "field_type", "]", "return", "fn", "(", "field_number", ",", "value", ")", "except", ...
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 ...
[ "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...
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L984-L1001
29,635
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py
_AddIsInitializedMethod
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(...
python
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", ")", ":", "required_fields", "=", "[", "field", "for", "field", "in", "message_descriptor", ".", "fields", "if", "field", ".", "label", "==", "_FieldDescriptor", ".", "LABEL_REQUIRED", "]", ...
Adds the IsInitialized and FindInitializationError methods to the protocol message class.
[ "Adds", "the", "IsInitialized", "and", "FindInitializationError", "methods", "to", "the", "protocol", "message", "class", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L1106-L1198
29,636
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py
_AddMessageMethods
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...
python
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", ")", ":", "_AddListFieldsMethod", "(", "message_descriptor", ",", "cls", ")", "_AddHasFieldMethod", "(", "message_descriptor", ",", "cls", ")", "_AddClearFieldMethod", "(", "message_descriptor", ",", ...
Adds implementations of all Message methods to cls.
[ "Adds", "implementations", "of", "all", "Message", "methods", "to", "cls", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L1295-L1318
29,637
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py
_AddPrivateHelperMethods
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...
python
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", ")", ":", "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 ...
Adds implementation of private helper methods to cls.
[ "Adds", "implementation", "of", "private", "helper", "methods", "to", "cls", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L1321-L1352
29,638
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py
_OneofListener.Modified
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
python
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", ")", ":", "try", ":", "self", ".", "_parent_message_weakref", ".", "_UpdateOneofState", "(", "self", ".", "_field", ")", "super", "(", "_OneofListener", ",", "self", ")", ".", "Modified", "(", ")", "except", "ReferenceError", ...
Also updates the state of the containing oneof in the parent message.
[ "Also", "updates", "the", "state", "of", "the", "containing", "oneof", "in", "the", "parent", "message", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L1413-L1419
29,639
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/enum_type_wrapper.py
EnumTypeWrapper.Name
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))
python
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", ")", ":", "if", "number", "in", "self", ".", "_enum_type", ".", "values_by_number", ":", "return", "self", ".", "_enum_type", ".", "values_by_number", "[", "number", "]", ".", "name", "raise", "ValueError", "(", ...
Returns a string containing the name of an enum value.
[ "Returns", "a", "string", "containing", "the", "name", "of", "an", "enum", "value", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/enum_type_wrapper.py#L51-L56
29,640
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/enum_type_wrapper.py
EnumTypeWrapper.Value
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))
python
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", ")", ":", "if", "name", "in", "self", ".", "_enum_type", ".", "values_by_name", ":", "return", "self", ".", "_enum_type", ".", "values_by_name", "[", "name", "]", ".", "number", "raise", "ValueError", "(", "'Enum...
Returns the value coresponding to the given enum name.
[ "Returns", "the", "value", "coresponding", "to", "the", "given", "enum", "name", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/enum_type_wrapper.py#L58-L63
29,641
apple/turicreate
src/unity/python/turicreate/toolkits/_mps_utils.py
_load_tcmps_lib
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 ...
python
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", "(", ")", ":", "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...
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.
[ "Load", "global", "singleton", "of", "tcmps", "lib", "handler", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_mps_utils.py#L141-L164
29,642
apple/turicreate
src/unity/python/turicreate/toolkits/_mps_utils.py
mps_device_name
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: ...
python
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", "(", ")", ":", "lib", "=", "_load_tcmps_lib", "(", ")", "if", "lib", "is", "None", ":", "return", "None", "n", "=", "256", "c_name", "=", "(", "_ctypes", ".", "c_char", "*", "n", ")", "(", ")", "ret", "=", "lib", ".", "T...
Returns name of MPS device that will be used, else None.
[ "Returns", "name", "of", "MPS", "device", "that", "will", "be", "used", "else", "None", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_mps_utils.py#L188-L202
29,643
apple/turicreate
src/unity/python/turicreate/toolkits/_mps_utils.py
mps_device_memory_limit
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...
python
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", "(", ")", ":", "lib", "=", "_load_tcmps_lib", "(", ")", "if", "lib", "is", "None", ":", "return", "None", "c_size", "=", "_ctypes", ".", "c_uint64", "(", ")", "ret", "=", "lib", ".", "TCMPSMetalDeviceMemoryLimit", "(", "_c...
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.
[ "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", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_mps_utils.py#L205-L216
29,644
apple/turicreate
src/unity/python/turicreate/toolkits/_mps_utils.py
MpsFloatArray.shape
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...
python
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", ")", ":", "# 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", "(...
Copy the shape from TCMPS as a new numpy ndarray.
[ "Copy", "the", "shape", "from", "TCMPS", "as", "a", "new", "numpy", "ndarray", "." ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_mps_utils.py#L314-L326
29,645
apple/turicreate
src/unity/python/turicreate/toolkits/_mps_utils.py
MpsFloatArray.asnumpy
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...
python
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", ")", ":", "# 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", ...
Copy the data from TCMPS into a new numpy ndarray
[ "Copy", "the", "data", "from", "TCMPS", "into", "a", "new", "numpy", "ndarray" ]
74514c3f99e25b46f22c6e02977fe3da69221c2e
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_mps_utils.py#L328-L344
29,646
Miserlou/Zappa
zappa/asynchronous.py
route_sns_task
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)
python
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", ")", ":", "record", "=", "event", "[", "'Records'", "]", "[", "0", "]", "message", "=", "json", ".", "loads", "(", "record", "[", "'Sns'", "]", "[", "'Message'", "]", ")", "return", "run_message", ...
Gets SNS Message, deserialises the message, imports the function, calls the function with args
[ "Gets", "SNS", "Message", "deserialises", "the", "message", "imports", "the", "function", "calls", "the", "function", "with", "args" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/asynchronous.py#L275-L284
29,647
Miserlou/Zappa
zappa/asynchronous.py
task
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...
python
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", ")", ":", "func", "=", "None", "if", "len", "(", "args", ")", "==", "1", "and", "callable", "(", "args", "[", "0", "]", ")", ":", "func", "=", "args", "[", "0", "]", "if", "not", "kw...
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...
[ "Async", "task", "decorator", "so", "that", "running" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/asynchronous.py#L364-L439
29,648
Miserlou/Zappa
zappa/asynchronous.py
get_func_task_path
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...
python
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", ")", ":", "module_path", "=", "inspect", ".", "getmodule", "(", "func", ")", ".", "__name__", "task_path", "=", "'{module_path}.{func_name}'", ".", "format", "(", "module_path", "=", "module_path", ",", "func_name", "=",...
Format the modular task path for a function via inspection.
[ "Format", "the", "modular", "task", "path", "for", "a", "function", "via", "inspection", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/asynchronous.py#L464-L473
29,649
Miserlou/Zappa
zappa/asynchronous.py
get_async_response
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...
python
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", ")", ":", "response", "=", "DYNAMODB_CLIENT", ".", "get_item", "(", "TableName", "=", "ASYNC_RESPONSE_TABLE", ",", "Key", "=", "{", "'id'", ":", "{", "'S'", ":", "str", "(", "response_id", ")", "}", "}", ")"...
Get the response from the async table
[ "Get", "the", "response", "from", "the", "async", "table" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/asynchronous.py#L476-L490
29,650
Miserlou/Zappa
zappa/asynchronous.py
LambdaAsyncResponse.send
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...
python
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", ")", ":", "message", "=", "{", "'task_path'", ":", "task_path", ",", "'capture_response'", ":", "self", ".", "capture_response", ",", "'response_id'", ":", "self", ".", "response_id", ...
Create the message object and pass it to the actual sender.
[ "Create", "the", "message", "object", "and", "pass", "it", "to", "the", "actual", "sender", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/asynchronous.py#L162-L174
29,651
Miserlou/Zappa
zappa/asynchronous.py
LambdaAsyncResponse._send
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...
python
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", ")", ":", "message", "[", "'command'", "]", "=", "'zappa.asynchronous.route_lambda_task'", "payload", "=", "json", ".", "dumps", "(", "message", ")", ".", "encode", "(", "'utf-8'", ")", "if", "len", "(", "payloa...
Given a message, directly invoke the lamdba function for this task.
[ "Given", "a", "message", "directly", "invoke", "the", "lamdba", "function", "for", "this", "task", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/asynchronous.py#L176-L189
29,652
Miserlou/Zappa
zappa/asynchronous.py
SnsAsyncResponse._send
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...
python
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", ")", ":", "message", "[", "'command'", "]", "=", "'zappa.asynchronous.route_sns_task'", "payload", "=", "json", ".", "dumps", "(", "message", ")", ".", "encode", "(", "'utf-8'", ")", "if", "len", "(", "payload",...
Given a message, publish to this topic.
[ "Given", "a", "message", "publish", "to", "this", "topic", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/asynchronous.py#L242-L254
29,653
Miserlou/Zappa
zappa/utilities.py
parse_s3_url
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
python
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", ")", ":", "bucket", "=", "''", "path", "=", "''", "if", "url", ":", "result", "=", "urlparse", "(", "url", ")", "bucket", "=", "result", ".", "netloc", "path", "=", "result", ".", "path", ".", "strip", "(", "'/'",...
Parses S3 URL. Returns bucket (domain) and file (full path).
[ "Parses", "S3", "URL", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/utilities.py#L67-L79
29,654
Miserlou/Zappa
zappa/utilities.py
string_to_timestamp
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...
python
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", ")", ":", "ts", "=", "None", "# Uses an extended version of Go's duration string.", "try", ":", "delta", "=", "durationpy", ".", "from_str", "(", "timestring", ")", "past", "=", "datetime", ".", "datetime", ".", "ut...
Accepts a str, returns an int timestamp.
[ "Accepts", "a", "str", "returns", "an", "int", "timestamp", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/utilities.py#L91-L111
29,655
Miserlou/Zappa
zappa/utilities.py
detect_django_settings
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...
python
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", "(", ")", ":", "matches", "=", "[", "]", "for", "root", ",", "dirnames", ",", "filenames", "in", "os", ".", "walk", "(", "os", ".", "getcwd", "(", ")", ")", ":", "for", "filename", "in", "fnmatch", ".", "filter", "(",...
Automatically try to discover Django settings files, return them as relative module paths.
[ "Automatically", "try", "to", "discover", "Django", "settings", "files", "return", "them", "as", "relative", "module", "paths", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/utilities.py#L117-L134
29,656
Miserlou/Zappa
zappa/utilities.py
detect_flask_apps
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) ...
python
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", "(", ")", ":", "matches", "=", "[", "]", "for", "root", ",", "dirnames", ",", "filenames", "in", "os", ".", "walk", "(", "os", ".", "getcwd", "(", ")", ")", ":", "for", "filename", "in", "fnmatch", ".", "filter", "(", "f...
Automatically try to discover Flask apps files, return them as relative module paths.
[ "Automatically", "try", "to", "discover", "Flask", "apps", "files", "return", "them", "as", "relative", "module", "paths", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/utilities.py#L136-L171
29,657
Miserlou/Zappa
zappa/utilities.py
check_new_version_available
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...
python
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", ")", ":", "import", "requests", "pypi_url", "=", "'https://pypi.python.org/pypi/Zappa/json'", "resp", "=", "requests", ".", "get", "(", "pypi_url", ",", "timeout", "=", "1.5", ")", "top_version", "=", "resp"...
Checks if a newer version of Zappa is available. Returns True is updateable, else False.
[ "Checks", "if", "a", "newer", "version", "of", "Zappa", "is", "available", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/utilities.py#L442-L455
29,658
Miserlou/Zappa
zappa/utilities.py
conflicts_with_a_neighbouring_module
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_...
python
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", ")", ":", "parent_dir_path", ",", "current_dir_name", "=", "os", ".", "path", ".", "split", "(", "os", ".", "path", ".", "normpath", "(", "directory_path", ")", ")", "neighbours", "=", "os", ...
Checks if a directory lies in the same directory as a .py file with the same name.
[ "Checks", "if", "a", "directory", "lies", "in", "the", "same", "directory", "as", "a", ".", "py", "file", "with", "the", "same", "name", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/utilities.py#L509-L516
29,659
Miserlou/Zappa
zappa/wsgi.py
common_log
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...
python
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", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", ")", "if", "response_time", ":", "formatter", "=", "ApacheFormatter", "(", "with_response_time", "=", "True", ...
Given the WSGI environ and the response, log this event in Common Log Format.
[ "Given", "the", "WSGI", "environ", "and", "the", "response", "log", "this", "event", "in", "Common", "Log", "Format", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/wsgi.py#L171-L196
29,660
Miserlou/Zappa
zappa/handler.py
LambdaHandler.load_remote_settings
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...
python
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", ")", ":", "if", "not", "self", ".", "session", ":", "boto_session", "=", "boto3", ".", "Session", "(", ")", "else", ":", "boto_session", "=", "self", ".", "session", "s3"...
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.
[ "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", "-", ...
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/handler.py#L184-L230
29,661
Miserlou/Zappa
zappa/handler.py
LambdaHandler.run_function
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 ...
python
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", ")", ":", "# getargspec does not support python 3 method with type hints", "# Related issue: https://github.com/Miserlou/Zappa/issues/1452", "if", "hasattr", "(", "inspect", ",", "\"getfullargspec\"", ")", ...
Given a function and event context, detect signature and execute, returning any result.
[ "Given", "a", "function", "and", "event", "context", "detect", "signature", "and", "execute", "returning", "any", "result", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/handler.py#L270-L291
29,662
Miserlou/Zappa
zappa/handler.py
LambdaHandler.get_function_for_aws_event
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'][...
python
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", ")", ":", "if", "'s3'", "in", "record", ":", "if", "':'", "in", "record", "[", "'s3'", "]", "[", "'configurationId'", "]", ":", "return", "record", "[", "'s3'", "]", "[", "'configurationId'",...
Get the associated function to execute for a triggered AWS event Support S3, SNS, DynamoDB, kinesis and SQS events
[ "Get", "the", "associated", "function", "to", "execute", "for", "a", "triggered", "AWS", "event" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/handler.py#L293-L322
29,663
Miserlou/Zappa
zappa/handler.py
LambdaHandler.get_function_from_bot_intent_trigger
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...
python
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", ")", ":", "intent", "=", "event", ".", "get", "(", "'currentIntent'", ")", "if", "intent", ":", "intent", "=", "intent", ".", "get", "(", "'name'", ")", "if", "intent", ":", "return"...
For the given event build ARN and return the configured function
[ "For", "the", "given", "event", "build", "ARN", "and", "return", "the", "configured", "function" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/handler.py#L324-L334
29,664
Miserlou/Zappa
zappa/handler.py
LambdaHandler.get_function_for_cognito_trigger
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...
python
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", ")", ":", "print", "(", "\"get_function_for_cognito_trigger\"", ",", "self", ".", "settings", ".", "COGNITO_TRIGGER_MAPPING", ",", "trigger", ",", "self", ".", "settings", ".", "COGNITO_TRIGGER_MA...
Get the associated function to execute for a cognito trigger
[ "Get", "the", "associated", "function", "to", "execute", "for", "a", "cognito", "trigger" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/handler.py#L336-L341
29,665
Miserlou/Zappa
example/authmodule.py
lambda_handler
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:""" ...
python
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'", "]", ")", "\"\"\"and produce the principal...
validate the incoming token
[ "validate", "the", "incoming", "token" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/example/authmodule.py#L15-L61
29,666
Miserlou/Zappa
example/authmodule.py
AuthPolicy._addMethod
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...
python
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", ")", ":", "if", "verb", "!=", "\"*\"", "and", "not", "hasattr", "(", "HttpVerb", ",", "verb", ")", ":", "raise", "NameError", "(", "\"Invalid HTTP verb \"", ...
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.
[ "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", ...
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/example/authmodule.py#L104-L134
29,667
Miserlou/Zappa
zappa/core.py
Zappa.boto_client
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))
python
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", ")", ":", "return", "self", ".", "boto_session", ".", "client", "(", "service", ",", "*", "args", ",", "*", "*", "self", ".", "configure_boto_session_method_kwa...
A wrapper to apply configuration options to boto clients
[ "A", "wrapper", "to", "apply", "configuration", "options", "to", "boto", "clients" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L334-L336
29,668
Miserlou/Zappa
zappa/core.py
Zappa.boto_resource
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))
python
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", ")", ":", "return", "self", ".", "boto_session", ".", "resource", "(", "service", ",", "*", "args", ",", "*", "*", "self", ".", "configure_boto_session_method...
A wrapper to apply configuration options to boto resources
[ "A", "wrapper", "to", "apply", "configuration", "options", "to", "boto", "resources" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L338-L340
29,669
Miserlou/Zappa
zappa/core.py
Zappa.cache_param
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...
python
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", ")", ":", "if", "value", "not", "in", "self", ".", "cf_parameters", ":", "keyname", "=", "chr", "(", "ord", "(", "'A'", ")", "+", "len", "(", "self", ".", "cf_parameters", ")", ")", "param", "=", "se...
Returns a troposphere Ref to a value cached as a parameter.
[ "Returns", "a", "troposphere", "Ref", "to", "a", "value", "cached", "as", "a", "parameter", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L342-L353
29,670
Miserlou/Zappa
zappa/core.py
Zappa.get_deps_list
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 ...
python
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", ")", ":", "# 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...
For a given package, returns a list of required packages. Recursive.
[ "For", "a", "given", "package", "returns", "a", "list", "of", "required", "packages", ".", "Recursive", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L373-L389
29,671
Miserlou/Zappa
zappa/core.py
Zappa.create_handler_venv
def create_handler_venv(self): """ Takes the installed zappa and brings it into a fresh virtualenv-like folder. All dependencies are then downloaded. """ import subprocess # We will need the currenv venv to pull Zappa from current_venv = self.get_current_venv() ...
python
def create_handler_venv(self): """ Takes the installed zappa and brings it into a fresh virtualenv-like folder. All dependencies are then downloaded. """ import subprocess # We will need the currenv venv to pull Zappa from current_venv = self.get_current_venv() ...
[ "def", "create_handler_venv", "(", "self", ")", ":", "import", "subprocess", "# We will need the currenv venv to pull Zappa from", "current_venv", "=", "self", ".", "get_current_venv", "(", ")", "# Make a new folder for the handler packages", "ve_path", "=", "os", ".", "pat...
Takes the installed zappa and brings it into a fresh virtualenv-like folder. All dependencies are then downloaded.
[ "Takes", "the", "installed", "zappa", "and", "brings", "it", "into", "a", "fresh", "virtualenv", "-", "like", "folder", ".", "All", "dependencies", "are", "then", "downloaded", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L391-L437
29,672
Miserlou/Zappa
zappa/core.py
Zappa.get_current_venv
def get_current_venv(): """ Returns the path to the current virtualenv """ if 'VIRTUAL_ENV' in os.environ: venv = os.environ['VIRTUAL_ENV'] elif os.path.exists('.python-version'): # pragma: no cover try: subprocess.check_output(['pyenv', '...
python
def get_current_venv(): """ Returns the path to the current virtualenv """ if 'VIRTUAL_ENV' in os.environ: venv = os.environ['VIRTUAL_ENV'] elif os.path.exists('.python-version'): # pragma: no cover try: subprocess.check_output(['pyenv', '...
[ "def", "get_current_venv", "(", ")", ":", "if", "'VIRTUAL_ENV'", "in", "os", ".", "environ", ":", "venv", "=", "os", ".", "environ", "[", "'VIRTUAL_ENV'", "]", "elif", "os", ".", "path", ".", "exists", "(", "'.python-version'", ")", ":", "# pragma: no cove...
Returns the path to the current virtualenv
[ "Returns", "the", "path", "to", "the", "current", "virtualenv" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L441-L461
29,673
Miserlou/Zappa
zappa/core.py
Zappa.extract_lambda_package
def extract_lambda_package(self, package_name, path): """ Extracts the lambda package into a given path. Assumes the package exists in lambda packages. """ lambda_package = lambda_packages[package_name][self.runtime] # Trash the local version to help with package space saving ...
python
def extract_lambda_package(self, package_name, path): """ Extracts the lambda package into a given path. Assumes the package exists in lambda packages. """ lambda_package = lambda_packages[package_name][self.runtime] # Trash the local version to help with package space saving ...
[ "def", "extract_lambda_package", "(", "self", ",", "package_name", ",", "path", ")", ":", "lambda_package", "=", "lambda_packages", "[", "package_name", "]", "[", "self", ".", "runtime", "]", "# Trash the local version to help with package space saving", "shutil", ".", ...
Extracts the lambda package into a given path. Assumes the package exists in lambda packages.
[ "Extracts", "the", "lambda", "package", "into", "a", "given", "path", ".", "Assumes", "the", "package", "exists", "in", "lambda", "packages", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L762-L773
29,674
Miserlou/Zappa
zappa/core.py
Zappa.get_installed_packages
def get_installed_packages(site_packages, site_packages_64): """ Returns a dict of installed packages that Zappa cares about. """ import pkg_resources package_to_keep = [] if os.path.isdir(site_packages): package_to_keep += os.listdir(site_packages) i...
python
def get_installed_packages(site_packages, site_packages_64): """ Returns a dict of installed packages that Zappa cares about. """ import pkg_resources package_to_keep = [] if os.path.isdir(site_packages): package_to_keep += os.listdir(site_packages) i...
[ "def", "get_installed_packages", "(", "site_packages", ",", "site_packages_64", ")", ":", "import", "pkg_resources", "package_to_keep", "=", "[", "]", "if", "os", ".", "path", ".", "isdir", "(", "site_packages", ")", ":", "package_to_keep", "+=", "os", ".", "l...
Returns a dict of installed packages that Zappa cares about.
[ "Returns", "a", "dict", "of", "installed", "packages", "that", "Zappa", "cares", "about", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L776-L795
29,675
Miserlou/Zappa
zappa/core.py
Zappa.have_correct_lambda_package_version
def have_correct_lambda_package_version(self, package_name, package_version): """ Checks if a given package version binary should be copied over from lambda packages. package_name should be lower-cased version of package name. """ lambda_package_details = lambda_packages.get(pack...
python
def have_correct_lambda_package_version(self, package_name, package_version): """ Checks if a given package version binary should be copied over from lambda packages. package_name should be lower-cased version of package name. """ lambda_package_details = lambda_packages.get(pack...
[ "def", "have_correct_lambda_package_version", "(", "self", ",", "package_name", ",", "package_version", ")", ":", "lambda_package_details", "=", "lambda_packages", ".", "get", "(", "package_name", ",", "{", "}", ")", ".", "get", "(", "self", ".", "runtime", ")",...
Checks if a given package version binary should be copied over from lambda packages. package_name should be lower-cased version of package name.
[ "Checks", "if", "a", "given", "package", "version", "binary", "should", "be", "copied", "over", "from", "lambda", "packages", ".", "package_name", "should", "be", "lower", "-", "cased", "version", "of", "package", "name", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L797-L812
29,676
Miserlou/Zappa
zappa/core.py
Zappa.get_cached_manylinux_wheel
def get_cached_manylinux_wheel(self, package_name, package_version, disable_progress=False): """ Gets the locally stored version of a manylinux wheel. If one does not exist, the function downloads it. """ cached_wheels_dir = os.path.join(tempfile.gettempdir(), 'cached_wheels') if...
python
def get_cached_manylinux_wheel(self, package_name, package_version, disable_progress=False): """ Gets the locally stored version of a manylinux wheel. If one does not exist, the function downloads it. """ cached_wheels_dir = os.path.join(tempfile.gettempdir(), 'cached_wheels') if...
[ "def", "get_cached_manylinux_wheel", "(", "self", ",", "package_name", ",", "package_version", ",", "disable_progress", "=", "False", ")", ":", "cached_wheels_dir", "=", "os", ".", "path", ".", "join", "(", "tempfile", ".", "gettempdir", "(", ")", ",", "'cache...
Gets the locally stored version of a manylinux wheel. If one does not exist, the function downloads it.
[ "Gets", "the", "locally", "stored", "version", "of", "a", "manylinux", "wheel", ".", "If", "one", "does", "not", "exist", "the", "function", "downloads", "it", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L838-L864
29,677
Miserlou/Zappa
zappa/core.py
Zappa.get_manylinux_wheel_url
def get_manylinux_wheel_url(self, package_name, package_version): """ For a given package name, returns a link to the download URL, else returns None. Related: https://github.com/Miserlou/Zappa/issues/398 Examples here: https://gist.github.com/perrygeo/9545f94eaddec18a65fd7b5688...
python
def get_manylinux_wheel_url(self, package_name, package_version): """ For a given package name, returns a link to the download URL, else returns None. Related: https://github.com/Miserlou/Zappa/issues/398 Examples here: https://gist.github.com/perrygeo/9545f94eaddec18a65fd7b5688...
[ "def", "get_manylinux_wheel_url", "(", "self", ",", "package_name", ",", "package_version", ")", ":", "cached_pypi_info_dir", "=", "os", ".", "path", ".", "join", "(", "tempfile", ".", "gettempdir", "(", ")", ",", "'cached_pypi_info'", ")", "if", "not", "os", ...
For a given package name, returns a link to the download URL, else returns None. Related: https://github.com/Miserlou/Zappa/issues/398 Examples here: https://gist.github.com/perrygeo/9545f94eaddec18a65fd7b56880adbae This function downloads metadata JSON of `package_name` from Pypi ...
[ "For", "a", "given", "package", "name", "returns", "a", "link", "to", "the", "download", "URL", "else", "returns", "None", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L866-L909
29,678
Miserlou/Zappa
zappa/core.py
Zappa.copy_on_s3
def copy_on_s3(self, src_file_name, dst_file_name, bucket_name): """ Copies src file to destination within a bucket. """ try: self.s3_client.head_bucket(Bucket=bucket_name) except botocore.exceptions.ClientError as e: # pragma: no cover # If a client erro...
python
def copy_on_s3(self, src_file_name, dst_file_name, bucket_name): """ Copies src file to destination within a bucket. """ try: self.s3_client.head_bucket(Bucket=bucket_name) except botocore.exceptions.ClientError as e: # pragma: no cover # If a client erro...
[ "def", "copy_on_s3", "(", "self", ",", "src_file_name", ",", "dst_file_name", ",", "bucket_name", ")", ":", "try", ":", "self", ".", "s3_client", ".", "head_bucket", "(", "Bucket", "=", "bucket_name", ")", "except", "botocore", ".", "exceptions", ".", "Clien...
Copies src file to destination within a bucket.
[ "Copies", "src", "file", "to", "destination", "within", "a", "bucket", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L975-L1000
29,679
Miserlou/Zappa
zappa/core.py
Zappa.remove_from_s3
def remove_from_s3(self, file_name, bucket_name): """ Given a file name and a bucket, remove it from S3. There's no reason to keep the file hosted on S3 once its been made into a Lambda function, so we can delete it from S3. Returns True on success, False on failure. """ ...
python
def remove_from_s3(self, file_name, bucket_name): """ Given a file name and a bucket, remove it from S3. There's no reason to keep the file hosted on S3 once its been made into a Lambda function, so we can delete it from S3. Returns True on success, False on failure. """ ...
[ "def", "remove_from_s3", "(", "self", ",", "file_name", ",", "bucket_name", ")", ":", "try", ":", "self", ".", "s3_client", ".", "head_bucket", "(", "Bucket", "=", "bucket_name", ")", "except", "botocore", ".", "exceptions", ".", "ClientError", "as", "e", ...
Given a file name and a bucket, remove it from S3. There's no reason to keep the file hosted on S3 once its been made into a Lambda function, so we can delete it from S3. Returns True on success, False on failure.
[ "Given", "a", "file", "name", "and", "a", "bucket", "remove", "it", "from", "S3", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L1002-L1024
29,680
Miserlou/Zappa
zappa/core.py
Zappa.update_lambda_configuration
def update_lambda_configuration( self, lambda_arn, function_name, handler, description='Zappa Deployment', timeout=30...
python
def update_lambda_configuration( self, lambda_arn, function_name, handler, description='Zappa Deployment', timeout=30...
[ "def", "update_lambda_configuration", "(", "self", ",", "lambda_arn", ",", "function_name", ",", "handler", ",", "description", "=", "'Zappa Deployment'", ",", "timeout", "=", "30", ",", "memory_size", "=", "512", ",", "publish", "=", "True", ",", "vpc_config", ...
Given an existing function ARN, update the configuration variables.
[ "Given", "an", "existing", "function", "ARN", "update", "the", "configuration", "variables", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L1174-L1232
29,681
Miserlou/Zappa
zappa/core.py
Zappa.invoke_lambda_function
def invoke_lambda_function( self, function_name, payload, invocation_type='Event', log_type='Tail', client_context=None, qualifi...
python
def invoke_lambda_function( self, function_name, payload, invocation_type='Event', log_type='Tail', client_context=None, qualifi...
[ "def", "invoke_lambda_function", "(", "self", ",", "function_name", ",", "payload", ",", "invocation_type", "=", "'Event'", ",", "log_type", "=", "'Tail'", ",", "client_context", "=", "None", ",", "qualifier", "=", "None", ")", ":", "return", "self", ".", "l...
Directly invoke a named Lambda function with a payload. Returns the response.
[ "Directly", "invoke", "a", "named", "Lambda", "function", "with", "a", "payload", ".", "Returns", "the", "response", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L1234-L1251
29,682
Miserlou/Zappa
zappa/core.py
Zappa.rollback_lambda_function_version
def rollback_lambda_function_version(self, function_name, versions_back=1, publish=True): """ Rollback the lambda function code 'versions_back' number of revisions. Returns the Function ARN. """ response = self.lambda_client.list_versions_by_function(FunctionName=function_name) ...
python
def rollback_lambda_function_version(self, function_name, versions_back=1, publish=True): """ Rollback the lambda function code 'versions_back' number of revisions. Returns the Function ARN. """ response = self.lambda_client.list_versions_by_function(FunctionName=function_name) ...
[ "def", "rollback_lambda_function_version", "(", "self", ",", "function_name", ",", "versions_back", "=", "1", ",", "publish", "=", "True", ")", ":", "response", "=", "self", ".", "lambda_client", ".", "list_versions_by_function", "(", "FunctionName", "=", "functio...
Rollback the lambda function code 'versions_back' number of revisions. Returns the Function ARN.
[ "Rollback", "the", "lambda", "function", "code", "versions_back", "number", "of", "revisions", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L1253-L1278
29,683
Miserlou/Zappa
zappa/core.py
Zappa.get_lambda_function
def get_lambda_function(self, function_name): """ Returns the lambda function ARN, given a name This requires the "lambda:GetFunction" role. """ response = self.lambda_client.get_function( FunctionName=function_name) return response['Configuration']['Func...
python
def get_lambda_function(self, function_name): """ Returns the lambda function ARN, given a name This requires the "lambda:GetFunction" role. """ response = self.lambda_client.get_function( FunctionName=function_name) return response['Configuration']['Func...
[ "def", "get_lambda_function", "(", "self", ",", "function_name", ")", ":", "response", "=", "self", ".", "lambda_client", ".", "get_function", "(", "FunctionName", "=", "function_name", ")", "return", "response", "[", "'Configuration'", "]", "[", "'FunctionArn'", ...
Returns the lambda function ARN, given a name This requires the "lambda:GetFunction" role.
[ "Returns", "the", "lambda", "function", "ARN", "given", "a", "name" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L1280-L1288
29,684
Miserlou/Zappa
zappa/core.py
Zappa.get_lambda_function_versions
def get_lambda_function_versions(self, function_name): """ Simply returns the versions available for a Lambda function, given a function name. """ try: response = self.lambda_client.list_versions_by_function( FunctionName=function_name ) ...
python
def get_lambda_function_versions(self, function_name): """ Simply returns the versions available for a Lambda function, given a function name. """ try: response = self.lambda_client.list_versions_by_function( FunctionName=function_name ) ...
[ "def", "get_lambda_function_versions", "(", "self", ",", "function_name", ")", ":", "try", ":", "response", "=", "self", ".", "lambda_client", ".", "list_versions_by_function", "(", "FunctionName", "=", "function_name", ")", "return", "response", ".", "get", "(", ...
Simply returns the versions available for a Lambda function, given a function name.
[ "Simply", "returns", "the", "versions", "available", "for", "a", "Lambda", "function", "given", "a", "function", "name", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L1290-L1301
29,685
Miserlou/Zappa
zappa/core.py
Zappa.create_api_gateway_routes
def create_api_gateway_routes( self, lambda_arn, api_name=None, api_key_required=False, authorization_type='NONE', authorizer=None, ...
python
def create_api_gateway_routes( self, lambda_arn, api_name=None, api_key_required=False, authorization_type='NONE', authorizer=None, ...
[ "def", "create_api_gateway_routes", "(", "self", ",", "lambda_arn", ",", "api_name", "=", "None", ",", "api_key_required", "=", "False", ",", "authorization_type", "=", "'NONE'", ",", "authorizer", "=", "None", ",", "cors_options", "=", "None", ",", "description...
Create the API Gateway for this Zappa deployment. Returns the new RestAPI CF resource.
[ "Create", "the", "API", "Gateway", "for", "this", "Zappa", "deployment", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L1525-L1616
29,686
Miserlou/Zappa
zappa/core.py
Zappa.create_authorizer
def create_authorizer(self, restapi, uri, authorizer): """ Create Authorizer for API gateway """ authorizer_type = authorizer.get("type", "TOKEN").upper() identity_validation_expression = authorizer.get('validation_expression', None) authorizer_resource = troposphere.api...
python
def create_authorizer(self, restapi, uri, authorizer): """ Create Authorizer for API gateway """ authorizer_type = authorizer.get("type", "TOKEN").upper() identity_validation_expression = authorizer.get('validation_expression', None) authorizer_resource = troposphere.api...
[ "def", "create_authorizer", "(", "self", ",", "restapi", ",", "uri", ",", "authorizer", ")", ":", "authorizer_type", "=", "authorizer", ".", "get", "(", "\"type\"", ",", "\"TOKEN\"", ")", ".", "upper", "(", ")", "identity_validation_expression", "=", "authoriz...
Create Authorizer for API gateway
[ "Create", "Authorizer", "for", "API", "gateway" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L1618-L1645
29,687
Miserlou/Zappa
zappa/core.py
Zappa.deploy_api_gateway
def deploy_api_gateway( self, api_id, stage_name, stage_description="", description="", cache_cluster_enabled=False, cache_cluster_size='0.5', ...
python
def deploy_api_gateway( self, api_id, stage_name, stage_description="", description="", cache_cluster_enabled=False, cache_cluster_size='0.5', ...
[ "def", "deploy_api_gateway", "(", "self", ",", "api_id", ",", "stage_name", ",", "stage_description", "=", "\"\"", ",", "description", "=", "\"\"", ",", "cache_cluster_enabled", "=", "False", ",", "cache_cluster_size", "=", "'0.5'", ",", "variables", "=", "None"...
Deploy the API Gateway! Return the deployed API URL.
[ "Deploy", "the", "API", "Gateway!" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L1751-L1797
29,688
Miserlou/Zappa
zappa/core.py
Zappa.remove_binary_support
def remove_binary_support(self, api_id, cors=False): """ Remove binary support """ response = self.apigateway_client.get_rest_api( restApiId=api_id ) if "binaryMediaTypes" in response and "*/*" in response["binaryMediaTypes"]: self.apigateway_clien...
python
def remove_binary_support(self, api_id, cors=False): """ Remove binary support """ response = self.apigateway_client.get_rest_api( restApiId=api_id ) if "binaryMediaTypes" in response and "*/*" in response["binaryMediaTypes"]: self.apigateway_clien...
[ "def", "remove_binary_support", "(", "self", ",", "api_id", ",", "cors", "=", "False", ")", ":", "response", "=", "self", ".", "apigateway_client", ".", "get_rest_api", "(", "restApiId", "=", "api_id", ")", "if", "\"binaryMediaTypes\"", "in", "response", "and"...
Remove binary support
[ "Remove", "binary", "support" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L1840-L1877
29,689
Miserlou/Zappa
zappa/core.py
Zappa.add_api_compression
def add_api_compression(self, api_id, min_compression_size): """ Add Rest API compression """ self.apigateway_client.update_rest_api( restApiId=api_id, patchOperations=[ { 'op': 'replace', 'path': '/minimumCo...
python
def add_api_compression(self, api_id, min_compression_size): """ Add Rest API compression """ self.apigateway_client.update_rest_api( restApiId=api_id, patchOperations=[ { 'op': 'replace', 'path': '/minimumCo...
[ "def", "add_api_compression", "(", "self", ",", "api_id", ",", "min_compression_size", ")", ":", "self", ".", "apigateway_client", ".", "update_rest_api", "(", "restApiId", "=", "api_id", ",", "patchOperations", "=", "[", "{", "'op'", ":", "'replace'", ",", "'...
Add Rest API compression
[ "Add", "Rest", "API", "compression" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L1879-L1892
29,690
Miserlou/Zappa
zappa/core.py
Zappa.get_api_keys
def get_api_keys(self, api_id, stage_name): """ Generator that allows to iterate per API keys associated to an api_id and a stage_name. """ response = self.apigateway_client.get_api_keys(limit=500) stage_key = '{}/{}'.format(api_id, stage_name) for api_key in response.get...
python
def get_api_keys(self, api_id, stage_name): """ Generator that allows to iterate per API keys associated to an api_id and a stage_name. """ response = self.apigateway_client.get_api_keys(limit=500) stage_key = '{}/{}'.format(api_id, stage_name) for api_key in response.get...
[ "def", "get_api_keys", "(", "self", ",", "api_id", ",", "stage_name", ")", ":", "response", "=", "self", ".", "apigateway_client", ".", "get_api_keys", "(", "limit", "=", "500", ")", "stage_key", "=", "'{}/{}'", ".", "format", "(", "api_id", ",", "stage_na...
Generator that allows to iterate per API keys associated to an api_id and a stage_name.
[ "Generator", "that", "allows", "to", "iterate", "per", "API", "keys", "associated", "to", "an", "api_id", "and", "a", "stage_name", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L1908-L1916
29,691
Miserlou/Zappa
zappa/core.py
Zappa.create_api_key
def create_api_key(self, api_id, stage_name): """ Create new API key and link it with an api_id and a stage_name """ response = self.apigateway_client.create_api_key( name='{}_{}'.format(stage_name, api_id), description='Api Key for {}'.format(api_id), ...
python
def create_api_key(self, api_id, stage_name): """ Create new API key and link it with an api_id and a stage_name """ response = self.apigateway_client.create_api_key( name='{}_{}'.format(stage_name, api_id), description='Api Key for {}'.format(api_id), ...
[ "def", "create_api_key", "(", "self", ",", "api_id", ",", "stage_name", ")", ":", "response", "=", "self", ".", "apigateway_client", ".", "create_api_key", "(", "name", "=", "'{}_{}'", ".", "format", "(", "stage_name", ",", "api_id", ")", ",", "description",...
Create new API key and link it with an api_id and a stage_name
[ "Create", "new", "API", "key", "and", "link", "it", "with", "an", "api_id", "and", "a", "stage_name" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L1918-L1933
29,692
Miserlou/Zappa
zappa/core.py
Zappa.remove_api_key
def remove_api_key(self, api_id, stage_name): """ Remove a generated API key for api_id and stage_name """ response = self.apigateway_client.get_api_keys( limit=1, nameQuery='{}_{}'.format(stage_name, api_id) ) for api_key in response.get('items'):...
python
def remove_api_key(self, api_id, stage_name): """ Remove a generated API key for api_id and stage_name """ response = self.apigateway_client.get_api_keys( limit=1, nameQuery='{}_{}'.format(stage_name, api_id) ) for api_key in response.get('items'):...
[ "def", "remove_api_key", "(", "self", ",", "api_id", ",", "stage_name", ")", ":", "response", "=", "self", ".", "apigateway_client", ".", "get_api_keys", "(", "limit", "=", "1", ",", "nameQuery", "=", "'{}_{}'", ".", "format", "(", "stage_name", ",", "api_...
Remove a generated API key for api_id and stage_name
[ "Remove", "a", "generated", "API", "key", "for", "api_id", "and", "stage_name" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L1935-L1946
29,693
Miserlou/Zappa
zappa/core.py
Zappa.add_api_stage_to_api_key
def add_api_stage_to_api_key(self, api_key, api_id, stage_name): """ Add api stage to Api key """ self.apigateway_client.update_api_key( apiKey=api_key, patchOperations=[ { 'op': 'add', 'path': '/stages', ...
python
def add_api_stage_to_api_key(self, api_key, api_id, stage_name): """ Add api stage to Api key """ self.apigateway_client.update_api_key( apiKey=api_key, patchOperations=[ { 'op': 'add', 'path': '/stages', ...
[ "def", "add_api_stage_to_api_key", "(", "self", ",", "api_key", ",", "api_id", ",", "stage_name", ")", ":", "self", ".", "apigateway_client", ".", "update_api_key", "(", "apiKey", "=", "api_key", ",", "patchOperations", "=", "[", "{", "'op'", ":", "'add'", "...
Add api stage to Api key
[ "Add", "api", "stage", "to", "Api", "key" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L1948-L1961
29,694
Miserlou/Zappa
zappa/core.py
Zappa.get_patch_op
def get_patch_op(self, keypath, value, op='replace'): """ Return an object that describes a change of configuration on the given staging. Setting will be applied on all available HTTP methods. """ if isinstance(value, bool): value = str(value).lower() return {...
python
def get_patch_op(self, keypath, value, op='replace'): """ Return an object that describes a change of configuration on the given staging. Setting will be applied on all available HTTP methods. """ if isinstance(value, bool): value = str(value).lower() return {...
[ "def", "get_patch_op", "(", "self", ",", "keypath", ",", "value", ",", "op", "=", "'replace'", ")", ":", "if", "isinstance", "(", "value", ",", "bool", ")", ":", "value", "=", "str", "(", "value", ")", ".", "lower", "(", ")", "return", "{", "'op'",...
Return an object that describes a change of configuration on the given staging. Setting will be applied on all available HTTP methods.
[ "Return", "an", "object", "that", "describes", "a", "change", "of", "configuration", "on", "the", "given", "staging", ".", "Setting", "will", "be", "applied", "on", "all", "available", "HTTP", "methods", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L1963-L1970
29,695
Miserlou/Zappa
zappa/core.py
Zappa.get_rest_apis
def get_rest_apis(self, project_name): """ Generator that allows to iterate per every available apis. """ all_apis = self.apigateway_client.get_rest_apis( limit=500 ) for api in all_apis['items']: if api['name'] != project_name: co...
python
def get_rest_apis(self, project_name): """ Generator that allows to iterate per every available apis. """ all_apis = self.apigateway_client.get_rest_apis( limit=500 ) for api in all_apis['items']: if api['name'] != project_name: co...
[ "def", "get_rest_apis", "(", "self", ",", "project_name", ")", ":", "all_apis", "=", "self", ".", "apigateway_client", ".", "get_rest_apis", "(", "limit", "=", "500", ")", "for", "api", "in", "all_apis", "[", "'items'", "]", ":", "if", "api", "[", "'name...
Generator that allows to iterate per every available apis.
[ "Generator", "that", "allows", "to", "iterate", "per", "every", "available", "apis", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L1972-L1983
29,696
Miserlou/Zappa
zappa/core.py
Zappa.undeploy_api_gateway
def undeploy_api_gateway(self, lambda_name, domain_name=None, base_path=None): """ Delete a deployed REST API Gateway. """ print("Deleting API Gateway..") api_id = self.get_api_id(lambda_name) if domain_name: # XXX - Remove Route53 smartly here? ...
python
def undeploy_api_gateway(self, lambda_name, domain_name=None, base_path=None): """ Delete a deployed REST API Gateway. """ print("Deleting API Gateway..") api_id = self.get_api_id(lambda_name) if domain_name: # XXX - Remove Route53 smartly here? ...
[ "def", "undeploy_api_gateway", "(", "self", ",", "lambda_name", ",", "domain_name", "=", "None", ",", "base_path", "=", "None", ")", ":", "print", "(", "\"Deleting API Gateway..\"", ")", "api_id", "=", "self", ".", "get_api_id", "(", "lambda_name", ")", "if", ...
Delete a deployed REST API Gateway.
[ "Delete", "a", "deployed", "REST", "API", "Gateway", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L1985-L2014
29,697
Miserlou/Zappa
zappa/core.py
Zappa.update_stage_config
def update_stage_config( self, project_name, stage_name, cloudwatch_log_level, cloudwatch_data_trace, cloudwatch_metrics_enabled ...
python
def update_stage_config( self, project_name, stage_name, cloudwatch_log_level, cloudwatch_data_trace, cloudwatch_metrics_enabled ...
[ "def", "update_stage_config", "(", "self", ",", "project_name", ",", "stage_name", ",", "cloudwatch_log_level", ",", "cloudwatch_data_trace", ",", "cloudwatch_metrics_enabled", ")", ":", "if", "cloudwatch_log_level", "not", "in", "self", ".", "cloudwatch_log_levels", ":...
Update CloudWatch metrics configuration.
[ "Update", "CloudWatch", "metrics", "configuration", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2016-L2038
29,698
Miserlou/Zappa
zappa/core.py
Zappa.delete_stack
def delete_stack(self, name, wait=False): """ Delete the CF stack managed by Zappa. """ try: stack = self.cf_client.describe_stacks(StackName=name)['Stacks'][0] except: # pragma: no cover print('No Zappa stack named {0}'.format(name)) return Fa...
python
def delete_stack(self, name, wait=False): """ Delete the CF stack managed by Zappa. """ try: stack = self.cf_client.describe_stacks(StackName=name)['Stacks'][0] except: # pragma: no cover print('No Zappa stack named {0}'.format(name)) return Fa...
[ "def", "delete_stack", "(", "self", ",", "name", ",", "wait", "=", "False", ")", ":", "try", ":", "stack", "=", "self", ".", "cf_client", ".", "describe_stacks", "(", "StackName", "=", "name", ")", "[", "'Stacks'", "]", "[", "0", "]", "except", ":", ...
Delete the CF stack managed by Zappa.
[ "Delete", "the", "CF", "stack", "managed", "by", "Zappa", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2076-L2096
29,699
Miserlou/Zappa
zappa/core.py
Zappa.create_stack_template
def create_stack_template( self, lambda_arn, lambda_name, api_key_required, iam_authorization, authorizer, cors_options=None, ...
python
def create_stack_template( self, lambda_arn, lambda_name, api_key_required, iam_authorization, authorizer, cors_options=None, ...
[ "def", "create_stack_template", "(", "self", ",", "lambda_arn", ",", "lambda_name", ",", "api_key_required", ",", "iam_authorization", ",", "authorizer", ",", "cors_options", "=", "None", ",", "description", "=", "None", ",", "endpoint_configuration", "=", "None", ...
Build the entire CF stack. Just used for the API Gateway, but could be expanded in the future.
[ "Build", "the", "entire", "CF", "stack", ".", "Just", "used", "for", "the", "API", "Gateway", "but", "could", "be", "expanded", "in", "the", "future", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2098-L2140