repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
sernst/cauldron
docker-builder.py
update_base_image
def update_base_image(path: str): """Pulls the latest version of the base image""" with open(path, 'r') as file_handle: contents = file_handle.read() regex = re.compile('from\s+(?P<source>[^\s]+)', re.IGNORECASE) matches = regex.findall(contents) if not matches: return None ma...
python
def update_base_image(path: str): """Pulls the latest version of the base image""" with open(path, 'r') as file_handle: contents = file_handle.read() regex = re.compile('from\s+(?P<source>[^\s]+)', re.IGNORECASE) matches = regex.findall(contents) if not matches: return None ma...
[ "def", "update_base_image", "(", "path", ":", "str", ")", ":", "with", "open", "(", "path", ",", "'r'", ")", "as", "file_handle", ":", "contents", "=", "file_handle", ".", "read", "(", ")", "regex", "=", "re", ".", "compile", "(", "'from\\s+(?P<source>[^...
Pulls the latest version of the base image
[ "Pulls", "the", "latest", "version", "of", "the", "base", "image" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/docker-builder.py#L19-L32
sernst/cauldron
docker-builder.py
build
def build(path: str) -> dict: """Builds the container from the specified docker file path""" update_base_image(path) match = file_pattern.search(os.path.basename(path)) build_id = match.group('id') tags = [ '{}:{}-{}'.format(HUB_PREFIX, version, build_id), '{}:latest-{}'.format(HUB_P...
python
def build(path: str) -> dict: """Builds the container from the specified docker file path""" update_base_image(path) match = file_pattern.search(os.path.basename(path)) build_id = match.group('id') tags = [ '{}:{}-{}'.format(HUB_PREFIX, version, build_id), '{}:latest-{}'.format(HUB_P...
[ "def", "build", "(", "path", ":", "str", ")", "->", "dict", ":", "update_base_image", "(", "path", ")", "match", "=", "file_pattern", ".", "search", "(", "os", ".", "path", ".", "basename", "(", "path", ")", ")", "build_id", "=", "match", ".", "group...
Builds the container from the specified docker file path
[ "Builds", "the", "container", "from", "the", "specified", "docker", "file", "path" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/docker-builder.py#L35-L61
sernst/cauldron
docker-builder.py
publish
def publish(build_entry: dict): """Publishes the specified build entry to docker hub""" for tag in build_entry['tags']: print('[PUSHING]:', tag) os.system('docker push {}'.format(tag))
python
def publish(build_entry: dict): """Publishes the specified build entry to docker hub""" for tag in build_entry['tags']: print('[PUSHING]:', tag) os.system('docker push {}'.format(tag))
[ "def", "publish", "(", "build_entry", ":", "dict", ")", ":", "for", "tag", "in", "build_entry", "[", "'tags'", "]", ":", "print", "(", "'[PUSHING]:'", ",", "tag", ")", "os", ".", "system", "(", "'docker push {}'", ".", "format", "(", "tag", ")", ")" ]
Publishes the specified build entry to docker hub
[ "Publishes", "the", "specified", "build", "entry", "to", "docker", "hub" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/docker-builder.py#L64-L68
sernst/cauldron
docker-builder.py
parse
def parse() -> dict: """Parse command line arguments""" parser = ArgumentParser() parser.add_argument('-p', '--publish', action='store_true', default=False) return vars(parser.parse_args())
python
def parse() -> dict: """Parse command line arguments""" parser = ArgumentParser() parser.add_argument('-p', '--publish', action='store_true', default=False) return vars(parser.parse_args())
[ "def", "parse", "(", ")", "->", "dict", ":", "parser", "=", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'-p'", ",", "'--publish'", ",", "action", "=", "'store_true'", ",", "default", "=", "False", ")", "return", "vars", "(", "parser"...
Parse command line arguments
[ "Parse", "command", "line", "arguments" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/docker-builder.py#L71-L75
sernst/cauldron
docker-builder.py
run
def run(): """Execute the build process""" args = parse() build_results = [build(p) for p in glob.iglob(glob_path)] if not args['publish']: return for entry in build_results: publish(entry)
python
def run(): """Execute the build process""" args = parse() build_results = [build(p) for p in glob.iglob(glob_path)] if not args['publish']: return for entry in build_results: publish(entry)
[ "def", "run", "(", ")", ":", "args", "=", "parse", "(", ")", "build_results", "=", "[", "build", "(", "p", ")", "for", "p", "in", "glob", ".", "iglob", "(", "glob_path", ")", "]", "if", "not", "args", "[", "'publish'", "]", ":", "return", "for", ...
Execute the build process
[ "Execute", "the", "build", "process" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/docker-builder.py#L78-L87
sernst/cauldron
cauldron/render/__init__.py
elapsed_time
def elapsed_time(seconds: float) -> str: """Displays the elapsed time since the current step started running.""" environ.abort_thread() parts = ( '{}'.format(timedelta(seconds=seconds)) .rsplit('.', 1) ) hours, minutes, seconds = parts[0].split(':') return templating.render_templ...
python
def elapsed_time(seconds: float) -> str: """Displays the elapsed time since the current step started running.""" environ.abort_thread() parts = ( '{}'.format(timedelta(seconds=seconds)) .rsplit('.', 1) ) hours, minutes, seconds = parts[0].split(':') return templating.render_templ...
[ "def", "elapsed_time", "(", "seconds", ":", "float", ")", "->", "str", ":", "environ", ".", "abort_thread", "(", ")", "parts", "=", "(", "'{}'", ".", "format", "(", "timedelta", "(", "seconds", "=", "seconds", ")", ")", ".", "rsplit", "(", "'.'", ","...
Displays the elapsed time since the current step started running.
[ "Displays", "the", "elapsed", "time", "since", "the", "current", "step", "started", "running", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/render/__init__.py#L18-L32
sernst/cauldron
cauldron/render/__init__.py
image
def image( rendered_path: str, width: int = None, height: int = None, justify: str = None ) -> str: """Renders an image block""" environ.abort_thread() return templating.render_template( 'image.html', path=rendered_path, width=width, height=hei...
python
def image( rendered_path: str, width: int = None, height: int = None, justify: str = None ) -> str: """Renders an image block""" environ.abort_thread() return templating.render_template( 'image.html', path=rendered_path, width=width, height=hei...
[ "def", "image", "(", "rendered_path", ":", "str", ",", "width", ":", "int", "=", "None", ",", "height", ":", "int", "=", "None", ",", "justify", ":", "str", "=", "None", ")", "->", "str", ":", "environ", ".", "abort_thread", "(", ")", "return", "te...
Renders an image block
[ "Renders", "an", "image", "block" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/render/__init__.py#L229-L243
sernst/cauldron
cauldron/__init__.py
get_environment_info
def get_environment_info() -> dict: """ Information about Cauldron and its Python interpreter. :return: A dictionary containing information about the Cauldron and its Python environment. This information is useful when providing feedback and bug reports. """ data = _environ....
python
def get_environment_info() -> dict: """ Information about Cauldron and its Python interpreter. :return: A dictionary containing information about the Cauldron and its Python environment. This information is useful when providing feedback and bug reports. """ data = _environ....
[ "def", "get_environment_info", "(", ")", "->", "dict", ":", "data", "=", "_environ", ".", "systems", ".", "get_system_data", "(", ")", "data", "[", "'cauldron'", "]", "=", "_environ", ".", "package_settings", ".", "copy", "(", ")", "return", "data" ]
Information about Cauldron and its Python interpreter. :return: A dictionary containing information about the Cauldron and its Python environment. This information is useful when providing feedback and bug reports.
[ "Information", "about", "Cauldron", "and", "its", "Python", "interpreter", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/__init__.py#L24-L35
sernst/cauldron
cauldron/__init__.py
run_server
def run_server(port=5010, debug=False, **kwargs): """ Run the cauldron http server used to interact with cauldron from a remote host. :param port: The port on which to bind the cauldron server. :param debug: Whether or not the server should be run in debug mode. If true, the ...
python
def run_server(port=5010, debug=False, **kwargs): """ Run the cauldron http server used to interact with cauldron from a remote host. :param port: The port on which to bind the cauldron server. :param debug: Whether or not the server should be run in debug mode. If true, the ...
[ "def", "run_server", "(", "port", "=", "5010", ",", "debug", "=", "False", ",", "*", "*", "kwargs", ")", ":", "from", "cauldron", ".", "cli", ".", "server", "import", "run", "run", ".", "execute", "(", "port", "=", "port", ",", "debug", "=", "debug...
Run the cauldron http server used to interact with cauldron from a remote host. :param port: The port on which to bind the cauldron server. :param debug: Whether or not the server should be run in debug mode. If true, the server will echo debugging information during operation. ...
[ "Run", "the", "cauldron", "http", "server", "used", "to", "interact", "with", "cauldron", "from", "a", "remote", "host", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/__init__.py#L44-L58
sernst/cauldron
cauldron/__init__.py
run_project
def run_project( project_directory: str, output_directory: str = None, logging_path: str = None, reader_path: str = None, reload_project_libraries: bool = False, **kwargs ) -> ExecutionResult: """ Runs a project as a single command directly within the current Pyth...
python
def run_project( project_directory: str, output_directory: str = None, logging_path: str = None, reader_path: str = None, reload_project_libraries: bool = False, **kwargs ) -> ExecutionResult: """ Runs a project as a single command directly within the current Pyth...
[ "def", "run_project", "(", "project_directory", ":", "str", ",", "output_directory", ":", "str", "=", "None", ",", "logging_path", ":", "str", "=", "None", ",", "reader_path", ":", "str", "=", "None", ",", "reload_project_libraries", ":", "bool", "=", "False...
Runs a project as a single command directly within the current Python interpreter. :param project_directory: The fully-qualified path to the directory where the Cauldron project is located :param output_directory: The fully-qualified path to the directory where the results will be ...
[ "Runs", "a", "project", "as", "a", "single", "command", "directly", "within", "the", "current", "Python", "interpreter", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/__init__.py#L61-L109
sernst/cauldron
cauldron/environ/response.py
Response.join
def join(self, timeout: float = None) -> bool: """ Joins on the thread associated with the response if it exists, or just returns after a no-op if no thread exists to join. :param timeout: Maximum number of seconds to block on the join before given up and continu...
python
def join(self, timeout: float = None) -> bool: """ Joins on the thread associated with the response if it exists, or just returns after a no-op if no thread exists to join. :param timeout: Maximum number of seconds to block on the join before given up and continu...
[ "def", "join", "(", "self", ",", "timeout", ":", "float", "=", "None", ")", "->", "bool", ":", "try", ":", "self", ".", "thread", ".", "join", "(", "timeout", ")", "return", "True", "except", "AttributeError", ":", "return", "False" ]
Joins on the thread associated with the response if it exists, or just returns after a no-op if no thread exists to join. :param timeout: Maximum number of seconds to block on the join before given up and continuing operation. The default `None` value will wait forev...
[ "Joins", "on", "the", "thread", "associated", "with", "the", "response", "if", "it", "exists", "or", "just", "returns", "after", "a", "no", "-", "op", "if", "no", "thread", "exists", "to", "join", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/environ/response.py#L194-L211
sernst/cauldron
cauldron/environ/response.py
Response.deserialize
def deserialize(serial_data: dict) -> 'Response': """ Converts a serialized dictionary response to a Response object """ r = Response(serial_data.get('id')) r.data.update(serial_data.get('data', {})) r.ended = serial_data.get('ended', False) r.failed = not serial_data.get('succe...
python
def deserialize(serial_data: dict) -> 'Response': """ Converts a serialized dictionary response to a Response object """ r = Response(serial_data.get('id')) r.data.update(serial_data.get('data', {})) r.ended = serial_data.get('ended', False) r.failed = not serial_data.get('succe...
[ "def", "deserialize", "(", "serial_data", ":", "dict", ")", "->", "'Response'", ":", "r", "=", "Response", "(", "serial_data", ".", "get", "(", "'id'", ")", ")", "r", ".", "data", ".", "update", "(", "serial_data", ".", "get", "(", "'data'", ",", "{"...
Converts a serialized dictionary response to a Response object
[ "Converts", "a", "serialized", "dictionary", "response", "to", "a", "Response", "object" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/environ/response.py#L455-L474
sernst/cauldron
cauldron/cli/threads.py
abort_thread
def abort_thread(): """ This function checks to see if the user has indicated that they want the currently running execution to stop prematurely by marking the running thread as aborted. It only applies to operations that are run within CauldronThreads and not the main thread. """ thread = ...
python
def abort_thread(): """ This function checks to see if the user has indicated that they want the currently running execution to stop prematurely by marking the running thread as aborted. It only applies to operations that are run within CauldronThreads and not the main thread. """ thread = ...
[ "def", "abort_thread", "(", ")", ":", "thread", "=", "threading", ".", "current_thread", "(", ")", "if", "not", "isinstance", "(", "thread", ",", "CauldronThread", ")", ":", "return", "if", "thread", ".", "is_executing", "and", "thread", ".", "abort", ":",...
This function checks to see if the user has indicated that they want the currently running execution to stop prematurely by marking the running thread as aborted. It only applies to operations that are run within CauldronThreads and not the main thread.
[ "This", "function", "checks", "to", "see", "if", "the", "user", "has", "indicated", "that", "they", "want", "the", "currently", "running", "execution", "to", "stop", "prematurely", "by", "marking", "the", "running", "thread", "as", "aborted", ".", "It", "onl...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/threads.py#L105-L119
sernst/cauldron
cauldron/cli/threads.py
CauldronThread.is_running
def is_running(self) -> bool: """Specifies whether or not the thread is running""" return ( self._has_started and self.is_alive() or self.completed_at is None or (datetime.utcnow() - self.completed_at).total_seconds() < 0.5 )
python
def is_running(self) -> bool: """Specifies whether or not the thread is running""" return ( self._has_started and self.is_alive() or self.completed_at is None or (datetime.utcnow() - self.completed_at).total_seconds() < 0.5 )
[ "def", "is_running", "(", "self", ")", "->", "bool", ":", "return", "(", "self", ".", "_has_started", "and", "self", ".", "is_alive", "(", ")", "or", "self", ".", "completed_at", "is", "None", "or", "(", "datetime", ".", "utcnow", "(", ")", "-", "sel...
Specifies whether or not the thread is running
[ "Specifies", "whether", "or", "not", "the", "thread", "is", "running" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/threads.py#L42-L49
sernst/cauldron
cauldron/cli/threads.py
CauldronThread.run
def run(self): """ Executes the Cauldron command in a thread to prevent long-running computations from locking the main Cauldron thread, which is needed to serve and print status information. """ async def run_command(): try: self.result = sel...
python
def run(self): """ Executes the Cauldron command in a thread to prevent long-running computations from locking the main Cauldron thread, which is needed to serve and print status information. """ async def run_command(): try: self.result = sel...
[ "def", "run", "(", "self", ")", ":", "async", "def", "run_command", "(", ")", ":", "try", ":", "self", ".", "result", "=", "self", ".", "command", "(", "context", "=", "self", ".", "context", ",", "*", "*", "self", ".", "kwargs", ")", "except", "...
Executes the Cauldron command in a thread to prevent long-running computations from locking the main Cauldron thread, which is needed to serve and print status information.
[ "Executes", "the", "Cauldron", "command", "in", "a", "thread", "to", "prevent", "long", "-", "running", "computations", "from", "locking", "the", "main", "Cauldron", "thread", "which", "is", "needed", "to", "serve", "and", "print", "status", "information", "."...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/threads.py#L51-L83
sernst/cauldron
cauldron/cli/threads.py
CauldronThread.abort_running
def abort_running(self) -> bool: """ Executes a hard abort by shutting down the event loop in this thread in which the running command was operating. This is carried out using the asyncio library to prevent the stopped execution from destabilizing the Python environment. ...
python
def abort_running(self) -> bool: """ Executes a hard abort by shutting down the event loop in this thread in which the running command was operating. This is carried out using the asyncio library to prevent the stopped execution from destabilizing the Python environment. ...
[ "def", "abort_running", "(", "self", ")", "->", "bool", ":", "if", "not", "self", ".", "_loop", ":", "return", "False", "try", ":", "self", ".", "_loop", ".", "stop", "(", ")", "return", "True", "except", "Exception", ":", "return", "False", "finally",...
Executes a hard abort by shutting down the event loop in this thread in which the running command was operating. This is carried out using the asyncio library to prevent the stopped execution from destabilizing the Python environment.
[ "Executes", "a", "hard", "abort", "by", "shutting", "down", "the", "event", "loop", "in", "this", "thread", "in", "which", "the", "running", "command", "was", "operating", ".", "This", "is", "carried", "out", "using", "the", "asyncio", "library", "to", "pr...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/threads.py#L85-L102
sernst/cauldron
cauldron/cli/server/arguments.py
from_request
def from_request(request=None) -> dict: """ Fetches the arguments for the current Flask application request """ request = request if request else flask_request try: json_args = request.get_json(silent=True) except Exception: json_args = None try: get_args = request.values ...
python
def from_request(request=None) -> dict: """ Fetches the arguments for the current Flask application request """ request = request if request else flask_request try: json_args = request.get_json(silent=True) except Exception: json_args = None try: get_args = request.values ...
[ "def", "from_request", "(", "request", "=", "None", ")", "->", "dict", ":", "request", "=", "request", "if", "request", "else", "flask_request", "try", ":", "json_args", "=", "request", ".", "get_json", "(", "silent", "=", "True", ")", "except", "Exception...
Fetches the arguments for the current Flask application request
[ "Fetches", "the", "arguments", "for", "the", "current", "Flask", "application", "request" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/server/arguments.py#L4-L24
myaooo/pysbrl
pysbrl/rule_list.py
print_rule
def print_rule(rule, feature_names=None, category_names=None, label="label", support=None): # type: (Rule, List[Union[str, None]], List[Union[List[str], None]], str, List[int]) -> str """ print the rule in a nice way :param rule: An instance of Rule :param feature_names: a list of n_features feature...
python
def print_rule(rule, feature_names=None, category_names=None, label="label", support=None): # type: (Rule, List[Union[str, None]], List[Union[List[str], None]], str, List[int]) -> str """ print the rule in a nice way :param rule: An instance of Rule :param feature_names: a list of n_features feature...
[ "def", "print_rule", "(", "rule", ",", "feature_names", "=", "None", ",", "category_names", "=", "None", ",", "label", "=", "\"label\"", ",", "support", "=", "None", ")", ":", "# type: (Rule, List[Union[str, None]], List[Union[List[str], None]], str, List[int]) -> str", ...
print the rule in a nice way :param rule: An instance of Rule :param feature_names: a list of n_features feature names, :param category_names: the names of the categories of each feature. :param label: Can take two values, 'label': just print the label as output, or 'prob': print the prob distribution. ...
[ "print", "the", "rule", "in", "a", "nice", "way", ":", "param", "rule", ":", "An", "instance", "of", "Rule", ":", "param", "feature_names", ":", "a", "list", "of", "n_features", "feature", "names", ":", "param", "category_names", ":", "the", "names", "of...
train
https://github.com/myaooo/pysbrl/blob/74bba8c6913a7f82e32313108f8c3e025b89d9c7/pysbrl/rule_list.py#L53-L103
myaooo/pysbrl
pysbrl/rule_list.py
rule_str2rule
def rule_str2rule(rule_str, prob): # type: (str, float) -> Rule """ A helper function that converts the resulting string returned from C function to the Rule object :param rule_str: a string representing the rule :param prob: the output probability :return: a Rule object """ if rule_str...
python
def rule_str2rule(rule_str, prob): # type: (str, float) -> Rule """ A helper function that converts the resulting string returned from C function to the Rule object :param rule_str: a string representing the rule :param prob: the output probability :return: a Rule object """ if rule_str...
[ "def", "rule_str2rule", "(", "rule_str", ",", "prob", ")", ":", "# type: (str, float) -> Rule", "if", "rule_str", "==", "\"default\"", ":", "return", "Rule", "(", "[", "]", ",", "prob", ")", "raw_rules", "=", "rule_str", "[", "1", ":", "-", "1", "]", "."...
A helper function that converts the resulting string returned from C function to the Rule object :param rule_str: a string representing the rule :param prob: the output probability :return: a Rule object
[ "A", "helper", "function", "that", "converts", "the", "resulting", "string", "returned", "from", "C", "function", "to", "the", "Rule", "object" ]
train
https://github.com/myaooo/pysbrl/blob/74bba8c6913a7f82e32313108f8c3e025b89d9c7/pysbrl/rule_list.py#L106-L125
myaooo/pysbrl
pysbrl/rule_list.py
Rule.is_satisfied
def is_satisfied(self, x_cat): """ :param x_cat: a 2D array of pure categorical data of shape [n_data, n_features] :return: a bool array of shape [n_data,] representing whether the rule is fired by each input data. """ satisfied = [] if self.is_default(): retu...
python
def is_satisfied(self, x_cat): """ :param x_cat: a 2D array of pure categorical data of shape [n_data, n_features] :return: a bool array of shape [n_data,] representing whether the rule is fired by each input data. """ satisfied = [] if self.is_default(): retu...
[ "def", "is_satisfied", "(", "self", ",", "x_cat", ")", ":", "satisfied", "=", "[", "]", "if", "self", ".", "is_default", "(", ")", ":", "return", "np", ".", "ones", "(", "x_cat", ".", "shape", "[", "0", "]", ",", "dtype", "=", "bool", ")", "for",...
:param x_cat: a 2D array of pure categorical data of shape [n_data, n_features] :return: a bool array of shape [n_data,] representing whether the rule is fired by each input data.
[ ":", "param", "x_cat", ":", "a", "2D", "array", "of", "pure", "categorical", "data", "of", "shape", "[", "n_data", "n_features", "]", ":", "return", ":", "a", "bool", "array", "of", "shape", "[", "n_data", "]", "representing", "whether", "the", "rule", ...
train
https://github.com/myaooo/pysbrl/blob/74bba8c6913a7f82e32313108f8c3e025b89d9c7/pysbrl/rule_list.py#L40-L50
myaooo/pysbrl
pysbrl/rule_list.py
BayesianRuleList.fit
def fit(self, x, y): """ :param x: 2D np.ndarray (n_instances, n_features) should be categorical data, must be of type int :param y: 1D np.ndarray (n_instances, ) labels :return: """ verbose = self.verbose # Create temporary files data_file = tempfile.Name...
python
def fit(self, x, y): """ :param x: 2D np.ndarray (n_instances, n_features) should be categorical data, must be of type int :param y: 1D np.ndarray (n_instances, ) labels :return: """ verbose = self.verbose # Create temporary files data_file = tempfile.Name...
[ "def", "fit", "(", "self", ",", "x", ",", "y", ")", ":", "verbose", "=", "self", ".", "verbose", "# Create temporary files", "data_file", "=", "tempfile", ".", "NamedTemporaryFile", "(", "\"w+b\"", ",", "delete", "=", "False", ")", "label_file", "=", "temp...
:param x: 2D np.ndarray (n_instances, n_features) should be categorical data, must be of type int :param y: 1D np.ndarray (n_instances, ) labels :return:
[ ":", "param", "x", ":", "2D", "np", ".", "ndarray", "(", "n_instances", "n_features", ")", "should", "be", "categorical", "data", "must", "be", "of", "type", "int", ":", "param", "y", ":", "1D", "np", ".", "ndarray", "(", "n_instances", ")", "labels", ...
train
https://github.com/myaooo/pysbrl/blob/74bba8c6913a7f82e32313108f8c3e025b89d9c7/pysbrl/rule_list.py#L185-L225
myaooo/pysbrl
pysbrl/rule_list.py
BayesianRuleList.from_raw
def from_raw(self, rule_ids, outputs, raw_rules): """ A helper function that converts the results returned from C function :param rule_ids: :param outputs: :param raw_rules: :return: """ self._rule_pool = [([], [])] + raw_rules self._rule_list = []...
python
def from_raw(self, rule_ids, outputs, raw_rules): """ A helper function that converts the results returned from C function :param rule_ids: :param outputs: :param raw_rules: :return: """ self._rule_pool = [([], [])] + raw_rules self._rule_list = []...
[ "def", "from_raw", "(", "self", ",", "rule_ids", ",", "outputs", ",", "raw_rules", ")", ":", "self", ".", "_rule_pool", "=", "[", "(", "[", "]", ",", "[", "]", ")", "]", "+", "raw_rules", "self", ".", "_rule_list", "=", "[", "]", "for", "i", ",",...
A helper function that converts the results returned from C function :param rule_ids: :param outputs: :param raw_rules: :return:
[ "A", "helper", "function", "that", "converts", "the", "results", "returned", "from", "C", "function", ":", "param", "rule_ids", ":", ":", "param", "outputs", ":", ":", "param", "raw_rules", ":", ":", "return", ":" ]
train
https://github.com/myaooo/pysbrl/blob/74bba8c6913a7f82e32313108f8c3e025b89d9c7/pysbrl/rule_list.py#L227-L242
myaooo/pysbrl
pysbrl/rule_list.py
BayesianRuleList.compute_support
def compute_support(self, x, y): # type: (np.ndarray, np.ndarray) -> np.ndarray """ Calculate the support for the rules. The support of each rule is a list of `n_classes` integers: [l1, l2, ...]. Each integer represents the number of data of label i that is caught by this rule ...
python
def compute_support(self, x, y): # type: (np.ndarray, np.ndarray) -> np.ndarray """ Calculate the support for the rules. The support of each rule is a list of `n_classes` integers: [l1, l2, ...]. Each integer represents the number of data of label i that is caught by this rule ...
[ "def", "compute_support", "(", "self", ",", "x", ",", "y", ")", ":", "# type: (np.ndarray, np.ndarray) -> np.ndarray", "caught_matrix", "=", "self", ".", "caught_matrix", "(", "x", ")", "if", "np", ".", "sum", "(", "caught_matrix", ".", "astype", "(", "np", ...
Calculate the support for the rules. The support of each rule is a list of `n_classes` integers: [l1, l2, ...]. Each integer represents the number of data of label i that is caught by this rule :param x: 2D np.ndarray (n_instances, n_features) should be categorical data, must be of type int ...
[ "Calculate", "the", "support", "for", "the", "rules", ".", "The", "support", "of", "each", "rule", "is", "a", "list", "of", "n_classes", "integers", ":", "[", "l1", "l2", "...", "]", ".", "Each", "integer", "represents", "the", "number", "of", "data", ...
train
https://github.com/myaooo/pysbrl/blob/74bba8c6913a7f82e32313108f8c3e025b89d9c7/pysbrl/rule_list.py#L244-L266
myaooo/pysbrl
pysbrl/rule_list.py
BayesianRuleList.caught_matrix
def caught_matrix(self, x): # type: (np.ndarray) -> np.ndarray """ compute the caught matrix of x Each rule has an array of bools, showing whether each instances is caught by this rule :param x: 2D np.ndarray (n_instances, n_features) should be categorical data, must be of type i...
python
def caught_matrix(self, x): # type: (np.ndarray) -> np.ndarray """ compute the caught matrix of x Each rule has an array of bools, showing whether each instances is caught by this rule :param x: 2D np.ndarray (n_instances, n_features) should be categorical data, must be of type i...
[ "def", "caught_matrix", "(", "self", ",", "x", ")", ":", "# type: (np.ndarray) -> np.ndarray", "un_satisfied", "=", "np", ".", "ones", "(", "(", "x", ".", "shape", "[", "0", "]", ",", ")", ",", "dtype", "=", "np", ".", "bool", ")", "supports", "=", "...
compute the caught matrix of x Each rule has an array of bools, showing whether each instances is caught by this rule :param x: 2D np.ndarray (n_instances, n_features) should be categorical data, must be of type int :return: a bool np.ndarray of shape (n_rules, n_instances)
[ "compute", "the", "caught", "matrix", "of", "x", "Each", "rule", "has", "an", "array", "of", "bools", "showing", "whether", "each", "instances", "is", "caught", "by", "this", "rule", ":", "param", "x", ":", "2D", "np", ".", "ndarray", "(", "n_instances",...
train
https://github.com/myaooo/pysbrl/blob/74bba8c6913a7f82e32313108f8c3e025b89d9c7/pysbrl/rule_list.py#L268-L285
myaooo/pysbrl
pysbrl/rule_list.py
BayesianRuleList.decision_path
def decision_path(self, x): # type: (np.ndarray) -> np.ndarray """ compute the decision path of the rule list on x :param x: x should be already transformed :return: return a np.ndarray of shape [n_rules, n_instances] of type bool, representing whether an ...
python
def decision_path(self, x): # type: (np.ndarray) -> np.ndarray """ compute the decision path of the rule list on x :param x: x should be already transformed :return: return a np.ndarray of shape [n_rules, n_instances] of type bool, representing whether an ...
[ "def", "decision_path", "(", "self", ",", "x", ")", ":", "# type: (np.ndarray) -> np.ndarray", "un_satisfied", "=", "np", ".", "ones", "(", "[", "x", ".", "shape", "[", "0", "]", "]", ",", "dtype", "=", "np", ".", "bool", ")", "paths", "=", "np", "."...
compute the decision path of the rule list on x :param x: x should be already transformed :return: return a np.ndarray of shape [n_rules, n_instances] of type bool, representing whether an instance has consulted a rule or not
[ "compute", "the", "decision", "path", "of", "the", "rule", "list", "on", "x", ":", "param", "x", ":", "x", "should", "be", "already", "transformed", ":", "return", ":", "return", "a", "np", ".", "ndarray", "of", "shape", "[", "n_rules", "n_instances", ...
train
https://github.com/myaooo/pysbrl/blob/74bba8c6913a7f82e32313108f8c3e025b89d9c7/pysbrl/rule_list.py#L287-L303
sernst/cauldron
cauldron/session/caching.py
SharedCache.put
def put(self, *args, **kwargs) -> 'SharedCache': """ Adds one or more variables to the cache. :param args: Variables can be specified by two consecutive arguments where the first argument is a key and the second one the corresponding value. For example: ...
python
def put(self, *args, **kwargs) -> 'SharedCache': """ Adds one or more variables to the cache. :param args: Variables can be specified by two consecutive arguments where the first argument is a key and the second one the corresponding value. For example: ...
[ "def", "put", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "->", "'SharedCache'", ":", "environ", ".", "abort_thread", "(", ")", "index", "=", "0", "while", "index", "<", "(", "len", "(", "args", ")", "-", "1", ")", ":", "key", ...
Adds one or more variables to the cache. :param args: Variables can be specified by two consecutive arguments where the first argument is a key and the second one the corresponding value. For example: ``` put('a', 1, 'b', False) ``` ...
[ "Adds", "one", "or", "more", "variables", "to", "the", "cache", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/caching.py#L25-L67
sernst/cauldron
cauldron/session/caching.py
SharedCache.grab
def grab( self, *keys: typing.List[str], default_value=None ) -> typing.Tuple: """ Returns a tuple containing multiple values from the cache specified by the keys arguments :param keys: One or more variable names stored in the cache th...
python
def grab( self, *keys: typing.List[str], default_value=None ) -> typing.Tuple: """ Returns a tuple containing multiple values from the cache specified by the keys arguments :param keys: One or more variable names stored in the cache th...
[ "def", "grab", "(", "self", ",", "*", "keys", ":", "typing", ".", "List", "[", "str", "]", ",", "default_value", "=", "None", ")", "->", "typing", ".", "Tuple", ":", "return", "tuple", "(", "[", "self", ".", "fetch", "(", "k", ",", "default_value",...
Returns a tuple containing multiple values from the cache specified by the keys arguments :param keys: One or more variable names stored in the cache that should be returned by the grab function. The order of these arguments are preserved by the returned tuple. ...
[ "Returns", "a", "tuple", "containing", "multiple", "values", "from", "the", "cache", "specified", "by", "the", "keys", "arguments" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/caching.py#L69-L90
sernst/cauldron
cauldron/session/caching.py
SharedCache.fetch
def fetch(self, key: typing.Union[str, None], default_value=None): """ Retrieves the value of the specified variable from the cache :param key: The name of the variable for which the value should be returned :param default_value: The value to return if the variab...
python
def fetch(self, key: typing.Union[str, None], default_value=None): """ Retrieves the value of the specified variable from the cache :param key: The name of the variable for which the value should be returned :param default_value: The value to return if the variab...
[ "def", "fetch", "(", "self", ",", "key", ":", "typing", ".", "Union", "[", "str", ",", "None", "]", ",", "default_value", "=", "None", ")", ":", "environ", ".", "abort_thread", "(", ")", "if", "key", "is", "None", ":", "return", "self", ".", "_shar...
Retrieves the value of the specified variable from the cache :param key: The name of the variable for which the value should be returned :param default_value: The value to return if the variable does not exist in the cache :return: The value of the specified ...
[ "Retrieves", "the", "value", "of", "the", "specified", "variable", "from", "the", "cache" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/caching.py#L92-L110
myaooo/pysbrl
pysbrl/train.py
train_sbrl
def train_sbrl(data_file, label_file, lambda_=20, eta=2, max_iters=300000, n_chains=20, alpha=1, seed=None, verbose=0): """ The basic training function of the scalable bayesian rule list. Users are suggested to use SBRL instead of this function. It takes the paths of the pre-processed data and label fil...
python
def train_sbrl(data_file, label_file, lambda_=20, eta=2, max_iters=300000, n_chains=20, alpha=1, seed=None, verbose=0): """ The basic training function of the scalable bayesian rule list. Users are suggested to use SBRL instead of this function. It takes the paths of the pre-processed data and label fil...
[ "def", "train_sbrl", "(", "data_file", ",", "label_file", ",", "lambda_", "=", "20", ",", "eta", "=", "2", ",", "max_iters", "=", "300000", ",", "n_chains", "=", "20", ",", "alpha", "=", "1", ",", "seed", "=", "None", ",", "verbose", "=", "0", ")",...
The basic training function of the scalable bayesian rule list. Users are suggested to use SBRL instead of this function. It takes the paths of the pre-processed data and label files as input, and return the parameters of the trained rule list. Check pysbrl.utils:categorical2pysbrl_data to see how to c...
[ "The", "basic", "training", "function", "of", "the", "scalable", "bayesian", "rule", "list", ".", "Users", "are", "suggested", "to", "use", "SBRL", "instead", "of", "this", "function", ".", "It", "takes", "the", "paths", "of", "the", "pre", "-", "processed...
train
https://github.com/myaooo/pysbrl/blob/74bba8c6913a7f82e32313108f8c3e025b89d9c7/pysbrl/train.py#L11-L46
ayoungprogrammer/Lango
lango/parser.py
OldStanfordLibParser.parse
def parse(self, line): """Returns tree objects from a sentence Args: line: Sentence to be parsed into a tree Returns: Tree object representing parsed sentence None if parse fails """ tree = list(self.parser.raw_parse(line))[0] tree = ...
python
def parse(self, line): """Returns tree objects from a sentence Args: line: Sentence to be parsed into a tree Returns: Tree object representing parsed sentence None if parse fails """ tree = list(self.parser.raw_parse(line))[0] tree = ...
[ "def", "parse", "(", "self", ",", "line", ")", ":", "tree", "=", "list", "(", "self", ".", "parser", ".", "raw_parse", "(", "line", ")", ")", "[", "0", "]", "tree", "=", "tree", "[", "0", "]", "return", "tree" ]
Returns tree objects from a sentence Args: line: Sentence to be parsed into a tree Returns: Tree object representing parsed sentence None if parse fails
[ "Returns", "tree", "objects", "from", "a", "sentence" ]
train
https://github.com/ayoungprogrammer/Lango/blob/0c4284c153abc2d8de4b03a86731bd84385e6afa/lango/parser.py#L22-L34
sernst/cauldron
cauldron/cli/sync/sync_io.py
pack_chunk
def pack_chunk(source_data: bytes) -> str: """ Packs the specified binary source data by compressing it with the Zlib library and then converting the bytes to a base64 encoded string for non-binary transmission. :param source_data: The data to be converted to a compressed, base64 string ...
python
def pack_chunk(source_data: bytes) -> str: """ Packs the specified binary source data by compressing it with the Zlib library and then converting the bytes to a base64 encoded string for non-binary transmission. :param source_data: The data to be converted to a compressed, base64 string ...
[ "def", "pack_chunk", "(", "source_data", ":", "bytes", ")", "->", "str", ":", "if", "not", "source_data", ":", "return", "''", "chunk_compressed", "=", "zlib", ".", "compress", "(", "source_data", ")", "return", "binascii", ".", "b2a_base64", "(", "chunk_com...
Packs the specified binary source data by compressing it with the Zlib library and then converting the bytes to a base64 encoded string for non-binary transmission. :param source_data: The data to be converted to a compressed, base64 string
[ "Packs", "the", "specified", "binary", "source", "data", "by", "compressing", "it", "with", "the", "Zlib", "library", "and", "then", "converting", "the", "bytes", "to", "a", "base64", "encoded", "string", "for", "non", "-", "binary", "transmission", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/sync/sync_io.py#L12-L25
sernst/cauldron
cauldron/cli/sync/sync_io.py
unpack_chunk
def unpack_chunk(chunk_data: str) -> bytes: """ Unpacks a previously packed chunk data back into the original bytes representation :param chunk_data: The compressed, base64 encoded string to convert back to the source bytes object. """ if not chunk_data: return b'' ...
python
def unpack_chunk(chunk_data: str) -> bytes: """ Unpacks a previously packed chunk data back into the original bytes representation :param chunk_data: The compressed, base64 encoded string to convert back to the source bytes object. """ if not chunk_data: return b'' ...
[ "def", "unpack_chunk", "(", "chunk_data", ":", "str", ")", "->", "bytes", ":", "if", "not", "chunk_data", ":", "return", "b''", "chunk_compressed", "=", "binascii", ".", "a2b_base64", "(", "chunk_data", ".", "encode", "(", "'utf-8'", ")", ")", "return", "z...
Unpacks a previously packed chunk data back into the original bytes representation :param chunk_data: The compressed, base64 encoded string to convert back to the source bytes object.
[ "Unpacks", "a", "previously", "packed", "chunk", "data", "back", "into", "the", "original", "bytes", "representation" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/sync/sync_io.py#L28-L42
sernst/cauldron
cauldron/cli/sync/sync_io.py
get_file_chunk_count
def get_file_chunk_count( file_path: str, chunk_size: int = DEFAULT_CHUNK_SIZE ) -> int: """ Determines the number of chunks necessary to send the file for the given chunk size :param file_path: The absolute path to the file that will be synchronized in chunks :param chunk_s...
python
def get_file_chunk_count( file_path: str, chunk_size: int = DEFAULT_CHUNK_SIZE ) -> int: """ Determines the number of chunks necessary to send the file for the given chunk size :param file_path: The absolute path to the file that will be synchronized in chunks :param chunk_s...
[ "def", "get_file_chunk_count", "(", "file_path", ":", "str", ",", "chunk_size", ":", "int", "=", "DEFAULT_CHUNK_SIZE", ")", "->", "int", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "file_path", ")", ":", "return", "0", "file_size", "=", "os"...
Determines the number of chunks necessary to send the file for the given chunk size :param file_path: The absolute path to the file that will be synchronized in chunks :param chunk_size: The maximum size of each chunk in bytes :return The number of chunks necessary to send the e...
[ "Determines", "the", "number", "of", "chunks", "necessary", "to", "send", "the", "file", "for", "the", "given", "chunk", "size" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/sync/sync_io.py#L45-L65
sernst/cauldron
cauldron/cli/sync/sync_io.py
read_file_chunks
def read_file_chunks( file_path: str, chunk_size: int = DEFAULT_CHUNK_SIZE ) -> bytes: """ Reads the specified file in chunks and returns a generator where each returned chunk is a compressed base64 encoded string for sync transmission :param file_path: The path to the file ...
python
def read_file_chunks( file_path: str, chunk_size: int = DEFAULT_CHUNK_SIZE ) -> bytes: """ Reads the specified file in chunks and returns a generator where each returned chunk is a compressed base64 encoded string for sync transmission :param file_path: The path to the file ...
[ "def", "read_file_chunks", "(", "file_path", ":", "str", ",", "chunk_size", ":", "int", "=", "DEFAULT_CHUNK_SIZE", ")", "->", "bytes", ":", "chunk_count", "=", "get_file_chunk_count", "(", "file_path", ",", "chunk_size", ")", "if", "chunk_count", "<", "1", ":"...
Reads the specified file in chunks and returns a generator where each returned chunk is a compressed base64 encoded string for sync transmission :param file_path: The path to the file to read in chunks :param chunk_size: The size, in bytes, of each chunk. The final chunk will be less th...
[ "Reads", "the", "specified", "file", "in", "chunks", "and", "returns", "a", "generator", "where", "each", "returned", "chunk", "is", "a", "compressed", "base64", "encoded", "string", "for", "sync", "transmission" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/sync/sync_io.py#L68-L92
sernst/cauldron
cauldron/cli/sync/sync_io.py
write_file_chunk
def write_file_chunk( file_path: str, packed_chunk: str, append: bool = True, offset: int = -1 ): """ Write or append the specified chunk data to the given file path, unpacking the chunk before writing. If the file does not yet exist, it will be created. Set the append ar...
python
def write_file_chunk( file_path: str, packed_chunk: str, append: bool = True, offset: int = -1 ): """ Write or append the specified chunk data to the given file path, unpacking the chunk before writing. If the file does not yet exist, it will be created. Set the append ar...
[ "def", "write_file_chunk", "(", "file_path", ":", "str", ",", "packed_chunk", ":", "str", ",", "append", ":", "bool", "=", "True", ",", "offset", ":", "int", "=", "-", "1", ")", ":", "mode", "=", "'ab'", "if", "append", "else", "'wb'", "contents", "=...
Write or append the specified chunk data to the given file path, unpacking the chunk before writing. If the file does not yet exist, it will be created. Set the append argument to False if you do not want the chunk to be appended to an existing file. :param file_path: The file where the chunk w...
[ "Write", "or", "append", "the", "specified", "chunk", "data", "to", "the", "given", "file", "path", "unpacking", "the", "chunk", "before", "writing", ".", "If", "the", "file", "does", "not", "yet", "exist", "it", "will", "be", "created", ".", "Set", "the...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/sync/sync_io.py#L95-L124
sernst/cauldron
cauldron/environ/logger.py
add_output_path
def add_output_path(path: str = None) -> str: """ Adds the specified path to the output logging paths if it is not already in the listed paths. :param path: The path to add to the logging output paths. If the path is empty or no path is given, the current working directory will be used ...
python
def add_output_path(path: str = None) -> str: """ Adds the specified path to the output logging paths if it is not already in the listed paths. :param path: The path to add to the logging output paths. If the path is empty or no path is given, the current working directory will be used ...
[ "def", "add_output_path", "(", "path", ":", "str", "=", "None", ")", "->", "str", ":", "cleaned", "=", "paths", ".", "clean", "(", "path", "or", "os", ".", "getcwd", "(", ")", ")", "if", "cleaned", "not", "in", "_logging_paths", ":", "_logging_paths", ...
Adds the specified path to the output logging paths if it is not already in the listed paths. :param path: The path to add to the logging output paths. If the path is empty or no path is given, the current working directory will be used instead.
[ "Adds", "the", "specified", "path", "to", "the", "output", "logging", "paths", "if", "it", "is", "not", "already", "in", "the", "listed", "paths", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/environ/logger.py#L14-L27
sernst/cauldron
cauldron/environ/logger.py
remove_output_path
def remove_output_path(path: str = None) -> str: """ Removes the specified path from the output logging paths if it is in the listed paths. :param path: The path to remove from the logging output paths. If the path is empty or no path is given, the current working directory will be used...
python
def remove_output_path(path: str = None) -> str: """ Removes the specified path from the output logging paths if it is in the listed paths. :param path: The path to remove from the logging output paths. If the path is empty or no path is given, the current working directory will be used...
[ "def", "remove_output_path", "(", "path", ":", "str", "=", "None", ")", "->", "str", ":", "cleaned", "=", "paths", ".", "clean", "(", "path", "or", "os", ".", "getcwd", "(", ")", ")", "if", "cleaned", "in", "_logging_paths", ":", "_logging_paths", ".",...
Removes the specified path from the output logging paths if it is in the listed paths. :param path: The path to remove from the logging output paths. If the path is empty or no path is given, the current working directory will be used instead.
[ "Removes", "the", "specified", "path", "from", "the", "output", "logging", "paths", "if", "it", "is", "in", "the", "listed", "paths", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/environ/logger.py#L30-L43
sernst/cauldron
cauldron/environ/logger.py
log
def log( message: typing.Union[str, typing.List[str]], whitespace: int = 0, whitespace_top: int = 0, whitespace_bottom: int = 0, indent_by: int = 0, trace: bool = True, file_path: str = None, append_to_file: bool = True, **kwargs ) -> str: """ ...
python
def log( message: typing.Union[str, typing.List[str]], whitespace: int = 0, whitespace_top: int = 0, whitespace_bottom: int = 0, indent_by: int = 0, trace: bool = True, file_path: str = None, append_to_file: bool = True, **kwargs ) -> str: """ ...
[ "def", "log", "(", "message", ":", "typing", ".", "Union", "[", "str", ",", "typing", ".", "List", "[", "str", "]", "]", ",", "whitespace", ":", "int", "=", "0", ",", "whitespace_top", ":", "int", "=", "0", ",", "whitespace_bottom", ":", "int", "="...
Logs a message to the console with the formatting support beyond a simple print statement or logger statement. :param message: The primary log message for the entry :param whitespace: The number of lines of whitespace to append to the beginning and end of the log message when printe...
[ "Logs", "a", "message", "to", "the", "console", "with", "the", "formatting", "support", "beyond", "a", "simple", "print", "statement", "or", "logger", "statement", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/environ/logger.py#L128-L188
sernst/cauldron
cauldron/environ/logger.py
add_to_message
def add_to_message(data, indent_level=0) -> list: """Adds data to the message object""" message = [] if isinstance(data, str): message.append(indent( dedent(data.strip('\n')).strip(), indent_level * ' ' )) return message for line in data: offset...
python
def add_to_message(data, indent_level=0) -> list: """Adds data to the message object""" message = [] if isinstance(data, str): message.append(indent( dedent(data.strip('\n')).strip(), indent_level * ' ' )) return message for line in data: offset...
[ "def", "add_to_message", "(", "data", ",", "indent_level", "=", "0", ")", "->", "list", ":", "message", "=", "[", "]", "if", "isinstance", "(", "data", ",", "str", ")", ":", "message", ".", "append", "(", "indent", "(", "dedent", "(", "data", ".", ...
Adds data to the message object
[ "Adds", "data", "to", "the", "message", "object" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/environ/logger.py#L226-L240
sernst/cauldron
cauldron/environ/modes.py
add
def add(mode_id: str) -> list: """ Adds the specified mode identifier to the list of active modes and returns a copy of the currently active modes list. """ if not has(mode_id): _current_modes.append(mode_id) return _current_modes.copy()
python
def add(mode_id: str) -> list: """ Adds the specified mode identifier to the list of active modes and returns a copy of the currently active modes list. """ if not has(mode_id): _current_modes.append(mode_id) return _current_modes.copy()
[ "def", "add", "(", "mode_id", ":", "str", ")", "->", "list", ":", "if", "not", "has", "(", "mode_id", ")", ":", "_current_modes", ".", "append", "(", "mode_id", ")", "return", "_current_modes", ".", "copy", "(", ")" ]
Adds the specified mode identifier to the list of active modes and returns a copy of the currently active modes list.
[ "Adds", "the", "specified", "mode", "identifier", "to", "the", "list", "of", "active", "modes", "and", "returns", "a", "copy", "of", "the", "currently", "active", "modes", "list", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/environ/modes.py#L20-L28
sernst/cauldron
cauldron/environ/modes.py
remove
def remove(mode_id: str) -> bool: """ Removes the specified mode identifier from the active modes and returns whether or not a remove operation was carried out. If the mode identifier is not in the currently active modes, it does need to be removed. """ had_mode = has(mode_id) if had_mode:...
python
def remove(mode_id: str) -> bool: """ Removes the specified mode identifier from the active modes and returns whether or not a remove operation was carried out. If the mode identifier is not in the currently active modes, it does need to be removed. """ had_mode = has(mode_id) if had_mode:...
[ "def", "remove", "(", "mode_id", ":", "str", ")", "->", "bool", ":", "had_mode", "=", "has", "(", "mode_id", ")", "if", "had_mode", ":", "_current_modes", ".", "remove", "(", "mode_id", ")", "return", "had_mode" ]
Removes the specified mode identifier from the active modes and returns whether or not a remove operation was carried out. If the mode identifier is not in the currently active modes, it does need to be removed.
[ "Removes", "the", "specified", "mode", "identifier", "from", "the", "active", "modes", "and", "returns", "whether", "or", "not", "a", "remove", "operation", "was", "carried", "out", ".", "If", "the", "mode", "identifier", "is", "not", "in", "the", "currently...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/environ/modes.py#L31-L43
seomoz/qless-py
qless/profile.py
Profiler.clone
def clone(client): '''Clone the redis client to be slowlog-compatible''' kwargs = client.redis.connection_pool.connection_kwargs kwargs['parser_class'] = redis.connection.PythonParser pool = redis.connection.ConnectionPool(**kwargs) return redis.Redis(connection_pool=pool)
python
def clone(client): '''Clone the redis client to be slowlog-compatible''' kwargs = client.redis.connection_pool.connection_kwargs kwargs['parser_class'] = redis.connection.PythonParser pool = redis.connection.ConnectionPool(**kwargs) return redis.Redis(connection_pool=pool)
[ "def", "clone", "(", "client", ")", ":", "kwargs", "=", "client", ".", "redis", ".", "connection_pool", ".", "connection_kwargs", "kwargs", "[", "'parser_class'", "]", "=", "redis", ".", "connection", ".", "PythonParser", "pool", "=", "redis", ".", "connecti...
Clone the redis client to be slowlog-compatible
[ "Clone", "the", "redis", "client", "to", "be", "slowlog", "-", "compatible" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/profile.py#L12-L17
seomoz/qless-py
qless/profile.py
Profiler.pretty
def pretty(timings, label): '''Print timing stats''' results = [(sum(values), len(values), key) for key, values in timings.items()] print(label) print('=' * 65) print('%20s => %13s | %8s | %13s' % ( 'Command', 'Average', '# Calls', 'Total time')) p...
python
def pretty(timings, label): '''Print timing stats''' results = [(sum(values), len(values), key) for key, values in timings.items()] print(label) print('=' * 65) print('%20s => %13s | %8s | %13s' % ( 'Command', 'Average', '# Calls', 'Total time')) p...
[ "def", "pretty", "(", "timings", ",", "label", ")", ":", "results", "=", "[", "(", "sum", "(", "values", ")", ",", "len", "(", "values", ")", ",", "key", ")", "for", "key", ",", "values", "in", "timings", ".", "items", "(", ")", "]", "print", "...
Print timing stats
[ "Print", "timing", "stats" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/profile.py#L20-L31
seomoz/qless-py
qless/profile.py
Profiler.start
def start(self): '''Get ready for a profiling run''' self._configs = self._client.config_get('slow-*') self._client.config_set('slowlog-max-len', 100000) self._client.config_set('slowlog-log-slower-than', 0) self._client.execute_command('slowlog', 'reset')
python
def start(self): '''Get ready for a profiling run''' self._configs = self._client.config_get('slow-*') self._client.config_set('slowlog-max-len', 100000) self._client.config_set('slowlog-log-slower-than', 0) self._client.execute_command('slowlog', 'reset')
[ "def", "start", "(", "self", ")", ":", "self", ".", "_configs", "=", "self", ".", "_client", ".", "config_get", "(", "'slow-*'", ")", "self", ".", "_client", ".", "config_set", "(", "'slowlog-max-len'", ",", "100000", ")", "self", ".", "_client", ".", ...
Get ready for a profiling run
[ "Get", "ready", "for", "a", "profiling", "run" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/profile.py#L39-L44
seomoz/qless-py
qless/profile.py
Profiler.stop
def stop(self): '''Set everything back to normal and collect our data''' for key, value in self._configs.items(): self._client.config_set(key, value) logs = self._client.execute_command('slowlog', 'get', 100000) current = { 'name': None, 'accumulated': defaultdict...
python
def stop(self): '''Set everything back to normal and collect our data''' for key, value in self._configs.items(): self._client.config_set(key, value) logs = self._client.execute_command('slowlog', 'get', 100000) current = { 'name': None, 'accumulated': defaultdict...
[ "def", "stop", "(", "self", ")", ":", "for", "key", ",", "value", "in", "self", ".", "_configs", ".", "items", "(", ")", ":", "self", ".", "_client", ".", "config_set", "(", "key", ",", "value", ")", "logs", "=", "self", ".", "_client", ".", "exe...
Set everything back to normal and collect our data
[ "Set", "everything", "back", "to", "normal", "and", "collect", "our", "data" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/profile.py#L46-L78
seomoz/qless-py
qless/profile.py
Profiler.display
def display(self): '''Print the results of this profiling''' self.pretty(self._timings, 'Raw Redis Commands') print() for key, value in self._commands.items(): self.pretty(value, 'Qless "%s" Command' % key) print()
python
def display(self): '''Print the results of this profiling''' self.pretty(self._timings, 'Raw Redis Commands') print() for key, value in self._commands.items(): self.pretty(value, 'Qless "%s" Command' % key) print()
[ "def", "display", "(", "self", ")", ":", "self", ".", "pretty", "(", "self", ".", "_timings", ",", "'Raw Redis Commands'", ")", "print", "(", ")", "for", "key", ",", "value", "in", "self", ".", "_commands", ".", "items", "(", ")", ":", "self", ".", ...
Print the results of this profiling
[ "Print", "the", "results", "of", "this", "profiling" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/profile.py#L80-L86
sernst/cauldron
cauldron/invoke/parser.py
add_shell_action
def add_shell_action(sub_parser: ArgumentParser) -> ArgumentParser: """Populates the sub parser with the shell arguments""" sub_parser.add_argument( '-p', '--project', dest='project_directory', type=str, default=None ) sub_parser.add_argument( '-l', '--log', ...
python
def add_shell_action(sub_parser: ArgumentParser) -> ArgumentParser: """Populates the sub parser with the shell arguments""" sub_parser.add_argument( '-p', '--project', dest='project_directory', type=str, default=None ) sub_parser.add_argument( '-l', '--log', ...
[ "def", "add_shell_action", "(", "sub_parser", ":", "ArgumentParser", ")", "->", "ArgumentParser", ":", "sub_parser", ".", "add_argument", "(", "'-p'", ",", "'--project'", ",", "dest", "=", "'project_directory'", ",", "type", "=", "str", ",", "default", "=", "N...
Populates the sub parser with the shell arguments
[ "Populates", "the", "sub", "parser", "with", "the", "shell", "arguments" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/invoke/parser.py#L11-L42
sernst/cauldron
cauldron/invoke/parser.py
parse
def parse(args: list = None) -> dict: """ Parses the command line arguments and returns a dictionary containing the results. :param args: The command line arguments to parse. If None, the system command line arguments will be used instead. """ parser = ArgumentParser(descri...
python
def parse(args: list = None) -> dict: """ Parses the command line arguments and returns a dictionary containing the results. :param args: The command line arguments to parse. If None, the system command line arguments will be used instead. """ parser = ArgumentParser(descri...
[ "def", "parse", "(", "args", ":", "list", "=", "None", ")", "->", "dict", ":", "parser", "=", "ArgumentParser", "(", "description", "=", "'Cauldron command'", ")", "parser", ".", "add_argument", "(", "'command'", ",", "nargs", "=", "'?'", ",", "default", ...
Parses the command line arguments and returns a dictionary containing the results. :param args: The command line arguments to parse. If None, the system command line arguments will be used instead.
[ "Parses", "the", "command", "line", "arguments", "and", "returns", "a", "dictionary", "containing", "the", "results", ".", ":", "param", "args", ":", "The", "command", "line", "arguments", "to", "parse", ".", "If", "None", "the", "system", "command", "line",...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/invoke/parser.py#L45-L83
seomoz/qless-py
qless/queue.py
Jobs.running
def running(self, offset=0, count=25): '''Return all the currently-running jobs''' return self.client('jobs', 'running', self.name, offset, count)
python
def running(self, offset=0, count=25): '''Return all the currently-running jobs''' return self.client('jobs', 'running', self.name, offset, count)
[ "def", "running", "(", "self", ",", "offset", "=", "0", ",", "count", "=", "25", ")", ":", "return", "self", ".", "client", "(", "'jobs'", ",", "'running'", ",", "self", ".", "name", ",", "offset", ",", "count", ")" ]
Return all the currently-running jobs
[ "Return", "all", "the", "currently", "-", "running", "jobs" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/queue.py#L19-L21
seomoz/qless-py
qless/queue.py
Jobs.stalled
def stalled(self, offset=0, count=25): '''Return all the currently-stalled jobs''' return self.client('jobs', 'stalled', self.name, offset, count)
python
def stalled(self, offset=0, count=25): '''Return all the currently-stalled jobs''' return self.client('jobs', 'stalled', self.name, offset, count)
[ "def", "stalled", "(", "self", ",", "offset", "=", "0", ",", "count", "=", "25", ")", ":", "return", "self", ".", "client", "(", "'jobs'", ",", "'stalled'", ",", "self", ".", "name", ",", "offset", ",", "count", ")" ]
Return all the currently-stalled jobs
[ "Return", "all", "the", "currently", "-", "stalled", "jobs" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/queue.py#L23-L25
seomoz/qless-py
qless/queue.py
Jobs.scheduled
def scheduled(self, offset=0, count=25): '''Return all the currently-scheduled jobs''' return self.client('jobs', 'scheduled', self.name, offset, count)
python
def scheduled(self, offset=0, count=25): '''Return all the currently-scheduled jobs''' return self.client('jobs', 'scheduled', self.name, offset, count)
[ "def", "scheduled", "(", "self", ",", "offset", "=", "0", ",", "count", "=", "25", ")", ":", "return", "self", ".", "client", "(", "'jobs'", ",", "'scheduled'", ",", "self", ".", "name", ",", "offset", ",", "count", ")" ]
Return all the currently-scheduled jobs
[ "Return", "all", "the", "currently", "-", "scheduled", "jobs" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/queue.py#L27-L29
seomoz/qless-py
qless/queue.py
Jobs.depends
def depends(self, offset=0, count=25): '''Return all the currently dependent jobs''' return self.client('jobs', 'depends', self.name, offset, count)
python
def depends(self, offset=0, count=25): '''Return all the currently dependent jobs''' return self.client('jobs', 'depends', self.name, offset, count)
[ "def", "depends", "(", "self", ",", "offset", "=", "0", ",", "count", "=", "25", ")", ":", "return", "self", ".", "client", "(", "'jobs'", ",", "'depends'", ",", "self", ".", "name", ",", "offset", ",", "count", ")" ]
Return all the currently dependent jobs
[ "Return", "all", "the", "currently", "dependent", "jobs" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/queue.py#L31-L33
seomoz/qless-py
qless/queue.py
Jobs.recurring
def recurring(self, offset=0, count=25): '''Return all the recurring jobs''' return self.client('jobs', 'recurring', self.name, offset, count)
python
def recurring(self, offset=0, count=25): '''Return all the recurring jobs''' return self.client('jobs', 'recurring', self.name, offset, count)
[ "def", "recurring", "(", "self", ",", "offset", "=", "0", ",", "count", "=", "25", ")", ":", "return", "self", ".", "client", "(", "'jobs'", ",", "'recurring'", ",", "self", ".", "name", ",", "offset", ",", "count", ")" ]
Return all the recurring jobs
[ "Return", "all", "the", "recurring", "jobs" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/queue.py#L35-L37
seomoz/qless-py
qless/queue.py
Queue.class_string
def class_string(self, klass): '''Return a string representative of the class''' if isinstance(klass, string_types): return klass return klass.__module__ + '.' + klass.__name__
python
def class_string(self, klass): '''Return a string representative of the class''' if isinstance(klass, string_types): return klass return klass.__module__ + '.' + klass.__name__
[ "def", "class_string", "(", "self", ",", "klass", ")", ":", "if", "isinstance", "(", "klass", ",", "string_types", ")", ":", "return", "klass", "return", "klass", ".", "__module__", "+", "'.'", "+", "klass", ".", "__name__" ]
Return a string representative of the class
[ "Return", "a", "string", "representative", "of", "the", "class" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/queue.py#L66-L70
seomoz/qless-py
qless/queue.py
Queue.put
def put(self, klass, data, priority=None, tags=None, delay=None, retries=None, jid=None, depends=None): '''Either create a new job in the provided queue with the provided attributes, or move that job into that queue. If the job is being serviced by a worker, subsequent attempts by that w...
python
def put(self, klass, data, priority=None, tags=None, delay=None, retries=None, jid=None, depends=None): '''Either create a new job in the provided queue with the provided attributes, or move that job into that queue. If the job is being serviced by a worker, subsequent attempts by that w...
[ "def", "put", "(", "self", ",", "klass", ",", "data", ",", "priority", "=", "None", ",", "tags", "=", "None", ",", "delay", "=", "None", ",", "retries", "=", "None", ",", "jid", "=", "None", ",", "depends", "=", "None", ")", ":", "return", "self"...
Either create a new job in the provided queue with the provided attributes, or move that job into that queue. If the job is being serviced by a worker, subsequent attempts by that worker to either `heartbeat` or `complete` the job should fail and return `false`. The `priority` argument ...
[ "Either", "create", "a", "new", "job", "in", "the", "provided", "queue", "with", "the", "provided", "attributes", "or", "move", "that", "job", "into", "that", "queue", ".", "If", "the", "job", "is", "being", "serviced", "by", "a", "worker", "subsequent", ...
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/queue.py#L78-L100
seomoz/qless-py
qless/queue.py
Queue.recur
def recur(self, klass, data, interval, offset=0, priority=None, tags=None, retries=None, jid=None): '''Place a recurring job in this queue''' return self.client('recur', self.name, jid or uuid.uuid4().hex, self.class_string(klass), json.dumps(data), ...
python
def recur(self, klass, data, interval, offset=0, priority=None, tags=None, retries=None, jid=None): '''Place a recurring job in this queue''' return self.client('recur', self.name, jid or uuid.uuid4().hex, self.class_string(klass), json.dumps(data), ...
[ "def", "recur", "(", "self", ",", "klass", ",", "data", ",", "interval", ",", "offset", "=", "0", ",", "priority", "=", "None", ",", "tags", "=", "None", ",", "retries", "=", "None", ",", "jid", "=", "None", ")", ":", "return", "self", ".", "clie...
Place a recurring job in this queue
[ "Place", "a", "recurring", "job", "in", "this", "queue" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/queue.py#L118-L129
seomoz/qless-py
qless/queue.py
Queue.pop
def pop(self, count=None): '''Passing in the queue from which to pull items, the current time, when the locks for these returned items should expire, and the number of items to be popped off.''' results = [Job(self.client, **job) for job in json.loads( self.client('pop', self...
python
def pop(self, count=None): '''Passing in the queue from which to pull items, the current time, when the locks for these returned items should expire, and the number of items to be popped off.''' results = [Job(self.client, **job) for job in json.loads( self.client('pop', self...
[ "def", "pop", "(", "self", ",", "count", "=", "None", ")", ":", "results", "=", "[", "Job", "(", "self", ".", "client", ",", "*", "*", "job", ")", "for", "job", "in", "json", ".", "loads", "(", "self", ".", "client", "(", "'pop'", ",", "self", ...
Passing in the queue from which to pull items, the current time, when the locks for these returned items should expire, and the number of items to be popped off.
[ "Passing", "in", "the", "queue", "from", "which", "to", "pull", "items", "the", "current", "time", "when", "the", "locks", "for", "these", "returned", "items", "should", "expire", "and", "the", "number", "of", "items", "to", "be", "popped", "off", "." ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/queue.py#L131-L139
seomoz/qless-py
qless/queue.py
Queue.peek
def peek(self, count=None): '''Similar to the pop command, except that it merely peeks at the next items''' results = [Job(self.client, **rec) for rec in json.loads( self.client('peek', self.name, count or 1))] if count is None: return (len(results) and results[0]...
python
def peek(self, count=None): '''Similar to the pop command, except that it merely peeks at the next items''' results = [Job(self.client, **rec) for rec in json.loads( self.client('peek', self.name, count or 1))] if count is None: return (len(results) and results[0]...
[ "def", "peek", "(", "self", ",", "count", "=", "None", ")", ":", "results", "=", "[", "Job", "(", "self", ".", "client", ",", "*", "*", "rec", ")", "for", "rec", "in", "json", ".", "loads", "(", "self", ".", "client", "(", "'peek'", ",", "self"...
Similar to the pop command, except that it merely peeks at the next items
[ "Similar", "to", "the", "pop", "command", "except", "that", "it", "merely", "peeks", "at", "the", "next", "items" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/queue.py#L141-L148
seomoz/qless-py
qless/queue.py
Queue.stats
def stats(self, date=None): '''Return the current statistics for a given queue on a given date. The results are returned are a JSON blob:: { 'total' : ..., 'mean' : ..., 'variance' : ..., 'histogram': [ ...
python
def stats(self, date=None): '''Return the current statistics for a given queue on a given date. The results are returned are a JSON blob:: { 'total' : ..., 'mean' : ..., 'variance' : ..., 'histogram': [ ...
[ "def", "stats", "(", "self", ",", "date", "=", "None", ")", ":", "return", "json", ".", "loads", "(", "self", ".", "client", "(", "'stats'", ",", "self", ".", "name", ",", "date", "or", "repr", "(", "time", ".", "time", "(", ")", ")", ")", ")" ...
Return the current statistics for a given queue on a given date. The results are returned are a JSON blob:: { 'total' : ..., 'mean' : ..., 'variance' : ..., 'histogram': [ ... ] } ...
[ "Return", "the", "current", "statistics", "for", "a", "given", "queue", "on", "a", "given", "date", ".", "The", "results", "are", "returned", "are", "a", "JSON", "blob", "::" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/queue.py#L150-L169
sernst/cauldron
cauldron/runner/markdown_file.py
run
def run( project: 'projects.Project', step: 'projects.ProjectStep' ) -> dict: """ Runs the markdown file and renders the contents to the notebook display :param project: :param step: :return: A run response dictionary containing """ with open(step.source_path, 'r') ...
python
def run( project: 'projects.Project', step: 'projects.ProjectStep' ) -> dict: """ Runs the markdown file and renders the contents to the notebook display :param project: :param step: :return: A run response dictionary containing """ with open(step.source_path, 'r') ...
[ "def", "run", "(", "project", ":", "'projects.Project'", ",", "step", ":", "'projects.ProjectStep'", ")", "->", "dict", ":", "with", "open", "(", "step", ".", "source_path", ",", "'r'", ")", "as", "f", ":", "code", "=", "f", ".", "read", "(", ")", "t...
Runs the markdown file and renders the contents to the notebook display :param project: :param step: :return: A run response dictionary containing
[ "Runs", "the", "markdown", "file", "and", "renders", "the", "contents", "to", "the", "notebook", "display" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/runner/markdown_file.py#L6-L32
sernst/cauldron
cauldron/cli/commander.py
fetch
def fetch(reload: bool = False) -> dict: """ Returns a dictionary containing all of the available Cauldron commands currently registered. This data is cached for performance. Unless the reload argument is set to True, the command list will only be generated the first time this function is called. ...
python
def fetch(reload: bool = False) -> dict: """ Returns a dictionary containing all of the available Cauldron commands currently registered. This data is cached for performance. Unless the reload argument is set to True, the command list will only be generated the first time this function is called. ...
[ "def", "fetch", "(", "reload", ":", "bool", "=", "False", ")", "->", "dict", ":", "if", "len", "(", "list", "(", "COMMANDS", ".", "keys", "(", ")", ")", ")", ">", "0", "and", "not", "reload", ":", "return", "COMMANDS", "COMMANDS", ".", "clear", "...
Returns a dictionary containing all of the available Cauldron commands currently registered. This data is cached for performance. Unless the reload argument is set to True, the command list will only be generated the first time this function is called. :param reload: Whether or not to disregard...
[ "Returns", "a", "dictionary", "containing", "all", "of", "the", "available", "Cauldron", "commands", "currently", "registered", ".", "This", "data", "is", "cached", "for", "performance", ".", "Unless", "the", "reload", "argument", "is", "set", "to", "True", "t...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/commander.py#L35-L61
sernst/cauldron
cauldron/cli/commander.py
get_command_from_module
def get_command_from_module( command_module, remote_connection: environ.RemoteConnection ): """ Returns the execution command to use for the specified module, which may be different depending upon remote connection :param command_module: :param remote_connection: :return: ""...
python
def get_command_from_module( command_module, remote_connection: environ.RemoteConnection ): """ Returns the execution command to use for the specified module, which may be different depending upon remote connection :param command_module: :param remote_connection: :return: ""...
[ "def", "get_command_from_module", "(", "command_module", ",", "remote_connection", ":", "environ", ".", "RemoteConnection", ")", ":", "use_remote", "=", "(", "remote_connection", ".", "active", "and", "hasattr", "(", "command_module", ",", "'execute_remote'", ")", "...
Returns the execution command to use for the specified module, which may be different depending upon remote connection :param command_module: :param remote_connection: :return:
[ "Returns", "the", "execution", "command", "to", "use", "for", "the", "specified", "module", "which", "may", "be", "different", "depending", "upon", "remote", "connection" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/commander.py#L64-L85
sernst/cauldron
cauldron/cli/commander.py
show_help
def show_help(command_name: str = None, raw_args: str = '') -> Response: """ Prints the basic command help to the console """ response = Response() cmds = fetch() if command_name and command_name in cmds: parser, result = parse.get_parser( cmds[command_name], parse.expl...
python
def show_help(command_name: str = None, raw_args: str = '') -> Response: """ Prints the basic command help to the console """ response = Response() cmds = fetch() if command_name and command_name in cmds: parser, result = parse.get_parser( cmds[command_name], parse.expl...
[ "def", "show_help", "(", "command_name", ":", "str", "=", "None", ",", "raw_args", ":", "str", "=", "''", ")", "->", "Response", ":", "response", "=", "Response", "(", ")", "cmds", "=", "fetch", "(", ")", "if", "command_name", "and", "command_name", "i...
Prints the basic command help to the console
[ "Prints", "the", "basic", "command", "help", "to", "the", "console" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/commander.py#L189-L228
seomoz/qless-py
qless/job.py
BaseJob._import
def _import(klass): '''1) Get a reference to the module 2) Check the file that module's imported from 3) If that file's been updated, force a reload of that module return it''' mod = __import__(klass.rpartition('.')[0]) for segment in klass.split('.')[1:-1]:...
python
def _import(klass): '''1) Get a reference to the module 2) Check the file that module's imported from 3) If that file's been updated, force a reload of that module return it''' mod = __import__(klass.rpartition('.')[0]) for segment in klass.split('.')[1:-1]:...
[ "def", "_import", "(", "klass", ")", ":", "mod", "=", "__import__", "(", "klass", ".", "rpartition", "(", "'.'", ")", "[", "0", "]", ")", "for", "segment", "in", "klass", ".", "split", "(", "'.'", ")", "[", "1", ":", "-", "1", "]", ":", "mod", ...
1) Get a reference to the module 2) Check the file that module's imported from 3) If that file's been updated, force a reload of that module return it
[ "1", ")", "Get", "a", "reference", "to", "the", "module", "2", ")", "Check", "the", "file", "that", "module", "s", "imported", "from", "3", ")", "If", "that", "file", "s", "been", "updated", "force", "a", "reload", "of", "that", "module", "return", "...
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/job.py#L59-L81
seomoz/qless-py
qless/job.py
Job.process
def process(self): '''Load the module containing your class, and run the appropriate method. For example, if this job was popped from the queue ``testing``, then this would invoke the ``testing`` staticmethod of your class.''' try: method = getattr(self.klass, self.qu...
python
def process(self): '''Load the module containing your class, and run the appropriate method. For example, if this job was popped from the queue ``testing``, then this would invoke the ``testing`` staticmethod of your class.''' try: method = getattr(self.klass, self.qu...
[ "def", "process", "(", "self", ")", ":", "try", ":", "method", "=", "getattr", "(", "self", ".", "klass", ",", "self", ".", "queue_name", ",", "getattr", "(", "self", ".", "klass", ",", "'process'", ",", "None", ")", ")", "except", "Exception", "as",...
Load the module containing your class, and run the appropriate method. For example, if this job was popped from the queue ``testing``, then this would invoke the ``testing`` staticmethod of your class.
[ "Load", "the", "module", "containing", "your", "class", "and", "run", "the", "appropriate", "method", ".", "For", "example", "if", "this", "job", "was", "popped", "from", "the", "queue", "testing", "then", "this", "would", "invoke", "the", "testing", "static...
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/job.py#L133-L173
seomoz/qless-py
qless/job.py
Job.move
def move(self, queue, delay=0, depends=None): '''Move this job out of its existing state and into another queue. If a worker has been given this job, then that worker's attempts to heartbeat that job will fail. Like ``Queue.put``, this accepts a delay, and dependencies''' logger....
python
def move(self, queue, delay=0, depends=None): '''Move this job out of its existing state and into another queue. If a worker has been given this job, then that worker's attempts to heartbeat that job will fail. Like ``Queue.put``, this accepts a delay, and dependencies''' logger....
[ "def", "move", "(", "self", ",", "queue", ",", "delay", "=", "0", ",", "depends", "=", "None", ")", ":", "logger", ".", "info", "(", "'Moving %s to %s from %s'", ",", "self", ".", "jid", ",", "queue", ",", "self", ".", "queue_name", ")", "return", "s...
Move this job out of its existing state and into another queue. If a worker has been given this job, then that worker's attempts to heartbeat that job will fail. Like ``Queue.put``, this accepts a delay, and dependencies
[ "Move", "this", "job", "out", "of", "its", "existing", "state", "and", "into", "another", "queue", ".", "If", "a", "worker", "has", "been", "given", "this", "job", "then", "that", "worker", "s", "attempts", "to", "heartbeat", "that", "job", "will", "fail...
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/job.py#L175-L185
seomoz/qless-py
qless/job.py
Job.complete
def complete(self, nextq=None, delay=None, depends=None): '''Turn this job in as complete, optionally advancing it to another queue. Like ``Queue.put`` and ``move``, it accepts a delay, and dependencies''' if nextq: logger.info('Advancing %s to %s from %s', se...
python
def complete(self, nextq=None, delay=None, depends=None): '''Turn this job in as complete, optionally advancing it to another queue. Like ``Queue.put`` and ``move``, it accepts a delay, and dependencies''' if nextq: logger.info('Advancing %s to %s from %s', se...
[ "def", "complete", "(", "self", ",", "nextq", "=", "None", ",", "delay", "=", "None", ",", "depends", "=", "None", ")", ":", "if", "nextq", ":", "logger", ".", "info", "(", "'Advancing %s to %s from %s'", ",", "self", ".", "jid", ",", "nextq", ",", "...
Turn this job in as complete, optionally advancing it to another queue. Like ``Queue.put`` and ``move``, it accepts a delay, and dependencies
[ "Turn", "this", "job", "in", "as", "complete", "optionally", "advancing", "it", "to", "another", "queue", ".", "Like", "Queue", ".", "put", "and", "move", "it", "accepts", "a", "delay", "and", "dependencies" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/job.py#L187-L201
seomoz/qless-py
qless/job.py
Job.heartbeat
def heartbeat(self): '''Renew the heartbeat, if possible, and optionally update the job's user data.''' logger.debug('Heartbeating %s (ttl = %s)', self.jid, self.ttl) try: self.expires_at = float(self.client('heartbeat', self.jid, self.client.worker_name, json.dum...
python
def heartbeat(self): '''Renew the heartbeat, if possible, and optionally update the job's user data.''' logger.debug('Heartbeating %s (ttl = %s)', self.jid, self.ttl) try: self.expires_at = float(self.client('heartbeat', self.jid, self.client.worker_name, json.dum...
[ "def", "heartbeat", "(", "self", ")", ":", "logger", ".", "debug", "(", "'Heartbeating %s (ttl = %s)'", ",", "self", ".", "jid", ",", "self", ".", "ttl", ")", "try", ":", "self", ".", "expires_at", "=", "float", "(", "self", ".", "client", "(", "'heart...
Renew the heartbeat, if possible, and optionally update the job's user data.
[ "Renew", "the", "heartbeat", "if", "possible", "and", "optionally", "update", "the", "job", "s", "user", "data", "." ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/job.py#L203-L213
seomoz/qless-py
qless/job.py
Job.fail
def fail(self, group, message): '''Mark the particular job as failed, with the provided type, and a more specific message. By `type`, we mean some phrase that might be one of several categorical modes of failure. The `message` is something more job-specific, like perhaps a traceback. ...
python
def fail(self, group, message): '''Mark the particular job as failed, with the provided type, and a more specific message. By `type`, we mean some phrase that might be one of several categorical modes of failure. The `message` is something more job-specific, like perhaps a traceback. ...
[ "def", "fail", "(", "self", ",", "group", ",", "message", ")", ":", "logger", ".", "warn", "(", "'Failing %s (%s): %s'", ",", "self", ".", "jid", ",", "group", ",", "message", ")", "return", "self", ".", "client", "(", "'fail'", ",", "self", ".", "ji...
Mark the particular job as failed, with the provided type, and a more specific message. By `type`, we mean some phrase that might be one of several categorical modes of failure. The `message` is something more job-specific, like perhaps a traceback. This method should __not__ be used to...
[ "Mark", "the", "particular", "job", "as", "failed", "with", "the", "provided", "type", "and", "a", "more", "specific", "message", ".", "By", "type", "we", "mean", "some", "phrase", "that", "might", "be", "one", "of", "several", "categorical", "modes", "of"...
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/job.py#L215-L235
seomoz/qless-py
qless/job.py
Job.retry
def retry(self, delay=0, group=None, message=None): '''Retry this job in a little bit, in the same queue. This is meant for the times when you detect a transient failure yourself''' args = ['retry', self.jid, self.queue_name, self.worker_name, delay] if group is not None and message is n...
python
def retry(self, delay=0, group=None, message=None): '''Retry this job in a little bit, in the same queue. This is meant for the times when you detect a transient failure yourself''' args = ['retry', self.jid, self.queue_name, self.worker_name, delay] if group is not None and message is n...
[ "def", "retry", "(", "self", ",", "delay", "=", "0", ",", "group", "=", "None", ",", "message", "=", "None", ")", ":", "args", "=", "[", "'retry'", ",", "self", ".", "jid", ",", "self", ".", "queue_name", ",", "self", ".", "worker_name", ",", "de...
Retry this job in a little bit, in the same queue. This is meant for the times when you detect a transient failure yourself
[ "Retry", "this", "job", "in", "a", "little", "bit", "in", "the", "same", "queue", ".", "This", "is", "meant", "for", "the", "times", "when", "you", "detect", "a", "transient", "failure", "yourself" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/job.py#L245-L252
seomoz/qless-py
qless/job.py
Job.undepend
def undepend(self, *args, **kwargs): '''Remove specific (or all) job dependencies from this job: job.remove(jid1, jid2) job.remove(all=True)''' if kwargs.get('all', False): return self.client('depends', self.jid, 'off', 'all') or False else: retur...
python
def undepend(self, *args, **kwargs): '''Remove specific (or all) job dependencies from this job: job.remove(jid1, jid2) job.remove(all=True)''' if kwargs.get('all', False): return self.client('depends', self.jid, 'off', 'all') or False else: retur...
[ "def", "undepend", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ".", "get", "(", "'all'", ",", "False", ")", ":", "return", "self", ".", "client", "(", "'depends'", ",", "self", ".", "jid", ",", "'off'", ",", ...
Remove specific (or all) job dependencies from this job: job.remove(jid1, jid2) job.remove(all=True)
[ "Remove", "specific", "(", "or", "all", ")", "job", "dependencies", "from", "this", "job", ":" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/job.py#L259-L267
sernst/cauldron
cauldron/runner/source.py
has_extension
def has_extension(file_path: str, *args: typing.Tuple[str]) -> bool: """ Checks to see if the given file path ends with any of the specified file extensions. If a file extension does not begin with a '.' it will be added automatically :param file_path: The path on which the extensions will ...
python
def has_extension(file_path: str, *args: typing.Tuple[str]) -> bool: """ Checks to see if the given file path ends with any of the specified file extensions. If a file extension does not begin with a '.' it will be added automatically :param file_path: The path on which the extensions will ...
[ "def", "has_extension", "(", "file_path", ":", "str", ",", "*", "args", ":", "typing", ".", "Tuple", "[", "str", "]", ")", "->", "bool", ":", "def", "add_dot", "(", "extension", ")", ":", "return", "(", "extension", "if", "extension", ".", "startswith"...
Checks to see if the given file path ends with any of the specified file extensions. If a file extension does not begin with a '.' it will be added automatically :param file_path: The path on which the extensions will be tested for a match :param args: One or more extensions to test for...
[ "Checks", "to", "see", "if", "the", "given", "file", "path", "ends", "with", "any", "of", "the", "specified", "file", "extensions", ".", "If", "a", "file", "extension", "does", "not", "begin", "with", "a", ".", "it", "will", "be", "added", "automatically...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/runner/source.py#L39-L64
sernst/cauldron
cauldron/docgen/parsing.py
get_docstring
def get_docstring(target) -> str: """ Retrieves the documentation string from the target object and returns it after removing insignificant whitespace :param target: The object for which the doc string should be retrieved :return: The cleaned documentation string for the target. If ...
python
def get_docstring(target) -> str: """ Retrieves the documentation string from the target object and returns it after removing insignificant whitespace :param target: The object for which the doc string should be retrieved :return: The cleaned documentation string for the target. If ...
[ "def", "get_docstring", "(", "target", ")", "->", "str", ":", "raw", "=", "getattr", "(", "target", ",", "'__doc__'", ")", "if", "raw", "is", "None", ":", "return", "''", "return", "textwrap", ".", "dedent", "(", "raw", ")" ]
Retrieves the documentation string from the target object and returns it after removing insignificant whitespace :param target: The object for which the doc string should be retrieved :return: The cleaned documentation string for the target. If no doc string exists an empty string w...
[ "Retrieves", "the", "documentation", "string", "from", "the", "target", "object", "and", "returns", "it", "after", "removing", "insignificant", "whitespace" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/docgen/parsing.py#L9-L26
sernst/cauldron
cauldron/docgen/parsing.py
get_doc_entries
def get_doc_entries(target: typing.Callable) -> list: """ Gets the lines of documentation from the given target, which are formatted so that each line is a documentation entry. :param target: :return: A list of strings containing the documentation block entries """ raw = get_docstr...
python
def get_doc_entries(target: typing.Callable) -> list: """ Gets the lines of documentation from the given target, which are formatted so that each line is a documentation entry. :param target: :return: A list of strings containing the documentation block entries """ raw = get_docstr...
[ "def", "get_doc_entries", "(", "target", ":", "typing", ".", "Callable", ")", "->", "list", ":", "raw", "=", "get_docstring", "(", "target", ")", "if", "not", "raw", ":", "return", "[", "]", "raw_lines", "=", "[", "line", ".", "strip", "(", ")", "for...
Gets the lines of documentation from the given target, which are formatted so that each line is a documentation entry. :param target: :return: A list of strings containing the documentation block entries
[ "Gets", "the", "lines", "of", "documentation", "from", "the", "given", "target", "which", "are", "formatted", "so", "that", "each", "line", "is", "a", "documentation", "entry", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/docgen/parsing.py#L29-L65
sernst/cauldron
cauldron/docgen/parsing.py
parse_function
def parse_function( name: str, target: typing.Callable ) -> typing.Union[None, dict]: """ Parses the documentation for a function, which is specified by the name of the function and the function itself. :param name: Name of the function to parse :param target: The fu...
python
def parse_function( name: str, target: typing.Callable ) -> typing.Union[None, dict]: """ Parses the documentation for a function, which is specified by the name of the function and the function itself. :param name: Name of the function to parse :param target: The fu...
[ "def", "parse_function", "(", "name", ":", "str", ",", "target", ":", "typing", ".", "Callable", ")", "->", "typing", ".", "Union", "[", "None", ",", "dict", "]", ":", "if", "not", "hasattr", "(", "target", ",", "'__code__'", ")", ":", "return", "Non...
Parses the documentation for a function, which is specified by the name of the function and the function itself. :param name: Name of the function to parse :param target: The function to parse into documentation :return: A dictionary containing documentation for the specified fu...
[ "Parses", "the", "documentation", "for", "a", "function", "which", "is", "specified", "by", "the", "name", "of", "the", "function", "and", "the", "function", "itself", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/docgen/parsing.py#L68-L98
sernst/cauldron
cauldron/docgen/parsing.py
variable
def variable(name: str, target: property) -> typing.Union[None, dict]: """ :param name: :param target: :return: """ if hasattr(target, 'fget'): doc = parse_function(name, target.fget) if doc: doc['read_only'] = bool(target.fset is None) return doc re...
python
def variable(name: str, target: property) -> typing.Union[None, dict]: """ :param name: :param target: :return: """ if hasattr(target, 'fget'): doc = parse_function(name, target.fget) if doc: doc['read_only'] = bool(target.fset is None) return doc re...
[ "def", "variable", "(", "name", ":", "str", ",", "target", ":", "property", ")", "->", "typing", ".", "Union", "[", "None", ",", "dict", "]", ":", "if", "hasattr", "(", "target", ",", "'fget'", ")", ":", "doc", "=", "parse_function", "(", "name", "...
:param name: :param target: :return:
[ ":", "param", "name", ":", ":", "param", "target", ":", ":", "return", ":" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/docgen/parsing.py#L101-L117
sernst/cauldron
cauldron/session/buffering.py
RedirectBuffer.read_all
def read_all(self) -> str: """ Reads the current state of the buffer and returns a string those contents :return: A string for the current state of the print buffer contents """ try: buffered_bytes = self.bytes_buffer.getvalue() if buf...
python
def read_all(self) -> str: """ Reads the current state of the buffer and returns a string those contents :return: A string for the current state of the print buffer contents """ try: buffered_bytes = self.bytes_buffer.getvalue() if buf...
[ "def", "read_all", "(", "self", ")", "->", "str", ":", "try", ":", "buffered_bytes", "=", "self", ".", "bytes_buffer", ".", "getvalue", "(", ")", "if", "buffered_bytes", "is", "None", ":", "return", "''", "return", "buffered_bytes", ".", "decode", "(", "...
Reads the current state of the buffer and returns a string those contents :return: A string for the current state of the print buffer contents
[ "Reads", "the", "current", "state", "of", "the", "buffer", "and", "returns", "a", "string", "those", "contents" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/buffering.py#L31-L46
sernst/cauldron
cauldron/session/buffering.py
RedirectBuffer.flush_all
def flush_all(self) -> str: """ :return: """ # self.bytes_buffer.seek(0) # contents = self.bytes_buffer.read() # self.bytes_buffer.truncate(0) # self.bytes_buffer.seek(0) # if contents is None: # return '' contents = self.by...
python
def flush_all(self) -> str: """ :return: """ # self.bytes_buffer.seek(0) # contents = self.bytes_buffer.read() # self.bytes_buffer.truncate(0) # self.bytes_buffer.seek(0) # if contents is None: # return '' contents = self.by...
[ "def", "flush_all", "(", "self", ")", "->", "str", ":", "# self.bytes_buffer.seek(0)", "# contents = self.bytes_buffer.read()", "# self.bytes_buffer.truncate(0)", "# self.bytes_buffer.seek(0)", "# if contents is None:", "# return ''", "contents", "=", "self", ".", "bytes_buff...
:return:
[ ":", "return", ":" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/buffering.py#L48-L70
sernst/cauldron
cauldron/session/writing/step.py
create_data
def create_data(step: 'projects.ProjectStep') -> STEP_DATA: """ Creates the data object that stores the step information in the notebook results JavaScript file. :param step: Project step for which to create the data :return: Step data tuple containing scaffold data structure for th...
python
def create_data(step: 'projects.ProjectStep') -> STEP_DATA: """ Creates the data object that stores the step information in the notebook results JavaScript file. :param step: Project step for which to create the data :return: Step data tuple containing scaffold data structure for th...
[ "def", "create_data", "(", "step", ":", "'projects.ProjectStep'", ")", "->", "STEP_DATA", ":", "return", "STEP_DATA", "(", "name", "=", "step", ".", "definition", ".", "name", ",", "status", "=", "step", ".", "status", "(", ")", ",", "has_error", "=", "F...
Creates the data object that stores the step information in the notebook results JavaScript file. :param step: Project step for which to create the data :return: Step data tuple containing scaffold data structure for the step output. The dictionary must then be populated with data f...
[ "Creates", "the", "data", "object", "that", "stores", "the", "step", "information", "in", "the", "notebook", "results", "JavaScript", "file", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/writing/step.py#L23-L48
sernst/cauldron
cauldron/session/writing/step.py
get_cached_data
def get_cached_data( step: 'projects.ProjectStep' ) -> typing.Union[None, STEP_DATA]: """ Attempts to load and return the cached step data for the specified step. If not cached data exists, or the cached data is corrupt, a None value is returned instead. :param step: The step for wh...
python
def get_cached_data( step: 'projects.ProjectStep' ) -> typing.Union[None, STEP_DATA]: """ Attempts to load and return the cached step data for the specified step. If not cached data exists, or the cached data is corrupt, a None value is returned instead. :param step: The step for wh...
[ "def", "get_cached_data", "(", "step", ":", "'projects.ProjectStep'", ")", "->", "typing", ".", "Union", "[", "None", ",", "STEP_DATA", "]", ":", "cache_path", "=", "step", ".", "report", ".", "results_cache_path", "if", "not", "os", ".", "path", ".", "exi...
Attempts to load and return the cached step data for the specified step. If not cached data exists, or the cached data is corrupt, a None value is returned instead. :param step: The step for which the cached data should be loaded :return: Either a step data structure containing the cac...
[ "Attempts", "to", "load", "and", "return", "the", "cached", "step", "data", "for", "the", "specified", "step", ".", "If", "not", "cached", "data", "exists", "or", "the", "cached", "data", "is", "corrupt", "a", "None", "value", "is", "returned", "instead", ...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/writing/step.py#L51-L86
sernst/cauldron
cauldron/cli/batcher.py
initialize_logging_path
def initialize_logging_path(path: str = None) -> str: """ Initializes the logging path for running the project. If no logging path is specified, the current directory will be used instead. :param path: Path to initialize for logging. Can be either a path to a file or a path to a directo...
python
def initialize_logging_path(path: str = None) -> str: """ Initializes the logging path for running the project. If no logging path is specified, the current directory will be used instead. :param path: Path to initialize for logging. Can be either a path to a file or a path to a directo...
[ "def", "initialize_logging_path", "(", "path", ":", "str", "=", "None", ")", "->", "str", ":", "path", "=", "environ", ".", "paths", ".", "clean", "(", "path", "if", "path", "else", "'.'", ")", "if", "os", ".", "path", ".", "isdir", "(", "path", ")...
Initializes the logging path for running the project. If no logging path is specified, the current directory will be used instead. :param path: Path to initialize for logging. Can be either a path to a file or a path to a directory. If a directory is specified, the log file written will...
[ "Initializes", "the", "logging", "path", "for", "running", "the", "project", ".", "If", "no", "logging", "path", "is", "specified", "the", "current", "directory", "will", "be", "used", "instead", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/batcher.py#L16-L40
sernst/cauldron
cauldron/cli/batcher.py
run_project
def run_project( project_directory: str, output_directory: str = None, log_path: str = None, shared_data: dict = None, reader_path: str = None, reload_project_libraries: bool = False ) -> ExecutionResult: """ Opens, executes and closes a Cauldron project in a sing...
python
def run_project( project_directory: str, output_directory: str = None, log_path: str = None, shared_data: dict = None, reader_path: str = None, reload_project_libraries: bool = False ) -> ExecutionResult: """ Opens, executes and closes a Cauldron project in a sing...
[ "def", "run_project", "(", "project_directory", ":", "str", ",", "output_directory", ":", "str", "=", "None", ",", "log_path", ":", "str", "=", "None", ",", "shared_data", ":", "dict", "=", "None", ",", "reader_path", ":", "str", "=", "None", ",", "reloa...
Opens, executes and closes a Cauldron project in a single command in production mode (non-interactive). :param project_directory: Directory where the project to run is located :param output_directory: Directory where the project display data will be saved :param log_path: Path t...
[ "Opens", "executes", "and", "closes", "a", "Cauldron", "project", "in", "a", "single", "command", "in", "production", "mode", "(", "non", "-", "interactive", ")", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/batcher.py#L43-L147
seomoz/qless-py
qless/workers/forking.py
ForkingWorker.stop
def stop(self, sig=signal.SIGINT): '''Stop all the workers, and then wait for them''' for cpid in self.sandboxes: logger.warn('Stopping %i...' % cpid) try: os.kill(cpid, sig) except OSError: # pragma: no cover logger.exception('Error s...
python
def stop(self, sig=signal.SIGINT): '''Stop all the workers, and then wait for them''' for cpid in self.sandboxes: logger.warn('Stopping %i...' % cpid) try: os.kill(cpid, sig) except OSError: # pragma: no cover logger.exception('Error s...
[ "def", "stop", "(", "self", ",", "sig", "=", "signal", ".", "SIGINT", ")", ":", "for", "cpid", "in", "self", ".", "sandboxes", ":", "logger", ".", "warn", "(", "'Stopping %i...'", "%", "cpid", ")", "try", ":", "os", ".", "kill", "(", "cpid", ",", ...
Stop all the workers, and then wait for them
[ "Stop", "all", "the", "workers", "and", "then", "wait", "for", "them" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/workers/forking.py#L33-L52
seomoz/qless-py
qless/workers/forking.py
ForkingWorker.spawn
def spawn(self, **kwargs): '''Return a new worker for a child process''' copy = dict(self.kwargs) copy.update(kwargs) # Apparently there's an issue with importing gevent in the parent # process and then using it int he child. This is meant to relieve that # problem by all...
python
def spawn(self, **kwargs): '''Return a new worker for a child process''' copy = dict(self.kwargs) copy.update(kwargs) # Apparently there's an issue with importing gevent in the parent # process and then using it int he child. This is meant to relieve that # problem by all...
[ "def", "spawn", "(", "self", ",", "*", "*", "kwargs", ")", ":", "copy", "=", "dict", "(", "self", ".", "kwargs", ")", "copy", ".", "update", "(", "kwargs", ")", "# Apparently there's an issue with importing gevent in the parent", "# process and then using it int he ...
Return a new worker for a child process
[ "Return", "a", "new", "worker", "for", "a", "child", "process" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/workers/forking.py#L54-L63
seomoz/qless-py
qless/workers/forking.py
ForkingWorker.run
def run(self): '''Run this worker''' self.signals(('TERM', 'INT', 'QUIT')) # Divide up the jobs that we have to divy up between the workers. This # produces evenly-sized groups of jobs resume = self.divide(self.resume, self.count) for index in range(self.count): ...
python
def run(self): '''Run this worker''' self.signals(('TERM', 'INT', 'QUIT')) # Divide up the jobs that we have to divy up between the workers. This # produces evenly-sized groups of jobs resume = self.divide(self.resume, self.count) for index in range(self.count): ...
[ "def", "run", "(", "self", ")", ":", "self", ".", "signals", "(", "(", "'TERM'", ",", "'INT'", ",", "'QUIT'", ")", ")", "# Divide up the jobs that we have to divy up between the workers. This", "# produces evenly-sized groups of jobs", "resume", "=", "self", ".", "div...
Run this worker
[ "Run", "this", "worker" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/workers/forking.py#L65-L110
seomoz/qless-py
qless/workers/forking.py
ForkingWorker.handler
def handler(self, signum, frame): # pragma: no cover '''Signal handler for this process''' if signum in (signal.SIGTERM, signal.SIGINT, signal.SIGQUIT): self.stop(signum) os._exit(0)
python
def handler(self, signum, frame): # pragma: no cover '''Signal handler for this process''' if signum in (signal.SIGTERM, signal.SIGINT, signal.SIGQUIT): self.stop(signum) os._exit(0)
[ "def", "handler", "(", "self", ",", "signum", ",", "frame", ")", ":", "# pragma: no cover", "if", "signum", "in", "(", "signal", ".", "SIGTERM", ",", "signal", ".", "SIGINT", ",", "signal", ".", "SIGQUIT", ")", ":", "self", ".", "stop", "(", "signum", ...
Signal handler for this process
[ "Signal", "handler", "for", "this", "process" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/workers/forking.py#L112-L116
sernst/cauldron
cauldron/render/stack.py
get_stack_frames
def get_stack_frames(error_stack: bool = True) -> list: """ Returns a list of the current stack frames, which are pruned focus on the Cauldron code where the relevant information resides. """ cauldron_path = environ.paths.package() resources_path = environ.paths.resources() frames = ( ...
python
def get_stack_frames(error_stack: bool = True) -> list: """ Returns a list of the current stack frames, which are pruned focus on the Cauldron code where the relevant information resides. """ cauldron_path = environ.paths.package() resources_path = environ.paths.resources() frames = ( ...
[ "def", "get_stack_frames", "(", "error_stack", ":", "bool", "=", "True", ")", "->", "list", ":", "cauldron_path", "=", "environ", ".", "paths", ".", "package", "(", ")", "resources_path", "=", "environ", ".", "paths", ".", "resources", "(", ")", "frames", ...
Returns a list of the current stack frames, which are pruned focus on the Cauldron code where the relevant information resides.
[ "Returns", "a", "list", "of", "the", "current", "stack", "frames", "which", "are", "pruned", "focus", "on", "the", "Cauldron", "code", "where", "the", "relevant", "information", "resides", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/render/stack.py#L8-L34
sernst/cauldron
cauldron/render/stack.py
format_stack_frame
def format_stack_frame(stack_frame, project: 'projects.Project') -> dict: """ Formats a raw stack frame into a dictionary formatted for render templating and enriched with information from the currently open project. :param stack_frame: A raw stack frame to turn into an enriched version for te...
python
def format_stack_frame(stack_frame, project: 'projects.Project') -> dict: """ Formats a raw stack frame into a dictionary formatted for render templating and enriched with information from the currently open project. :param stack_frame: A raw stack frame to turn into an enriched version for te...
[ "def", "format_stack_frame", "(", "stack_frame", ",", "project", ":", "'projects.Project'", ")", "->", "dict", ":", "filename", "=", "stack_frame", ".", "filename", "if", "filename", ".", "startswith", "(", "project", ".", "source_directory", ")", ":", "filename...
Formats a raw stack frame into a dictionary formatted for render templating and enriched with information from the currently open project. :param stack_frame: A raw stack frame to turn into an enriched version for templating. :param project: The currently open project, which is used to con...
[ "Formats", "a", "raw", "stack", "frame", "into", "a", "dictionary", "formatted", "for", "render", "templating", "and", "enriched", "with", "information", "from", "the", "currently", "open", "project", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/render/stack.py#L37-L64
sernst/cauldron
cauldron/render/stack.py
get_formatted_stack_frame
def get_formatted_stack_frame( project: 'projects.Project', error_stack: bool = True ) -> list: """ Returns a list of the stack frames formatted for user display that has been enriched by the project-specific data. :param project: The currently open project used to enrich t...
python
def get_formatted_stack_frame( project: 'projects.Project', error_stack: bool = True ) -> list: """ Returns a list of the stack frames formatted for user display that has been enriched by the project-specific data. :param project: The currently open project used to enrich t...
[ "def", "get_formatted_stack_frame", "(", "project", ":", "'projects.Project'", ",", "error_stack", ":", "bool", "=", "True", ")", "->", "list", ":", "return", "[", "format_stack_frame", "(", "f", ",", "project", ")", "for", "f", "in", "get_stack_frames", "(", ...
Returns a list of the stack frames formatted for user display that has been enriched by the project-specific data. :param project: The currently open project used to enrich the stack data. :param error_stack: Whether or not to return the error stack. When True the stack of the ...
[ "Returns", "a", "list", "of", "the", "stack", "frames", "formatted", "for", "user", "display", "that", "has", "been", "enriched", "by", "the", "project", "-", "specific", "data", ".", ":", "param", "project", ":", "The", "currently", "open", "project", "us...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/render/stack.py#L67-L87
sernst/cauldron
cauldron/docgen/conversions.py
arg_type_to_string
def arg_type_to_string(arg_type) -> str: """ Converts the argument type to a string :param arg_type: :return: String representation of the argument type. Multiple return types are turned into a comma delimited list of type names """ union_params = ( getattr(arg_type, '_...
python
def arg_type_to_string(arg_type) -> str: """ Converts the argument type to a string :param arg_type: :return: String representation of the argument type. Multiple return types are turned into a comma delimited list of type names """ union_params = ( getattr(arg_type, '_...
[ "def", "arg_type_to_string", "(", "arg_type", ")", "->", "str", ":", "union_params", "=", "(", "getattr", "(", "arg_type", ",", "'__union_params__'", ",", "None", ")", "or", "getattr", "(", "arg_type", ",", "'__args__'", ",", "None", ")", ")", "if", "union...
Converts the argument type to a string :param arg_type: :return: String representation of the argument type. Multiple return types are turned into a comma delimited list of type names
[ "Converts", "the", "argument", "type", "to", "a", "string" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/docgen/conversions.py#L1-L22
sernst/cauldron
cauldron/session/writing/components/definitions.py
merge_components
def merge_components( *components: typing.List[typing.Union[list, tuple, COMPONENT]] ) -> COMPONENT: """ Merges multiple COMPONENT instances into a single one by merging the lists of includes and files. Has support for elements of the components arguments list to be lists or tuples of COMPONENT ...
python
def merge_components( *components: typing.List[typing.Union[list, tuple, COMPONENT]] ) -> COMPONENT: """ Merges multiple COMPONENT instances into a single one by merging the lists of includes and files. Has support for elements of the components arguments list to be lists or tuples of COMPONENT ...
[ "def", "merge_components", "(", "*", "components", ":", "typing", ".", "List", "[", "typing", ".", "Union", "[", "list", ",", "tuple", ",", "COMPONENT", "]", "]", ")", "->", "COMPONENT", ":", "flat_components", "=", "functools", ".", "reduce", "(", "flat...
Merges multiple COMPONENT instances into a single one by merging the lists of includes and files. Has support for elements of the components arguments list to be lists or tuples of COMPONENT instances as well. :param components: :return:
[ "Merges", "multiple", "COMPONENT", "instances", "into", "a", "single", "one", "by", "merging", "the", "lists", "of", "includes", "and", "files", ".", "Has", "support", "for", "elements", "of", "the", "components", "arguments", "list", "to", "be", "lists", "o...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/writing/components/definitions.py#L9-L33
sernst/cauldron
cauldron/session/writing/components/definitions.py
flatten_reducer
def flatten_reducer( flattened_list: list, entry: typing.Union[list, tuple, COMPONENT] ) -> list: """ Flattens a list of COMPONENT instances to remove any lists or tuples of COMPONENTS contained within the list :param flattened_list: The existing flattened list that has been pop...
python
def flatten_reducer( flattened_list: list, entry: typing.Union[list, tuple, COMPONENT] ) -> list: """ Flattens a list of COMPONENT instances to remove any lists or tuples of COMPONENTS contained within the list :param flattened_list: The existing flattened list that has been pop...
[ "def", "flatten_reducer", "(", "flattened_list", ":", "list", ",", "entry", ":", "typing", ".", "Union", "[", "list", ",", "tuple", ",", "COMPONENT", "]", ")", "->", "list", ":", "if", "hasattr", "(", "entry", ",", "'includes'", ")", "and", "hasattr", ...
Flattens a list of COMPONENT instances to remove any lists or tuples of COMPONENTS contained within the list :param flattened_list: The existing flattened list that has been populated from previous calls of this reducer function :param entry: An entry to be reduced. Either a COMPONE...
[ "Flattens", "a", "list", "of", "COMPONENT", "instances", "to", "remove", "any", "lists", "or", "tuples", "of", "COMPONENTS", "contained", "within", "the", "list" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/writing/components/definitions.py#L36-L58
sernst/cauldron
cauldron/session/writing/components/definitions.py
combine_lists_reducer
def combine_lists_reducer( key: str, merged_list: list, component: COMPONENT ) -> list: """ Reducer function to combine the lists for the specified key into a single, flat list :param key: The key on the COMPONENT instances to operate upon :param merged_list: ...
python
def combine_lists_reducer( key: str, merged_list: list, component: COMPONENT ) -> list: """ Reducer function to combine the lists for the specified key into a single, flat list :param key: The key on the COMPONENT instances to operate upon :param merged_list: ...
[ "def", "combine_lists_reducer", "(", "key", ":", "str", ",", "merged_list", ":", "list", ",", "component", ":", "COMPONENT", ")", "->", "list", ":", "merged_list", ".", "extend", "(", "getattr", "(", "component", ",", "key", ")", ")", "return", "merged_lis...
Reducer function to combine the lists for the specified key into a single, flat list :param key: The key on the COMPONENT instances to operate upon :param merged_list: The accumulated list of values populated by previous calls to this reducer function :param component: T...
[ "Reducer", "function", "to", "combine", "the", "lists", "for", "the", "specified", "key", "into", "a", "single", "flat", "list" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/writing/components/definitions.py#L61-L84
seomoz/qless-py
qless/listener.py
Listener.listen
def listen(self): '''Listen for events as they come in''' try: self._pubsub.subscribe(self._channels) for message in self._pubsub.listen(): if message['type'] == 'message': yield message finally: self._channels = []
python
def listen(self): '''Listen for events as they come in''' try: self._pubsub.subscribe(self._channels) for message in self._pubsub.listen(): if message['type'] == 'message': yield message finally: self._channels = []
[ "def", "listen", "(", "self", ")", ":", "try", ":", "self", ".", "_pubsub", ".", "subscribe", "(", "self", ".", "_channels", ")", "for", "message", "in", "self", ".", "_pubsub", ".", "listen", "(", ")", ":", "if", "message", "[", "'type'", "]", "==...
Listen for events as they come in
[ "Listen", "for", "events", "as", "they", "come", "in" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/listener.py#L17-L25
seomoz/qless-py
qless/listener.py
Listener.thread
def thread(self): '''Run in a thread''' thread = threading.Thread(target=self.listen) thread.start() try: yield self finally: self.unlisten() thread.join()
python
def thread(self): '''Run in a thread''' thread = threading.Thread(target=self.listen) thread.start() try: yield self finally: self.unlisten() thread.join()
[ "def", "thread", "(", "self", ")", ":", "thread", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "listen", ")", "thread", ".", "start", "(", ")", "try", ":", "yield", "self", "finally", ":", "self", ".", "unlisten", "(", ")", "th...
Run in a thread
[ "Run", "in", "a", "thread" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/listener.py#L32-L40
seomoz/qless-py
qless/listener.py
Events.listen
def listen(self): '''Listen for events''' for message in Listener.listen(self): logger.debug('Message: %s', message) # Strip off the 'namespace' from the channel channel = message['channel'][len(self.namespace):] func = self._callbacks.get(channel) ...
python
def listen(self): '''Listen for events''' for message in Listener.listen(self): logger.debug('Message: %s', message) # Strip off the 'namespace' from the channel channel = message['channel'][len(self.namespace):] func = self._callbacks.get(channel) ...
[ "def", "listen", "(", "self", ")", ":", "for", "message", "in", "Listener", ".", "listen", "(", "self", ")", ":", "logger", ".", "debug", "(", "'Message: %s'", ",", "message", ")", "# Strip off the 'namespace' from the channel", "channel", "=", "message", "[",...
Listen for events
[ "Listen", "for", "events" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/listener.py#L56-L64
seomoz/qless-py
qless/listener.py
Events.on
def on(self, evt, func): '''Set a callback handler for a pubsub event''' if evt not in self._callbacks: raise NotImplementedError('callback "%s"' % evt) else: self._callbacks[evt] = func
python
def on(self, evt, func): '''Set a callback handler for a pubsub event''' if evt not in self._callbacks: raise NotImplementedError('callback "%s"' % evt) else: self._callbacks[evt] = func
[ "def", "on", "(", "self", ",", "evt", ",", "func", ")", ":", "if", "evt", "not", "in", "self", ".", "_callbacks", ":", "raise", "NotImplementedError", "(", "'callback \"%s\"'", "%", "evt", ")", "else", ":", "self", ".", "_callbacks", "[", "evt", "]", ...
Set a callback handler for a pubsub event
[ "Set", "a", "callback", "handler", "for", "a", "pubsub", "event" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/listener.py#L66-L71
seomoz/qless-py
qless/config.py
Config.get
def get(self, option, default=None): '''Get a particular option, or the default if it's missing''' val = self[option] return (val is None and default) or val
python
def get(self, option, default=None): '''Get a particular option, or the default if it's missing''' val = self[option] return (val is None and default) or val
[ "def", "get", "(", "self", ",", "option", ",", "default", "=", "None", ")", ":", "val", "=", "self", "[", "option", "]", "return", "(", "val", "is", "None", "and", "default", ")", "or", "val" ]
Get a particular option, or the default if it's missing
[ "Get", "a", "particular", "option", "or", "the", "default", "if", "it", "s", "missing" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/config.py#L45-L48
seomoz/qless-py
qless/config.py
Config.pop
def pop(self, option, default=None): '''Just like `dict.pop`''' val = self[option] del self[option] return (val is None and default) or val
python
def pop(self, option, default=None): '''Just like `dict.pop`''' val = self[option] del self[option] return (val is None and default) or val
[ "def", "pop", "(", "self", ",", "option", ",", "default", "=", "None", ")", ":", "val", "=", "self", "[", "option", "]", "del", "self", "[", "option", "]", "return", "(", "val", "is", "None", "and", "default", ")", "or", "val" ]
Just like `dict.pop`
[ "Just", "like", "dict", ".", "pop" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/config.py#L58-L62
seomoz/qless-py
qless/config.py
Config.update
def update(self, other=(), **kwargs): '''Just like `dict.update`''' _kwargs = dict(kwargs) _kwargs.update(other) for key, value in _kwargs.items(): self[key] = value
python
def update(self, other=(), **kwargs): '''Just like `dict.update`''' _kwargs = dict(kwargs) _kwargs.update(other) for key, value in _kwargs.items(): self[key] = value
[ "def", "update", "(", "self", ",", "other", "=", "(", ")", ",", "*", "*", "kwargs", ")", ":", "_kwargs", "=", "dict", "(", "kwargs", ")", "_kwargs", ".", "update", "(", "other", ")", "for", "key", ",", "value", "in", "_kwargs", ".", "items", "(",...
Just like `dict.update`
[ "Just", "like", "dict", ".", "update" ]
train
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/config.py#L64-L69