_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q247400 | Plugin.load_plugins | train | def load_plugins():
"""
Load all availabe plugins.
Returns
-------
plugin_cls : dict
mapping from plugin names to plugin classes
"""
plugin_cls = {}
for entry_point in pkg_resources.iter_entry_points('docker_interface.plugins'):
cl... | python | {
"resource": ""
} |
q247401 | SubstitutionPlugin.substitute_variables | train | def substitute_variables(cls, configuration, value, ref):
"""
Substitute variables in `value` from `configuration` where any path reference is relative to
`ref`.
Parameters
----------
configuration : dict
configuration (required to resolve intra-document refe... | python | {
"resource": ""
} |
q247402 | UserPlugin.get_user_group | train | def get_user_group(self, user=None, group=None):
"""
Get the user and group information.
Parameters
----------
user : str
User name or user id (default is the `os.getuid()`).
group : str
Group name or group id (default is the group of `user`).
... | python | {
"resource": ""
} |
q247403 | pretty_str | train | def pretty_str(something, indent=0):
"""Return a human-readable string representation of an object.
Uses `pretty_str` if the given value is an instance of
`CodeEntity` and `repr` otherwise.
Args:
something: Some value to convert.
Kwargs:
indent (int): The | python | {
"resource": ""
} |
q247404 | CodeEntity.walk_preorder | train | def walk_preorder(self):
"""Iterates the program tree starting from this object, going down."""
| python | {
"resource": ""
} |
q247405 | CodeEntity._lookup_parent | train | def _lookup_parent(self, cls):
"""Lookup a transitive parent object that is an instance
of a given class."""
codeobj = self.parent
| python | {
"resource": ""
} |
q247406 | CodeEntity.ast_str | train | def ast_str(self, indent=0):
"""Return a minimal string to print a tree-like structure.
Kwargs:
indent (int): The number of indentation levels.
"""
line = self.line or 0
col = self.column or 0
name = type(self).__name__
spell = getattr(self, 'name', '... | python | {
"resource": ""
} |
q247407 | CodeVariable.is_local | train | def is_local(self):
"""Whether this is a local variable.
In general, a variable is *local* if its containing scope is a
statement (e.g. a block), or a function, given that the variable
is not one of the function's parameters.
"""
| python | {
"resource": ""
} |
q247408 | CodeVariable.is_parameter | train | def is_parameter(self):
"""Whether this is a function parameter."""
return | python | {
"resource": ""
} |
q247409 | CodeFunction._afterpass | train | def _afterpass(self):
"""Assign a function-local index to each child object and register
write operations to variables.
This should only be called after the object is fully built.
"""
if hasattr(self, '_fi'):
return
fi = 0
for codeobj in self.... | python | {
"resource": ""
} |
q247410 | CodeControlFlow._set_condition | train | def _set_condition(self, condition):
"""Set the condition for this control flow structure."""
| python | {
"resource": ""
} |
q247411 | CodeControlFlow._set_body | train | def _set_body(self, body):
"""Set the main body for this control flow structure."""
assert isinstance(body, CodeStatement)
| python | {
"resource": ""
} |
q247412 | CodeConditional.get_branches | train | def get_branches(self):
"""Return a list with the conditional branch and the default branch."""
if self.else_branch:
| python | {
"resource": ""
} |
q247413 | list_files | train | def list_files(path):
"""Recursively collects a list of files at a path."""
files = []
if os.path.isdir(path):
for stats in os.walk(path):
for f in stats[2]:
| python | {
"resource": ""
} |
q247414 | ResultCollection.dump | train | def dump(self):
"""Returns the results in string format."""
text = ''
for result in self.objects:
if result.is_failure or result.is_error:
text += '\n#{red}#{bright}'
text += '{}\n'.format(''.ljust(79, '='))
status = 'FAILED' if resul... | python | {
"resource": ""
} |
q247415 | ResultCollection.dump_junit | train | def dump_junit(self):
"""Returns a string containing XML mapped to the JUnit schema."""
testsuites = ElementTree.Element('testsuites', name='therapist', time=str(round(self.execution_time, 2)),
tests=str(self.count()), failures=str(self.count(status=Result.FAILUR... | python | {
"resource": ""
} |
q247416 | install | train | def install(**kwargs):
"""Install the pre-commit hook."""
force = kwargs.get('force')
preserve_legacy = kwargs.get('preserve_legacy')
colorama.init(strip=kwargs.get('no_color'))
stdout = subprocess.check_output('which therapist', shell=True)
therapist_bin = stdout.decode('utf-8').split()[0]
... | python | {
"resource": ""
} |
q247417 | uninstall | train | def uninstall(**kwargs):
"""Uninstall the current pre-commit hook."""
force = kwargs.get('force')
restore_legacy = kwargs.get('restore_legacy')
colorama.init(strip=kwargs.get('no_color'))
git_dir = current_git_dir()
if git_dir is None:
output(NOT_GIT_REPO_MSG)
exit(1)
hoo... | python | {
"resource": ""
} |
q247418 | run | train | def run(**kwargs):
"""Run the Therapist suite."""
paths = kwargs.pop('paths', ())
action = kwargs.pop('action')
plugin = kwargs.pop('plugin')
junit_xml = kwargs.pop('junit_xml')
use_tracked_files = kwargs.pop('use_tracked_files')
quiet = kwargs.pop('quiet')
colorama.init(strip=kwargs.po... | python | {
"resource": ""
} |
q247419 | use | train | def use(ctx, shortcut):
"""Use a shortcut."""
git_dir = current_git_dir()
if git_dir is None:
output(NOT_GIT_REPO_MSG)
exit(1)
repo_root = os.path.dirname(git_dir)
config = get_config(repo_root)
try:
use_shortcut = config.shortcuts.get(shortcut)
while use_sho... | python | {
"resource": ""
} |
q247420 | identify_hook | train | def identify_hook(path):
"""Verify that the file at path is the therapist hook and return the hash"""
with open(path, 'r') as f:
f.readline() # Discard the shebang line
| python | {
"resource": ""
} |
q247421 | hash_hook | train | def hash_hook(path, options):
"""Hash a hook file"""
with open(path, 'r') as f:
data = f.read()
for key in sorted(iterkeys(options)):
| python | {
"resource": ""
} |
q247422 | Runner.run_process | train | def run_process(self, process):
"""Runs a single action."""
message = u'#{bright}'
message += u'{} '.format(str(process)[:68]).ljust(69, '.')
stashed = False
if self.unstaged_changes and not self.include_unstaged_changes:
out, err, code = self.git.stash(keep_index=Tr... | python | {
"resource": ""
} |
q247423 | SOAP._extract_upnperror | train | def _extract_upnperror(self, err_xml):
"""
Extract the error code and error description from an error returned by the device.
"""
nsmap = {'s': list(err_xml.nsmap.values())[0]}
fault_str = err_xml.findtext(
's:Body/s:Fault/faultstring', namespaces=nsmap)
try:
... | python | {
"resource": ""
} |
q247424 | SOAP._remove_extraneous_xml_declarations | train | def _remove_extraneous_xml_declarations(xml_str):
"""
Sometimes devices return XML with more than one XML declaration in, such as when returning
their own XML config files. This removes the extra ones and preserves the first one.
"""
xml_declaration = ''
if xml_str.starts... | python | {
"resource": ""
} |
q247425 | SOAP.call | train | def call(self, action_name, arg_in=None, http_auth=None, http_headers=None):
"""
Construct the XML and make the call to the device. Parse the response values into a dict.
"""
if arg_in is None:
arg_in = {}
soap_env = '{%s}' % NS_SOAP_ENV
m = '{%s}' % self.ser... | python | {
"resource": ""
} |
q247426 | Device._read_services | train | def _read_services(self):
"""
Read the control XML file and populate self.services with a list of
services in the form of Service class instances.
"""
# The double slash in the XPath is deliberate, as services can be
# listed in two places (Section 2.3 of uPNP device arch... | python | {
"resource": ""
} |
q247427 | Device.find_action | train | def find_action(self, action_name):
"""Find an action by name.
Convenience method that searches through all the services offered by
the Server for an action and returns an Action instance. If the action
is not found, returns None. If multiple actions with the same name are
found ... | python | {
"resource": ""
} |
q247428 | Service.subscribe | train | def subscribe(self, callback_url, timeout=None):
"""
Set up a subscription to the events offered by this service.
"""
url = urljoin(self._url_base, self._event_sub_url)
headers = dict(
HOST=urlparse(url).netloc,
| python | {
"resource": ""
} |
q247429 | Service.renew_subscription | train | def renew_subscription(self, sid, timeout=None):
"""
Renews a previously configured subscription.
"""
url = urljoin(self._url_base, self._event_sub_url)
headers = dict(
HOST=urlparse(url).netloc,
SID=sid
)
if timeout is not None:
| python | {
"resource": ""
} |
q247430 | Service.cancel_subscription | train | def cancel_subscription(self, sid):
"""
Unsubscribes from a previously configured subscription.
"""
url = urljoin(self._url_base, self._event_sub_url)
headers = dict(
HOST=urlparse(url).netloc,
| python | {
"resource": ""
} |
q247431 | discover | train | def discover(timeout=5):
"""
Convenience method to discover UPnP devices on the network. Returns a
list of `upnp.Device` instances. Any invalid servers are silently
ignored.
"""
devices = {}
for entry in scan(timeout):
if entry.location in devices:
continue
| python | {
"resource": ""
} |
q247432 | DFA.to_dot | train | def to_dot(self, path: str, title: Optional[str] = None):
"""
Print the automaton to a dot file
:param path: the path where to save the file.
:param title:
:return:
"""
g = graphviz.Digraph(format='svg')
g.node('fake', style='invisible')
for state... | python | {
"resource": ""
} |
q247433 | DFA.levels_to_accepting_states | train | def levels_to_accepting_states(self) -> dict:
"""Return a dict from states to level, i.e. the number of steps to reach any accepting state.
level = -1 if the state cannot reach any accepting state"""
res = {accepting_state: 0 for accepting_state in self._accepting_states}
level = 0
... | python | {
"resource": ""
} |
q247434 | NFA.determinize | train | def determinize(self) -> DFA:
"""Determinize the NFA
:return: the DFA equivalent to the DFA.
"""
nfa = self
new_states = {macro_state for macro_state in powerset(nfa._states)}
initial_state = frozenset([nfa._initial_state])
final_states = {q for q in new_states... | python | {
"resource": ""
} |
q247435 | Client.req | train | def req(self, method, params=()):
"""send request to ppcoind"""
response = self.session.post(
self.url,
data=json.dumps({"method": method, "params": params, "jsonrpc": "1.1"}),
).json()
| python | {
"resource": ""
} |
q247436 | Client.batch | train | def batch(self, reqs):
""" send batch request using jsonrpc 2.0 """
batch_data = []
for req_id, req in enumerate(reqs):
batch_data.append(
{"method": req[0], "params": req[1], "jsonrpc": "2.0", "id": req_id}
| python | {
"resource": ""
} |
q247437 | Client.walletpassphrase | train | def walletpassphrase(self, passphrase, timeout=99999999, mint_only=True):
| python | {
"resource": ""
} |
q247438 | Client.getblock | train | def getblock(self, blockhash, decode=False):
"""returns detail block info."""
if not decode:
decode = "false"
| python | {
"resource": ""
} |
q247439 | Client.sendfrom | train | def sendfrom(self, account, address, amount):
"""send outgoing tx from | python | {
"resource": ""
} |
q247440 | Client.listtransactions | train | def listtransactions(self, account="", many=999, since=0):
"""list all transactions associated with this wallet"""
| python | {
"resource": ""
} |
q247441 | Client.verifymessage | train | def verifymessage(self, address, signature, message):
"""Verify a signed message."""
| python | {
"resource": ""
} |
q247442 | coroutine | train | def coroutine(f):
"""
A sink should be send `None` first, so that the coroutine arrives
at the `yield` position. This wrapper takes care that this is done
automatically when the coroutine is started.
| python | {
"resource": ""
} |
q247443 | Fail.add_call | train | def add_call(self, func):
"""Add a call to the trace."""
self.trace.append("{} ({}:{})".format(
object_name(func),
| python | {
"resource": ""
} |
q247444 | all | train | def all(pred: Callable, xs: Iterable):
"""
Check whether all the elements of the iterable `xs`
fullfill predicate `pred`.
:param pred:
predicate function
:param xs:
iterable object.
:returns: | python | {
"resource": ""
} |
q247445 | any | train | def any(pred: Callable, xs: Iterable):
"""
Check if at least one element of the iterable `xs`
fullfills predicate `pred`.
| python | {
"resource": ""
} |
q247446 | map | train | def map(fun: Callable, xs: Iterable):
"""
Traverse an iterable object applying function `fun`
to each element and finally creats a workflow from it.
:param fun:
function to call in each element of the iterable
object.
:param xs:
| python | {
"resource": ""
} |
q247447 | zip_with | train | def zip_with(fun: Callable, xs: Iterable, ys: Iterable):
"""
Fuse two Iterable object using the function `fun`.
Notice that if the two objects have different len,
the shortest object gives the result's shape.
:param fun:
function taking two argument use to process
element x from `xs` ... | python | {
"resource": ""
} |
q247448 | _arg_to_str | train | def _arg_to_str(arg):
"""Convert argument to a string."""
if isinstance(arg, str):
return _sugar(repr(arg))
elif arg is | python | {
"resource": ""
} |
q247449 | is_node_ready | train | def is_node_ready(node):
"""Returns True if none of the argument holders contain any `Empty` object.
"""
| python | {
"resource": ""
} |
q247450 | JobDB.add_job_to_db | train | def add_job_to_db(self, key, job):
"""Add job info to the database."""
job_msg = self.registry.deep_encode(job)
prov = prov_key(job_msg)
def set_link(duplicate_id):
self.cur.execute(
'update "jobs" set "link" = ?, "status" = ? where "id" = ?',
... | python | {
"resource": ""
} |
q247451 | JobDB.job_exists | train | def job_exists(self, prov):
"""Check if a job exists in the database."""
with self.lock:
self.cur.execute('select * from "jobs" where "prov" | python | {
"resource": ""
} |
q247452 | JobDB.store_result_in_db | train | def store_result_in_db(self, result, always_cache=True):
"""Store a result in the database."""
job = self[result.key]
def extend_dependent_links():
with self.lock:
new_workflow_id = id(get_workflow(result.value))
self.links[new_workflow_id].extend(
... | python | {
"resource": ""
} |
q247453 | JobDB.add_time_stamp | train | def add_time_stamp(self, db_id, name):
"""Add a timestamp to the database."""
with self.lock:
| python | {
"resource": ""
} |
q247454 | static_sum | train | def static_sum(values, limit_n=1000):
"""Example of static sum routine."""
if len(values) < limit_n:
return sum(values)
else:
half = len(values) // 2
return add(
| python | {
"resource": ""
} |
q247455 | dynamic_sum | train | def dynamic_sum(values, limit_n=1000, acc=0, depth=4):
"""Example of dynamic sum."""
if len(values) < limit_n:
return acc + sum(values)
if depth > 0:
half = len(values) // 2
return add(
dynamic_sum(values[:half], limit_n, acc, depth=depth-1),
| python | {
"resource": ""
} |
q247456 | Queue.flush | train | def flush(self):
"""Erases queue and set `end-of-queue` message."""
while not self._queue.empty():
| python | {
"resource": ""
} |
q247457 | find_links_to | train | def find_links_to(links, node):
"""Find links to a node.
:param links:
forward links of a workflow
:type links: Mapping[NodeId, Set[(NodeId, ArgumentType, [int|str]])]
:param node:
index to a node
:type node: int
:returns:
dictionary of | python | {
"resource": ""
} |
q247458 | _all_valid | train | def _all_valid(links):
"""Iterates over all links, forgetting emtpy registers."""
for k, v | python | {
"resource": ""
} |
q247459 | from_call | train | def from_call(foo, args, kwargs, hints, call_by_value=True):
"""Takes a function and a set of arguments it needs to run on. Returns a newly
constructed workflow representing the promised value from the evaluation of
the function with said arguments.
These arguments are stored in a BoundArguments object... | python | {
"resource": ""
} |
q247460 | make_logger | train | def make_logger(name, stream_type, jobs):
"""Create a logger component.
:param name: name of logger child, i.e. logger will be named
`noodles.<name>`.
:type name: str
:param stream_type: type of the stream that this logger will
be inserted into, should be |pull_map| or |push_map|.
:... | python | {
"resource": ""
} |
q247461 | run_process | train | def run_process(workflow, *, n_processes, registry,
verbose=False, jobdirs=False,
init=None, finish=None, deref=False):
"""Run the workflow using a number of new python processes. Use this
runner to test the workflow in a situation where data serial
is needed.
:param wor... | python | {
"resource": ""
} |
q247462 | xenon_interactive_worker | train | def xenon_interactive_worker(
machine, worker_config, input_queue=None, stderr_sink=None):
"""Uses Xenon to run a single remote interactive worker.
Jobs are read from stdin, and results written to stdout.
:param machine:
Specification of the machine on which to run.
:type machine: nood... | python | {
"resource": ""
} |
q247463 | XenonInteractiveWorker.wait_until_running | train | def wait_until_running(self, callback=None):
"""Waits until the remote worker is running, then calls the callback.
Usually, this method is passed to a different thread; the callback
is then a function patching results through to the result queue."""
| python | {
"resource": ""
} |
q247464 | DynamicPool.add_xenon_worker | train | def add_xenon_worker(self, worker_config):
"""Adds a worker to the pool; sets gears in motion."""
c = XenonInteractiveWorker(self.machine, worker_config)
w = RemoteWorker(
worker_config.name, threading.Lock(),
worker_config.n_threads, [], *c.setup())
with self.wl... | python | {
"resource": ""
} |
q247465 | find_first | train | def find_first(pred, lst):
"""Find the first result of a list of promises `lst` that satisfies a
predicate `pred`.
:param pred: a function of one argument returning `True` or `False`.
:param lst: a list of promises or values.
:return: a promise of a value or `None`.
This is a wrapper around :f... | python | {
"resource": ""
} |
q247466 | s_find_first | train | def s_find_first(pred, first, lst):
"""Evaluate `first`; if predicate `pred` succeeds on the result of `first`,
return the result; otherwise recur on the first element of `lst`.
:param pred: a predicate. | python | {
"resource": ""
} |
q247467 | run_online_mode | train | def run_online_mode(args):
"""Run jobs.
:param args: arguments resulting from program ArgumentParser.
:return: None
This reads messages containing job descriptions from standard input,
and writes messages to standard output containing the result.
Messages can be encoded as either JSON or Mess... | python | {
"resource": ""
} |
q247468 | _format_arg_list | train | def _format_arg_list(args, variadic=False):
"""Format a list of arguments for pretty printing.
:param a: list of arguments.
:type a: list
:param v: tell if the function accepts variadic arguments
:type v: bool
"""
def sugar(s):
"""Shorten strings that are too long for decency."""
... | python | {
"resource": ""
} |
q247469 | get_workflow_graph | train | def get_workflow_graph(promise):
"""Get a graph of a promise."""
workflow = get_workflow(promise)
dot = Digraph()
for i, n in workflow.nodes.items():
dot.node(str(i), label="{0} \n {1}".format(
n.foo.__name__,
_format_arg_list(n.bound_args.args)))
for i | python | {
"resource": ""
} |
q247470 | display_workflows | train | def display_workflows(prefix, **kwargs):
"""Display workflows in a table. This generates SVG files. Use this in a
Jupyter notebook and ship the images
:param prefix: name prefix for svg files generated.
:param kwargs: keyword arguments containing a workflow each.
"""
from IPython.display import... | python | {
"resource": ""
} |
q247471 | snip_line | train | def snip_line(line, max_width, split_at):
"""Shorten a line to a maximum length."""
if len(line) < max_width:
return line | python | {
"resource": ""
} |
q247472 | run_and_print_log | train | def run_and_print_log(workflow, highlight=None):
"""Run workflow on multi-threaded worker cached with Sqlite3.
:param workflow: workflow to evaluate.
:param highlight: highlight these lines.
"""
from noodles.run.threading.sqlite3 import run_parallel
from noodles import serial
import io
... | python | {
"resource": ""
} |
q247473 | run_single_with_display | train | def run_single_with_display(wf, display):
"""Adds a display to the single runner. Everything still runs in a single
thread. Every time a job is pulled by the worker, a message goes to the
display routine; when | python | {
"resource": ""
} |
q247474 | run_parallel_with_display | train | def run_parallel_with_display(wf, n_threads, display):
"""Adds a display to the parallel runner. Because messages come in
asynchronously now, we start an extra thread just for the display
routine."""
LogQ = Queue()
S = Scheduler(error_handler=display.error_handler)
threading.Thread(
ta... | python | {
"resource": ""
} |
q247475 | decorator | train | def decorator(f):
"""Creates a paramatric decorator from a function. The resulting decorator
will optionally take keyword arguments."""
@functools.wraps(f)
def decoratored_function(*args, **kwargs):
if args and len(args) == 1:
return f(*args, **kwargs)
| python | {
"resource": ""
} |
q247476 | Scheduler.run | train | def run(self, connection: Connection, master: Workflow):
"""Run a workflow.
:param connection:
A connection giving a sink to the job-queue and a source yielding
results.
:type connection: Connection
:param master:
The workflow.
:type master: ... | python | {
"resource": ""
} |
q247477 | ref_argument | train | def ref_argument(bound_args, address):
""" Taking a bound_args object, and an ArgumentAddress, retrieves the data
currently stored in bound_args for this particular address."""
if address.kind == ArgumentKind.regular:
| python | {
"resource": ""
} |
q247478 | set_argument | train | def set_argument(bound_args, address, value):
""" Taking a bound_args object, and an |ArgumentAddress| and a value, sets
the value pointed to by the address to `value`."""
if address.kind == ArgumentKind.regular:
bound_args.arguments[address.name] = value
return
if address.kind == Argum... | python | {
"resource": ""
} |
q247479 | format_address | train | def format_address(address):
"""Formats an ArgumentAddress for human reading."""
| python | {
"resource": ""
} |
q247480 | run_parallel | train | def run_parallel(workflow, n_threads):
"""Run a workflow in parallel threads.
:param workflow: Workflow or PromisedObject to evaluate.
:param n_threads: number of threads to use (in addition to the scheduler).
:returns: evaluated workflow.
| python | {
"resource": ""
} |
q247481 | thread_counter | train | def thread_counter(finalize):
"""Modifies a thread target function, such that the number of active
threads is counted. If the count reaches zero, a finalizer is called."""
n_threads = 0
lock = threading.Lock()
def target_modifier(target):
@functools.wraps(target)
def modified_target... | python | {
"resource": ""
} |
q247482 | thread_pool | train | def thread_pool(*workers, results=None, end_of_queue=EndOfQueue):
"""Returns a |pull| object, call it ``r``, starting a thread for each given
worker. Each thread pulls from the source that ``r`` is connected to, and
the returned results are pushed to a |Queue|. ``r`` yields from the other
end of the s... | python | {
"resource": ""
} |
q247483 | run | train | def run(wf, *, display, n_threads=1):
"""Run the workflow using the dynamic-exclusion worker."""
worker | python | {
"resource": ""
} |
q247484 | create_object | train | def create_object(cls, members):
"""Promise an object of class `cls` with content `members`."""
obj = | python | {
"resource": ""
} |
q247485 | lift | train | def lift(obj, memo=None):
"""Make a promise out of object `obj`, where `obj` may contain promises
internally.
:param obj: Any object.
:param memo: used for internal caching (similar to :func:`deepcopy`).
If the object is a :class:`PromisedObject`, or *pass-by-value*
(:class:`str`, :class:`int`... | python | {
"resource": ""
} |
q247486 | branch | train | def branch(*sinks_):
"""The |branch| decorator creates a |pull| object that pulls from a single
source and then sends to all the sinks given. After all the sinks received
the message, it is yielded.
.. |branch| replace:: :py:func:`branch`
"""
@pull
def junction(source):
| python | {
"resource": ""
} |
q247487 | broadcast | train | def broadcast(*sinks_):
"""The |broadcast| decorator creates a |push| object that receives a
message by ``yield`` and then sends this message on to all the given sinks.
.. |broadcast| replace:: :py:func:`broadcast`
"""
@push
def bc():
sinks = | python | {
"resource": ""
} |
q247488 | push_from | train | def push_from(iterable):
"""Creates a |push| object from an iterable. The resulting function
is not a coroutine, but can be chained to another |push|.
:param iterable: an iterable object.
:type iterable: :py:class:`~collections.abc.Iterable`
:rtype: |push|
| python | {
"resource": ""
} |
q247489 | patch | train | def patch(source, sink):
"""Create a direct link between a source and a sink.
Implementation::
sink = sink()
for value in source():
| python | {
"resource": ""
} |
q247490 | conditional | train | def conditional(
b: bool,
branch_true: Any,
branch_false: Any=None) -> Any:
"""
Control statement to follow a branch
in workflow. Equivalent to the `if` statement
in standard Python.
The quote function delay the evaluation of the branches
until the boolean is evaluated.
... | python | {
"resource": ""
} |
q247491 | schedule_branches | train | def schedule_branches(b: bool, quoted_true, quoted_false):
"""
Helper function to choose which workflow to execute
based on the boolean `b`.
:param b:
promised boolean value
:param quoted_true:
quoted workflow to eval if the boolean is true.
:param quoted_true:
| python | {
"resource": ""
} |
q247492 | array_sha256 | train | def array_sha256(a):
"""Create a SHA256 hash from a Numpy array."""
dtype = str(a.dtype).encode()
shape = numpy.array(a.shape)
sha = hashlib.sha256()
| python | {
"resource": ""
} |
q247493 | arrays_to_file | train | def arrays_to_file(file_prefix=None):
"""Returns a serialisation registry for serialising NumPy data and
as well as any UFuncs that have no normal way of retrieving
| python | {
"resource": ""
} |
q247494 | arrays_to_string | train | def arrays_to_string(file_prefix=None):
"""Returns registry for serialising arrays as a Base64 string."""
return Registry(
| python | {
"resource": ""
} |
q247495 | arrays_to_hdf5 | train | def arrays_to_hdf5(filename="cache.hdf5"):
"""Returns registry for serialising arrays to a HDF5 reference."""
return Registry(
| python | {
"resource": ""
} |
q247496 | run_xenon_simple | train | def run_xenon_simple(workflow, machine, worker_config):
"""Run a workflow using a single Xenon remote worker.
:param workflow: |Workflow| or |PromisedObject| to evaluate.
:param machine: |Machine| instance.
:param worker_config: Configuration for the pilot | python | {
"resource": ""
} |
q247497 | run_xenon | train | def run_xenon(
workflow, *, machine, worker_config, n_processes, deref=False,
verbose=False):
"""Run the workflow using a number of online Xenon workers.
:param workflow: |Workflow| or |PromisedObject| to evaluate.
:param machine: The |Machine| instance.
:param worker_config: Configurat... | python | {
"resource": ""
} |
q247498 | pass_job | train | def pass_job(db: JobDB, result_queue: Queue, always_cache=False):
"""Create a pull stream that receives jobs and passes them on to the
database. If the job already has a result, that result is pushed onto
the `result_queue`.
"""
@pull
def pass_job_stream(job_source):
"""Pull stream insta... | python | {
"resource": ""
} |
q247499 | pass_result | train | def pass_result(db: JobDB, always_cache=False):
"""Creates a pull stream receiving results, storing them in the database,
then sending them on. At this stage, the database may return a list of
attached jobs which also need to be sent on to the scheduler."""
@pull
def pass_result_stream(worker_source... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.