Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
DBReporting.addFailure
(self, test, err, capt=None, tbinfo=None)
After a test failure, we want to record testcase run information.
After a test failure, we want to record testcase run information.
def addFailure(self, test, err, capt=None, tbinfo=None): """ After a test failure, we want to record testcase run information. """ self.__insert_test_result(constants.State.FAILURE, test, err)
[ "def", "addFailure", "(", "self", ",", "test", ",", "err", ",", "capt", "=", "None", ",", "tbinfo", "=", "None", ")", ":", "self", ".", "__insert_test_result", "(", "constants", ".", "State", ".", "FAILURE", ",", "test", ",", "err", ")" ]
[ 128, 4 ]
[ 132, 69 ]
python
en
['en', 'error', 'th']
False
_waitid_system_task
(pid: int, event: Event)
Spawn a thread that waits for ``pid`` to exit, then wake any tasks that were waiting on it.
Spawn a thread that waits for ``pid`` to exit, then wake any tasks that were waiting on it.
async def _waitid_system_task(pid: int, event: Event) -> None: """Spawn a thread that waits for ``pid`` to exit, then wake any tasks that were waiting on it. """ # cancellable=True: if this task is cancelled, then we abandon the # thread to keep running waitpid in the background. Since this is #...
[ "async", "def", "_waitid_system_task", "(", "pid", ":", "int", ",", "event", ":", "Event", ")", "->", "None", ":", "# cancellable=True: if this task is cancelled, then we abandon the", "# thread to keep running waitpid in the background. Since this is", "# always run as a system ta...
[ 68, 0 ]
[ 89, 19 ]
python
en
['en', 'en', 'en']
True
TLSContextTest._go_close_connection_error
(url)
:param url: url passed to the query :return: error message string that Go's net/http package throws when server closes connection
:param url: url passed to the query :return: error message string that Go's net/http package throws when server closes connection
def _go_close_connection_error(url): """ :param url: url passed to the query :return: error message string that Go's net/http package throws when server closes connection """ return "Get {}: EOF".format(url)
[ "def", "_go_close_connection_error", "(", "url", ")", ":", "return", "\"Get {}: EOF\"", ".", "format", "(", "url", ")" ]
[ 615, 4 ]
[ 620, 40 ]
python
en
['en', 'error', 'th']
False
TLSIngressTest._go_close_connection_error
(url)
:param url: url passed to the query :return: error message string that Go's net/http package throws when server closes connection
:param url: url passed to the query :return: error message string that Go's net/http package throws when server closes connection
def _go_close_connection_error(url): """ :param url: url passed to the query :return: error message string that Go's net/http package throws when server closes connection """ return "Get {}: EOF".format(url)
[ "def", "_go_close_connection_error", "(", "url", ")", ":", "return", "\"Get {}: EOF\"", ".", "format", "(", "url", ")" ]
[ 863, 4 ]
[ 868, 40 ]
python
en
['en', 'error', 'th']
False
TLSContextProtocolMaxVersion._go_close_connection_error
(url)
:param url: url passed to the query :return: error message string that Go's net/http package throws when server closes connection
:param url: url passed to the query :return: error message string that Go's net/http package throws when server closes connection
def _go_close_connection_error(url): """ :param url: url passed to the query :return: error message string that Go's net/http package throws when server closes connection """ return "Get {}: EOF".format(url)
[ "def", "_go_close_connection_error", "(", "url", ")", ":", "return", "\"Get {}: EOF\"", ".", "format", "(", "url", ")" ]
[ 1032, 4 ]
[ 1037, 40 ]
python
en
['en', 'error', 'th']
False
TLSContextProtocolMinVersion._go_close_connection_error
(url)
:param url: url passed to the query :return: error message string that Go's net/http package throws when server closes connection
:param url: url passed to the query :return: error message string that Go's net/http package throws when server closes connection
def _go_close_connection_error(url): """ :param url: url passed to the query :return: error message string that Go's net/http package throws when server closes connection """ return "Get {}: EOF".format(url)
[ "def", "_go_close_connection_error", "(", "url", ")", ":", "return", "\"Get {}: EOF\"", ".", "format", "(", "url", ")" ]
[ 1144, 4 ]
[ 1149, 40 ]
python
en
['en', 'error', 'th']
False
TLSContextCipherSuites._go_close_connection_error
(url)
:param url: url passed to the query :return: error message string that Go's net/http package throws when server closes connection
:param url: url passed to the query :return: error message string that Go's net/http package throws when server closes connection
def _go_close_connection_error(url): """ :param url: url passed to the query :return: error message string that Go's net/http package throws when server closes connection """ return "Get {}: EOF".format(url)
[ "def", "_go_close_connection_error", "(", "url", ")", ":", "return", "\"Get {}: EOF\"", ".", "format", "(", "url", ")" ]
[ 1247, 4 ]
[ 1252, 40 ]
python
en
['en', 'error', 'th']
False
TLSCoalescing._go_close_connection_error
(url)
:param url: url passed to the query :return: error message string that Go's net/http package throws when server closes connection
:param url: url passed to the query :return: error message string that Go's net/http package throws when server closes connection
def _go_close_connection_error(url): """ :param url: url passed to the query :return: error message string that Go's net/http package throws when server closes connection """ return "Get {}: EOF".format(url)
[ "def", "_go_close_connection_error", "(", "url", ")", ":", "return", "\"Get {}: EOF\"", ".", "format", "(", "url", ")" ]
[ 1384, 4 ]
[ 1389, 40 ]
python
en
['en', 'error', 'th']
False
_ToGypPath
(path)
Converts a path to the format used by gyp.
Converts a path to the format used by gyp.
def _ToGypPath(path): """Converts a path to the format used by gyp.""" if os.sep == '\\' and os.altsep == '/': return path.replace('\\', '/') return path
[ "def", "_ToGypPath", "(", "path", ")", ":", "if", "os", ".", "sep", "==", "'\\\\'", "and", "os", ".", "altsep", "==", "'/'", ":", "return", "path", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", "return", "path" ]
[ 111, 0 ]
[ 115, 13 ]
python
en
['en', 'en', 'en']
True
_ResolveParent
(path, base_path_components)
Resolves |path|, which starts with at least one '../'. Returns an empty string if the path shouldn't be considered. See _AddSources() for a description of |base_path_components|.
Resolves |path|, which starts with at least one '../'. Returns an empty string if the path shouldn't be considered. See _AddSources() for a description of |base_path_components|.
def _ResolveParent(path, base_path_components): """Resolves |path|, which starts with at least one '../'. Returns an empty string if the path shouldn't be considered. See _AddSources() for a description of |base_path_components|.""" depth = 0 while path.startswith('../'): depth += 1 path = path[3:] ...
[ "def", "_ResolveParent", "(", "path", ",", "base_path_components", ")", ":", "depth", "=", "0", "while", "path", ".", "startswith", "(", "'../'", ")", ":", "depth", "+=", "1", "path", "=", "path", "[", "3", ":", "]", "# Relative includes may go outside the s...
[ 118, 0 ]
[ 133, 16 ]
python
en
['en', 'en', 'en']
True
_AddSources
(sources, base_path, base_path_components, result)
Extracts valid sources from |sources| and adds them to |result|. Each source file is relative to |base_path|, but may contain '..'. To make resolving '..' easier |base_path_components| contains each of the directories in |base_path|. Additionally each source may contain variables. Such sources are ignored as it...
Extracts valid sources from |sources| and adds them to |result|. Each source file is relative to |base_path|, but may contain '..'. To make resolving '..' easier |base_path_components| contains each of the directories in |base_path|. Additionally each source may contain variables. Such sources are ignored as it...
def _AddSources(sources, base_path, base_path_components, result): """Extracts valid sources from |sources| and adds them to |result|. Each source file is relative to |base_path|, but may contain '..'. To make resolving '..' easier |base_path_components| contains each of the directories in |base_path|. Addition...
[ "def", "_AddSources", "(", "sources", ",", "base_path", ",", "base_path_components", ",", "result", ")", ":", "# NOTE: gyp paths are always posix style.", "for", "source", "in", "sources", ":", "if", "not", "len", "(", "source", ")", "or", "source", ".", "starts...
[ 136, 0 ]
[ 157, 60 ]
python
en
['en', 'en', 'en']
True
_ToLocalPath
(toplevel_dir, path)
Converts |path| to a path relative to |toplevel_dir|.
Converts |path| to a path relative to |toplevel_dir|.
def _ToLocalPath(toplevel_dir, path): """Converts |path| to a path relative to |toplevel_dir|.""" if path == toplevel_dir: return '' if path.startswith(toplevel_dir + '/'): return path[len(toplevel_dir) + len('/'):] return path
[ "def", "_ToLocalPath", "(", "toplevel_dir", ",", "path", ")", ":", "if", "path", "==", "toplevel_dir", ":", "return", "''", "if", "path", ".", "startswith", "(", "toplevel_dir", "+", "'/'", ")", ":", "return", "path", "[", "len", "(", "toplevel_dir", ")"...
[ 166, 0 ]
[ 172, 13 ]
python
en
['en', 'en', 'en']
True
_WasBuildFileModified
(build_file, data, files, toplevel_dir)
Returns true if the build file |build_file| is either in |files| or one of the files included by |build_file| is in |files|. |toplevel_dir| is the root of the source tree.
Returns true if the build file |build_file| is either in |files| or one of the files included by |build_file| is in |files|. |toplevel_dir| is the root of the source tree.
def _WasBuildFileModified(build_file, data, files, toplevel_dir): """Returns true if the build file |build_file| is either in |files| or one of the files included by |build_file| is in |files|. |toplevel_dir| is the root of the source tree.""" if _ToLocalPath(toplevel_dir, _ToGypPath(build_file)) in files: ...
[ "def", "_WasBuildFileModified", "(", "build_file", ",", "data", ",", "files", ",", "toplevel_dir", ")", ":", "if", "_ToLocalPath", "(", "toplevel_dir", ",", "_ToGypPath", "(", "build_file", ")", ")", "in", "files", ":", "if", "debug", ":", "print", "'gyp fil...
[ 274, 0 ]
[ 296, 14 ]
python
en
['en', 'en', 'en']
True
_GetOrCreateTargetByName
(targets, target_name)
Creates or returns the Target at targets[target_name]. If there is no Target for |target_name| one is created. Returns a tuple of whether a new Target was created and the Target.
Creates or returns the Target at targets[target_name]. If there is no Target for |target_name| one is created. Returns a tuple of whether a new Target was created and the Target.
def _GetOrCreateTargetByName(targets, target_name): """Creates or returns the Target at targets[target_name]. If there is no Target for |target_name| one is created. Returns a tuple of whether a new Target was created and the Target.""" if target_name in targets: return False, targets[target_name] target ...
[ "def", "_GetOrCreateTargetByName", "(", "targets", ",", "target_name", ")", ":", "if", "target_name", "in", "targets", ":", "return", "False", ",", "targets", "[", "target_name", "]", "target", "=", "Target", "(", "target_name", ")", "targets", "[", "target_na...
[ 299, 0 ]
[ 307, 21 ]
python
en
['en', 'en', 'en']
True
_DoesTargetTypeRequireBuild
(target_dict)
Returns true if the target type is such that it needs to be built.
Returns true if the target type is such that it needs to be built.
def _DoesTargetTypeRequireBuild(target_dict): """Returns true if the target type is such that it needs to be built.""" # If a 'none' target has rules or actions we assume it requires a build. return bool(target_dict['type'] != 'none' or target_dict.get('actions') or target_dict.get('rules'))
[ "def", "_DoesTargetTypeRequireBuild", "(", "target_dict", ")", ":", "# If a 'none' target has rules or actions we assume it requires a build.", "return", "bool", "(", "target_dict", "[", "'type'", "]", "!=", "'none'", "or", "target_dict", ".", "get", "(", "'actions'", ")"...
[ 310, 0 ]
[ 314, 69 ]
python
en
['en', 'en', 'en']
True
_GenerateTargets
(data, target_list, target_dicts, toplevel_dir, files, build_files)
Returns a tuple of the following: . A dictionary mapping from fully qualified name to Target. . A list of the targets that have a source file in |files|. . Targets that constitute the 'all' target. See description at top of file for details on the 'all' target. This sets the |match_status| of the targets th...
Returns a tuple of the following: . A dictionary mapping from fully qualified name to Target. . A list of the targets that have a source file in |files|. . Targets that constitute the 'all' target. See description at top of file for details on the 'all' target. This sets the |match_status| of the targets th...
def _GenerateTargets(data, target_list, target_dicts, toplevel_dir, files, build_files): """Returns a tuple of the following: . A dictionary mapping from fully qualified name to Target. . A list of the targets that have a source file in |files|. . Targets that constitute the 'all' target. S...
[ "def", "_GenerateTargets", "(", "data", ",", "target_list", ",", "target_dicts", ",", "toplevel_dir", ",", "files", ",", "build_files", ")", ":", "# Maps from target name to Target.", "name_to_target", "=", "{", "}", "# Targets that matched.", "matching_targets", "=", ...
[ 317, 0 ]
[ 400, 69 ]
python
en
['en', 'en', 'en']
True
_GetUnqualifiedToTargetMapping
(all_targets, to_find)
Returns a tuple of the following: . mapping (dictionary) from unqualified name to Target for all the Targets in |to_find|. . any target names not found. If this is empty all targets were found.
Returns a tuple of the following: . mapping (dictionary) from unqualified name to Target for all the Targets in |to_find|. . any target names not found. If this is empty all targets were found.
def _GetUnqualifiedToTargetMapping(all_targets, to_find): """Returns a tuple of the following: . mapping (dictionary) from unqualified name to Target for all the Targets in |to_find|. . any target names not found. If this is empty all targets were found.""" result = {} if not to_find: return {}, [] ...
[ "def", "_GetUnqualifiedToTargetMapping", "(", "all_targets", ",", "to_find", ")", ":", "result", "=", "{", "}", "if", "not", "to_find", ":", "return", "{", "}", ",", "[", "]", "to_find", "=", "set", "(", "to_find", ")", "for", "target_name", "in", "all_t...
[ 403, 0 ]
[ 419, 37 ]
python
en
['en', 'en', 'en']
True
_DoesTargetDependOnMatchingTargets
(target)
Returns true if |target| or any of its dependencies is one of the targets containing the files supplied as input to analyzer. This updates |matches| of the Targets as it recurses. target: the Target to look for.
Returns true if |target| or any of its dependencies is one of the targets containing the files supplied as input to analyzer. This updates |matches| of the Targets as it recurses. target: the Target to look for.
def _DoesTargetDependOnMatchingTargets(target): """Returns true if |target| or any of its dependencies is one of the targets containing the files supplied as input to analyzer. This updates |matches| of the Targets as it recurses. target: the Target to look for.""" if target.match_status == MATCH_STATUS_DOESN...
[ "def", "_DoesTargetDependOnMatchingTargets", "(", "target", ")", ":", "if", "target", ".", "match_status", "==", "MATCH_STATUS_DOESNT_MATCH", ":", "return", "False", "if", "target", ".", "match_status", "==", "MATCH_STATUS_MATCHES", "or", "target", ".", "match_status"...
[ 422, 0 ]
[ 438, 14 ]
python
en
['en', 'en', 'en']
True
_GetTargetsDependingOnMatchingTargets
(possible_targets)
Returns the list of Targets in |possible_targets| that depend (either directly on indirectly) on at least one of the targets containing the files supplied as input to analyzer. possible_targets: targets to search from.
Returns the list of Targets in |possible_targets| that depend (either directly on indirectly) on at least one of the targets containing the files supplied as input to analyzer. possible_targets: targets to search from.
def _GetTargetsDependingOnMatchingTargets(possible_targets): """Returns the list of Targets in |possible_targets| that depend (either directly on indirectly) on at least one of the targets containing the files supplied as input to analyzer. possible_targets: targets to search from.""" found = [] print 'Targ...
[ "def", "_GetTargetsDependingOnMatchingTargets", "(", "possible_targets", ")", ":", "found", "=", "[", "]", "print", "'Targets that matched by dependency:'", "for", "target", "in", "possible_targets", ":", "if", "_DoesTargetDependOnMatchingTargets", "(", "target", ")", ":"...
[ 441, 0 ]
[ 451, 14 ]
python
en
['en', 'en', 'en']
True
_AddCompileTargets
(target, roots, add_if_no_ancestor, result)
Recurses through all targets that depend on |target|, adding all targets that need to be built (and are in |roots|) to |result|. roots: set of root targets. add_if_no_ancestor: If true and there are no ancestors of |target| then add |target| to |result|. |target| must still be in |roots|. result: targets that...
Recurses through all targets that depend on |target|, adding all targets that need to be built (and are in |roots|) to |result|. roots: set of root targets. add_if_no_ancestor: If true and there are no ancestors of |target| then add |target| to |result|. |target| must still be in |roots|. result: targets that...
def _AddCompileTargets(target, roots, add_if_no_ancestor, result): """Recurses through all targets that depend on |target|, adding all targets that need to be built (and are in |roots|) to |result|. roots: set of root targets. add_if_no_ancestor: If true and there are no ancestors of |target| then add |target...
[ "def", "_AddCompileTargets", "(", "target", ",", "roots", ",", "add_if_no_ancestor", ",", "result", ")", ":", "if", "target", ".", "visited", ":", "return", "target", ".", "visited", "=", "True", "target", ".", "in_roots", "=", "target", "in", "roots", "fo...
[ 454, 0 ]
[ 493, 42 ]
python
en
['en', 'en', 'en']
True
_GetCompileTargets
(matching_targets, supplied_targets)
Returns the set of Targets that require a build. matching_targets: targets that changed and need to be built. supplied_targets: set of targets supplied to analyzer to search from.
Returns the set of Targets that require a build. matching_targets: targets that changed and need to be built. supplied_targets: set of targets supplied to analyzer to search from.
def _GetCompileTargets(matching_targets, supplied_targets): """Returns the set of Targets that require a build. matching_targets: targets that changed and need to be built. supplied_targets: set of targets supplied to analyzer to search from.""" result = set() for target in matching_targets: print 'findin...
[ "def", "_GetCompileTargets", "(", "matching_targets", ",", "supplied_targets", ")", ":", "result", "=", "set", "(", ")", "for", "target", "in", "matching_targets", ":", "print", "'finding compile targets for match'", ",", "target", ".", "name", "_AddCompileTargets", ...
[ 496, 0 ]
[ 504, 15 ]
python
en
['en', 'en', 'en']
True
_WriteOutput
(params, **values)
Writes the output, either to stdout or a file is specified.
Writes the output, either to stdout or a file is specified.
def _WriteOutput(params, **values): """Writes the output, either to stdout or a file is specified.""" if 'error' in values: print 'Error:', values['error'] if 'status' in values: print values['status'] if 'targets' in values: values['targets'].sort() print 'Supplied targets that depend on change...
[ "def", "_WriteOutput", "(", "params", ",", "*", "*", "values", ")", ":", "if", "'error'", "in", "values", ":", "print", "'Error:'", ",", "values", "[", "'error'", "]", "if", "'status'", "in", "values", ":", "print", "values", "[", "'status'", "]", "if"...
[ 507, 0 ]
[ 549, 61 ]
python
en
['en', 'en', 'en']
True
_WasGypIncludeFileModified
(params, files)
Returns true if one of the files in |files| is in the set of included files.
Returns true if one of the files in |files| is in the set of included files.
def _WasGypIncludeFileModified(params, files): """Returns true if one of the files in |files| is in the set of included files.""" if params['options'].includes: for include in params['options'].includes: if _ToGypPath(os.path.normpath(include)) in files: print 'Include file modified, assuming al...
[ "def", "_WasGypIncludeFileModified", "(", "params", ",", "files", ")", ":", "if", "params", "[", "'options'", "]", ".", "includes", ":", "for", "include", "in", "params", "[", "'options'", "]", ".", "includes", ":", "if", "_ToGypPath", "(", "os", ".", "p...
[ 552, 0 ]
[ 560, 14 ]
python
en
['en', 'en', 'en']
True
_NamesNotIn
(names, mapping)
Returns a list of the values in |names| that are not in |mapping|.
Returns a list of the values in |names| that are not in |mapping|.
def _NamesNotIn(names, mapping): """Returns a list of the values in |names| that are not in |mapping|.""" return [name for name in names if name not in mapping]
[ "def", "_NamesNotIn", "(", "names", ",", "mapping", ")", ":", "return", "[", "name", "for", "name", "in", "names", "if", "name", "not", "in", "mapping", "]" ]
[ 563, 0 ]
[ 565, 56 ]
python
en
['en', 'en', 'en']
True
_LookupTargets
(names, mapping)
Returns a list of the mapping[name] for each value in |names| that is in |mapping|.
Returns a list of the mapping[name] for each value in |names| that is in |mapping|.
def _LookupTargets(names, mapping): """Returns a list of the mapping[name] for each value in |names| that is in |mapping|.""" return [mapping[name] for name in names if name in mapping]
[ "def", "_LookupTargets", "(", "names", ",", "mapping", ")", ":", "return", "[", "mapping", "[", "name", "]", "for", "name", "in", "names", "if", "name", "in", "mapping", "]" ]
[ 568, 0 ]
[ 571, 61 ]
python
en
['en', 'en', 'en']
True
CalculateVariables
(default_variables, params)
Calculate additional variables for use in the build (called by gyp).
Calculate additional variables for use in the build (called by gyp).
def CalculateVariables(default_variables, params): """Calculate additional variables for use in the build (called by gyp).""" flavor = gyp.common.GetFlavor(params) if flavor == 'mac': default_variables.setdefault('OS', 'mac') elif flavor == 'win': default_variables.setdefault('OS', 'win') # Copy add...
[ "def", "CalculateVariables", "(", "default_variables", ",", "params", ")", ":", "flavor", "=", "gyp", ".", "common", ".", "GetFlavor", "(", "params", ")", "if", "flavor", "==", "'mac'", ":", "default_variables", ".", "setdefault", "(", "'OS'", ",", "'mac'", ...
[ 574, 0 ]
[ 594, 56 ]
python
en
['en', 'en', 'en']
True
GenerateOutput
(target_list, target_dicts, data, params)
Called by gyp as the final stage. Outputs results.
Called by gyp as the final stage. Outputs results.
def GenerateOutput(target_list, target_dicts, data, params): """Called by gyp as the final stage. Outputs results.""" config = Config() try: config.Init(params) if not config.files: raise Exception('Must specify files to analyze via config_path generator ' 'flag') topleve...
[ "def", "GenerateOutput", "(", "target_list", ",", "target_dicts", ",", "data", ",", "params", ")", ":", "config", "=", "Config", "(", ")", "try", ":", "config", ".", "Init", "(", "params", ")", "if", "not", "config", ".", "files", ":", "raise", "Except...
[ 689, 0 ]
[ 740, 38 ]
python
en
['en', 'en', 'en']
True
Config.Init
(self, params)
Initializes Config. This is a separate method as it raises an exception if there is a parse error.
Initializes Config. This is a separate method as it raises an exception if there is a parse error.
def Init(self, params): """Initializes Config. This is a separate method as it raises an exception if there is a parse error.""" generator_flags = params.get('generator_flags', {}) config_path = generator_flags.get('config_path', None) if not config_path: return try: f = open(config_...
[ "def", "Init", "(", "self", ",", "params", ")", ":", "generator_flags", "=", "params", ".", "get", "(", "'generator_flags'", ",", "{", "}", ")", "config_path", "=", "generator_flags", ".", "get", "(", "'config_path'", ",", "None", ")", "if", "not", "conf...
[ 251, 2 ]
[ 271, 64 ]
python
en
['en', 'en', 'en']
True
TargetCalculator._supplied_target_names_no_all
(self)
Returns the supplied test targets without 'all'.
Returns the supplied test targets without 'all'.
def _supplied_target_names_no_all(self): """Returns the supplied test targets without 'all'.""" result = self._supplied_target_names(); result.discard('all') return result
[ "def", "_supplied_target_names_no_all", "(", "self", ")", ":", "result", "=", "self", ".", "_supplied_target_names", "(", ")", "result", ".", "discard", "(", "'all'", ")", "return", "result" ]
[ 613, 2 ]
[ 617, 17 ]
python
en
['en', 'en', 'en']
True
TargetCalculator.is_build_impacted
(self)
Returns true if the supplied files impact the build at all.
Returns true if the supplied files impact the build at all.
def is_build_impacted(self): """Returns true if the supplied files impact the build at all.""" return self._changed_targets
[ "def", "is_build_impacted", "(", "self", ")", ":", "return", "self", ".", "_changed_targets" ]
[ 619, 2 ]
[ 621, 32 ]
python
en
['en', 'en', 'en']
True
TargetCalculator.find_matching_test_target_names
(self)
Returns the set of output test targets.
Returns the set of output test targets.
def find_matching_test_target_names(self): """Returns the set of output test targets.""" assert self.is_build_impacted() # Find the test targets first. 'all' is special cased to mean all the # root targets. To deal with all the supplied |test_targets| are expanded # to include the root targets durin...
[ "def", "find_matching_test_target_names", "(", "self", ")", ":", "assert", "self", ".", "is_build_impacted", "(", ")", "# Find the test targets first. 'all' is special cased to mean all the", "# root targets. To deal with all the supplied |test_targets| are expanded", "# to include the r...
[ 623, 2 ]
[ 664, 32 ]
python
en
['en', 'en', 'en']
True
TargetCalculator.find_matching_compile_target_names
(self)
Returns the set of output compile targets.
Returns the set of output compile targets.
def find_matching_compile_target_names(self): """Returns the set of output compile targets.""" assert self.is_build_impacted(); # Compile targets are found by searching up from changed targets. # Reset the visited status for _GetBuildTargets. for target in self._name_to_target.itervalues(): ta...
[ "def", "find_matching_compile_target_names", "(", "self", ")", ":", "assert", "self", ".", "is_build_impacted", "(", ")", "# Compile targets are found by searching up from changed targets.", "# Reset the visited status for _GetBuildTargets.", "for", "target", "in", "self", ".", ...
[ 666, 2 ]
[ 686, 42 ]
python
en
['en', 'en', 'en']
True
cli
(file)
\b Read Azure IoT Hub Avro files Returns the content of Avro file FILE as a json string. Examples: \b hubavroreader c:\\temp\\05 hubavroreader c:\\temp\\25.avro
\b Read Azure IoT Hub Avro files Returns the content of Avro file FILE as a json string.
def cli(file): """ \b Read Azure IoT Hub Avro files Returns the content of Avro file FILE as a json string. Examples: \b hubavroreader c:\\temp\\05 hubavroreader c:\\temp\\25.avro """ if (isfile(file)): messages = load_avro_file(file) click.echo(jso...
[ "def", "cli", "(", "file", ")", ":", "if", "(", "isfile", "(", "file", ")", ")", ":", "messages", "=", "load_avro_file", "(", "file", ")", "click", ".", "echo", "(", "json", ".", "dumps", "(", "messages", ",", "indent", "=", "4", ",", "sort_keys", ...
[ 19, 0 ]
[ 36, 47 ]
python
en
['en', 'error', 'th']
False
Profiler.__init__
( self, *, profiler_config: Optional[Dict[str, Dict[str, Dict[str, Any]]]] = None, data_context: Optional[DataContext] = None, )
Create a new Profiler using configured rules. For a rule or an item in a rule configuration, instantiates the following if available: a domain builder, a parameter builder, and a configuration builder. These will be used to define profiler computation patterns. Args: ...
Create a new Profiler using configured rules. For a rule or an item in a rule configuration, instantiates the following if available: a domain builder, a parameter builder, and a configuration builder. These will be used to define profiler computation patterns.
def __init__( self, *, profiler_config: Optional[Dict[str, Dict[str, Dict[str, Any]]]] = None, data_context: Optional[DataContext] = None, ): """ Create a new Profiler using configured rules. For a rule or an item in a rule configuration, instantiates the foll...
[ "def", "__init__", "(", "self", ",", "*", ",", "profiler_config", ":", "Optional", "[", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "Any", "]", "]", "]", "]", "=", "None", ",", "data_context", ":", "Optional", "[", ...
[ 97, 4 ]
[ 198, 13 ]
python
en
['en', 'error', 'th']
False
Profiler.profile
( self, *, expectation_suite_name: Optional[str] = None, include_citation: bool = True, )
Args: :param expectation_suite_name: A name for returned Expectation suite. :param include_citation: Whether or not to include the Profiler config in the metadata for the ExpectationSuite produced by the Profiler :return: Set of rule evaluation results in the form of an Expectat...
Args: :param expectation_suite_name: A name for returned Expectation suite. :param include_citation: Whether or not to include the Profiler config in the metadata for the ExpectationSuite produced by the Profiler :return: Set of rule evaluation results in the form of an Expectat...
def profile( self, *, expectation_suite_name: Optional[str] = None, include_citation: bool = True, ) -> ExpectationSuite: """ Args: :param expectation_suite_name: A name for returned Expectation suite. :param include_citation: Whether or not to...
[ "def", "profile", "(", "self", ",", "*", ",", "expectation_suite_name", ":", "Optional", "[", "str", "]", "=", "None", ",", "include_citation", ":", "bool", "=", "True", ",", ")", "->", "ExpectationSuite", ":", "if", "expectation_suite_name", "is", "None", ...
[ 200, 4 ]
[ 236, 32 ]
python
en
['en', 'error', 'th']
False
compute_convolution
(I, T, stride: int = 1, padding: int = 0)
This function takes an image <I> and a template <T> (both numpy arrays) and returns a heatmap where each grid represents the output produced by convolution at each location.
This function takes an image <I> and a template <T> (both numpy arrays) and returns a heatmap where each grid represents the output produced by convolution at each location.
def compute_convolution(I, T, stride: int = 1, padding: int = 0): """ This function takes an image <I> and a template <T> (both numpy arrays) and returns a heatmap where each grid represents the output produced by convolution at each location. """ # Validate input assert np.ndim(I) == np.ndi...
[ "def", "compute_convolution", "(", "I", ",", "T", ",", "stride", ":", "int", "=", "1", ",", "padding", ":", "int", "=", "0", ")", ":", "# Validate input", "assert", "np", ".", "ndim", "(", "I", ")", "==", "np", ".", "ndim", "(", "T", ")", "==", ...
[ 11, 0 ]
[ 48, 18 ]
python
en
['en', 'error', 'th']
False
predict_boxes
( heatmap: np.ndarray, bbox_shapes: np.ndarray, stride: int = 1, padding: int = 0, threshold: float = 0.7, )
This function takes heatmap and returns the bounding boxes and associated confidence scores. Arguments --------- heatmap: np.array of confidence scores (correlations with template) bbox_shapes: (heatmap_rows, heatmap_cols, 2) map that stores the size of the bounding box that performed best...
This function takes heatmap and returns the bounding boxes and associated confidence scores.
def predict_boxes( heatmap: np.ndarray, bbox_shapes: np.ndarray, stride: int = 1, padding: int = 0, threshold: float = 0.7, ): """ This function takes heatmap and returns the bounding boxes and associated confidence scores. Arguments --------- heatmap: np.array of confidence...
[ "def", "predict_boxes", "(", "heatmap", ":", "np", ".", "ndarray", ",", "bbox_shapes", ":", "np", ".", "ndarray", ",", "stride", ":", "int", "=", "1", ",", "padding", ":", "int", "=", "0", ",", "threshold", ":", "float", "=", "0.7", ",", ")", ":", ...
[ 51, 0 ]
[ 90, 20 ]
python
en
['en', 'error', 'th']
False
heatmap_idx_to_image_idx
(idx_h: int, stride: int, padding: int)
Helper function to convert between heatmap coordinates to image coordinates Arguments --------- idx_h : int or 1-D np.array of heatmap indices
Helper function to convert between heatmap coordinates to image coordinates
def heatmap_idx_to_image_idx(idx_h: int, stride: int, padding: int): """ Helper function to convert between heatmap coordinates to image coordinates Arguments --------- idx_h : int or 1-D np.array of heatmap indices """ idx_i = (stride * idx_h) - padding return idx_i
[ "def", "heatmap_idx_to_image_idx", "(", "idx_h", ":", "int", ",", "stride", ":", "int", ",", "padding", ":", "int", ")", ":", "idx_i", "=", "(", "stride", "*", "idx_h", ")", "-", "padding", "return", "idx_i" ]
[ 93, 0 ]
[ 102, 16 ]
python
en
['en', 'error', 'th']
False
detect_red_light_mf
(I, template_list: List)
This function takes a numpy array <I> and returns a list <output>. The length of <output> is the number of bounding boxes predicted for <I>. Each entry of <output> is a list <[row_TL,col_TL,row_BR,col_BR,score]>. The first four entries are four integers specifying a bounding box (the row and column...
This function takes a numpy array <I> and returns a list <output>. The length of <output> is the number of bounding boxes predicted for <I>. Each entry of <output> is a list <[row_TL,col_TL,row_BR,col_BR,score]>. The first four entries are four integers specifying a bounding box (the row and column...
def detect_red_light_mf(I, template_list: List): """ This function takes a numpy array <I> and returns a list <output>. The length of <output> is the number of bounding boxes predicted for <I>. Each entry of <output> is a list <[row_TL,col_TL,row_BR,col_BR,score]>. The first four entries are four in...
[ "def", "detect_red_light_mf", "(", "I", ",", "template_list", ":", "List", ")", ":", "# Use a shallow, \"wide\"-CNN with multiple matched filters", "# If an image matches any one of the templates, it gets added.", "stride", "=", "2", "# Speed up the computations", "# The less robust ...
[ 105, 0 ]
[ 167, 20 ]
python
en
['en', 'error', 'th']
False
endpad_to_size
(array: np.ndarray, output_size: tuple, fill_value=np.nan)
Pad an array with fill_values at the end, up to output_size.
Pad an array with fill_values at the end, up to output_size.
def endpad_to_size(array: np.ndarray, output_size: tuple, fill_value=np.nan) -> np.ndarray: """Pad an array with fill_values at the end, up to output_size.""" pad_amounts = np.array(output_size, dtype=int) - np.array(array.shape, dtype=int) assert (pad_amounts >= 0).all() pad_before_after = [(0, pad) f...
[ "def", "endpad_to_size", "(", "array", ":", "np", ".", "ndarray", ",", "output_size", ":", "tuple", ",", "fill_value", "=", "np", ".", "nan", ")", "->", "np", ".", "ndarray", ":", "pad_amounts", "=", "np", ".", "array", "(", "output_size", ",", "dtype"...
[ 170, 0 ]
[ 177, 17 ]
python
en
['en', 'en', 'en']
True
main
()
Make predictions on the training set.
Make predictions on the training set.
def main(): args = parse_args() # Load splits file_names_train = np.load(args.splits_folder.joinpath('file_names_train.npy')) file_names_test = np.load(args.splits_folder.joinpath('file_names_test.npy')) # Potentially sub-sample the file names if args.num_images is not None: file_names_...
[ "def", "main", "(", ")", ":", "args", "=", "parse_args", "(", ")", "# Load splits", "file_names_train", "=", "np", ".", "load", "(", "args", ".", "splits_folder", ".", "joinpath", "(", "'file_names_train.npy'", ")", ")", "file_names_test", "=", "np", ".", ...
[ 228, 0 ]
[ 292, 36 ]
python
en
['en', 'error', 'th']
False
V3Route.host_constraints
(self, prune_unreachable_routes: bool)
Return a set of hostglobs that match (a superset of) all hostnames that this route can apply to. An emtpy set means that this route cannot possibly apply to any hostnames. This considers SNI information and (if prune_unreachable_routes) HeaderMatchers that `exact_match` on the `:author...
Return a set of hostglobs that match (a superset of) all hostnames that this route can apply to.
def host_constraints(self, prune_unreachable_routes: bool) -> Set[str]: """Return a set of hostglobs that match (a superset of) all hostnames that this route can apply to. An emtpy set means that this route cannot possibly apply to any hostnames. This considers SNI information and (if ...
[ "def", "host_constraints", "(", "self", ",", "prune_unreachable_routes", ":", "bool", ")", "->", "Set", "[", "str", "]", ":", "# Start by grabbing a list of all the SNI host globs for this route. If there aren't any,", "# default to \"*\".", "hostglobs", "=", "set", "(", "s...
[ 411, 4 ]
[ 464, 24 ]
python
en
['en', 'en', 'en']
True
test_expectation_suite_equality
(baseline_suite, identical_suite, equivalent_suite)
Equality should depend on all defined properties of a configuration object, but not on whether the *instances* are the same.
Equality should depend on all defined properties of a configuration object, but not on whether the *instances* are the same.
def test_expectation_suite_equality(baseline_suite, identical_suite, equivalent_suite): """Equality should depend on all defined properties of a configuration object, but not on whether the *instances* are the same.""" assert baseline_suite is baseline_suite # no difference assert ( baseline_su...
[ "def", "test_expectation_suite_equality", "(", "baseline_suite", ",", "identical_suite", ",", "equivalent_suite", ")", ":", "assert", "baseline_suite", "is", "baseline_suite", "# no difference", "assert", "(", "baseline_suite", "is", "not", "identical_suite", ")", "# diff...
[ 215, 0 ]
[ 225, 45 ]
python
en
['en', 'en', 'en']
True
test_expectation_suite_equivalence
( baseline_suite, identical_suite, equivalent_suite, different_suite, single_expectation_suite, )
Equivalence should depend only on properties that affect the result of the expectation.
Equivalence should depend only on properties that affect the result of the expectation.
def test_expectation_suite_equivalence( baseline_suite, identical_suite, equivalent_suite, different_suite, single_expectation_suite, ): """Equivalence should depend only on properties that affect the result of the expectation.""" assert baseline_suite.isEquivalentTo(baseline_suite) # no di...
[ "def", "test_expectation_suite_equivalence", "(", "baseline_suite", ",", "identical_suite", ",", "equivalent_suite", ",", "different_suite", ",", "single_expectation_suite", ",", ")", ":", "assert", "baseline_suite", ".", "isEquivalentTo", "(", "baseline_suite", ")", "# n...
[ 228, 0 ]
[ 242, 70 ]
python
en
['en', 'en', 'en']
True
DefaultJinjaView.render_content_block
( self, jinja_context, content_block, index=None, content_block_id=None, render_to_markdown: bool = False, )
:param jinja_context: :param content_block: :param index: :param content_block_id: :param render_to_markdown: Whether this method should render the markdown version instead of HTML :return:
def render_content_block( self, jinja_context, content_block, index=None, content_block_id=None, render_to_markdown: bool = False, ): """ :param jinja_context: :param content_block: :param index: :param content_block_id: ...
[ "def", "render_content_block", "(", "self", ",", "jinja_context", ",", "content_block", ",", "index", "=", "None", ",", "content_block_id", "=", "None", ",", "render_to_markdown", ":", "bool", "=", "False", ",", ")", ":", "if", "isinstance", "(", "content_bloc...
[ 128, 4 ]
[ 194, 13 ]
python
en
['en', 'error', 'th']
False
DefaultJinjaView.render_styling
(self, styling)
Adds styling information suitable for an html tag. Example styling block:: styling = { "classes": ["alert", "alert-warning"], "attributes": { "role": "alert", "data-toggle": "popover", }, "style...
Adds styling information suitable for an html tag.
def render_styling(self, styling): """Adds styling information suitable for an html tag. Example styling block:: styling = { "classes": ["alert", "alert-warning"], "attributes": { "role": "alert", "data-toggle": "popo...
[ "def", "render_styling", "(", "self", ",", "styling", ")", ":", "class_list", "=", "styling", ".", "get", "(", "\"classes\"", ",", "None", ")", "if", "class_list", "is", "None", ":", "class_str", "=", "\"\"", "else", ":", "if", "type", "(", "class_list",...
[ 223, 4 ]
[ 283, 29 ]
python
en
['en', 'en', 'en']
True
DefaultJinjaView.render_styling_from_string_template
(self, template)
This method is a thin wrapper use to call `render_styling` from within jinja templates.
This method is a thin wrapper use to call `render_styling` from within jinja templates.
def render_styling_from_string_template(self, template): # NOTE: We should add some kind of type-checking to template """This method is a thin wrapper use to call `render_styling` from within jinja templates.""" if not isinstance(template, (dict, OrderedDict)): return template ...
[ "def", "render_styling_from_string_template", "(", "self", ",", "template", ")", ":", "# NOTE: We should add some kind of type-checking to template", "if", "not", "isinstance", "(", "template", ",", "(", "dict", ",", "OrderedDict", ")", ")", ":", "return", "template", ...
[ 285, 4 ]
[ 295, 21 ]
python
en
['en', 'en', 'en']
True
DefaultMarkdownPageView._validate_document
(self, document: RenderedDocumentContent)
Validate that the document is of the appropriate type at runtime.
Validate that the document is of the appropriate type at runtime.
def _validate_document(self, document: RenderedDocumentContent) -> bool: """ Validate that the document is of the appropriate type at runtime. """ assert isinstance(document, RenderedDocumentContent)
[ "def", "_validate_document", "(", "self", ",", "document", ":", "RenderedDocumentContent", ")", "->", "bool", ":", "assert", "isinstance", "(", "document", ",", "RenderedDocumentContent", ")" ]
[ 470, 4 ]
[ 474, 60 ]
python
en
['en', 'error', 'th']
False
DefaultMarkdownPageView.render
(self, document, template=None, **kwargs)
Handle list as well as single document
Handle list as well as single document
def render(self, document, template=None, **kwargs): """ Handle list as well as single document """ if isinstance(document, list): # We need to keep this as super(DefaultMarkdownPageView, self); otherwise a wrong render will be called. return [ sup...
[ "def", "render", "(", "self", ",", "document", ",", "template", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "document", ",", "list", ")", ":", "# We need to keep this as super(DefaultMarkdownPageView, self); otherwise a wrong render will b...
[ 478, 4 ]
[ 492, 81 ]
python
en
['en', 'error', 'th']
False
DefaultMarkdownPageView.render_string_template
(self, template: pTemplate)
Render string for markdown rendering. Bold all parameters and perform substitution. Args: template: python Template object Returns: Template with substituted values and all parameters bolded
Render string for markdown rendering. Bold all parameters and perform substitution. Args: template: python Template object
def render_string_template(self, template: pTemplate) -> pTemplate: """ Render string for markdown rendering. Bold all parameters and perform substitution. Args: template: python Template object Returns: Template with substituted values and all parameters bolded ...
[ "def", "render_string_template", "(", "self", ",", "template", ":", "pTemplate", ")", "->", "pTemplate", ":", "if", "not", "isinstance", "(", "template", ",", "(", "dict", ",", "OrderedDict", ")", ")", ":", "return", "template", "# replace and render any horizon...
[ 494, 4 ]
[ 553, 9 ]
python
en
['en', 'error', 'th']
False
DefaultMarkdownPageView.render_content_block
( self, jinja_context, content_block, index=None, content_block_id=None, render_to_markdown: bool = True, )
Render a content block to markdown using jinja templates. Args: jinja_context: content_block: index: content_block_id: render_to_markdown: Default of True here instead of parent class default of False Returns:
Render a content block to markdown using jinja templates. Args: jinja_context: content_block: index: content_block_id: render_to_markdown: Default of True here instead of parent class default of False
def render_content_block( self, jinja_context, content_block, index=None, content_block_id=None, render_to_markdown: bool = True, ): """ Render a content block to markdown using jinja templates. Args: jinja_context: cont...
[ "def", "render_content_block", "(", "self", ",", "jinja_context", ",", "content_block", ",", "index", "=", "None", ",", "content_block_id", "=", "None", ",", "render_to_markdown", ":", "bool", "=", "True", ",", ")", ":", "return", "super", "(", ")", ".", "...
[ 556, 4 ]
[ 583, 9 ]
python
en
['en', 'error', 'th']
False
test_checkpoint_script_happy_path_executable_successful_validation_with_ge_config_v2
( caplog, titanic_data_context_v2_with_checkpoint_suite_and_stats_enabled )
We call the "checkpoint script" command on a project with a Checkpoint. The command should: - create the script (note output is tested in other tests) When run the script should: - execute - return a 0 status code - print a success message
We call the "checkpoint script" command on a project with a Checkpoint.
def test_checkpoint_script_happy_path_executable_successful_validation_with_ge_config_v2( caplog, titanic_data_context_v2_with_checkpoint_suite_and_stats_enabled ): """ We call the "checkpoint script" command on a project with a Checkpoint. The command should: - create the script (note output is te...
[ "def", "test_checkpoint_script_happy_path_executable_successful_validation_with_ge_config_v2", "(", "caplog", ",", "titanic_data_context_v2_with_checkpoint_suite_and_stats_enabled", ")", ":", "context", "=", "titanic_data_context_v2_with_checkpoint_suite_and_stats_enabled", "root_dir", "=", ...
[ 989, 0 ]
[ 1039, 44 ]
python
en
['en', 'error', 'th']
False
test_checkpoint_script_happy_path_executable_failed_validation_with_ge_config_v2
( caplog, titanic_data_context_v2_with_checkpoint_suite_and_stats_enabled )
We call the "checkpoint script" command on a project with a Checkpoint. The command should: - create the script (note output is tested in other tests) When run the script should: - execute - return a 1 status code - print a failure message
We call the "checkpoint script" command on a project with a Checkpoint.
def test_checkpoint_script_happy_path_executable_failed_validation_with_ge_config_v2( caplog, titanic_data_context_v2_with_checkpoint_suite_and_stats_enabled ): """ We call the "checkpoint script" command on a project with a Checkpoint. The command should: - create the script (note output is tested...
[ "def", "test_checkpoint_script_happy_path_executable_failed_validation_with_ge_config_v2", "(", "caplog", ",", "titanic_data_context_v2_with_checkpoint_suite_and_stats_enabled", ")", ":", "context", "=", "titanic_data_context_v2_with_checkpoint_suite_and_stats_enabled", "root_dir", "=", "c...
[ 1042, 0 ]
[ 1095, 41 ]
python
en
['en', 'error', 'th']
False
series_to_supervised
(data, n_in=1, n_out=1, dropnan=True)
Frame a time series as a supervised learning dataset. Arguments: :param data: Sequence of observations as a list or NumPy array. :param n_in: Number of lag observations as input (X). :param n_out: Number of observations as output (y). :param dropnan: Boolean whether or not to drop rows with NaN...
Frame a time series as a supervised learning dataset. Arguments: :param data: Sequence of observations as a list or NumPy array. :param n_in: Number of lag observations as input (X). :param n_out: Number of observations as output (y). :param dropnan: Boolean whether or not to drop rows with NaN...
def series_to_supervised(data, n_in=1, n_out=1, dropnan=True): """ Frame a time series as a supervised learning dataset. Arguments: :param data: Sequence of observations as a list or NumPy array. :param n_in: Number of lag observations as input (X). :param n_out: Number of observations as output...
[ "def", "series_to_supervised", "(", "data", ",", "n_in", "=", "1", ",", "n_out", "=", "1", ",", "dropnan", "=", "True", ")", ":", "n_vars", "=", "1", "if", "type", "(", "data", ")", "is", "list", "else", "data", ".", "shape", "[", "1", "]", "data...
[ 31, 0 ]
[ 62, 14 ]
python
en
['en', 'ja', 'th']
False
UserProfileSerializer.create
(self, validated_data)
Create and return a new user.
Create and return a new user.
def create(self, validated_data): """Create and return a new user.""" user = models.UserProfile.objects.create_user( email=validated_data['email'], name=validated_data['name'], password=validated_data['password'] ) return user
[ "def", "create", "(", "self", ",", "validated_data", ")", ":", "user", "=", "models", ".", "UserProfile", ".", "objects", ".", "create_user", "(", "email", "=", "validated_data", "[", "'email'", "]", ",", "name", "=", "validated_data", "[", "'name'", "]", ...
[ 23, 4 ]
[ 34, 19 ]
python
en
['en', 'en', 'en']
True
create_session
()
create a db session @return: db session
create a db session
def create_session(): """ create a db session @return: db session """ engine = create_engine(Config.SQLALCHEMY_DATABASE_URI) return sessionmaker(bind=engine)()
[ "def", "create_session", "(", ")", ":", "engine", "=", "create_engine", "(", "Config", ".", "SQLALCHEMY_DATABASE_URI", ")", "return", "sessionmaker", "(", "bind", "=", "engine", ")", "(", ")" ]
[ 24, 0 ]
[ 30, 38 ]
python
en
['en', 'error', 'th']
False
start_timer
()
start time count @return:
start time count
def start_timer(): """ start time count @return: """ request.start_time = time.time()
[ "def", "start_timer", "(", ")", ":", "request", ".", "start_time", "=", "time", ".", "time", "(", ")" ]
[ 33, 0 ]
[ 38, 36 ]
python
en
['en', 'error', 'th']
False
stop_timer
(response)
record request detail @param response: http response @return: response
record request detail
def stop_timer(response): """ record request detail @param response: http response @return: response """ content_type = response.content_type.replace(" ", "") if "static" in request.path or content_type != "application/json": return response endpoint = request.path if endpoin...
[ "def", "stop_timer", "(", "response", ")", ":", "content_type", "=", "response", ".", "content_type", ".", "replace", "(", "\" \"", ",", "\"\"", ")", "if", "\"static\"", "in", "request", ".", "path", "or", "content_type", "!=", "\"application/json\"", ":", "...
[ 41, 0 ]
[ 108, 19 ]
python
en
['en', 'error', 'th']
False
setup_access_log
(app)
set up access log recording @param app: flask app @return:
set up access log recording
def setup_access_log(app): """ set up access log recording @param app: flask app @return: """ # record start time of each request app.before_request(start_timer) # record request detail app.after_request(stop_timer)
[ "def", "setup_access_log", "(", "app", ")", ":", "# record start time of each request", "app", ".", "before_request", "(", "start_timer", ")", "# record request detail", "app", ".", "after_request", "(", "stop_timer", ")" ]
[ 111, 0 ]
[ 120, 33 ]
python
en
['en', 'error', 'th']
False
GCP.download_metrics
( self, function_name: str, start_time: int, end_time: int, requests: dict, metrics: dict )
Use GCP's logging system to find execution time of each function invocation. There shouldn't be problem of waiting for complete results, since logs appear very quickly here.
Use GCP's logging system to find execution time of each function invocation.
def download_metrics( self, function_name: str, start_time: int, end_time: int, requests: dict, metrics: dict ): from google.api_core import exceptions from time import sleep def wrapper(gen): while True: try: yield next(gen) ...
[ "def", "download_metrics", "(", "self", ",", "function_name", ":", "str", ",", "start_time", ":", "int", ",", "end_time", ":", "int", ",", "requests", ":", "dict", ",", "metrics", ":", "dict", ")", ":", "from", "google", ".", "api_core", "import", "excep...
[ 369, 4 ]
[ 480, 25 ]
python
en
['en', 'error', 'th']
False
location_t.file_name
(self)
Absolute source file name, type string.
Absolute source file name, type string.
def file_name(self): """ Absolute source file name, type string. """ return self._file_name
[ "def", "file_name", "(", "self", ")", ":", "return", "self", ".", "_file_name" ]
[ 35, 4 ]
[ 41, 30 ]
python
en
['en', 'error', 'th']
False
location_t.line
(self)
Line number, type int.
Line number, type int.
def line(self): """ Line number, type int. """ return self._line
[ "def", "line", "(", "self", ")", ":", "return", "self", ".", "_line" ]
[ 48, 4 ]
[ 54, 25 ]
python
en
['en', 'error', 'th']
False
location_t.as_tuple
(self)
Return tuple(self.file_name, self.line)
Return tuple(self.file_name, self.line)
def as_tuple(self): """ Return tuple(self.file_name, self.line) """ return self.file_name, self.line
[ "def", "as_tuple", "(", "self", ")", ":", "return", "self", ".", "file_name", ",", "self", ".", "line" ]
[ 60, 4 ]
[ 66, 40 ]
python
en
['en', 'error', 'th']
False
cancel_shielded_checkpoint
()
Introduce a schedule point, but not a cancel point. This is *not* a :ref:`checkpoint <checkpoints>`, but it is half of a checkpoint, and when combined with :func:`checkpoint_if_cancelled` it can make a full checkpoint. Equivalent to (but potentially more efficient than):: with trio.CancelScop...
Introduce a schedule point, but not a cancel point.
async def cancel_shielded_checkpoint(): """Introduce a schedule point, but not a cancel point. This is *not* a :ref:`checkpoint <checkpoints>`, but it is half of a checkpoint, and when combined with :func:`checkpoint_if_cancelled` it can make a full checkpoint. Equivalent to (but potentially more ...
[ "async", "def", "cancel_shielded_checkpoint", "(", ")", ":", "return", "(", "await", "_async_yield", "(", "CancelShieldedCheckpoint", ")", ")", ".", "unwrap", "(", ")" ]
[ 29, 0 ]
[ 42, 66 ]
python
en
['en', 'en', 'en']
True
wait_task_rescheduled
(abort_func)
Put the current task to sleep, with cancellation support. This is the lowest-level API for blocking in Trio. Every time a :class:`~trio.lowlevel.Task` blocks, it does so by calling this function (usually indirectly via some higher-level API). This is a tricky interface with no guard rails. If you can ...
Put the current task to sleep, with cancellation support.
async def wait_task_rescheduled(abort_func): """Put the current task to sleep, with cancellation support. This is the lowest-level API for blocking in Trio. Every time a :class:`~trio.lowlevel.Task` blocks, it does so by calling this function (usually indirectly via some higher-level API). This is...
[ "async", "def", "wait_task_rescheduled", "(", "abort_func", ")", ":", "return", "(", "await", "_async_yield", "(", "WaitTaskRescheduled", "(", "abort_func", ")", ")", ")", ".", "unwrap", "(", ")" ]
[ 66, 0 ]
[ 165, 73 ]
python
en
['en', 'en', 'en']
True
permanently_detach_coroutine_object
(final_outcome)
Permanently detach the current task from the Trio scheduler. Normally, a Trio task doesn't exit until its coroutine object exits. When you call this function, Trio acts like the coroutine object just exited and the task terminates with the given outcome. This is useful if you want to permanently switch...
Permanently detach the current task from the Trio scheduler.
async def permanently_detach_coroutine_object(final_outcome): """Permanently detach the current task from the Trio scheduler. Normally, a Trio task doesn't exit until its coroutine object exits. When you call this function, Trio acts like the coroutine object just exited and the task terminates with th...
[ "async", "def", "permanently_detach_coroutine_object", "(", "final_outcome", ")", ":", "if", "_run", ".", "current_task", "(", ")", ".", "child_nurseries", ":", "raise", "RuntimeError", "(", "\"can't permanently detach a coroutine object with open nurseries\"", ")", "return...
[ 174, 0 ]
[ 202, 78 ]
python
en
['en', 'en', 'en']
True
temporarily_detach_coroutine_object
(abort_func)
Temporarily detach the current coroutine object from the Trio scheduler. When the calling coroutine enters this function it's running under Trio, and when the function returns it's running under the foreign coroutine runner. The Trio :class:`Task` will continue to exist, but will be suspended unti...
Temporarily detach the current coroutine object from the Trio scheduler.
async def temporarily_detach_coroutine_object(abort_func): """Temporarily detach the current coroutine object from the Trio scheduler. When the calling coroutine enters this function it's running under Trio, and when the function returns it's running under the foreign coroutine runner. The Tri...
[ "async", "def", "temporarily_detach_coroutine_object", "(", "abort_func", ")", ":", "return", "await", "_async_yield", "(", "WaitTaskRescheduled", "(", "abort_func", ")", ")" ]
[ 205, 0 ]
[ 238, 62 ]
python
en
['en', 'en', 'en']
True
reattach_detached_coroutine_object
(task, yield_value)
Reattach a coroutine object that was detached using :func:`temporarily_detach_coroutine_object`. When the calling coroutine enters this function it's running under the foreign coroutine runner, and when the function returns it's running under Trio. This must be called from inside the coroutine bei...
Reattach a coroutine object that was detached using :func:`temporarily_detach_coroutine_object`.
async def reattach_detached_coroutine_object(task, yield_value): """Reattach a coroutine object that was detached using :func:`temporarily_detach_coroutine_object`. When the calling coroutine enters this function it's running under the foreign coroutine runner, and when the function returns it's runnin...
[ "async", "def", "reattach_detached_coroutine_object", "(", "task", ",", "yield_value", ")", ":", "# This is a kind of crude check – in particular, it can fail if the", "# passed-in task is where the coroutine *runner* is running. But this is", "# an experts-only interface, and there's no easy ...
[ 241, 0 ]
[ 269, 48 ]
python
en
['en', 'en', 'en']
True
test_expectations_store_report_store_backend_id_in_memory_store_backend
()
What does this test and why? A Store should be able to report it's store_backend_id which is set when the StoreBackend is instantiated.
What does this test and why? A Store should be able to report it's store_backend_id which is set when the StoreBackend is instantiated.
def test_expectations_store_report_store_backend_id_in_memory_store_backend(): """ What does this test and why? A Store should be able to report it's store_backend_id which is set when the StoreBackend is instantiated. """ in_memory_expectations_store = ExpectationsStore() # Check that store...
[ "def", "test_expectations_store_report_store_backend_id_in_memory_store_backend", "(", ")", ":", "in_memory_expectations_store", "=", "ExpectationsStore", "(", ")", "# Check that store_backend_id exists can be read", "assert", "in_memory_expectations_store", ".", "store_backend_id", "i...
[ 94, 0 ]
[ 104, 83 ]
python
en
['en', 'error', 'th']
False
test_expectations_store_report_same_id_with_same_configuration_TupleFilesystemStoreBackend
( tmp_path_factory, )
What does this test and why? A store with the same config (must be persistent store) should report the same store_backend_id
What does this test and why? A store with the same config (must be persistent store) should report the same store_backend_id
def test_expectations_store_report_same_id_with_same_configuration_TupleFilesystemStoreBackend( tmp_path_factory, ): """ What does this test and why? A store with the same config (must be persistent store) should report the same store_backend_id """ path = "dummy_str" project_path = str( ...
[ "def", "test_expectations_store_report_same_id_with_same_configuration_TupleFilesystemStoreBackend", "(", "tmp_path_factory", ",", ")", ":", "path", "=", "\"dummy_str\"", "project_path", "=", "str", "(", "tmp_path_factory", ".", "mktemp", "(", "\"test_expectations_store_report_sa...
[ 107, 0 ]
[ 162, 5 ]
python
en
['en', 'error', 'th']
False
PandasExecutionEngine.dataframe
(self)
Tests whether or not a Batch has been loaded. If the loaded batch does not exist, raises a ValueError Exception
Tests whether or not a Batch has been loaded. If the loaded batch does not exist, raises a ValueError Exception
def dataframe(self): """Tests whether or not a Batch has been loaded. If the loaded batch does not exist, raises a ValueError Exception """ # Changed to is None because was breaking prior if self.active_batch_data is None: raise ValueError( "Batch has ...
[ "def", "dataframe", "(", "self", ")", ":", "# Changed to is None because was breaking prior", "if", "self", ".", "active_batch_data", "is", "None", ":", "raise", "ValueError", "(", "\"Batch has not been loaded - please run load_batch_data() to load a batch.\"", ")", "return", ...
[ 197, 4 ]
[ 207, 47 ]
python
en
['en', 'en', 'en']
True
PandasExecutionEngine._get_reader_fn
(self, reader_method=None, path=None)
Static helper for parsing reader types. If reader_method is not provided, path will be used to guess the correct reader_method. Args: reader_method (str): the name of the reader method to use, if available. path (str): the path used to guess Returns: ReaderM...
Static helper for parsing reader types. If reader_method is not provided, path will be used to guess the correct reader_method.
def _get_reader_fn(self, reader_method=None, path=None): """Static helper for parsing reader types. If reader_method is not provided, path will be used to guess the correct reader_method. Args: reader_method (str): the name of the reader method to use, if available. path...
[ "def", "_get_reader_fn", "(", "self", ",", "reader_method", "=", "None", ",", "path", "=", "None", ")", ":", "if", "reader_method", "is", "None", "and", "path", "is", "None", ":", "raise", "ge_exceptions", ".", "BatchSpecError", "(", "\"Unable to determine pan...
[ 209, 4 ]
[ 242, 13 ]
python
en
['en', 'en', 'en']
True
PandasExecutionEngine.guess_reader_method_from_path
(path)
Helper method for deciding which reader to use to read in a certain path. Args: path (str): the to use to guess Returns: ReaderMethod to use for the filepath
Helper method for deciding which reader to use to read in a certain path.
def guess_reader_method_from_path(path): """Helper method for deciding which reader to use to read in a certain path. Args: path (str): the to use to guess Returns: ReaderMethod to use for the filepath """ if path.endswith(".csv") or path.endswith(".tsv...
[ "def", "guess_reader_method_from_path", "(", "path", ")", ":", "if", "path", ".", "endswith", "(", "\".csv\"", ")", "or", "path", ".", "endswith", "(", "\".tsv\"", ")", ":", "return", "{", "\"reader_method\"", ":", "\"read_csv\"", "}", "elif", "path", ".", ...
[ 246, 4 ]
[ 276, 9 ]
python
en
['en', 'en', 'en']
True
PandasExecutionEngine.get_compute_domain
( self, domain_kwargs: dict, domain_type: Union[str, MetricDomainTypes], accessor_keys: Optional[Iterable[str]] = None, )
Uses a given batch dictionary and domain kwargs (which include a row condition and a condition parser) to obtain and/or query a batch. Returns in the format of a Pandas DataFrame. If the domain is a single column, this is added to 'accessor domain kwargs' and used for later access Args: ...
Uses a given batch dictionary and domain kwargs (which include a row condition and a condition parser) to obtain and/or query a batch. Returns in the format of a Pandas DataFrame. If the domain is a single column, this is added to 'accessor domain kwargs' and used for later access
def get_compute_domain( self, domain_kwargs: dict, domain_type: Union[str, MetricDomainTypes], accessor_keys: Optional[Iterable[str]] = None, ) -> Tuple[pd.DataFrame, dict, dict]: """Uses a given batch dictionary and domain kwargs (which include a row condition and a conditio...
[ "def", "get_compute_domain", "(", "self", ",", "domain_kwargs", ":", "dict", ",", "domain_type", ":", "Union", "[", "str", ",", "MetricDomainTypes", "]", ",", "accessor_keys", ":", "Optional", "[", "Iterable", "[", "str", "]", "]", "=", "None", ",", ")", ...
[ 278, 4 ]
[ 446, 66 ]
python
en
['en', 'en', 'en']
True
PandasExecutionEngine._split_on_converted_datetime
( df, column_name: str, batch_identifiers: dict, date_format_string: str = "%Y-%m-%d", )
Convert the values in the named column to the given date_format, and split on that
Convert the values in the named column to the given date_format, and split on that
def _split_on_converted_datetime( df, column_name: str, batch_identifiers: dict, date_format_string: str = "%Y-%m-%d", ): """Convert the values in the named column to the given date_format, and split on that""" stringified_datetime_series = df[column_name].map( ...
[ "def", "_split_on_converted_datetime", "(", "df", ",", "column_name", ":", "str", ",", "batch_identifiers", ":", "dict", ",", "date_format_string", ":", "str", "=", "\"%Y-%m-%d\"", ",", ")", ":", "stringified_datetime_series", "=", "df", "[", "column_name", "]", ...
[ 463, 4 ]
[ 474, 65 ]
python
en
['en', 'en', 'en']
True
PandasExecutionEngine._split_on_divided_integer
( df, column_name: str, divisor: int, batch_identifiers: dict )
Divide the values in the named column by `divisor`, and split on that
Divide the values in the named column by `divisor`, and split on that
def _split_on_divided_integer( df, column_name: str, divisor: int, batch_identifiers: dict ): """Divide the values in the named column by `divisor`, and split on that""" matching_divisor = batch_identifiers[column_name] matching_rows = df[column_name].map( lambda x: int(...
[ "def", "_split_on_divided_integer", "(", "df", ",", "column_name", ":", "str", ",", "divisor", ":", "int", ",", "batch_identifiers", ":", "dict", ")", ":", "matching_divisor", "=", "batch_identifiers", "[", "column_name", "]", "matching_rows", "=", "df", "[", ...
[ 477, 4 ]
[ 487, 32 ]
python
en
['en', 'en', 'en']
True
PandasExecutionEngine._split_on_mod_integer
(df, column_name: str, mod: int, batch_identifiers: dict)
Divide the values in the named column by `divisor`, and split on that
Divide the values in the named column by `divisor`, and split on that
def _split_on_mod_integer(df, column_name: str, mod: int, batch_identifiers: dict): """Divide the values in the named column by `divisor`, and split on that""" matching_mod_value = batch_identifiers[column_name] matching_rows = df[column_name].map(lambda x: x % mod == matching_mod_value) ...
[ "def", "_split_on_mod_integer", "(", "df", ",", "column_name", ":", "str", ",", "mod", ":", "int", ",", "batch_identifiers", ":", "dict", ")", ":", "matching_mod_value", "=", "batch_identifiers", "[", "column_name", "]", "matching_rows", "=", "df", "[", "colum...
[ 490, 4 ]
[ 496, 32 ]
python
en
['en', 'en', 'en']
True
PandasExecutionEngine._split_on_multi_column_values
( df, column_names: List[str], batch_identifiers: dict )
Split on the joint values in the named columns
Split on the joint values in the named columns
def _split_on_multi_column_values( df, column_names: List[str], batch_identifiers: dict ): """Split on the joint values in the named columns""" subset_df = df.copy() for column_name in column_names: value = batch_identifiers.get(column_name) if not value: ...
[ "def", "_split_on_multi_column_values", "(", "df", ",", "column_names", ":", "List", "[", "str", "]", ",", "batch_identifiers", ":", "dict", ")", ":", "subset_df", "=", "df", ".", "copy", "(", ")", "for", "column_name", "in", "column_names", ":", "value", ...
[ 499, 4 ]
[ 514, 24 ]
python
en
['en', 'en', 'en']
True
PandasExecutionEngine._split_on_hashed_column
( df, column_name: str, hash_digits: int, batch_identifiers: dict, hash_function_name: str = "md5", )
Split on the hashed value of the named column
Split on the hashed value of the named column
def _split_on_hashed_column( df, column_name: str, hash_digits: int, batch_identifiers: dict, hash_function_name: str = "md5", ): """Split on the hashed value of the named column""" try: hash_method = getattr(hashlib, hash_function_name) ex...
[ "def", "_split_on_hashed_column", "(", "df", ",", "column_name", ":", "str", ",", "hash_digits", ":", "int", ",", "batch_identifiers", ":", "dict", ",", "hash_function_name", ":", "str", "=", "\"md5\"", ",", ")", ":", "try", ":", "hash_method", "=", "getattr...
[ 517, 4 ]
[ 538, 32 ]
python
en
['en', 'en', 'en']
True
PandasExecutionEngine._sample_using_random
( df, p: float = 0.1, )
Take a random sample of rows, retaining proportion p Note: the Random function behaves differently on different dialects of SQL
Take a random sample of rows, retaining proportion p
def _sample_using_random( df, p: float = 0.1, ): """Take a random sample of rows, retaining proportion p Note: the Random function behaves differently on different dialects of SQL """ return df[df.index.map(lambda x: random.random() < p)]
[ "def", "_sample_using_random", "(", "df", ",", "p", ":", "float", "=", "0.1", ",", ")", ":", "return", "df", "[", "df", ".", "index", ".", "map", "(", "lambda", "x", ":", "random", ".", "random", "(", ")", "<", "p", ")", "]" ]
[ 543, 4 ]
[ 551, 62 ]
python
en
['en', 'en', 'en']
True
PandasExecutionEngine._sample_using_mod
( df, column_name: str, mod: int, value: int, )
Take the mod of named column, and only keep rows that match the given value
Take the mod of named column, and only keep rows that match the given value
def _sample_using_mod( df, column_name: str, mod: int, value: int, ): """Take the mod of named column, and only keep rows that match the given value""" return df[df[column_name].map(lambda x: x % mod == value)]
[ "def", "_sample_using_mod", "(", "df", ",", "column_name", ":", "str", ",", "mod", ":", "int", ",", "value", ":", "int", ",", ")", ":", "return", "df", "[", "df", "[", "column_name", "]", ".", "map", "(", "lambda", "x", ":", "x", "%", "mod", "=="...
[ 554, 4 ]
[ 561, 66 ]
python
en
['en', 'en', 'en']
True
PandasExecutionEngine._sample_using_a_list
( df, column_name: str, value_list: list, )
Match the values in the named column against value_list, and only keep the matches
Match the values in the named column against value_list, and only keep the matches
def _sample_using_a_list( df, column_name: str, value_list: list, ): """Match the values in the named column against value_list, and only keep the matches""" return df[df[column_name].isin(value_list)]
[ "def", "_sample_using_a_list", "(", "df", ",", "column_name", ":", "str", ",", "value_list", ":", "list", ",", ")", ":", "return", "df", "[", "df", "[", "column_name", "]", ".", "isin", "(", "value_list", ")", "]" ]
[ 564, 4 ]
[ 570, 51 ]
python
en
['en', 'en', 'en']
True
PandasExecutionEngine._sample_using_hash
( df, column_name: str, hash_digits: int = 1, hash_value: str = "f", hash_function_name: str = "md5", )
Hash the values in the named column, and split on that
Hash the values in the named column, and split on that
def _sample_using_hash( df, column_name: str, hash_digits: int = 1, hash_value: str = "f", hash_function_name: str = "md5", ): """Hash the values in the named column, and split on that""" try: hash_func = getattr(hashlib, hash_function_name) ...
[ "def", "_sample_using_hash", "(", "df", ",", "column_name", ":", "str", ",", "hash_digits", ":", "int", "=", "1", ",", "hash_value", ":", "str", "=", "\"f\"", ",", "hash_function_name", ":", "str", "=", "\"md5\"", ",", ")", ":", "try", ":", "hash_func", ...
[ 573, 4 ]
[ 595, 26 ]
python
en
['en', 'en', 'en']
True
print_declarations
( decls, detailed=True, recursive=True, writer=lambda x: sys.stdout.write(x + os.linesep), verbose=True)
print declarations tree rooted at each of the included nodes. :param decls: either a single :class:declaration_t object or list of :class:declaration_t objects
print declarations tree rooted at each of the included nodes.
def print_declarations( decls, detailed=True, recursive=True, writer=lambda x: sys.stdout.write(x + os.linesep), verbose=True): """ print declarations tree rooted at each of the included nodes. :param decls: either a single :class:declaration_t object or list ...
[ "def", "print_declarations", "(", "decls", ",", "detailed", "=", "True", ",", "recursive", "=", "True", ",", "writer", "=", "lambda", "x", ":", "sys", ".", "stdout", ".", "write", "(", "x", "+", "os", ".", "linesep", ")", ",", "verbose", "=", "True",...
[ 465, 0 ]
[ 483, 39 ]
python
en
['en', 'error', 'th']
False
dump_declarations
(declarations, file_path)
Dump declarations tree rooted at each of the included nodes to the file :param declarations: either a single :class:declaration_t object or a list of :class:declaration_t objects :param file_path: path to a file
Dump declarations tree rooted at each of the included nodes to the file
def dump_declarations(declarations, file_path): """ Dump declarations tree rooted at each of the included nodes to the file :param declarations: either a single :class:declaration_t object or a list of :class:declaration_t objects :param file_path: path to a file """ with open(file_pa...
[ "def", "dump_declarations", "(", "declarations", ",", "file_path", ")", ":", "with", "open", "(", "file_path", ",", "\"w+\"", ")", "as", "f", ":", "print_declarations", "(", "declarations", ",", "writer", "=", "f", ".", "write", ")" ]
[ 486, 0 ]
[ 497, 56 ]
python
en
['en', 'error', 'th']
False
FlaskRageFormatter.__prepare_error_info
(self, output: Dict[str, Any], record: logging.LogRecord)
Adds some information about potential exception to the output message.
Adds some information about potential exception to the output message.
def __prepare_error_info(self, output: Dict[str, Any], record: logging.LogRecord): """ Adds some information about potential exception to the output message. """ if record.exc_info: backtrace = self.formatException(record.exc_info) if backtrace: ou...
[ "def", "__prepare_error_info", "(", "self", ",", "output", ":", "Dict", "[", "str", ",", "Any", "]", ",", "record", ":", "logging", ".", "LogRecord", ")", ":", "if", "record", ".", "exc_info", ":", "backtrace", "=", "self", ".", "formatException", "(", ...
[ 45, 4 ]
[ 56, 13 ]
python
en
['en', 'error', 'th']
False
FlaskRage.init_app
(self, flask_app: flask.Flask)
Initialize logging for Flask application :param flask_app: Flask application
Initialize logging for Flask application
def init_app(self, flask_app: flask.Flask) -> None: """ Initialize logging for Flask application :param flask_app: Flask application """ self.logger = logging.getLogger(getattr(flask_app, "logger_name", "name")) self._setup_db_timer() self._register_handlers(flas...
[ "def", "init_app", "(", "self", ",", "flask_app", ":", "flask", ".", "Flask", ")", "->", "None", ":", "self", ".", "logger", "=", "logging", ".", "getLogger", "(", "getattr", "(", "flask_app", ",", "\"logger_name\"", ",", "\"name\"", ")", ")", "self", ...
[ 82, 4 ]
[ 90, 42 ]
python
en
['en', 'error', 'th']
False
FlaskRage.log_request
(self, response: flask.Response)
Log a regular HTTP request in lograge-ish format :param response: flask.Response :return: response
Log a regular HTTP request in lograge-ish format
def log_request(self, response: flask.Response) -> flask.Response: """ Log a regular HTTP request in lograge-ish format :param response: flask.Response :return: response """ if response.status_code >= 500: return response if response.status_code >= 4...
[ "def", "log_request", "(", "self", ",", "response", ":", "flask", ".", "Response", ")", "->", "flask", ".", "Response", ":", "if", "response", ".", "status_code", ">=", "500", ":", "return", "response", "if", "response", ".", "status_code", ">=", "400", ...
[ 92, 4 ]
[ 108, 23 ]
python
en
['en', 'error', 'th']
False
FlaskRage.log_exception
(self, exception: Exception)
Log an exception in lograge-ish format This can be called e.g. from flask's errorhandlers :param exception: Exception
Log an exception in lograge-ish format
def log_exception(self, exception: Exception) -> None: """ Log an exception in lograge-ish format This can be called e.g. from flask's errorhandlers :param exception: Exception """ message, extra = self._parse(request, exception) self.logger.error(message, extra...
[ "def", "log_exception", "(", "self", ",", "exception", ":", "Exception", ")", "->", "None", ":", "message", ",", "extra", "=", "self", ".", "_parse", "(", "request", ",", "exception", ")", "self", ".", "logger", ".", "error", "(", "message", ",", "extr...
[ 110, 4 ]
[ 119, 47 ]
python
en
['en', 'error', 'th']
False
add_instrument
(instrument: Instrument)
Start instrumenting the current run loop with the given instrument. Args: instrument (trio.abc.Instrument): The instrument to activate. If ``instrument`` is already active, does nothing.
Start instrumenting the current run loop with the given instrument.
def add_instrument(instrument: Instrument) ->None: """Start instrumenting the current run loop with the given instrument. Args: instrument (trio.abc.Instrument): The instrument to activate. If ``instrument`` is already active, does nothing. """ locals()[LOCALS_KEY_KI_PROTECT...
[ "def", "add_instrument", "(", "instrument", ":", "Instrument", ")", "->", "None", ":", "locals", "(", ")", "[", "LOCALS_KEY_KI_PROTECTION_ENABLED", "]", "=", "True", "try", ":", "return", "GLOBAL_RUN_CONTEXT", ".", "runner", ".", "instruments", ".", "add_instrum...
[ 10, 0 ]
[ 23, 63 ]
python
en
['en', 'en', 'en']
True
remove_instrument
(instrument: Instrument)
Stop instrumenting the current run loop with the given instrument. Args: instrument (trio.abc.Instrument): The instrument to de-activate. Raises: KeyError: if the instrument is not currently active. This could occur either because you never added it, or because you ad...
Stop instrumenting the current run loop with the given instrument.
def remove_instrument(instrument: Instrument) ->None: """Stop instrumenting the current run loop with the given instrument. Args: instrument (trio.abc.Instrument): The instrument to de-activate. Raises: KeyError: if the instrument is not currently active. This could ...
[ "def", "remove_instrument", "(", "instrument", ":", "Instrument", ")", "->", "None", ":", "locals", "(", ")", "[", "LOCALS_KEY_KI_PROTECTION_ENABLED", "]", "=", "True", "try", ":", "return", "GLOBAL_RUN_CONTEXT", ".", "runner", ".", "instruments", ".", "remove_i...
[ 26, 0 ]
[ 43, 63 ]
python
en
['en', 'en', 'en']
True
Orion.fit
(self, data: pd.DataFrame)
Fit the pipeline to the given data. Args: data (DataFrame): Input data, passed as a ``pandas.DataFrame`` containing exactly two columns: timestamp and value.
Fit the pipeline to the given data.
def fit(self, data: pd.DataFrame): """Fit the pipeline to the given data. Args: data (DataFrame): Input data, passed as a ``pandas.DataFrame`` containing exactly two columns: timestamp and value. """ self._mlpipeline = self._get_mlpipeline() ...
[ "def", "fit", "(", "self", ",", "data", ":", "pd", ".", "DataFrame", ")", ":", "self", ".", "_mlpipeline", "=", "self", ".", "_get_mlpipeline", "(", ")", "self", ".", "_mlpipeline", ".", "fit", "(", "data", ")", "self", ".", "_fitted", "=", "True" ]
[ 74, 4 ]
[ 84, 27 ]
python
en
['en', 'en', 'en']
True
Orion.detect
(self, data: pd.DataFrame, visualization: bool = False)
Detect anomalies in the given data.. If ``visualization=True``, also return the visualization outputs from the MLPipeline object. Args: data (DataFrame): Input data, passed as a ``pandas.DataFrame`` containing exactly two columns: timestamp and value...
Detect anomalies in the given data..
def detect(self, data: pd.DataFrame, visualization: bool = False) -> pd.DataFrame: """Detect anomalies in the given data.. If ``visualization=True``, also return the visualization outputs from the MLPipeline object. Args: data (DataFrame): Input data, passed...
[ "def", "detect", "(", "self", ",", "data", ":", "pd", ".", "DataFrame", ",", "visualization", ":", "bool", "=", "False", ")", "->", "pd", ".", "DataFrame", ":", "return", "self", ".", "_detect", "(", "self", ".", "_mlpipeline", ".", "predict", ",", "...
[ 125, 4 ]
[ 147, 74 ]
python
en
['en', 'en', 'en']
True
Orion.fit_detect
(self, data: pd.DataFrame, visualization: bool = False)
Fit the pipeline to the data and then detect anomalies. This method is functionally equivalent to calling ``fit(data)`` and later on ``detect(data)`` but with the difference that here the ``MLPipeline`` is called only once, using its ``fit`` method, and the output is directly captured w...
Fit the pipeline to the data and then detect anomalies.
def fit_detect(self, data: pd.DataFrame, visualization: bool = False) -> pd.DataFrame: """Fit the pipeline to the data and then detect anomalies. This method is functionally equivalent to calling ``fit(data)`` and later on ``detect(data)`` but with the difference that here the ``MLPipel...
[ "def", "fit_detect", "(", "self", ",", "data", ":", "pd", ".", "DataFrame", ",", "visualization", ":", "bool", "=", "False", ")", "->", "pd", ".", "DataFrame", ":", "self", ".", "_mlpipeline", "=", "self", ".", "_get_mlpipeline", "(", ")", "result", "=...
[ 149, 4 ]
[ 181, 21 ]
python
en
['en', 'en', 'en']
True
Orion.save
(self, path: str)
Save this object using pickle. Args: path (str): Path to the file where the serialization of this object will be stored.
Save this object using pickle.
def save(self, path: str): """Save this object using pickle. Args: path (str): Path to the file where the serialization of this object will be stored. """ os.makedirs(os.path.dirname(path), exist_ok=True) with open(path, 'wb') as pickl...
[ "def", "save", "(", "self", ",", "path", ":", "str", ")", ":", "os", ".", "makedirs", "(", "os", ".", "path", ".", "dirname", "(", "path", ")", ",", "exist_ok", "=", "True", ")", "with", "open", "(", "path", ",", "'wb'", ")", "as", "pickle_file",...
[ 183, 4 ]
[ 193, 42 ]
python
en
['en', 'en', 'en']
True
Orion.load
(cls, path: str)
Load an Orion instance from a pickle file. Args: path (str): Path to the file where the instance has been previously serialized. Returns: Orion Raises: ValueError: If the serialized object is not an Orion inst...
Load an Orion instance from a pickle file.
def load(cls, path: str): """Load an Orion instance from a pickle file. Args: path (str): Path to the file where the instance has been previously serialized. Returns: Orion Raises: ValueError: If the s...
[ "def", "load", "(", "cls", ",", "path", ":", "str", ")", ":", "with", "open", "(", "path", ",", "'rb'", ")", "as", "pickle_file", ":", "orion", "=", "pickle", ".", "load", "(", "pickle_file", ")", "if", "not", "isinstance", "(", "orion", ",", "cls"...
[ 196, 4 ]
[ 216, 24 ]
python
en
['en', 'en', 'en']
True
Orion.evaluate
(self, data: pd.DataFrame, ground_truth: pd.DataFrame, fit: bool = False, train_data: pd.DataFrame = None, metrics: List[str] = METRICS)
Evaluate the performance against ground truth anomalies. Args: data (DataFrame): Input data, passed as a ``pandas.DataFrame`` containing exactly two columns: timestamp and value. ground_truth (DataFrame): Ground truth anomalies passed as a...
Evaluate the performance against ground truth anomalies.
def evaluate(self, data: pd.DataFrame, ground_truth: pd.DataFrame, fit: bool = False, train_data: pd.DataFrame = None, metrics: List[str] = METRICS) -> pd.Series: """Evaluate the performance against ground truth anomalies. Args: data (DataFrame): Input data,...
[ "def", "evaluate", "(", "self", ",", "data", ":", "pd", ".", "DataFrame", ",", "ground_truth", ":", "pd", ".", "DataFrame", ",", "fit", ":", "bool", "=", "False", ",", "train_data", ":", "pd", ".", "DataFrame", "=", "None", ",", "metrics", ":", "List...
[ 218, 4 ]
[ 264, 32 ]
python
en
['en', 'en', 'en']
True
from_pandas_contextual
(df)
Convert contextual ``pandas.DataFrame`` to list of tuples. Args: df (DataFrame): anomalies, passed as ``pandas.DataFrame`` containing two columns: start and stop. Returns: list: tuple (start, end) timestamp. Raises: KeyError: If the...
Convert contextual ``pandas.DataFrame`` to list of tuples.
def from_pandas_contextual(df): """ Convert contextual ``pandas.DataFrame`` to list of tuples. Args: df (DataFrame): anomalies, passed as ``pandas.DataFrame`` containing two columns: start and stop. Returns: list: tuple (start, end) timestamp. Raise...
[ "def", "from_pandas_contextual", "(", "df", ")", ":", "require", "=", "[", "'start'", ",", "'end'", "]", "columns", "=", "df", ".", "columns", ".", "tolist", "(", ")", "if", "all", "(", "x", "in", "columns", "for", "x", "in", "require", ")", ":", "...
[ 6, 0 ]
[ 30, 75 ]
python
en
['en', 'lb', 'en']
True
from_list_points_timestamps
(timestamps, gap=1)
Convert list of timestamps to list of tuples. Convert a list of anomalies identified by timestamps, to a list of tuples marking the start and end interval of anomalies; make it contextually defined. Args: timestamps (list): contains timestamp of anomalies. gap (int): allowed gap betwe...
Convert list of timestamps to list of tuples.
def from_list_points_timestamps(timestamps, gap=1): """ Convert list of timestamps to list of tuples. Convert a list of anomalies identified by timestamps, to a list of tuples marking the start and end interval of anomalies; make it contextually defined. Args: timestamps (list): contains t...
[ "def", "from_list_points_timestamps", "(", "timestamps", ",", "gap", "=", "1", ")", ":", "timestamps", "=", "sorted", "(", "timestamps", ")", "start_ts", "=", "0", "max_ts", "=", "len", "(", "timestamps", ")", "-", "1", "anomalies", "=", "list", "(", ")"...
[ 33, 0 ]
[ 65, 20 ]
python
en
['en', 'en', 'en']
True
from_pandas_points
(df)
Convert point ``pandas.DataFrame`` to list of tuples. Convert a ``pandas.DataFrame`` of anomalies identified by one column (timestamp) to a list of tuples marking the start and end interval of anomalies; make it contextually defined. Args: df (DataFrame): anomalies, passed as ...
Convert point ``pandas.DataFrame`` to list of tuples.
def from_pandas_points(df): """ Convert point ``pandas.DataFrame`` to list of tuples. Convert a ``pandas.DataFrame`` of anomalies identified by one column (timestamp) to a list of tuples marking the start and end interval of anomalies; make it contextually defined. Args: df (DataFrame)...
[ "def", "from_pandas_points", "(", "df", ")", ":", "time_column", "=", "'timestamp'", "columns", "=", "df", ".", "columns", ".", "tolist", "(", ")", "if", "time_column", "not", "in", "columns", ":", "raise", "KeyError", "(", "'{} not found in columns: {}.'", "....
[ 68, 0 ]
[ 96, 50 ]
python
en
['en', 'lb', 'en']
True