partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
MetricsSet.counter
Returns an existing or creates and returns a new counter :param name: name of the counter :return: the counter object
elasticapm/metrics/base_metrics.py
def counter(self, name): """ Returns an existing or creates and returns a new counter :param name: name of the counter :return: the counter object """ with self._lock: if name not in self._counters: if self._registry._ignore_patterns and any( ...
def counter(self, name): """ Returns an existing or creates and returns a new counter :param name: name of the counter :return: the counter object """ with self._lock: if name not in self._counters: if self._registry._ignore_patterns and any( ...
[ "Returns", "an", "existing", "or", "creates", "and", "returns", "a", "new", "counter", ":", "param", "name", ":", "name", "of", "the", "counter", ":", "return", ":", "the", "counter", "object" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/metrics/base_metrics.py#L111-L126
[ "def", "counter", "(", "self", ",", "name", ")", ":", "with", "self", ".", "_lock", ":", "if", "name", "not", "in", "self", ".", "_counters", ":", "if", "self", ".", "_registry", ".", "_ignore_patterns", "and", "any", "(", "pattern", ".", "match", "(...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
MetricsSet.gauge
Returns an existing or creates and returns a new gauge :param name: name of the gauge :return: the gauge object
elasticapm/metrics/base_metrics.py
def gauge(self, name): """ Returns an existing or creates and returns a new gauge :param name: name of the gauge :return: the gauge object """ with self._lock: if name not in self._gauges: if self._registry._ignore_patterns and any( ...
def gauge(self, name): """ Returns an existing or creates and returns a new gauge :param name: name of the gauge :return: the gauge object """ with self._lock: if name not in self._gauges: if self._registry._ignore_patterns and any( ...
[ "Returns", "an", "existing", "or", "creates", "and", "returns", "a", "new", "gauge", ":", "param", "name", ":", "name", "of", "the", "gauge", ":", "return", ":", "the", "gauge", "object" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/metrics/base_metrics.py#L128-L143
[ "def", "gauge", "(", "self", ",", "name", ")", ":", "with", "self", ".", "_lock", ":", "if", "name", "not", "in", "self", ".", "_gauges", ":", "if", "self", ".", "_registry", ".", "_ignore_patterns", "and", "any", "(", "pattern", ".", "match", "(", ...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
MetricsSet.collect
Collects all metrics attached to this metricset, and returns it as a list, together with a timestamp in microsecond precision. The format of the return value should be { "samples": {"metric.name": {"value": some_float}, ...}, "timestamp": unix epoch in micro...
elasticapm/metrics/base_metrics.py
def collect(self): """ Collects all metrics attached to this metricset, and returns it as a list, together with a timestamp in microsecond precision. The format of the return value should be { "samples": {"metric.name": {"value": some_float}, ...}, ...
def collect(self): """ Collects all metrics attached to this metricset, and returns it as a list, together with a timestamp in microsecond precision. The format of the return value should be { "samples": {"metric.name": {"value": some_float}, ...}, ...
[ "Collects", "all", "metrics", "attached", "to", "this", "metricset", "and", "returns", "it", "as", "a", "list", "together", "with", "a", "timestamp", "in", "microsecond", "precision", "." ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/metrics/base_metrics.py#L145-L167
[ "def", "collect", "(", "self", ")", ":", "samples", "=", "{", "}", "if", "self", ".", "_counters", ":", "samples", ".", "update", "(", "{", "label", ":", "{", "\"value\"", ":", "c", ".", "val", "}", "for", "label", ",", "c", "in", "compat", ".", ...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
tag
Tags current transaction. Both key and value of the tag should be strings.
elasticapm/traces.py
def tag(**tags): """ Tags current transaction. Both key and value of the tag should be strings. """ transaction = execution_context.get_transaction() if not transaction: error_logger.warning("Ignored tags %s. No transaction currently active.", ", ".join(tags.keys())) else: transa...
def tag(**tags): """ Tags current transaction. Both key and value of the tag should be strings. """ transaction = execution_context.get_transaction() if not transaction: error_logger.warning("Ignored tags %s. No transaction currently active.", ", ".join(tags.keys())) else: transa...
[ "Tags", "current", "transaction", ".", "Both", "key", "and", "value", "of", "the", "tag", "should", "be", "strings", "." ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/traces.py#L367-L375
[ "def", "tag", "(", "*", "*", "tags", ")", ":", "transaction", "=", "execution_context", ".", "get_transaction", "(", ")", "if", "not", "transaction", ":", "error_logger", ".", "warning", "(", "\"Ignored tags %s. No transaction currently active.\"", ",", "\", \"", ...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
Transaction.begin_span
Begin a new span :param name: name of the span :param span_type: type of the span :param context: a context dict :param leaf: True if this is a leaf span :param tags: a flat string/string dict of tags :return: the Span object
elasticapm/traces.py
def begin_span(self, name, span_type, context=None, leaf=False, tags=None): """ Begin a new span :param name: name of the span :param span_type: type of the span :param context: a context dict :param leaf: True if this is a leaf span :param tags: a flat string/str...
def begin_span(self, name, span_type, context=None, leaf=False, tags=None): """ Begin a new span :param name: name of the span :param span_type: type of the span :param context: a context dict :param leaf: True if this is a leaf span :param tags: a flat string/str...
[ "Begin", "a", "new", "span", ":", "param", "name", ":", "name", "of", "the", "span", ":", "param", "span_type", ":", "type", "of", "the", "span", ":", "param", "context", ":", "a", "context", "dict", ":", "param", "leaf", ":", "True", "if", "this", ...
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/traces.py#L104-L114
[ "def", "begin_span", "(", "self", ",", "name", ",", "span_type", ",", "context", "=", "None", ",", "leaf", "=", "False", ",", "tags", "=", "None", ")", ":", "return", "self", ".", "_begin_span", "(", "name", ",", "span_type", ",", "context", "=", "co...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
Transaction.ensure_parent_id
If current trace_parent has no span_id, generate one, then return it This is used to generate a span ID which the RUM agent will use to correlate the RUM transaction with the backend transaction.
elasticapm/traces.py
def ensure_parent_id(self): """If current trace_parent has no span_id, generate one, then return it This is used to generate a span ID which the RUM agent will use to correlate the RUM transaction with the backend transaction. """ if self.trace_parent.span_id == self.id: ...
def ensure_parent_id(self): """If current trace_parent has no span_id, generate one, then return it This is used to generate a span ID which the RUM agent will use to correlate the RUM transaction with the backend transaction. """ if self.trace_parent.span_id == self.id: ...
[ "If", "current", "trace_parent", "has", "no", "span_id", "generate", "one", "then", "return", "it" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/traces.py#L134-L143
[ "def", "ensure_parent_id", "(", "self", ")", ":", "if", "self", ".", "trace_parent", ".", "span_id", "==", "self", ".", "id", ":", "self", ".", "trace_parent", ".", "span_id", "=", "\"%016x\"", "%", "random", ".", "getrandbits", "(", "64", ")", "logger",...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
Transaction.tag
Tag this transaction with one or multiple key/value tags. Both the values should be strings transaction_obj.tag(key1="value1", key2="value2") Note that keys will be dedotted, replacing dot (.), star (*) and double quote (") with an underscore (_)
elasticapm/traces.py
def tag(self, **tags): """ Tag this transaction with one or multiple key/value tags. Both the values should be strings transaction_obj.tag(key1="value1", key2="value2") Note that keys will be dedotted, replacing dot (.), star (*) and double quote (") with an underscore (_) ...
def tag(self, **tags): """ Tag this transaction with one or multiple key/value tags. Both the values should be strings transaction_obj.tag(key1="value1", key2="value2") Note that keys will be dedotted, replacing dot (.), star (*) and double quote (") with an underscore (_) ...
[ "Tag", "this", "transaction", "with", "one", "or", "multiple", "key", "/", "value", "tags", ".", "Both", "the", "values", "should", "be", "strings" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/traces.py#L145-L154
[ "def", "tag", "(", "self", ",", "*", "*", "tags", ")", ":", "for", "key", "in", "tags", ".", "keys", "(", ")", ":", "self", ".", "tags", "[", "TAG_RE", ".", "sub", "(", "\"_\"", ",", "compat", ".", "text_type", "(", "key", ")", ")", "]", "=",...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
Tracer.begin_transaction
Start a new transactions and bind it in a thread-local variable :returns the Transaction object
elasticapm/traces.py
def begin_transaction(self, transaction_type, trace_parent=None): """ Start a new transactions and bind it in a thread-local variable :returns the Transaction object """ if trace_parent: is_sampled = bool(trace_parent.trace_options.recorded) else: ...
def begin_transaction(self, transaction_type, trace_parent=None): """ Start a new transactions and bind it in a thread-local variable :returns the Transaction object """ if trace_parent: is_sampled = bool(trace_parent.trace_options.recorded) else: ...
[ "Start", "a", "new", "transactions", "and", "bind", "it", "in", "a", "thread", "-", "local", "variable" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/traces.py#L293-L312
[ "def", "begin_transaction", "(", "self", ",", "transaction_type", ",", "trace_parent", "=", "None", ")", ":", "if", "trace_parent", ":", "is_sampled", "=", "bool", "(", "trace_parent", ".", "trace_options", ".", "recorded", ")", "else", ":", "is_sampled", "=",...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
Command.handle_check
Check your settings for common misconfigurations
elasticapm/contrib/django/management/commands/elasticapm.py
def handle_check(self, command, **options): """Check your settings for common misconfigurations""" passed = True client = DjangoClient(metrics_interval="0ms") def is_set(x): return x and x != "None" # check if org/app is set: if is_set(client.config.service_...
def handle_check(self, command, **options): """Check your settings for common misconfigurations""" passed = True client = DjangoClient(metrics_interval="0ms") def is_set(x): return x and x != "None" # check if org/app is set: if is_set(client.config.service_...
[ "Check", "your", "settings", "for", "common", "misconfigurations" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/contrib/django/management/commands/elasticapm.py#L161-L283
[ "def", "handle_check", "(", "self", ",", "command", ",", "*", "*", "options", ")", ":", "passed", "=", "True", "client", "=", "DjangoClient", "(", "metrics_interval", "=", "\"0ms\"", ")", "def", "is_set", "(", "x", ")", ":", "return", "x", "and", "x", ...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
Command.write
wrapper around self.stdout/stderr to ensure Django 1.4 compatibility
elasticapm/contrib/django/management/commands/elasticapm.py
def write(self, msg, style_func=None, ending=None, stream=None): """ wrapper around self.stdout/stderr to ensure Django 1.4 compatibility """ if stream is None: stream = self.stdout if OutputWrapper is None: ending = "\n" if ending is None else ending ...
def write(self, msg, style_func=None, ending=None, stream=None): """ wrapper around self.stdout/stderr to ensure Django 1.4 compatibility """ if stream is None: stream = self.stdout if OutputWrapper is None: ending = "\n" if ending is None else ending ...
[ "wrapper", "around", "self", ".", "stdout", "/", "stderr", "to", "ensure", "Django", "1", ".", "4", "compatibility" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/contrib/django/management/commands/elasticapm.py#L293-L304
[ "def", "write", "(", "self", ",", "msg", ",", "style_func", "=", "None", ",", "ending", "=", "None", ",", "stream", "=", "None", ")", ":", "if", "stream", "is", "None", ":", "stream", "=", "self", ".", "stdout", "if", "OutputWrapper", "is", "None", ...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
Middleware.server_inspect_exception
Called when an exception has been raised in the code run by ZeroRPC
elasticapm/contrib/zerorpc/__init__.py
def server_inspect_exception(self, req_event, rep_event, task_ctx, exc_info): """Called when an exception has been raised in the code run by ZeroRPC""" # Hide the zerorpc internal frames for readability, for a REQ/REP or # REQ/STREAM server the frames to hide are: # - core.ServerBase._a...
def server_inspect_exception(self, req_event, rep_event, task_ctx, exc_info): """Called when an exception has been raised in the code run by ZeroRPC""" # Hide the zerorpc internal frames for readability, for a REQ/REP or # REQ/STREAM server the frames to hide are: # - core.ServerBase._a...
[ "Called", "when", "an", "exception", "has", "been", "raised", "in", "the", "code", "run", "by", "ZeroRPC" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/contrib/zerorpc/__init__.py#L60-L84
[ "def", "server_inspect_exception", "(", "self", ",", "req_event", ",", "rep_event", ",", "task_ctx", ",", "exc_info", ")", ":", "# Hide the zerorpc internal frames for readability, for a REQ/REP or", "# REQ/STREAM server the frames to hide are:", "# - core.ServerBase._async_task", ...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
AbstractInstrumentedModule.mutate_unsampled_call_args
Method called for unsampled wrapped calls. This can e.g. be used to add traceparent headers to the underlying http call for HTTP instrumentations. :param module: :param method: :param wrapped: :param instance: :param args: :param kwargs: :param transactio...
elasticapm/instrumentation/packages/base.py
def mutate_unsampled_call_args(self, module, method, wrapped, instance, args, kwargs, transaction): """ Method called for unsampled wrapped calls. This can e.g. be used to add traceparent headers to the underlying http call for HTTP instrumentations. :param module: :param method...
def mutate_unsampled_call_args(self, module, method, wrapped, instance, args, kwargs, transaction): """ Method called for unsampled wrapped calls. This can e.g. be used to add traceparent headers to the underlying http call for HTTP instrumentations. :param module: :param method...
[ "Method", "called", "for", "unsampled", "wrapped", "calls", ".", "This", "can", "e", ".", "g", ".", "be", "used", "to", "add", "traceparent", "headers", "to", "the", "underlying", "http", "call", "for", "HTTP", "instrumentations", "." ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/instrumentation/packages/base.py#L143-L157
[ "def", "mutate_unsampled_call_args", "(", "self", ",", "module", ",", "method", ",", "wrapped", ",", "instance", ",", "args", ",", "kwargs", ",", "transaction", ")", ":", "return", "args", ",", "kwargs" ]
2975663d7bd22282dc39336b2c37b37c12c7a774
train
instrument
Auto-instruments code to get nice spans
elasticapm/contrib/django/apps.py
def instrument(client): """ Auto-instruments code to get nice spans """ from elasticapm.instrumentation.control import instrument instrument() try: import celery # noqa F401 from elasticapm.contrib.celery import register_instrumentation register_instrumentation(client)...
def instrument(client): """ Auto-instruments code to get nice spans """ from elasticapm.instrumentation.control import instrument instrument() try: import celery # noqa F401 from elasticapm.contrib.celery import register_instrumentation register_instrumentation(client)...
[ "Auto", "-", "instruments", "code", "to", "get", "nice", "spans" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/contrib/django/apps.py#L119-L132
[ "def", "instrument", "(", "client", ")", ":", "from", "elasticapm", ".", "instrumentation", ".", "control", "import", "instrument", "instrument", "(", ")", "try", ":", "import", "celery", "# noqa F401", "from", "elasticapm", ".", "contrib", ".", "celery", "imp...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
setup_logging
Configures logging to pipe to Elastic APM. - ``exclude`` is a list of loggers that shouldn't go to ElasticAPM. For a typical Python install: >>> from elasticapm.handlers.logging import LoggingHandler >>> client = ElasticAPM(...) >>> setup_logging(LoggingHandler(client)) Within Django: >...
elasticapm/conf/__init__.py
def setup_logging(handler, exclude=("gunicorn", "south", "elasticapm.errors")): """ Configures logging to pipe to Elastic APM. - ``exclude`` is a list of loggers that shouldn't go to ElasticAPM. For a typical Python install: >>> from elasticapm.handlers.logging import LoggingHandler >>> clien...
def setup_logging(handler, exclude=("gunicorn", "south", "elasticapm.errors")): """ Configures logging to pipe to Elastic APM. - ``exclude`` is a list of loggers that shouldn't go to ElasticAPM. For a typical Python install: >>> from elasticapm.handlers.logging import LoggingHandler >>> clien...
[ "Configures", "logging", "to", "pipe", "to", "Elastic", "APM", "." ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/conf/__init__.py#L292-L317
[ "def", "setup_logging", "(", "handler", ",", "exclude", "=", "(", "\"gunicorn\"", ",", "\"south\"", ",", "\"elasticapm.errors\"", ")", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", ")", "if", "handler", ".", "__class__", "in", "map", "(", "typ...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
register_elasticapm
Given an ElasticAPM client and an RQ worker, registers exception handlers with the worker so exceptions are logged to the apm server. E.g.: from elasticapm.contrib.django.models import client from elasticapm.contrib.rq import register_elasticapm worker = Worker(map(Queue, listen)) register_el...
elasticapm/contrib/rq/__init__.py
def register_elasticapm(client, worker): """Given an ElasticAPM client and an RQ worker, registers exception handlers with the worker so exceptions are logged to the apm server. E.g.: from elasticapm.contrib.django.models import client from elasticapm.contrib.rq import register_elasticapm wor...
def register_elasticapm(client, worker): """Given an ElasticAPM client and an RQ worker, registers exception handlers with the worker so exceptions are logged to the apm server. E.g.: from elasticapm.contrib.django.models import client from elasticapm.contrib.rq import register_elasticapm wor...
[ "Given", "an", "ElasticAPM", "client", "and", "an", "RQ", "worker", "registers", "exception", "handlers", "with", "the", "worker", "so", "exceptions", "are", "logged", "to", "the", "apm", "server", "." ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/contrib/rq/__init__.py#L32-L59
[ "def", "register_elasticapm", "(", "client", ",", "worker", ")", ":", "def", "send_to_server", "(", "job", ",", "*", "exc_info", ")", ":", "client", ".", "capture_exception", "(", "exc_info", "=", "exc_info", ",", "extra", "=", "{", "\"job_id\"", ":", "job...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
ThreadLocalContext.get_transaction
Get the transaction registered for the current thread. :return: :rtype: Transaction
elasticapm/context/threadlocal.py
def get_transaction(self, clear=False): """ Get the transaction registered for the current thread. :return: :rtype: Transaction """ transaction = getattr(self.thread_local, "transaction", None) if clear: self.thread_local.transaction = None re...
def get_transaction(self, clear=False): """ Get the transaction registered for the current thread. :return: :rtype: Transaction """ transaction = getattr(self.thread_local, "transaction", None) if clear: self.thread_local.transaction = None re...
[ "Get", "the", "transaction", "registered", "for", "the", "current", "thread", "." ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/context/threadlocal.py#L42-L52
[ "def", "get_transaction", "(", "self", ",", "clear", "=", "False", ")", ":", "transaction", "=", "getattr", "(", "self", ".", "thread_local", ",", "\"transaction\"", ",", "None", ")", "if", "clear", ":", "self", ".", "thread_local", ".", "transaction", "="...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
get_lines_from_file
Returns context_lines before and after lineno from file. Returns (pre_context_lineno, pre_context, context_line, post_context).
elasticapm/utils/stacks.py
def get_lines_from_file(filename, lineno, context_lines, loader=None, module_name=None): """ Returns context_lines before and after lineno from file. Returns (pre_context_lineno, pre_context, context_line, post_context). """ lineno = lineno - 1 lower_bound = max(0, lineno - context_lines) up...
def get_lines_from_file(filename, lineno, context_lines, loader=None, module_name=None): """ Returns context_lines before and after lineno from file. Returns (pre_context_lineno, pre_context, context_line, post_context). """ lineno = lineno - 1 lower_bound = max(0, lineno - context_lines) up...
[ "Returns", "context_lines", "before", "and", "after", "lineno", "from", "file", ".", "Returns", "(", "pre_context_lineno", "pre_context", "context_line", "post_context", ")", "." ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/utils/stacks.py#L52-L91
[ "def", "get_lines_from_file", "(", "filename", ",", "lineno", ",", "context_lines", ",", "loader", "=", "None", ",", "module_name", "=", "None", ")", ":", "lineno", "=", "lineno", "-", "1", "lower_bound", "=", "max", "(", "0", ",", "lineno", "-", "contex...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
iter_traceback_frames
Given a traceback object, it will iterate over all frames that do not contain the ``__traceback_hide__`` local variable.
elasticapm/utils/stacks.py
def iter_traceback_frames(tb): """ Given a traceback object, it will iterate over all frames that do not contain the ``__traceback_hide__`` local variable. """ while tb: # support for __traceback_hide__ which is used by a few libraries # to hide internal frames. frame = t...
def iter_traceback_frames(tb): """ Given a traceback object, it will iterate over all frames that do not contain the ``__traceback_hide__`` local variable. """ while tb: # support for __traceback_hide__ which is used by a few libraries # to hide internal frames. frame = t...
[ "Given", "a", "traceback", "object", "it", "will", "iterate", "over", "all", "frames", "that", "do", "not", "contain", "the", "__traceback_hide__", "local", "variable", "." ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/utils/stacks.py#L166-L179
[ "def", "iter_traceback_frames", "(", "tb", ")", ":", "while", "tb", ":", "# support for __traceback_hide__ which is used by a few libraries", "# to hide internal frames.", "frame", "=", "tb", ".", "tb_frame", "f_locals", "=", "getattr", "(", "frame", ",", "\"f_locals\"", ...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
iter_stack_frames
Given an optional list of frames (defaults to current stack), iterates over all frames that do not contain the ``__traceback_hide__`` local variable. Frames can be skipped by either providing a number, or a tuple of module names. If the module of a frame matches one of the names (using `.startswith...
elasticapm/utils/stacks.py
def iter_stack_frames(frames=None, start_frame=None, skip=0, skip_top_modules=()): """ Given an optional list of frames (defaults to current stack), iterates over all frames that do not contain the ``__traceback_hide__`` local variable. Frames can be skipped by either providing a number, or a tuple...
def iter_stack_frames(frames=None, start_frame=None, skip=0, skip_top_modules=()): """ Given an optional list of frames (defaults to current stack), iterates over all frames that do not contain the ``__traceback_hide__`` local variable. Frames can be skipped by either providing a number, or a tuple...
[ "Given", "an", "optional", "list", "of", "frames", "(", "defaults", "to", "current", "stack", ")", "iterates", "over", "all", "frames", "that", "do", "not", "contain", "the", "__traceback_hide__", "local", "variable", "." ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/utils/stacks.py#L182-L215
[ "def", "iter_stack_frames", "(", "frames", "=", "None", ",", "start_frame", "=", "None", ",", "skip", "=", "0", ",", "skip_top_modules", "=", "(", ")", ")", ":", "if", "not", "frames", ":", "frame", "=", "start_frame", "if", "start_frame", "is", "not", ...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
get_stack_info
Given a list of frames, returns a list of stack information dictionary objects that are JSON-ready. We have to be careful here as certain implementations of the _Frame class do not contain the necessary data to lookup all of the information we want. :param frames: a list of (Frame, lineno) tuples ...
elasticapm/utils/stacks.py
def get_stack_info( frames, with_locals=True, library_frame_context_lines=None, in_app_frame_context_lines=None, include_paths_re=None, exclude_paths_re=None, locals_processor_func=None, ): """ Given a list of frames, returns a list of stack information dictionary objects that ar...
def get_stack_info( frames, with_locals=True, library_frame_context_lines=None, in_app_frame_context_lines=None, include_paths_re=None, exclude_paths_re=None, locals_processor_func=None, ): """ Given a list of frames, returns a list of stack information dictionary objects that ar...
[ "Given", "a", "list", "of", "frames", "returns", "a", "list", "of", "stack", "information", "dictionary", "objects", "that", "are", "JSON", "-", "ready", "." ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/utils/stacks.py#L290-L328
[ "def", "get_stack_info", "(", "frames", ",", "with_locals", "=", "True", ",", "library_frame_context_lines", "=", "None", ",", "in_app_frame_context_lines", "=", "None", ",", "include_paths_re", "=", "None", ",", "exclude_paths_re", "=", "None", ",", "locals_process...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
atexit_register
Uses either uwsgi's atexit mechanism, or atexit from the stdlib. When running under uwsgi, using their atexit handler is more reliable, especially when using gevent :param func: the function to call at exit
elasticapm/utils/compat.py
def atexit_register(func): """ Uses either uwsgi's atexit mechanism, or atexit from the stdlib. When running under uwsgi, using their atexit handler is more reliable, especially when using gevent :param func: the function to call at exit """ try: import uwsgi orig = getattr...
def atexit_register(func): """ Uses either uwsgi's atexit mechanism, or atexit from the stdlib. When running under uwsgi, using their atexit handler is more reliable, especially when using gevent :param func: the function to call at exit """ try: import uwsgi orig = getattr...
[ "Uses", "either", "uwsgi", "s", "atexit", "mechanism", "or", "atexit", "from", "the", "stdlib", "." ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/utils/compat.py#L49-L69
[ "def", "atexit_register", "(", "func", ")", ":", "try", ":", "import", "uwsgi", "orig", "=", "getattr", "(", "uwsgi", ",", "\"atexit\"", ",", "None", ")", "def", "uwsgi_atexit", "(", ")", ":", "if", "callable", "(", "orig", ")", ":", "orig", "(", ")"...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
get_default_library_patters
Returns library paths depending on the used platform. :return: a list of glob paths
elasticapm/utils/compat.py
def get_default_library_patters(): """ Returns library paths depending on the used platform. :return: a list of glob paths """ python_version = platform.python_version_tuple() python_implementation = platform.python_implementation() system = platform.system() if python_implementation ==...
def get_default_library_patters(): """ Returns library paths depending on the used platform. :return: a list of glob paths """ python_version = platform.python_version_tuple() python_implementation = platform.python_implementation() system = platform.system() if python_implementation ==...
[ "Returns", "library", "paths", "depending", "on", "the", "used", "platform", "." ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/utils/compat.py#L142-L159
[ "def", "get_default_library_patters", "(", ")", ":", "python_version", "=", "platform", ".", "python_version_tuple", "(", ")", "python_implementation", "=", "platform", ".", "python_implementation", "(", ")", "system", "=", "platform", ".", "system", "(", ")", "if...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
multidict_to_dict
Turns a werkzeug.MultiDict or django.MultiValueDict into a dict with list values :param d: a MultiDict or MultiValueDict instance :return: a dict instance
elasticapm/utils/compat.py
def multidict_to_dict(d): """ Turns a werkzeug.MultiDict or django.MultiValueDict into a dict with list values :param d: a MultiDict or MultiValueDict instance :return: a dict instance """ return dict((k, v[0] if len(v) == 1 else v) for k, v in iterlists(d))
def multidict_to_dict(d): """ Turns a werkzeug.MultiDict or django.MultiValueDict into a dict with list values :param d: a MultiDict or MultiValueDict instance :return: a dict instance """ return dict((k, v[0] if len(v) == 1 else v) for k, v in iterlists(d))
[ "Turns", "a", "werkzeug", ".", "MultiDict", "or", "django", ".", "MultiValueDict", "into", "a", "dict", "with", "list", "values", ":", "param", "d", ":", "a", "MultiDict", "or", "MultiValueDict", "instance", ":", "return", ":", "a", "dict", "instance" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/utils/compat.py#L162-L169
[ "def", "multidict_to_dict", "(", "d", ")", ":", "return", "dict", "(", "(", "k", ",", "v", "[", "0", "]", "if", "len", "(", "v", ")", "==", "1", "else", "v", ")", "for", "k", ",", "v", "in", "iterlists", "(", "d", ")", ")" ]
2975663d7bd22282dc39336b2c37b37c12c7a774
train
_is_ignorable_404
Returns True if the given request *shouldn't* notify the site managers.
elasticapm/contrib/django/middleware/__init__.py
def _is_ignorable_404(uri): """ Returns True if the given request *shouldn't* notify the site managers. """ urls = getattr(django_settings, "IGNORABLE_404_URLS", ()) return any(pattern.search(uri) for pattern in urls)
def _is_ignorable_404(uri): """ Returns True if the given request *shouldn't* notify the site managers. """ urls = getattr(django_settings, "IGNORABLE_404_URLS", ()) return any(pattern.search(uri) for pattern in urls)
[ "Returns", "True", "if", "the", "given", "request", "*", "shouldn", "t", "*", "notify", "the", "site", "managers", "." ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/contrib/django/middleware/__init__.py#L57-L62
[ "def", "_is_ignorable_404", "(", "uri", ")", ":", "urls", "=", "getattr", "(", "django_settings", ",", "\"IGNORABLE_404_URLS\"", ",", "(", ")", ")", "return", "any", "(", "pattern", ".", "search", "(", "uri", ")", "for", "pattern", "in", "urls", ")" ]
2975663d7bd22282dc39336b2c37b37c12c7a774
train
get_cgroup_container_metadata
Reads docker/kubernetes metadata (container id, pod id) from /proc/self/cgroup The result is a nested dictionary with the detected IDs, e.g. { "container": {"id": "2227daf62df6694645fee5df53c1f91271546a9560e8600a525690ae252b7f63"}, "pod": {"uid": "90d81341_92de_11e7_8cf2_507b9d4141...
elasticapm/utils/cgroup.py
def get_cgroup_container_metadata(): """ Reads docker/kubernetes metadata (container id, pod id) from /proc/self/cgroup The result is a nested dictionary with the detected IDs, e.g. { "container": {"id": "2227daf62df6694645fee5df53c1f91271546a9560e8600a525690ae252b7f63"}, "...
def get_cgroup_container_metadata(): """ Reads docker/kubernetes metadata (container id, pod id) from /proc/self/cgroup The result is a nested dictionary with the detected IDs, e.g. { "container": {"id": "2227daf62df6694645fee5df53c1f91271546a9560e8600a525690ae252b7f63"}, "...
[ "Reads", "docker", "/", "kubernetes", "metadata", "(", "container", "id", "pod", "id", ")", "from", "/", "proc", "/", "self", "/", "cgroup" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/utils/cgroup.py#L45-L61
[ "def", "get_cgroup_container_metadata", "(", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "CGROUP_PATH", ")", ":", "return", "{", "}", "with", "open", "(", "CGROUP_PATH", ")", "as", "f", ":", "return", "parse_cgroups", "(", "f", ")", "...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
parse_cgroups
Reads lines from a file handle and tries to parse docker container IDs and kubernetes Pod IDs. See tests.utils.docker_tests.test_cgroup_parsing for a set of test cases :param filehandle: :return: nested dictionary or None
elasticapm/utils/cgroup.py
def parse_cgroups(filehandle): """ Reads lines from a file handle and tries to parse docker container IDs and kubernetes Pod IDs. See tests.utils.docker_tests.test_cgroup_parsing for a set of test cases :param filehandle: :return: nested dictionary or None """ for line in filehandle: ...
def parse_cgroups(filehandle): """ Reads lines from a file handle and tries to parse docker container IDs and kubernetes Pod IDs. See tests.utils.docker_tests.test_cgroup_parsing for a set of test cases :param filehandle: :return: nested dictionary or None """ for line in filehandle: ...
[ "Reads", "lines", "from", "a", "file", "handle", "and", "tries", "to", "parse", "docker", "container", "IDs", "and", "kubernetes", "Pod", "IDs", "." ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/utils/cgroup.py#L64-L105
[ "def", "parse_cgroups", "(", "filehandle", ")", ":", "for", "line", "in", "filehandle", ":", "parts", "=", "line", ".", "strip", "(", ")", ".", "split", "(", "\":\"", ")", "if", "len", "(", "parts", ")", "!=", "3", ":", "continue", "cgroup_path", "="...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
for_events
:param events: list of event types Only calls wrapped function if given event_type is in list of events
elasticapm/processors.py
def for_events(*events): """ :param events: list of event types Only calls wrapped function if given event_type is in list of events """ events = set(events) def wrap(func): func.event_types = events return func return wrap
def for_events(*events): """ :param events: list of event types Only calls wrapped function if given event_type is in list of events """ events = set(events) def wrap(func): func.event_types = events return func return wrap
[ ":", "param", "events", ":", "list", "of", "event", "types" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/processors.py#L46-L58
[ "def", "for_events", "(", "*", "events", ")", ":", "events", "=", "set", "(", "events", ")", "def", "wrap", "(", "func", ")", ":", "func", ".", "event_types", "=", "events", "return", "func", "return", "wrap" ]
2975663d7bd22282dc39336b2c37b37c12c7a774
train
remove_stacktrace_locals
Removes local variables from any frames. :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event
elasticapm/processors.py
def remove_stacktrace_locals(client, event): """ Removes local variables from any frames. :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event """ func = lambda frame: frame.pop("vars", None) return _process_stack_frames(event, func)
def remove_stacktrace_locals(client, event): """ Removes local variables from any frames. :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event """ func = lambda frame: frame.pop("vars", None) return _process_stack_frames(event, func)
[ "Removes", "local", "variables", "from", "any", "frames", "." ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/processors.py#L76-L85
[ "def", "remove_stacktrace_locals", "(", "client", ",", "event", ")", ":", "func", "=", "lambda", "frame", ":", "frame", ".", "pop", "(", "\"vars\"", ",", "None", ")", "return", "_process_stack_frames", "(", "event", ",", "func", ")" ]
2975663d7bd22282dc39336b2c37b37c12c7a774
train
sanitize_stacktrace_locals
Sanitizes local variables in all frames :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event
elasticapm/processors.py
def sanitize_stacktrace_locals(client, event): """ Sanitizes local variables in all frames :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event """ def func(frame): if "vars" in frame: frame["vars"] = varmap(_sanitiz...
def sanitize_stacktrace_locals(client, event): """ Sanitizes local variables in all frames :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event """ def func(frame): if "vars" in frame: frame["vars"] = varmap(_sanitiz...
[ "Sanitizes", "local", "variables", "in", "all", "frames" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/processors.py#L89-L102
[ "def", "sanitize_stacktrace_locals", "(", "client", ",", "event", ")", ":", "def", "func", "(", "frame", ")", ":", "if", "\"vars\"", "in", "frame", ":", "frame", "[", "\"vars\"", "]", "=", "varmap", "(", "_sanitize", ",", "frame", "[", "\"vars\"", "]", ...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
sanitize_http_request_cookies
Sanitizes http request cookies :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event
elasticapm/processors.py
def sanitize_http_request_cookies(client, event): """ Sanitizes http request cookies :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event """ # sanitize request.cookies dict try: cookies = event["context"]["request"]["cookie...
def sanitize_http_request_cookies(client, event): """ Sanitizes http request cookies :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event """ # sanitize request.cookies dict try: cookies = event["context"]["request"]["cookie...
[ "Sanitizes", "http", "request", "cookies" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/processors.py#L106-L128
[ "def", "sanitize_http_request_cookies", "(", "client", ",", "event", ")", ":", "# sanitize request.cookies dict", "try", ":", "cookies", "=", "event", "[", "\"context\"", "]", "[", "\"request\"", "]", "[", "\"cookies\"", "]", "event", "[", "\"context\"", "]", "[...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
sanitize_http_response_cookies
Sanitizes the set-cookie header of the response :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event
elasticapm/processors.py
def sanitize_http_response_cookies(client, event): """ Sanitizes the set-cookie header of the response :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event """ try: cookie_string = event["context"]["response"]["headers"]["set-cook...
def sanitize_http_response_cookies(client, event): """ Sanitizes the set-cookie header of the response :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event """ try: cookie_string = event["context"]["response"]["headers"]["set-cook...
[ "Sanitizes", "the", "set", "-", "cookie", "header", "of", "the", "response", ":", "param", "client", ":", "an", "ElasticAPM", "client", ":", "param", "event", ":", "a", "transaction", "or", "error", "event", ":", "return", ":", "The", "modified", "event" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/processors.py#L132-L144
[ "def", "sanitize_http_response_cookies", "(", "client", ",", "event", ")", ":", "try", ":", "cookie_string", "=", "event", "[", "\"context\"", "]", "[", "\"response\"", "]", "[", "\"headers\"", "]", "[", "\"set-cookie\"", "]", "event", "[", "\"context\"", "]",...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
sanitize_http_headers
Sanitizes http request/response headers :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event
elasticapm/processors.py
def sanitize_http_headers(client, event): """ Sanitizes http request/response headers :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event """ # request headers try: headers = event["context"]["request"]["headers"] ev...
def sanitize_http_headers(client, event): """ Sanitizes http request/response headers :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event """ # request headers try: headers = event["context"]["request"]["headers"] ev...
[ "Sanitizes", "http", "request", "/", "response", "headers" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/processors.py#L148-L170
[ "def", "sanitize_http_headers", "(", "client", ",", "event", ")", ":", "# request headers", "try", ":", "headers", "=", "event", "[", "\"context\"", "]", "[", "\"request\"", "]", "[", "\"headers\"", "]", "event", "[", "\"context\"", "]", "[", "\"request\"", ...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
sanitize_http_wsgi_env
Sanitizes WSGI environment variables :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event
elasticapm/processors.py
def sanitize_http_wsgi_env(client, event): """ Sanitizes WSGI environment variables :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event """ try: env = event["context"]["request"]["env"] event["context"]["request"]["env"]...
def sanitize_http_wsgi_env(client, event): """ Sanitizes WSGI environment variables :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event """ try: env = event["context"]["request"]["env"] event["context"]["request"]["env"]...
[ "Sanitizes", "WSGI", "environment", "variables" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/processors.py#L174-L187
[ "def", "sanitize_http_wsgi_env", "(", "client", ",", "event", ")", ":", "try", ":", "env", "=", "event", "[", "\"context\"", "]", "[", "\"request\"", "]", "[", "\"env\"", "]", "event", "[", "\"context\"", "]", "[", "\"request\"", "]", "[", "\"env\"", "]"...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
sanitize_http_request_querystring
Sanitizes http request query string :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event
elasticapm/processors.py
def sanitize_http_request_querystring(client, event): """ Sanitizes http request query string :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event """ try: query_string = force_text(event["context"]["request"]["url"]["search"], e...
def sanitize_http_request_querystring(client, event): """ Sanitizes http request query string :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event """ try: query_string = force_text(event["context"]["request"]["url"]["search"], e...
[ "Sanitizes", "http", "request", "query", "string" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/processors.py#L191-L208
[ "def", "sanitize_http_request_querystring", "(", "client", ",", "event", ")", ":", "try", ":", "query_string", "=", "force_text", "(", "event", "[", "\"context\"", "]", "[", "\"request\"", "]", "[", "\"url\"", "]", "[", "\"search\"", "]", ",", "errors", "=",...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
sanitize_http_request_body
Sanitizes http request body. This only works if the request body is a query-encoded string. Other types (e.g. JSON) are not handled by this sanitizer. :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event
elasticapm/processors.py
def sanitize_http_request_body(client, event): """ Sanitizes http request body. This only works if the request body is a query-encoded string. Other types (e.g. JSON) are not handled by this sanitizer. :param client: an ElasticAPM client :param event: a transaction or error event :return: T...
def sanitize_http_request_body(client, event): """ Sanitizes http request body. This only works if the request body is a query-encoded string. Other types (e.g. JSON) are not handled by this sanitizer. :param client: an ElasticAPM client :param event: a transaction or error event :return: T...
[ "Sanitizes", "http", "request", "body", ".", "This", "only", "works", "if", "the", "request", "body", "is", "a", "query", "-", "encoded", "string", ".", "Other", "types", "(", "e", ".", "g", ".", "JSON", ")", "are", "not", "handled", "by", "this", "s...
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/processors.py#L212-L229
[ "def", "sanitize_http_request_body", "(", "client", ",", "event", ")", ":", "try", ":", "body", "=", "force_text", "(", "event", "[", "\"context\"", "]", "[", "\"request\"", "]", "[", "\"body\"", "]", ",", "errors", "=", "\"replace\"", ")", "except", "(", ...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
_sanitize_string
sanitizes a string that contains multiple key/value items :param unsanitized: the unsanitized string :param itemsep: string that separates items :param kvsep: string that separates key from value :return: a sanitized string
elasticapm/processors.py
def _sanitize_string(unsanitized, itemsep, kvsep): """ sanitizes a string that contains multiple key/value items :param unsanitized: the unsanitized string :param itemsep: string that separates items :param kvsep: string that separates key from value :return: a sanitized string """ sanit...
def _sanitize_string(unsanitized, itemsep, kvsep): """ sanitizes a string that contains multiple key/value items :param unsanitized: the unsanitized string :param itemsep: string that separates items :param kvsep: string that separates key from value :return: a sanitized string """ sanit...
[ "sanitizes", "a", "string", "that", "contains", "multiple", "key", "/", "value", "items", ":", "param", "unsanitized", ":", "the", "unsanitized", "string", ":", "param", "itemsep", ":", "string", "that", "separates", "items", ":", "param", "kvsep", ":", "str...
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/processors.py#L259-L275
[ "def", "_sanitize_string", "(", "unsanitized", ",", "itemsep", ",", "kvsep", ")", ":", "sanitized", "=", "[", "]", "kvs", "=", "unsanitized", ".", "split", "(", "itemsep", ")", "for", "kv", "in", "kvs", ":", "kv", "=", "kv", ".", "split", "(", "kvsep...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
Client.capture
Captures and processes an event and pipes it off to Client.send.
elasticapm/base.py
def capture(self, event_type, date=None, context=None, custom=None, stack=None, handled=True, **kwargs): """ Captures and processes an event and pipes it off to Client.send. """ if event_type == "Exception": # never gather log stack for exceptions stack = False ...
def capture(self, event_type, date=None, context=None, custom=None, stack=None, handled=True, **kwargs): """ Captures and processes an event and pipes it off to Client.send. """ if event_type == "Exception": # never gather log stack for exceptions stack = False ...
[ "Captures", "and", "processes", "an", "event", "and", "pipes", "it", "off", "to", "Client", ".", "send", "." ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/base.py#L176-L190
[ "def", "capture", "(", "self", ",", "event_type", ",", "date", "=", "None", ",", "context", "=", "None", ",", "custom", "=", "None", ",", "stack", "=", "None", ",", "handled", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "event_type", "=="...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
Client.capture_message
Creates an event from ``message``. >>> client.capture_message('My event just happened!')
elasticapm/base.py
def capture_message(self, message=None, param_message=None, **kwargs): """ Creates an event from ``message``. >>> client.capture_message('My event just happened!') """ return self.capture("Message", message=message, param_message=param_message, **kwargs)
def capture_message(self, message=None, param_message=None, **kwargs): """ Creates an event from ``message``. >>> client.capture_message('My event just happened!') """ return self.capture("Message", message=message, param_message=param_message, **kwargs)
[ "Creates", "an", "event", "from", "message", "." ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/base.py#L192-L198
[ "def", "capture_message", "(", "self", ",", "message", "=", "None", ",", "param_message", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "capture", "(", "\"Message\"", ",", "message", "=", "message", ",", "param_message", "=", "pa...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
Client.capture_exception
Creates an event from an exception. >>> try: >>> exc_info = sys.exc_info() >>> client.capture_exception(exc_info) >>> finally: >>> del exc_info If exc_info is not provided, or is set to True, then this method will perform the ``exc_info = sys.exc_inf...
elasticapm/base.py
def capture_exception(self, exc_info=None, handled=True, **kwargs): """ Creates an event from an exception. >>> try: >>> exc_info = sys.exc_info() >>> client.capture_exception(exc_info) >>> finally: >>> del exc_info If exc_info is not provide...
def capture_exception(self, exc_info=None, handled=True, **kwargs): """ Creates an event from an exception. >>> try: >>> exc_info = sys.exc_info() >>> client.capture_exception(exc_info) >>> finally: >>> del exc_info If exc_info is not provide...
[ "Creates", "an", "event", "from", "an", "exception", "." ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/base.py#L200-L214
[ "def", "capture_exception", "(", "self", ",", "exc_info", "=", "None", ",", "handled", "=", "True", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "capture", "(", "\"Exception\"", ",", "exc_info", "=", "exc_info", ",", "handled", "=", "handled...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
Client.begin_transaction
Register the start of a transaction on the client
elasticapm/base.py
def begin_transaction(self, transaction_type, trace_parent=None): """Register the start of a transaction on the client """ return self.tracer.begin_transaction(transaction_type, trace_parent=trace_parent)
def begin_transaction(self, transaction_type, trace_parent=None): """Register the start of a transaction on the client """ return self.tracer.begin_transaction(transaction_type, trace_parent=trace_parent)
[ "Register", "the", "start", "of", "a", "transaction", "on", "the", "client" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/base.py#L228-L231
[ "def", "begin_transaction", "(", "self", ",", "transaction_type", ",", "trace_parent", "=", "None", ")", ":", "return", "self", ".", "tracer", ".", "begin_transaction", "(", "transaction_type", ",", "trace_parent", "=", "trace_parent", ")" ]
2975663d7bd22282dc39336b2c37b37c12c7a774
train
Client._build_msg_for_logging
Captures, processes and serializes an event into a dict object
elasticapm/base.py
def _build_msg_for_logging( self, event_type, date=None, context=None, custom=None, stack=None, handled=True, **kwargs ): """ Captures, processes and serializes an event into a dict object """ transaction = execution_context.get_transaction() if transaction: ...
def _build_msg_for_logging( self, event_type, date=None, context=None, custom=None, stack=None, handled=True, **kwargs ): """ Captures, processes and serializes an event into a dict object """ transaction = execution_context.get_transaction() if transaction: ...
[ "Captures", "processes", "and", "serializes", "an", "event", "into", "a", "dict", "object" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/base.py#L313-L415
[ "def", "_build_msg_for_logging", "(", "self", ",", "event_type", ",", "date", "=", "None", ",", "context", "=", "None", ",", "custom", "=", "None", ",", "stack", "=", "None", ",", "handled", "=", "True", ",", "*", "*", "kwargs", ")", ":", "transaction"...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
Client._get_stack_info_for_trace
Overrideable in derived clients to add frames/info, e.g. templates
elasticapm/base.py
def _get_stack_info_for_trace( self, frames, library_frame_context_lines=None, in_app_frame_context_lines=None, with_locals=True, locals_processor_func=None, ): """Overrideable in derived clients to add frames/info, e.g. templates""" return stacks.get_...
def _get_stack_info_for_trace( self, frames, library_frame_context_lines=None, in_app_frame_context_lines=None, with_locals=True, locals_processor_func=None, ): """Overrideable in derived clients to add frames/info, e.g. templates""" return stacks.get_...
[ "Overrideable", "in", "derived", "clients", "to", "add", "frames", "/", "info", "e", ".", "g", ".", "templates" ]
elastic/apm-agent-python
python
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/base.py#L438-L455
[ "def", "_get_stack_info_for_trace", "(", "self", ",", "frames", ",", "library_frame_context_lines", "=", "None", ",", "in_app_frame_context_lines", "=", "None", ",", "with_locals", "=", "True", ",", "locals_processor_func", "=", "None", ",", ")", ":", "return", "s...
2975663d7bd22282dc39336b2c37b37c12c7a774
train
papermill
This utility executes a single notebook on a container. Papermill takes a source notebook, applies parameters to the source notebook, executes the notebook with the specified kernel, and saves the output in the destination notebook.
papermill/cli.py
def papermill( notebook_path, output_path, parameters, parameters_raw, parameters_file, parameters_yaml, parameters_base64, inject_input_path, inject_output_path, inject_paths, engine, prepare_only, kernel, cwd, progress_bar, log_output, log_level, ...
def papermill( notebook_path, output_path, parameters, parameters_raw, parameters_file, parameters_yaml, parameters_base64, inject_input_path, inject_output_path, inject_paths, engine, prepare_only, kernel, cwd, progress_bar, log_output, log_level, ...
[ "This", "utility", "executes", "a", "single", "notebook", "on", "a", "container", "." ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/cli.py#L104-L166
[ "def", "papermill", "(", "notebook_path", ",", "output_path", ",", "parameters", ",", "parameters_raw", ",", "parameters_file", ",", "parameters_yaml", ",", "parameters_base64", ",", "inject_input_path", ",", "inject_output_path", ",", "inject_paths", ",", "engine", "...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
catch_nb_assignment
Wrapper to catch `nb` keyword arguments This helps catch `nb` keyword arguments and assign onto self when passed to the wrapped function. Used for callback methods when the caller may optionally have a new copy of the originally wrapped `nb` object.
papermill/engines.py
def catch_nb_assignment(func): """ Wrapper to catch `nb` keyword arguments This helps catch `nb` keyword arguments and assign onto self when passed to the wrapped function. Used for callback methods when the caller may optionally have a new copy of the originally wrapped `nb` object. """ ...
def catch_nb_assignment(func): """ Wrapper to catch `nb` keyword arguments This helps catch `nb` keyword arguments and assign onto self when passed to the wrapped function. Used for callback methods when the caller may optionally have a new copy of the originally wrapped `nb` object. """ ...
[ "Wrapper", "to", "catch", "nb", "keyword", "arguments" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/engines.py#L60-L79
[ "def", "catch_nb_assignment", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "nb", "=", "kwargs", ".", "get", "(", "'nb'", ")", "if", "nb", ":", "# Reassi...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
PapermillEngines.register_entry_points
Register entrypoints for an engine Load handlers provided by other packages
papermill/engines.py
def register_entry_points(self): """Register entrypoints for an engine Load handlers provided by other packages """ for entrypoint in entrypoints.get_group_all("papermill.engine"): self.register(entrypoint.name, entrypoint.load())
def register_entry_points(self): """Register entrypoints for an engine Load handlers provided by other packages """ for entrypoint in entrypoints.get_group_all("papermill.engine"): self.register(entrypoint.name, entrypoint.load())
[ "Register", "entrypoints", "for", "an", "engine" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/engines.py#L40-L46
[ "def", "register_entry_points", "(", "self", ")", ":", "for", "entrypoint", "in", "entrypoints", ".", "get_group_all", "(", "\"papermill.engine\"", ")", ":", "self", ".", "register", "(", "entrypoint", ".", "name", ",", "entrypoint", ".", "load", "(", ")", "...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
PapermillEngines.get_engine
Retrieves an engine by name.
papermill/engines.py
def get_engine(self, name=None): """Retrieves an engine by name.""" engine = self._engines.get(name) if not engine: raise PapermillException("No engine named '{}' found".format(name)) return engine
def get_engine(self, name=None): """Retrieves an engine by name.""" engine = self._engines.get(name) if not engine: raise PapermillException("No engine named '{}' found".format(name)) return engine
[ "Retrieves", "an", "engine", "by", "name", "." ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/engines.py#L48-L53
[ "def", "get_engine", "(", "self", ",", "name", "=", "None", ")", ":", "engine", "=", "self", ".", "_engines", ".", "get", "(", "name", ")", "if", "not", "engine", ":", "raise", "PapermillException", "(", "\"No engine named '{}' found\"", ".", "format", "("...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
PapermillEngines.execute_notebook_with_engine
Fetch a named engine and execute the nb object against it.
papermill/engines.py
def execute_notebook_with_engine(self, engine_name, nb, kernel_name, **kwargs): """Fetch a named engine and execute the nb object against it.""" return self.get_engine(engine_name).execute_notebook(nb, kernel_name, **kwargs)
def execute_notebook_with_engine(self, engine_name, nb, kernel_name, **kwargs): """Fetch a named engine and execute the nb object against it.""" return self.get_engine(engine_name).execute_notebook(nb, kernel_name, **kwargs)
[ "Fetch", "a", "named", "engine", "and", "execute", "the", "nb", "object", "against", "it", "." ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/engines.py#L55-L57
[ "def", "execute_notebook_with_engine", "(", "self", ",", "engine_name", ",", "nb", ",", "kernel_name", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "get_engine", "(", "engine_name", ")", ".", "execute_notebook", "(", "nb", ",", "kernel_name", ",...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
NotebookExecutionManager.save
Saves the wrapped notebook state. If an output path is known, this triggers a save of the wrapped notebook state to the provided path. Can be used outside of cell state changes if execution is taking a long time to conclude but the notebook object should be synced. For example...
papermill/engines.py
def save(self, **kwargs): """ Saves the wrapped notebook state. If an output path is known, this triggers a save of the wrapped notebook state to the provided path. Can be used outside of cell state changes if execution is taking a long time to conclude but the notebook...
def save(self, **kwargs): """ Saves the wrapped notebook state. If an output path is known, this triggers a save of the wrapped notebook state to the provided path. Can be used outside of cell state changes if execution is taking a long time to conclude but the notebook...
[ "Saves", "the", "wrapped", "notebook", "state", "." ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/engines.py#L125-L139
[ "def", "save", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "output_path", ":", "write_ipynb", "(", "self", ".", "nb", ",", "self", ".", "output_path", ")" ]
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
NotebookExecutionManager.notebook_start
Initialize a notebook, clearing its metadata, and save it. When starting a notebook, this initializes and clears the metadata for the notebook and its cells, and saves the notebook to the given output path. Called by Engine when execution begins.
papermill/engines.py
def notebook_start(self, **kwargs): """ Initialize a notebook, clearing its metadata, and save it. When starting a notebook, this initializes and clears the metadata for the notebook and its cells, and saves the notebook to the given output path. Called by Engine when e...
def notebook_start(self, **kwargs): """ Initialize a notebook, clearing its metadata, and save it. When starting a notebook, this initializes and clears the metadata for the notebook and its cells, and saves the notebook to the given output path. Called by Engine when e...
[ "Initialize", "a", "notebook", "clearing", "its", "metadata", "and", "save", "it", "." ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/engines.py#L142-L175
[ "def", "notebook_start", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "set_timer", "(", ")", "self", ".", "nb", ".", "metadata", ".", "papermill", "[", "'start_time'", "]", "=", "self", ".", "start_time", ".", "isoformat", "(", ")", "...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
NotebookExecutionManager.cell_start
Set and save a cell's start state. Optionally called by engines during execution to initialize the metadata for a cell and save the notebook to the output path.
papermill/engines.py
def cell_start(self, cell, cell_index=None, **kwargs): """ Set and save a cell's start state. Optionally called by engines during execution to initialize the metadata for a cell and save the notebook to the output path. """ if self.log_output: ceel_num = cell...
def cell_start(self, cell, cell_index=None, **kwargs): """ Set and save a cell's start state. Optionally called by engines during execution to initialize the metadata for a cell and save the notebook to the output path. """ if self.log_output: ceel_num = cell...
[ "Set", "and", "save", "a", "cell", "s", "start", "state", "." ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/engines.py#L178-L193
[ "def", "cell_start", "(", "self", ",", "cell", ",", "cell_index", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "log_output", ":", "ceel_num", "=", "cell_index", "+", "1", "if", "cell_index", "is", "not", "None", "else", "''", "l...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
NotebookExecutionManager.cell_exception
Set metadata when an exception is raised. Called by engines when an exception is raised within a notebook to set the metadata on the notebook indicating the location of the failure.
papermill/engines.py
def cell_exception(self, cell, cell_index=None, **kwargs): """ Set metadata when an exception is raised. Called by engines when an exception is raised within a notebook to set the metadata on the notebook indicating the location of the failure. """ cell.metadata....
def cell_exception(self, cell, cell_index=None, **kwargs): """ Set metadata when an exception is raised. Called by engines when an exception is raised within a notebook to set the metadata on the notebook indicating the location of the failure. """ cell.metadata....
[ "Set", "metadata", "when", "an", "exception", "is", "raised", "." ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/engines.py#L196-L206
[ "def", "cell_exception", "(", "self", ",", "cell", ",", "cell_index", "=", "None", ",", "*", "*", "kwargs", ")", ":", "cell", ".", "metadata", ".", "papermill", "[", "'exception'", "]", "=", "True", "cell", ".", "metadata", ".", "papermill", "[", "'sta...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
NotebookExecutionManager.cell_complete
Finalize metadata for a cell and save notebook. Optionally called by engines during execution to finalize the metadata for a cell and save the notebook to the output path.
papermill/engines.py
def cell_complete(self, cell, cell_index=None, **kwargs): """ Finalize metadata for a cell and save notebook. Optionally called by engines during execution to finalize the metadata for a cell and save the notebook to the output path. """ end_time = self.now() if...
def cell_complete(self, cell, cell_index=None, **kwargs): """ Finalize metadata for a cell and save notebook. Optionally called by engines during execution to finalize the metadata for a cell and save the notebook to the output path. """ end_time = self.now() if...
[ "Finalize", "metadata", "for", "a", "cell", "and", "save", "notebook", "." ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/engines.py#L209-L234
[ "def", "cell_complete", "(", "self", ",", "cell", ",", "cell_index", "=", "None", ",", "*", "*", "kwargs", ")", ":", "end_time", "=", "self", ".", "now", "(", ")", "if", "self", ".", "log_output", ":", "ceel_num", "=", "cell_index", "+", "1", "if", ...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
NotebookExecutionManager.notebook_complete
Finalize the metadata for a notebook and save the notebook to the output path. Called by Engine when execution concludes, regardless of exceptions.
papermill/engines.py
def notebook_complete(self, **kwargs): """ Finalize the metadata for a notebook and save the notebook to the output path. Called by Engine when execution concludes, regardless of exceptions. """ self.end_time = self.now() self.nb.metadata.papermill['end_time'] = ...
def notebook_complete(self, **kwargs): """ Finalize the metadata for a notebook and save the notebook to the output path. Called by Engine when execution concludes, regardless of exceptions. """ self.end_time = self.now() self.nb.metadata.papermill['end_time'] = ...
[ "Finalize", "the", "metadata", "for", "a", "notebook", "and", "save", "the", "notebook", "to", "the", "output", "path", "." ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/engines.py#L237-L262
[ "def", "notebook_complete", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "end_time", "=", "self", ".", "now", "(", ")", "self", ".", "nb", ".", "metadata", ".", "papermill", "[", "'end_time'", "]", "=", "self", ".", "end_time", ".", ...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
NotebookExecutionManager.complete_pbar
Refresh progress bar
papermill/engines.py
def complete_pbar(self): """Refresh progress bar""" if hasattr(self, 'pbar') and self.pbar: self.pbar.n = len(self.nb.cells) self.pbar.refresh()
def complete_pbar(self): """Refresh progress bar""" if hasattr(self, 'pbar') and self.pbar: self.pbar.n = len(self.nb.cells) self.pbar.refresh()
[ "Refresh", "progress", "bar" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/engines.py#L264-L268
[ "def", "complete_pbar", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'pbar'", ")", "and", "self", ".", "pbar", ":", "self", ".", "pbar", ".", "n", "=", "len", "(", "self", ".", "nb", ".", "cells", ")", "self", ".", "pbar", ".", "r...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
NotebookExecutionManager.cleanup_pbar
Clean up a progress bar
papermill/engines.py
def cleanup_pbar(self): """Clean up a progress bar""" if hasattr(self, 'pbar') and self.pbar: self.pbar.close() self.pbar = None
def cleanup_pbar(self): """Clean up a progress bar""" if hasattr(self, 'pbar') and self.pbar: self.pbar.close() self.pbar = None
[ "Clean", "up", "a", "progress", "bar" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/engines.py#L270-L274
[ "def", "cleanup_pbar", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'pbar'", ")", "and", "self", ".", "pbar", ":", "self", ".", "pbar", ".", "close", "(", ")", "self", ".", "pbar", "=", "None" ]
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
Engine.execute_notebook
A wrapper to handle notebook execution tasks. Wraps the notebook object in a `NotebookExecutionManager` in order to track execution state in a uniform manner. This is meant to help simplify engine implementations. This allows a developer to just focus on iterating and executing the cell...
papermill/engines.py
def execute_notebook( cls, nb, kernel_name, output_path=None, progress_bar=True, log_output=False, **kwargs ): """ A wrapper to handle notebook execution tasks. Wraps the notebook object in a `NotebookExecutionManager` in order to track execution state in a uniform manner. T...
def execute_notebook( cls, nb, kernel_name, output_path=None, progress_bar=True, log_output=False, **kwargs ): """ A wrapper to handle notebook execution tasks. Wraps the notebook object in a `NotebookExecutionManager` in order to track execution state in a uniform manner. T...
[ "A", "wrapper", "to", "handle", "notebook", "execution", "tasks", "." ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/engines.py#L292-L317
[ "def", "execute_notebook", "(", "cls", ",", "nb", ",", "kernel_name", ",", "output_path", "=", "None", ",", "progress_bar", "=", "True", ",", "log_output", "=", "False", ",", "*", "*", "kwargs", ")", ":", "nb_man", "=", "NotebookExecutionManager", "(", "nb...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
NBConvertEngine.execute_managed_notebook
Performs the actual execution of the parameterized notebook locally. Args: nb (NotebookNode): Executable notebook object. kernel_name (str): Name of kernel to execute the notebook against. log_output (bool): Flag for whether or not to write notebook output to stderr. ...
papermill/engines.py
def execute_managed_notebook( cls, nb_man, kernel_name, log_output=False, start_timeout=60, execution_timeout=None, **kwargs ): """ Performs the actual execution of the parameterized notebook locally. Args: nb (NotebookNode...
def execute_managed_notebook( cls, nb_man, kernel_name, log_output=False, start_timeout=60, execution_timeout=None, **kwargs ): """ Performs the actual execution of the parameterized notebook locally. Args: nb (NotebookNode...
[ "Performs", "the", "actual", "execution", "of", "the", "parameterized", "notebook", "locally", "." ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/engines.py#L334-L365
[ "def", "execute_managed_notebook", "(", "cls", ",", "nb_man", ",", "kernel_name", ",", "log_output", "=", "False", ",", "start_timeout", "=", "60", ",", "execution_timeout", "=", "None", ",", "*", "*", "kwargs", ")", ":", "preprocessor", "=", "PapermillExecute...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
AzureBlobStore._split_url
see: https://docs.microsoft.com/en-us/azure/storage/common/storage-dotnet-shared-access-signature-part-1 # noqa: E501 abs://myaccount.blob.core.windows.net/sascontainer/sasblob.txt?sastoken
papermill/abs.py
def _split_url(self, url): """ see: https://docs.microsoft.com/en-us/azure/storage/common/storage-dotnet-shared-access-signature-part-1 # noqa: E501 abs://myaccount.blob.core.windows.net/sascontainer/sasblob.txt?sastoken """ match = re.match(r"abs://(.*)\.blob\.core\.windows\.ne...
def _split_url(self, url): """ see: https://docs.microsoft.com/en-us/azure/storage/common/storage-dotnet-shared-access-signature-part-1 # noqa: E501 abs://myaccount.blob.core.windows.net/sascontainer/sasblob.txt?sastoken """ match = re.match(r"abs://(.*)\.blob\.core\.windows\.ne...
[ "see", ":", "https", ":", "//", "docs", ".", "microsoft", ".", "com", "/", "en", "-", "us", "/", "azure", "/", "storage", "/", "common", "/", "storage", "-", "dotnet", "-", "shared", "-", "access", "-", "signature", "-", "part", "-", "1", "#", "n...
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/abs.py#L31-L46
[ "def", "_split_url", "(", "self", ",", "url", ")", ":", "match", "=", "re", ".", "match", "(", "r\"abs://(.*)\\.blob\\.core\\.windows\\.net\\/(.*)\\/(.*)\\?(.*)$\"", ",", "url", ")", "if", "not", "match", ":", "raise", "Exception", "(", "\"Invalid azure blob url '{0...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
AzureBlobStore.read
Read storage at a given url
papermill/abs.py
def read(self, url): """Read storage at a given url""" params = self._split_url(url) output_stream = io.BytesIO() block_blob_service = self._block_blob_service( account_name=params["account"], sas_token=params["sas_token"] ) block_blob_service.get_blob_to_str...
def read(self, url): """Read storage at a given url""" params = self._split_url(url) output_stream = io.BytesIO() block_blob_service = self._block_blob_service( account_name=params["account"], sas_token=params["sas_token"] ) block_blob_service.get_blob_to_str...
[ "Read", "storage", "at", "a", "given", "url" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/abs.py#L48-L61
[ "def", "read", "(", "self", ",", "url", ")", ":", "params", "=", "self", ".", "_split_url", "(", "url", ")", "output_stream", "=", "io", ".", "BytesIO", "(", ")", "block_blob_service", "=", "self", ".", "_block_blob_service", "(", "account_name", "=", "p...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
AzureBlobStore.listdir
Returns a list of the files under the specified path
papermill/abs.py
def listdir(self, url): """Returns a list of the files under the specified path""" params = self._split_url(url) block_blob_service = self._block_blob_service( account_name=params["account"], sas_token=params["sas_token"] ) blobs = block_blob_service.list_blobs(param...
def listdir(self, url): """Returns a list of the files under the specified path""" params = self._split_url(url) block_blob_service = self._block_blob_service( account_name=params["account"], sas_token=params["sas_token"] ) blobs = block_blob_service.list_blobs(param...
[ "Returns", "a", "list", "of", "the", "files", "under", "the", "specified", "path" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/abs.py#L63-L71
[ "def", "listdir", "(", "self", ",", "url", ")", ":", "params", "=", "self", ".", "_split_url", "(", "url", ")", "block_blob_service", "=", "self", ".", "_block_blob_service", "(", "account_name", "=", "params", "[", "\"account\"", "]", ",", "sas_token", "=...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
AzureBlobStore.write
Write buffer to storage at a given url
papermill/abs.py
def write(self, buf, url): """Write buffer to storage at a given url""" params = self._split_url(url) block_blob_service = self._block_blob_service( account_name=params["account"], sas_token=params["sas_token"] ) block_blob_service.create_blob_from_text( ...
def write(self, buf, url): """Write buffer to storage at a given url""" params = self._split_url(url) block_blob_service = self._block_blob_service( account_name=params["account"], sas_token=params["sas_token"] ) block_blob_service.create_blob_from_text( ...
[ "Write", "buffer", "to", "storage", "at", "a", "given", "url" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/abs.py#L73-L83
[ "def", "write", "(", "self", ",", "buf", ",", "url", ")", ":", "params", "=", "self", ".", "_split_url", "(", "url", ")", "block_blob_service", "=", "self", ".", "_block_blob_service", "(", "account_name", "=", "params", "[", "\"account\"", "]", ",", "sa...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
execute_notebook
Executes a single notebook locally. Parameters ---------- input_path : str Path to input notebook output_path : str Path to save executed notebook parameters : dict, optional Arbitrary keyword arguments to pass to the notebook parameters engine_name : str, optional ...
papermill/execute.py
def execute_notebook( input_path, output_path, parameters=None, engine_name=None, prepare_only=False, kernel_name=None, progress_bar=True, log_output=False, start_timeout=60, report_mode=False, cwd=None, ): """Executes a single notebook locally. Parameters ------...
def execute_notebook( input_path, output_path, parameters=None, engine_name=None, prepare_only=False, kernel_name=None, progress_bar=True, log_output=False, start_timeout=60, report_mode=False, cwd=None, ): """Executes a single notebook locally. Parameters ------...
[ "Executes", "a", "single", "notebook", "locally", "." ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/execute.py#L16-L102
[ "def", "execute_notebook", "(", "input_path", ",", "output_path", ",", "parameters", "=", "None", ",", "engine_name", "=", "None", ",", "prepare_only", "=", "False", ",", "kernel_name", "=", "None", ",", "progress_bar", "=", "True", ",", "log_output", "=", "...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
prepare_notebook_metadata
Prepare metadata associated with a notebook and its cells Parameters ---------- nb : NotebookNode Executable notebook object input_path : str Path to input notebook output_path : str Path to write executed notebook report_mode : bool, optional Flag to set report mod...
papermill/execute.py
def prepare_notebook_metadata(nb, input_path, output_path, report_mode=False): """Prepare metadata associated with a notebook and its cells Parameters ---------- nb : NotebookNode Executable notebook object input_path : str Path to input notebook output_path : str Path to ...
def prepare_notebook_metadata(nb, input_path, output_path, report_mode=False): """Prepare metadata associated with a notebook and its cells Parameters ---------- nb : NotebookNode Executable notebook object input_path : str Path to input notebook output_path : str Path to ...
[ "Prepare", "metadata", "associated", "with", "a", "notebook", "and", "its", "cells" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/execute.py#L105-L133
[ "def", "prepare_notebook_metadata", "(", "nb", ",", "input_path", ",", "output_path", ",", "report_mode", "=", "False", ")", ":", "# Copy the nb object to avoid polluting the input", "nb", "=", "copy", ".", "deepcopy", "(", "nb", ")", "# Hide input if report-mode is set...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
raise_for_execution_errors
Assigned parameters into the appropriate place in the input notebook Parameters ---------- nb : NotebookNode Executable notebook object output_path : str Path to write executed notebook
papermill/execute.py
def raise_for_execution_errors(nb, output_path): """Assigned parameters into the appropriate place in the input notebook Parameters ---------- nb : NotebookNode Executable notebook object output_path : str Path to write executed notebook """ error = None for cell in nb.cel...
def raise_for_execution_errors(nb, output_path): """Assigned parameters into the appropriate place in the input notebook Parameters ---------- nb : NotebookNode Executable notebook object output_path : str Path to write executed notebook """ error = None for cell in nb.cel...
[ "Assigned", "parameters", "into", "the", "appropriate", "place", "in", "the", "input", "notebook" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/execute.py#L143-L181
[ "def", "raise_for_execution_errors", "(", "nb", ",", "output_path", ")", ":", "error", "=", "None", "for", "cell", "in", "nb", ".", "cells", ":", "if", "cell", ".", "get", "(", "\"outputs\"", ")", "is", "None", ":", "continue", "for", "output", "in", "...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
Bucket.list
Limits a list of Bucket's objects based on prefix and delimiter.
papermill/s3.py
def list(self, prefix='', delimiter=None): """Limits a list of Bucket's objects based on prefix and delimiter.""" return self.service._list( bucket=self.name, prefix=prefix, delimiter=delimiter, objects=True )
def list(self, prefix='', delimiter=None): """Limits a list of Bucket's objects based on prefix and delimiter.""" return self.service._list( bucket=self.name, prefix=prefix, delimiter=delimiter, objects=True )
[ "Limits", "a", "list", "of", "Bucket", "s", "objects", "based", "on", "prefix", "and", "delimiter", "." ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/s3.py#L36-L40
[ "def", "list", "(", "self", ",", "prefix", "=", "''", ",", "delimiter", "=", "None", ")", ":", "return", "self", ".", "service", ".", "_list", "(", "bucket", "=", "self", ".", "name", ",", "prefix", "=", "prefix", ",", "delimiter", "=", "delimiter", ...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
S3.cat
Returns an iterator for the data in the key or nothing if the key doesn't exist. Decompresses data on the fly (if compressed is True or key ends with .gz) unless raw is True. Pass None for encoding to skip encoding.
papermill/s3.py
def cat( self, source, buffersize=None, memsize=2 ** 24, compressed=False, encoding='UTF-8', raw=False, ): """ Returns an iterator for the data in the key or nothing if the key doesn't exist. Decompresses data on the fly (if compressed ...
def cat( self, source, buffersize=None, memsize=2 ** 24, compressed=False, encoding='UTF-8', raw=False, ): """ Returns an iterator for the data in the key or nothing if the key doesn't exist. Decompresses data on the fly (if compressed ...
[ "Returns", "an", "iterator", "for", "the", "data", "in", "the", "key", "or", "nothing", "if", "the", "key", "doesn", "t", "exist", ".", "Decompresses", "data", "on", "the", "fly", "(", "if", "compressed", "is", "True", "or", "key", "ends", "with", ".",...
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/s3.py#L263-L353
[ "def", "cat", "(", "self", ",", "source", ",", "buffersize", "=", "None", ",", "memsize", "=", "2", "**", "24", ",", "compressed", "=", "False", ",", "encoding", "=", "'UTF-8'", ",", "raw", "=", "False", ",", ")", ":", "assert", "self", ".", "_is_s...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
S3.cp_string
Copies source string into the destination location. Parameters ---------- source: string the string with the content to copy dest: string the s3 location
papermill/s3.py
def cp_string(self, source, dest, **kwargs): """ Copies source string into the destination location. Parameters ---------- source: string the string with the content to copy dest: string the s3 location """ assert isinstance(sourc...
def cp_string(self, source, dest, **kwargs): """ Copies source string into the destination location. Parameters ---------- source: string the string with the content to copy dest: string the s3 location """ assert isinstance(sourc...
[ "Copies", "source", "string", "into", "the", "destination", "location", "." ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/s3.py#L355-L370
[ "def", "cp_string", "(", "self", ",", "source", ",", "dest", ",", "*", "*", "kwargs", ")", ":", "assert", "isinstance", "(", "source", ",", "six", ".", "string_types", ")", ",", "\"source must be a string\"", "assert", "self", ".", "_is_s3", "(", "dest", ...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
S3.list
Returns a list of the files under the specified path name must be in the form of `s3://bucket/prefix` Parameters ---------- keys: optional if True then this will return the actual boto keys for files that are encountered objects: optional if True...
papermill/s3.py
def list(self, name, iterator=False, **kwargs): """ Returns a list of the files under the specified path name must be in the form of `s3://bucket/prefix` Parameters ---------- keys: optional if True then this will return the actual boto keys for files ...
def list(self, name, iterator=False, **kwargs): """ Returns a list of the files under the specified path name must be in the form of `s3://bucket/prefix` Parameters ---------- keys: optional if True then this will return the actual boto keys for files ...
[ "Returns", "a", "list", "of", "the", "files", "under", "the", "specified", "path", "name", "must", "be", "in", "the", "form", "of", "s3", ":", "//", "bucket", "/", "prefix" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/s3.py#L372-L394
[ "def", "list", "(", "self", ",", "name", ",", "iterator", "=", "False", ",", "*", "*", "kwargs", ")", ":", "assert", "self", ".", "_is_s3", "(", "name", ")", ",", "\"name must be in form s3://bucket/key\"", "it", "=", "self", ".", "_list", "(", "bucket",...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
S3.listdir
Returns a list of the files under the specified path. This is different from list as it will only give you files under the current directory, much like ls. name must be in the form of `s3://bucket/prefix/` Parameters ---------- keys: optional if True then t...
papermill/s3.py
def listdir(self, name, **kwargs): """ Returns a list of the files under the specified path. This is different from list as it will only give you files under the current directory, much like ls. name must be in the form of `s3://bucket/prefix/` Parameters -----...
def listdir(self, name, **kwargs): """ Returns a list of the files under the specified path. This is different from list as it will only give you files under the current directory, much like ls. name must be in the form of `s3://bucket/prefix/` Parameters -----...
[ "Returns", "a", "list", "of", "the", "files", "under", "the", "specified", "path", "." ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/s3.py#L396-L419
[ "def", "listdir", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "assert", "self", ".", "_is_s3", "(", "name", ")", ",", "\"name must be in form s3://bucket/prefix/\"", "if", "not", "name", ".", "endswith", "(", "'/'", ")", ":", "name", "+=...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
S3.read
Iterates over a file in s3 split on newline. Yields a line in file.
papermill/s3.py
def read(self, source, compressed=False, encoding='UTF-8'): """ Iterates over a file in s3 split on newline. Yields a line in file. """ buf = '' for block in self.cat(source, compressed=compressed, encoding=encoding): buf += block if '\n' in buf:...
def read(self, source, compressed=False, encoding='UTF-8'): """ Iterates over a file in s3 split on newline. Yields a line in file. """ buf = '' for block in self.cat(source, compressed=compressed, encoding=encoding): buf += block if '\n' in buf:...
[ "Iterates", "over", "a", "file", "in", "s3", "split", "on", "newline", "." ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/s3.py#L421-L442
[ "def", "read", "(", "self", ",", "source", ",", "compressed", "=", "False", ",", "encoding", "=", "'UTF-8'", ")", ":", "buf", "=", "''", "for", "block", "in", "self", ".", "cat", "(", "source", ",", "compressed", "=", "compressed", ",", "encoding", "...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
Translator.translate_escaped_str
Reusable by most interpreters
papermill/translators.py
def translate_escaped_str(cls, str_val): """Reusable by most interpreters""" if isinstance(str_val, string_types): str_val = str_val.encode('unicode_escape') if sys.version_info >= (3, 0): str_val = str_val.decode('utf-8') str_val = str_val.replace('"'...
def translate_escaped_str(cls, str_val): """Reusable by most interpreters""" if isinstance(str_val, string_types): str_val = str_val.encode('unicode_escape') if sys.version_info >= (3, 0): str_val = str_val.decode('utf-8') str_val = str_val.replace('"'...
[ "Reusable", "by", "most", "interpreters" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/translators.py#L38-L45
[ "def", "translate_escaped_str", "(", "cls", ",", "str_val", ")", ":", "if", "isinstance", "(", "str_val", ",", "string_types", ")", ":", "str_val", "=", "str_val", ".", "encode", "(", "'unicode_escape'", ")", "if", "sys", ".", "version_info", ">=", "(", "3...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
Translator.translate
Translate each of the standard json/yaml types to appropiate objects.
papermill/translators.py
def translate(cls, val): """Translate each of the standard json/yaml types to appropiate objects.""" if val is None: return cls.translate_none(val) elif isinstance(val, string_types): return cls.translate_str(val) # Needs to be before integer checks elif i...
def translate(cls, val): """Translate each of the standard json/yaml types to appropiate objects.""" if val is None: return cls.translate_none(val) elif isinstance(val, string_types): return cls.translate_str(val) # Needs to be before integer checks elif i...
[ "Translate", "each", "of", "the", "standard", "json", "/", "yaml", "types", "to", "appropiate", "objects", "." ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/translators.py#L81-L99
[ "def", "translate", "(", "cls", ",", "val", ")", ":", "if", "val", "is", "None", ":", "return", "cls", ".", "translate_none", "(", "val", ")", "elif", "isinstance", "(", "val", ",", "string_types", ")", ":", "return", "cls", ".", "translate_str", "(", ...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
ScalaTranslator.translate_dict
Translate dicts to scala Maps
papermill/translators.py
def translate_dict(cls, val): """Translate dicts to scala Maps""" escaped = ', '.join( ["{} -> {}".format(cls.translate_str(k), cls.translate(v)) for k, v in val.items()] ) return 'Map({})'.format(escaped)
def translate_dict(cls, val): """Translate dicts to scala Maps""" escaped = ', '.join( ["{} -> {}".format(cls.translate_str(k), cls.translate(v)) for k, v in val.items()] ) return 'Map({})'.format(escaped)
[ "Translate", "dicts", "to", "scala", "Maps" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/translators.py#L172-L177
[ "def", "translate_dict", "(", "cls", ",", "val", ")", ":", "escaped", "=", "', '", ".", "join", "(", "[", "\"{} -> {}\"", ".", "format", "(", "cls", ".", "translate_str", "(", "k", ")", ",", "cls", ".", "translate", "(", "v", ")", ")", "for", "k", ...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
ScalaTranslator.translate_list
Translate list to scala Seq
papermill/translators.py
def translate_list(cls, val): """Translate list to scala Seq""" escaped = ', '.join([cls.translate(v) for v in val]) return 'Seq({})'.format(escaped)
def translate_list(cls, val): """Translate list to scala Seq""" escaped = ', '.join([cls.translate(v) for v in val]) return 'Seq({})'.format(escaped)
[ "Translate", "list", "to", "scala", "Seq" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/translators.py#L180-L183
[ "def", "translate_list", "(", "cls", ",", "val", ")", ":", "escaped", "=", "', '", ".", "join", "(", "[", "cls", ".", "translate", "(", "v", ")", "for", "v", "in", "val", "]", ")", "return", "'Seq({})'", ".", "format", "(", "escaped", ")" ]
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
load_notebook_node
Returns a notebook object with papermill metadata loaded from the specified path. Args: notebook_path (str): Path to the notebook file. Returns: nbformat.NotebookNode
papermill/iorw.py
def load_notebook_node(notebook_path): """Returns a notebook object with papermill metadata loaded from the specified path. Args: notebook_path (str): Path to the notebook file. Returns: nbformat.NotebookNode """ nb = nbformat.reads(papermill_io.read(notebook_path), as_version=4) ...
def load_notebook_node(notebook_path): """Returns a notebook object with papermill metadata loaded from the specified path. Args: notebook_path (str): Path to the notebook file. Returns: nbformat.NotebookNode """ nb = nbformat.reads(papermill_io.read(notebook_path), as_version=4) ...
[ "Returns", "a", "notebook", "object", "with", "papermill", "metadata", "loaded", "from", "the", "specified", "path", "." ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/iorw.py#L340-L365
[ "def", "load_notebook_node", "(", "notebook_path", ")", ":", "nb", "=", "nbformat", ".", "reads", "(", "papermill_io", ".", "read", "(", "notebook_path", ")", ",", "as_version", "=", "4", ")", "if", "not", "hasattr", "(", "nb", ".", "metadata", ",", "'pa...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
LocalHandler.cwd
Sets the cwd during reads and writes
papermill/iorw.py
def cwd(self, new_path): '''Sets the cwd during reads and writes''' old_cwd = self._cwd self._cwd = new_path return old_cwd
def cwd(self, new_path): '''Sets the cwd during reads and writes''' old_cwd = self._cwd self._cwd = new_path return old_cwd
[ "Sets", "the", "cwd", "during", "reads", "and", "writes" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/iorw.py#L188-L192
[ "def", "cwd", "(", "self", ",", "new_path", ")", ":", "old_cwd", "=", "self", ".", "_cwd", "self", ".", "_cwd", "=", "new_path", "return", "old_cwd" ]
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
ADL.listdir
Returns a list of the files under the specified path
papermill/adl.py
def listdir(self, url): """Returns a list of the files under the specified path""" (store_name, path) = self._split_url(url) adapter = self._create_adapter(store_name) return [ "adl://{store_name}.azuredatalakestore.net/{path_to_child}".format( store_name=stor...
def listdir(self, url): """Returns a list of the files under the specified path""" (store_name, path) = self._split_url(url) adapter = self._create_adapter(store_name) return [ "adl://{store_name}.azuredatalakestore.net/{path_to_child}".format( store_name=stor...
[ "Returns", "a", "list", "of", "the", "files", "under", "the", "specified", "path" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/adl.py#L38-L47
[ "def", "listdir", "(", "self", ",", "url", ")", ":", "(", "store_name", ",", "path", ")", "=", "self", ".", "_split_url", "(", "url", ")", "adapter", "=", "self", ".", "_create_adapter", "(", "store_name", ")", "return", "[", "\"adl://{store_name}.azuredat...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
ADL.read
Read storage at a given url
papermill/adl.py
def read(self, url): """Read storage at a given url""" (store_name, path) = self._split_url(url) adapter = self._create_adapter(store_name) lines = [] with adapter.open(path) as f: for line in f: lines.append(line.decode()) return lines
def read(self, url): """Read storage at a given url""" (store_name, path) = self._split_url(url) adapter = self._create_adapter(store_name) lines = [] with adapter.open(path) as f: for line in f: lines.append(line.decode()) return lines
[ "Read", "storage", "at", "a", "given", "url" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/adl.py#L49-L57
[ "def", "read", "(", "self", ",", "url", ")", ":", "(", "store_name", ",", "path", ")", "=", "self", ".", "_split_url", "(", "url", ")", "adapter", "=", "self", ".", "_create_adapter", "(", "store_name", ")", "lines", "=", "[", "]", "with", "adapter",...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
ADL.write
Write buffer to storage at a given url
papermill/adl.py
def write(self, buf, url): """Write buffer to storage at a given url""" (store_name, path) = self._split_url(url) adapter = self._create_adapter(store_name) with adapter.open(path, 'wb') as f: f.write(buf.encode())
def write(self, buf, url): """Write buffer to storage at a given url""" (store_name, path) = self._split_url(url) adapter = self._create_adapter(store_name) with adapter.open(path, 'wb') as f: f.write(buf.encode())
[ "Write", "buffer", "to", "storage", "at", "a", "given", "url" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/adl.py#L59-L64
[ "def", "write", "(", "self", ",", "buf", ",", "url", ")", ":", "(", "store_name", ",", "path", ")", "=", "self", ".", "_split_url", "(", "url", ")", "adapter", "=", "self", ".", "_create_adapter", "(", "store_name", ")", "with", "adapter", ".", "open...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
PapermillExecutePreprocessor.preprocess
Wraps the parent class process call slightly
papermill/preprocess.py
def preprocess(self, nb_man, resources, km=None): """ Wraps the parent class process call slightly """ with self.setup_preprocessor(nb_man.nb, resources, km=km): if self.log_output: self.log.info("Executing notebook with kernel: {}".format(self.kernel_name)) ...
def preprocess(self, nb_man, resources, km=None): """ Wraps the parent class process call slightly """ with self.setup_preprocessor(nb_man.nb, resources, km=km): if self.log_output: self.log.info("Executing notebook with kernel: {}".format(self.kernel_name)) ...
[ "Wraps", "the", "parent", "class", "process", "call", "slightly" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/preprocess.py#L14-L26
[ "def", "preprocess", "(", "self", ",", "nb_man", ",", "resources", ",", "km", "=", "None", ")", ":", "with", "self", ".", "setup_preprocessor", "(", "nb_man", ".", "nb", ",", "resources", ",", "km", "=", "km", ")", ":", "if", "self", ".", "log_output...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
PapermillExecutePreprocessor.papermill_process
This function acts as a replacement for the grandparent's `preprocess` method. We are doing this for the following reasons: 1. Notebooks will stop executing when they encounter a failure but not raise a `CellException`. This allows us to save the notebook with the traceba...
papermill/preprocess.py
def papermill_process(self, nb_man, resources): """ This function acts as a replacement for the grandparent's `preprocess` method. We are doing this for the following reasons: 1. Notebooks will stop executing when they encounter a failure but not raise a `CellExcepti...
def papermill_process(self, nb_man, resources): """ This function acts as a replacement for the grandparent's `preprocess` method. We are doing this for the following reasons: 1. Notebooks will stop executing when they encounter a failure but not raise a `CellExcepti...
[ "This", "function", "acts", "as", "a", "replacement", "for", "the", "grandparent", "s", "preprocess", "method", "." ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/preprocess.py#L28-L67
[ "def", "papermill_process", "(", "self", ",", "nb_man", ",", "resources", ")", ":", "# Execute each cell and update the output in real time.", "nb", "=", "nb_man", ".", "nb", "for", "index", ",", "cell", "in", "enumerate", "(", "nb", ".", "cells", ")", ":", "t...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
add_builtin_parameters
Add built-in parameters to a dictionary of parameters Parameters ---------- parameters : dict Dictionary of parameters provided by the user
papermill/parameterize.py
def add_builtin_parameters(parameters): """Add built-in parameters to a dictionary of parameters Parameters ---------- parameters : dict Dictionary of parameters provided by the user """ with_builtin_parameters = { "pm": { "run_uuid": str(uuid4()), "curren...
def add_builtin_parameters(parameters): """Add built-in parameters to a dictionary of parameters Parameters ---------- parameters : dict Dictionary of parameters provided by the user """ with_builtin_parameters = { "pm": { "run_uuid": str(uuid4()), "curren...
[ "Add", "built", "-", "in", "parameters", "to", "a", "dictionary", "of", "parameters" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/parameterize.py#L14-L33
[ "def", "add_builtin_parameters", "(", "parameters", ")", ":", "with_builtin_parameters", "=", "{", "\"pm\"", ":", "{", "\"run_uuid\"", ":", "str", "(", "uuid4", "(", ")", ")", ",", "\"current_datetime_local\"", ":", "datetime", ".", "now", "(", ")", ",", "\"...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
parameterize_path
Format a path with a provided dictionary of parameters Parameters ---------- path : string Path with optional parameters, as a python format string parameters : dict Arbitrary keyword arguments to fill in the path
papermill/parameterize.py
def parameterize_path(path, parameters): """Format a path with a provided dictionary of parameters Parameters ---------- path : string Path with optional parameters, as a python format string parameters : dict Arbitrary keyword arguments to fill in the path """ if parameters i...
def parameterize_path(path, parameters): """Format a path with a provided dictionary of parameters Parameters ---------- path : string Path with optional parameters, as a python format string parameters : dict Arbitrary keyword arguments to fill in the path """ if parameters i...
[ "Format", "a", "path", "with", "a", "provided", "dictionary", "of", "parameters" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/parameterize.py#L36-L52
[ "def", "parameterize_path", "(", "path", ",", "parameters", ")", ":", "if", "parameters", "is", "None", ":", "parameters", "=", "{", "}", "try", ":", "return", "path", ".", "format", "(", "*", "*", "parameters", ")", "except", "KeyError", "as", "key_erro...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
parameterize_notebook
Assigned parameters into the appropriate place in the input notebook Parameters ---------- nb : NotebookNode Executable notebook object parameters : dict Arbitrary keyword arguments to pass as notebook parameters report_mode : bool, optional Flag to set report mode
papermill/parameterize.py
def parameterize_notebook(nb, parameters, report_mode=False): """Assigned parameters into the appropriate place in the input notebook Parameters ---------- nb : NotebookNode Executable notebook object parameters : dict Arbitrary keyword arguments to pass as notebook parameters rep...
def parameterize_notebook(nb, parameters, report_mode=False): """Assigned parameters into the appropriate place in the input notebook Parameters ---------- nb : NotebookNode Executable notebook object parameters : dict Arbitrary keyword arguments to pass as notebook parameters rep...
[ "Assigned", "parameters", "into", "the", "appropriate", "place", "in", "the", "input", "notebook" ]
nteract/papermill
python
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/parameterize.py#L55-L106
[ "def", "parameterize_notebook", "(", "nb", ",", "parameters", ",", "report_mode", "=", "False", ")", ":", "# Load from a file if 'parameters' is a string.", "if", "isinstance", "(", "parameters", ",", "six", ".", "string_types", ")", ":", "parameters", "=", "read_ya...
7423a303f3fa22ec6d03edf5fd9700d659b5a6fa
train
is_modifier
Returns True if `key` is a scan code or name of a modifier key.
keyboard/__init__.py
def is_modifier(key): """ Returns True if `key` is a scan code or name of a modifier key. """ if _is_str(key): return key in all_modifiers else: if not _modifier_scan_codes: scan_codes = (key_to_scan_codes(name, False) for name in all_modifiers) _modifier_sca...
def is_modifier(key): """ Returns True if `key` is a scan code or name of a modifier key. """ if _is_str(key): return key in all_modifiers else: if not _modifier_scan_codes: scan_codes = (key_to_scan_codes(name, False) for name in all_modifiers) _modifier_sca...
[ "Returns", "True", "if", "key", "is", "a", "scan", "code", "or", "name", "of", "a", "modifier", "key", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L133-L143
[ "def", "is_modifier", "(", "key", ")", ":", "if", "_is_str", "(", "key", ")", ":", "return", "key", "in", "all_modifiers", "else", ":", "if", "not", "_modifier_scan_codes", ":", "scan_codes", "=", "(", "key_to_scan_codes", "(", "name", ",", "False", ")", ...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
key_to_scan_codes
Returns a list of scan codes associated with this key (name or scan code).
keyboard/__init__.py
def key_to_scan_codes(key, error_if_missing=True): """ Returns a list of scan codes associated with this key (name or scan code). """ if _is_number(key): return (key,) elif _is_list(key): return sum((key_to_scan_codes(i) for i in key), ()) elif not _is_str(key): raise Val...
def key_to_scan_codes(key, error_if_missing=True): """ Returns a list of scan codes associated with this key (name or scan code). """ if _is_number(key): return (key,) elif _is_list(key): return sum((key_to_scan_codes(i) for i in key), ()) elif not _is_str(key): raise Val...
[ "Returns", "a", "list", "of", "scan", "codes", "associated", "with", "this", "key", "(", "name", "or", "scan", "code", ")", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L296-L324
[ "def", "key_to_scan_codes", "(", "key", ",", "error_if_missing", "=", "True", ")", ":", "if", "_is_number", "(", "key", ")", ":", "return", "(", "key", ",", ")", "elif", "_is_list", "(", "key", ")", ":", "return", "sum", "(", "(", "key_to_scan_codes", ...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
parse_hotkey
Parses a user-provided hotkey into nested tuples representing the parsed structure, with the bottom values being lists of scan codes. Also accepts raw scan codes, which are then wrapped in the required number of nestings. Example: parse_hotkey("alt+shift+a, alt+b, c") # Keys: ^~^...
keyboard/__init__.py
def parse_hotkey(hotkey): """ Parses a user-provided hotkey into nested tuples representing the parsed structure, with the bottom values being lists of scan codes. Also accepts raw scan codes, which are then wrapped in the required number of nestings. Example: parse_hotkey("alt+shift+a...
def parse_hotkey(hotkey): """ Parses a user-provided hotkey into nested tuples representing the parsed structure, with the bottom values being lists of scan codes. Also accepts raw scan codes, which are then wrapped in the required number of nestings. Example: parse_hotkey("alt+shift+a...
[ "Parses", "a", "user", "-", "provided", "hotkey", "into", "nested", "tuples", "representing", "the", "parsed", "structure", "with", "the", "bottom", "values", "being", "lists", "of", "scan", "codes", ".", "Also", "accepts", "raw", "scan", "codes", "which", "...
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L326-L357
[ "def", "parse_hotkey", "(", "hotkey", ")", ":", "if", "_is_number", "(", "hotkey", ")", "or", "len", "(", "hotkey", ")", "==", "1", ":", "scan_codes", "=", "key_to_scan_codes", "(", "hotkey", ")", "step", "=", "(", "scan_codes", ",", ")", "steps", "=",...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
send
Sends OS events that perform the given *hotkey* hotkey. - `hotkey` can be either a scan code (e.g. 57 for space), single key (e.g. 'space') or multi-key, multi-step hotkey (e.g. 'alt+F4, enter'). - `do_press` if true then press events are sent. Defaults to True. - `do_release` if true then release even...
keyboard/__init__.py
def send(hotkey, do_press=True, do_release=True): """ Sends OS events that perform the given *hotkey* hotkey. - `hotkey` can be either a scan code (e.g. 57 for space), single key (e.g. 'space') or multi-key, multi-step hotkey (e.g. 'alt+F4, enter'). - `do_press` if true then press events are sent. ...
def send(hotkey, do_press=True, do_release=True): """ Sends OS events that perform the given *hotkey* hotkey. - `hotkey` can be either a scan code (e.g. 57 for space), single key (e.g. 'space') or multi-key, multi-step hotkey (e.g. 'alt+F4, enter'). - `do_press` if true then press events are sent. ...
[ "Sends", "OS", "events", "that", "perform", "the", "given", "*", "hotkey", "*", "hotkey", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L359-L387
[ "def", "send", "(", "hotkey", ",", "do_press", "=", "True", ",", "do_release", "=", "True", ")", ":", "_listener", ".", "is_replaying", "=", "True", "parsed", "=", "parse_hotkey", "(", "hotkey", ")", "for", "step", "in", "parsed", ":", "if", "do_press", ...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
is_pressed
Returns True if the key is pressed. is_pressed(57) #-> True is_pressed('space') #-> True is_pressed('ctrl+space') #-> True
keyboard/__init__.py
def is_pressed(hotkey): """ Returns True if the key is pressed. is_pressed(57) #-> True is_pressed('space') #-> True is_pressed('ctrl+space') #-> True """ _listener.start_if_necessary() if _is_number(hotkey): # Shortcut. with _pressed_events_lock: ...
def is_pressed(hotkey): """ Returns True if the key is pressed. is_pressed(57) #-> True is_pressed('space') #-> True is_pressed('ctrl+space') #-> True """ _listener.start_if_necessary() if _is_number(hotkey): # Shortcut. with _pressed_events_lock: ...
[ "Returns", "True", "if", "the", "key", "is", "pressed", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L400-L425
[ "def", "is_pressed", "(", "hotkey", ")", ":", "_listener", ".", "start_if_necessary", "(", ")", "if", "_is_number", "(", "hotkey", ")", ":", "# Shortcut.", "with", "_pressed_events_lock", ":", "return", "hotkey", "in", "_pressed_events", "steps", "=", "parse_hot...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
call_later
Calls the provided function in a new thread after waiting some time. Useful for giving the system some time to process an event, without blocking the current execution flow.
keyboard/__init__.py
def call_later(fn, args=(), delay=0.001): """ Calls the provided function in a new thread after waiting some time. Useful for giving the system some time to process an event, without blocking the current execution flow. """ thread = _Thread(target=lambda: (_time.sleep(delay), fn(*args))) thr...
def call_later(fn, args=(), delay=0.001): """ Calls the provided function in a new thread after waiting some time. Useful for giving the system some time to process an event, without blocking the current execution flow. """ thread = _Thread(target=lambda: (_time.sleep(delay), fn(*args))) thr...
[ "Calls", "the", "provided", "function", "in", "a", "new", "thread", "after", "waiting", "some", "time", ".", "Useful", "for", "giving", "the", "system", "some", "time", "to", "process", "an", "event", "without", "blocking", "the", "current", "execution", "fl...
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L427-L434
[ "def", "call_later", "(", "fn", ",", "args", "=", "(", ")", ",", "delay", "=", "0.001", ")", ":", "thread", "=", "_Thread", "(", "target", "=", "lambda", ":", "(", "_time", ".", "sleep", "(", "delay", ")", ",", "fn", "(", "*", "args", ")", ")",...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
hook
Installs a global listener on all available keyboards, invoking `callback` each time a key is pressed or released. The event passed to the callback is of type `keyboard.KeyboardEvent`, with the following attributes: - `name`: an Unicode representation of the character (e.g. "&") or description...
keyboard/__init__.py
def hook(callback, suppress=False, on_remove=lambda: None): """ Installs a global listener on all available keyboards, invoking `callback` each time a key is pressed or released. The event passed to the callback is of type `keyboard.KeyboardEvent`, with the following attributes: - `name`: ...
def hook(callback, suppress=False, on_remove=lambda: None): """ Installs a global listener on all available keyboards, invoking `callback` each time a key is pressed or released. The event passed to the callback is of type `keyboard.KeyboardEvent`, with the following attributes: - `name`: ...
[ "Installs", "a", "global", "listener", "on", "all", "available", "keyboards", "invoking", "callback", "each", "time", "a", "key", "is", "pressed", "or", "released", ".", "The", "event", "passed", "to", "the", "callback", "is", "of", "type", "keyboard", ".", ...
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L437-L466
[ "def", "hook", "(", "callback", ",", "suppress", "=", "False", ",", "on_remove", "=", "lambda", ":", "None", ")", ":", "if", "suppress", ":", "_listener", ".", "start_if_necessary", "(", ")", "append", ",", "remove", "=", "_listener", ".", "blocking_hooks"...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
on_press
Invokes `callback` for every KEY_DOWN event. For details see `hook`.
keyboard/__init__.py
def on_press(callback, suppress=False): """ Invokes `callback` for every KEY_DOWN event. For details see `hook`. """ return hook(lambda e: e.event_type == KEY_UP or callback(e), suppress=suppress)
def on_press(callback, suppress=False): """ Invokes `callback` for every KEY_DOWN event. For details see `hook`. """ return hook(lambda e: e.event_type == KEY_UP or callback(e), suppress=suppress)
[ "Invokes", "callback", "for", "every", "KEY_DOWN", "event", ".", "For", "details", "see", "hook", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L468-L472
[ "def", "on_press", "(", "callback", ",", "suppress", "=", "False", ")", ":", "return", "hook", "(", "lambda", "e", ":", "e", ".", "event_type", "==", "KEY_UP", "or", "callback", "(", "e", ")", ",", "suppress", "=", "suppress", ")" ]
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
on_release
Invokes `callback` for every KEY_UP event. For details see `hook`.
keyboard/__init__.py
def on_release(callback, suppress=False): """ Invokes `callback` for every KEY_UP event. For details see `hook`. """ return hook(lambda e: e.event_type == KEY_DOWN or callback(e), suppress=suppress)
def on_release(callback, suppress=False): """ Invokes `callback` for every KEY_UP event. For details see `hook`. """ return hook(lambda e: e.event_type == KEY_DOWN or callback(e), suppress=suppress)
[ "Invokes", "callback", "for", "every", "KEY_UP", "event", ".", "For", "details", "see", "hook", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L474-L478
[ "def", "on_release", "(", "callback", ",", "suppress", "=", "False", ")", ":", "return", "hook", "(", "lambda", "e", ":", "e", ".", "event_type", "==", "KEY_DOWN", "or", "callback", "(", "e", ")", ",", "suppress", "=", "suppress", ")" ]
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
hook_key
Hooks key up and key down events for a single key. Returns the event handler created. To remove a hooked key use `unhook_key(key)` or `unhook_key(handler)`. Note: this function shares state with hotkeys, so `clear_all_hotkeys` affects it aswell.
keyboard/__init__.py
def hook_key(key, callback, suppress=False): """ Hooks key up and key down events for a single key. Returns the event handler created. To remove a hooked key use `unhook_key(key)` or `unhook_key(handler)`. Note: this function shares state with hotkeys, so `clear_all_hotkeys` affects it aswell. ...
def hook_key(key, callback, suppress=False): """ Hooks key up and key down events for a single key. Returns the event handler created. To remove a hooked key use `unhook_key(key)` or `unhook_key(handler)`. Note: this function shares state with hotkeys, so `clear_all_hotkeys` affects it aswell. ...
[ "Hooks", "key", "up", "and", "key", "down", "events", "for", "a", "single", "key", ".", "Returns", "the", "event", "handler", "created", ".", "To", "remove", "a", "hooked", "key", "use", "unhook_key", "(", "key", ")", "or", "unhook_key", "(", "handler", ...
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L480-L502
[ "def", "hook_key", "(", "key", ",", "callback", ",", "suppress", "=", "False", ")", ":", "_listener", ".", "start_if_necessary", "(", ")", "store", "=", "_listener", ".", "blocking_keys", "if", "suppress", "else", "_listener", ".", "nonblocking_keys", "scan_co...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
on_press_key
Invokes `callback` for KEY_DOWN event related to the given key. For details see `hook`.
keyboard/__init__.py
def on_press_key(key, callback, suppress=False): """ Invokes `callback` for KEY_DOWN event related to the given key. For details see `hook`. """ return hook_key(key, lambda e: e.event_type == KEY_UP or callback(e), suppress=suppress)
def on_press_key(key, callback, suppress=False): """ Invokes `callback` for KEY_DOWN event related to the given key. For details see `hook`. """ return hook_key(key, lambda e: e.event_type == KEY_UP or callback(e), suppress=suppress)
[ "Invokes", "callback", "for", "KEY_DOWN", "event", "related", "to", "the", "given", "key", ".", "For", "details", "see", "hook", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L504-L508
[ "def", "on_press_key", "(", "key", ",", "callback", ",", "suppress", "=", "False", ")", ":", "return", "hook_key", "(", "key", ",", "lambda", "e", ":", "e", ".", "event_type", "==", "KEY_UP", "or", "callback", "(", "e", ")", ",", "suppress", "=", "su...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
on_release_key
Invokes `callback` for KEY_UP event related to the given key. For details see `hook`.
keyboard/__init__.py
def on_release_key(key, callback, suppress=False): """ Invokes `callback` for KEY_UP event related to the given key. For details see `hook`. """ return hook_key(key, lambda e: e.event_type == KEY_DOWN or callback(e), suppress=suppress)
def on_release_key(key, callback, suppress=False): """ Invokes `callback` for KEY_UP event related to the given key. For details see `hook`. """ return hook_key(key, lambda e: e.event_type == KEY_DOWN or callback(e), suppress=suppress)
[ "Invokes", "callback", "for", "KEY_UP", "event", "related", "to", "the", "given", "key", ".", "For", "details", "see", "hook", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L510-L514
[ "def", "on_release_key", "(", "key", ",", "callback", ",", "suppress", "=", "False", ")", ":", "return", "hook_key", "(", "key", ",", "lambda", "e", ":", "e", ".", "event_type", "==", "KEY_DOWN", "or", "callback", "(", "e", ")", ",", "suppress", "=", ...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
unhook_all
Removes all keyboard hooks in use, including hotkeys, abbreviations, word listeners, `record`ers and `wait`s.
keyboard/__init__.py
def unhook_all(): """ Removes all keyboard hooks in use, including hotkeys, abbreviations, word listeners, `record`ers and `wait`s. """ _listener.start_if_necessary() _listener.blocking_keys.clear() _listener.nonblocking_keys.clear() del _listener.blocking_hooks[:] del _listener.hand...
def unhook_all(): """ Removes all keyboard hooks in use, including hotkeys, abbreviations, word listeners, `record`ers and `wait`s. """ _listener.start_if_necessary() _listener.blocking_keys.clear() _listener.nonblocking_keys.clear() del _listener.blocking_hooks[:] del _listener.hand...
[ "Removes", "all", "keyboard", "hooks", "in", "use", "including", "hotkeys", "abbreviations", "word", "listeners", "record", "ers", "and", "wait", "s", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L524-L534
[ "def", "unhook_all", "(", ")", ":", "_listener", ".", "start_if_necessary", "(", ")", "_listener", ".", "blocking_keys", ".", "clear", "(", ")", "_listener", ".", "nonblocking_keys", ".", "clear", "(", ")", "del", "_listener", ".", "blocking_hooks", "[", ":"...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
remap_key
Whenever the key `src` is pressed or released, regardless of modifiers, press or release the hotkey `dst` instead.
keyboard/__init__.py
def remap_key(src, dst): """ Whenever the key `src` is pressed or released, regardless of modifiers, press or release the hotkey `dst` instead. """ def handler(event): if event.event_type == KEY_DOWN: press(dst) else: release(dst) return False retu...
def remap_key(src, dst): """ Whenever the key `src` is pressed or released, regardless of modifiers, press or release the hotkey `dst` instead. """ def handler(event): if event.event_type == KEY_DOWN: press(dst) else: release(dst) return False retu...
[ "Whenever", "the", "key", "src", "is", "pressed", "or", "released", "regardless", "of", "modifiers", "press", "or", "release", "the", "hotkey", "dst", "instead", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L543-L554
[ "def", "remap_key", "(", "src", ",", "dst", ")", ":", "def", "handler", "(", "event", ")", ":", "if", "event", ".", "event_type", "==", "KEY_DOWN", ":", "press", "(", "dst", ")", "else", ":", "release", "(", "dst", ")", "return", "False", "return", ...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
parse_hotkey_combinations
Parses a user-provided hotkey. Differently from `parse_hotkey`, instead of each step being a list of the different scan codes for each key, each step is a list of all possible combinations of those scan codes.
keyboard/__init__.py
def parse_hotkey_combinations(hotkey): """ Parses a user-provided hotkey. Differently from `parse_hotkey`, instead of each step being a list of the different scan codes for each key, each step is a list of all possible combinations of those scan codes. """ def combine_step(step): # A sin...
def parse_hotkey_combinations(hotkey): """ Parses a user-provided hotkey. Differently from `parse_hotkey`, instead of each step being a list of the different scan codes for each key, each step is a list of all possible combinations of those scan codes. """ def combine_step(step): # A sin...
[ "Parses", "a", "user", "-", "provided", "hotkey", ".", "Differently", "from", "parse_hotkey", "instead", "of", "each", "step", "being", "a", "list", "of", "the", "different", "scan", "codes", "for", "each", "key", "each", "step", "is", "a", "list", "of", ...
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L557-L571
[ "def", "parse_hotkey_combinations", "(", "hotkey", ")", ":", "def", "combine_step", "(", "step", ")", ":", "# A single step may be composed of many keys, and each key can have", "# multiple scan codes. To speed up hotkey matching and avoid introducing", "# event delays, we list all possi...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
_add_hotkey_step
Hooks a single-step hotkey (e.g. 'shift+a').
keyboard/__init__.py
def _add_hotkey_step(handler, combinations, suppress): """ Hooks a single-step hotkey (e.g. 'shift+a'). """ container = _listener.blocking_hotkeys if suppress else _listener.nonblocking_hotkeys # Register the scan codes of every possible combination of # modfiier + main key. Modifiers have to b...
def _add_hotkey_step(handler, combinations, suppress): """ Hooks a single-step hotkey (e.g. 'shift+a'). """ container = _listener.blocking_hotkeys if suppress else _listener.nonblocking_hotkeys # Register the scan codes of every possible combination of # modfiier + main key. Modifiers have to b...
[ "Hooks", "a", "single", "-", "step", "hotkey", "(", "e", ".", "g", ".", "shift", "+", "a", ")", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L573-L594
[ "def", "_add_hotkey_step", "(", "handler", ",", "combinations", ",", "suppress", ")", ":", "container", "=", "_listener", ".", "blocking_hotkeys", "if", "suppress", "else", "_listener", ".", "nonblocking_hotkeys", "# Register the scan codes of every possible combination of"...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50