sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def terminate(self):
"""Delete all files created by this server, invalidating `self`. Use with care."""
logger.info("deleting entire server %s" % self)
self.close()
try:
shutil.rmtree(self.basedir)
logger.info("deleted server under %s" % self.basedir)
... | Delete all files created by this server, invalidating `self`. Use with care. | entailment |
def find_similar(self, *args, **kwargs):
"""
Find similar articles.
With autosession off, use the index state *before* current session started,
so that changes made in the session will not be visible here. With autosession
on, close the current session first (so that session cha... | Find similar articles.
With autosession off, use the index state *before* current session started,
so that changes made in the session will not be visible here. With autosession
on, close the current session first (so that session changes *are* committed
and visible). | entailment |
async def profile(self, ctx, platform, name):
'''Fetch a profile.'''
player = await self.client.get_player(platform, name)
solos = await player.get_solos()
await ctx.send("# of kills in solos for {}: {}".format(name,solos.kills.value)) | Fetch a profile. | entailment |
def start(io_loop=None, check_time=2):
"""Begins watching source files for changes.
.. versionchanged:: 4.1
The ``io_loop`` argument is deprecated.
"""
io_loop = io_loop or asyncio.get_event_loop()
if io_loop in _io_loops:
return
_io_loops[io_loop] = True
if len(_io_loops) >... | Begins watching source files for changes.
.. versionchanged:: 4.1
The ``io_loop`` argument is deprecated. | entailment |
def generate_chunks(data, chunk_size=DEFAULT_CHUNK_SIZE):
"""Yield 'chunk_size' items from 'data' at a time."""
iterator = iter(repeated.getvalues(data))
while True:
chunk = list(itertools.islice(iterator, chunk_size))
if not chunk:
return
yield chunk | Yield 'chunk_size' items from 'data' at a time. | entailment |
def reduce(reducer, data, chunk_size=DEFAULT_CHUNK_SIZE):
"""Repeatedly call fold and merge on data and then finalize.
Arguments:
data: Input for the fold function.
reducer: The IReducer to use.
chunk_size: How many items should be passed to fold at a time?
Returns:
Return ... | Repeatedly call fold and merge on data and then finalize.
Arguments:
data: Input for the fold function.
reducer: The IReducer to use.
chunk_size: How many items should be passed to fold at a time?
Returns:
Return value of finalize. | entailment |
def conditions(self):
"""The if-else pairs."""
for idx in six.moves.range(1, len(self.children), 2):
yield (self.children[idx - 1], self.children[idx]) | The if-else pairs. | entailment |
def resolve_placeholders(path, placeholder_dict):
"""
**Purpose**: Substitute placeholders in staging attributes of a Task with actual paths to the corresponding tasks.
:arguments:
:path: string describing the staging paths, possibly containing a placeholder
:placeholder_dict: dictionary ho... | **Purpose**: Substitute placeholders in staging attributes of a Task with actual paths to the corresponding tasks.
:arguments:
:path: string describing the staging paths, possibly containing a placeholder
:placeholder_dict: dictionary holding the values for placeholders | entailment |
def get_input_list_from_task(task, placeholder_dict):
"""
Purpose: Parse a Task object to extract the files to be staged as the output.
Details: The extracted data is then converted into the appropriate RP directive depending on whether the data
is to be copied/downloaded.
:arguments:
:tas... | Purpose: Parse a Task object to extract the files to be staged as the output.
Details: The extracted data is then converted into the appropriate RP directive depending on whether the data
is to be copied/downloaded.
:arguments:
:task: EnTK Task object
:placeholder_dict: dictionary holding ... | entailment |
def get_output_list_from_task(task, placeholder_dict):
"""
Purpose: Parse a Task object to extract the files to be staged as the output.
Details: The extracted data is then converted into the appropriate RP directive depending on whether the data
is to be copied/downloaded.
:arguments:
:ta... | Purpose: Parse a Task object to extract the files to be staged as the output.
Details: The extracted data is then converted into the appropriate RP directive depending on whether the data
is to be copied/downloaded.
:arguments:
:task: EnTK Task object
:placeholder_dict: dictionary holding ... | entailment |
def create_cud_from_task(task, placeholder_dict, prof=None):
"""
Purpose: Create a Compute Unit description based on the defined Task.
:arguments:
:task: EnTK Task object
:placeholder_dict: dictionary holding the values for placeholders
:return: ComputeUnitDescription
"""
try:... | Purpose: Create a Compute Unit description based on the defined Task.
:arguments:
:task: EnTK Task object
:placeholder_dict: dictionary holding the values for placeholders
:return: ComputeUnitDescription | entailment |
def create_task_from_cu(cu, prof=None):
"""
Purpose: Create a Task based on the Compute Unit.
Details: Currently, only the uid, parent_stage and parent_pipeline are retrieved. The exact initial Task (that was
converted to a CUD) cannot be recovered as the RP API does not provide the same attributes for... | Purpose: Create a Task based on the Compute Unit.
Details: Currently, only the uid, parent_stage and parent_pipeline are retrieved. The exact initial Task (that was
converted to a CUD) cannot be recovered as the RP API does not provide the same attributes for a CU as for a CUD.
Also, this is not required f... | entailment |
def handle_noargs(self, **options):
"""Send Report E-mails."""
r = get_r()
since = datetime.utcnow() - timedelta(days=1)
metrics = {}
categories = r.metric_slugs_by_category()
for category_name, slug_list in categories.items():
metrics[category_name] = []
... | Send Report E-mails. | entailment |
def luid(self):
"""
Unique ID of the current stage (fully qualified).
example:
>>> stage.luid
pipe.0001.stage.0004
:getter: Returns the fully qualified uid of the current stage
:type: String
"""
p_elem = self.parent_pipeline.get('name')
... | Unique ID of the current stage (fully qualified).
example:
>>> stage.luid
pipe.0001.stage.0004
:getter: Returns the fully qualified uid of the current stage
:type: String | entailment |
def add_tasks(self, value):
"""
Adds tasks to the existing set of tasks of the Stage
:argument: set of tasks
"""
tasks = self._validate_entities(value)
self._tasks.update(tasks)
self._task_count = len(self._tasks) | Adds tasks to the existing set of tasks of the Stage
:argument: set of tasks | entailment |
def to_dict(self):
"""
Convert current Stage into a dictionary
:return: python dictionary
"""
stage_desc_as_dict = {
'uid': self._uid,
'name': self._name,
'state': self._state,
'state_history': self._state_history,
'p... | Convert current Stage into a dictionary
:return: python dictionary | entailment |
def from_dict(self, d):
"""
Create a Stage from a dictionary. The change is in inplace.
:argument: python dictionary
:return: None
"""
if 'uid' in d:
if d['uid']:
self._uid = d['uid']
if 'name' in d:
if d['name']:
... | Create a Stage from a dictionary. The change is in inplace.
:argument: python dictionary
:return: None | entailment |
def _set_tasks_state(self, value):
"""
Purpose: Set state of all tasks of the current stage.
:arguments: String
"""
if value not in states.state_numbers.keys():
raise ValueError(obj=self._uid,
attribute='set_tasks_state',
... | Purpose: Set state of all tasks of the current stage.
:arguments: String | entailment |
def _check_stage_complete(self):
"""
Purpose: Check if all tasks of the current stage have completed, i.e., are in either DONE or FAILED state.
"""
try:
for task in self._tasks:
if task.state not in [states.DONE, states.FAILED]:
return Fa... | Purpose: Check if all tasks of the current stage have completed, i.e., are in either DONE or FAILED state. | entailment |
def _validate_entities(self, tasks):
"""
Purpose: Validate whether the 'tasks' is of type set. Validate the description of each Task.
"""
if not tasks:
raise TypeError(expected_type=Task, actual_type=type(tasks))
if not isinstance(tasks, set):
if not is... | Purpose: Validate whether the 'tasks' is of type set. Validate the description of each Task. | entailment |
def _assign_uid(self, sid):
"""
Purpose: Assign a uid to the current object based on the sid passed. Pass the current uid to children of
current object
"""
self._uid = ru.generate_id('stage.%(item_counter)04d', ru.ID_CUSTOM, namespace=sid)
for task in self._tasks:
... | Purpose: Assign a uid to the current object based on the sid passed. Pass the current uid to children of
current object | entailment |
def _pass_uid(self):
"""
Purpose: Assign the parent Stage and the parent Pipeline to all the tasks of the current stage.
:arguments: set of Tasks (optional)
:return: list of updated Tasks
"""
for task in self._tasks:
task.parent_stage['uid'] = self._uid
... | Purpose: Assign the parent Stage and the parent Pipeline to all the tasks of the current stage.
:arguments: set of Tasks (optional)
:return: list of updated Tasks | entailment |
def application(tokens):
"""Matches function call (application)."""
tokens = iter(tokens)
func = next(tokens)
paren = next(tokens)
if func and func.name == "symbol" and paren.name == "lparen":
# We would be able to unambiguously parse function application with
# whitespace between t... | Matches function call (application). | entailment |
def _make_spec_file(self):
"""Generates the text of an RPM spec file.
Returns:
A list of strings containing the lines of text.
"""
# Note that bdist_rpm can be an old style class.
if issubclass(BdistRPMCommand, object):
spec_file = super(BdistRPMCommand, se... | Generates the text of an RPM spec file.
Returns:
A list of strings containing the lines of text. | entailment |
def resolve(self, name):
"""Call IStructured.resolve across all scopes and return first hit."""
for scope in reversed(self.scopes):
try:
return structured.resolve(scope, name)
except (KeyError, AttributeError):
continue
raise AttributeErro... | Call IStructured.resolve across all scopes and return first hit. | entailment |
def getmembers(self):
"""Gets members (vars) from all scopes, using both runtime and static.
This method will attempt both static and runtime getmembers. This is the
recommended way of getting available members.
Returns:
Set of available vars.
Raises:
N... | Gets members (vars) from all scopes, using both runtime and static.
This method will attempt both static and runtime getmembers. This is the
recommended way of getting available members.
Returns:
Set of available vars.
Raises:
NotImplementedError if any scope f... | entailment |
def getmembers_runtime(self):
"""Gets members (vars) from all scopes using ONLY runtime information.
You most likely want to use ScopeStack.getmembers instead.
Returns:
Set of available vars.
Raises:
NotImplementedError if any scope fails to implement 'getmembe... | Gets members (vars) from all scopes using ONLY runtime information.
You most likely want to use ScopeStack.getmembers instead.
Returns:
Set of available vars.
Raises:
NotImplementedError if any scope fails to implement 'getmembers'. | entailment |
def getmembers_static(cls):
"""Gets members (vars) from all scopes using ONLY static information.
You most likely want to use ScopeStack.getmembers instead.
Returns:
Set of available vars.
Raises:
NotImplementedError if any scope fails to implement 'getmembers'... | Gets members (vars) from all scopes using ONLY static information.
You most likely want to use ScopeStack.getmembers instead.
Returns:
Set of available vars.
Raises:
NotImplementedError if any scope fails to implement 'getmembers'. | entailment |
def reflect(self, name):
"""Reflect 'name' starting with local scope all the way up to global.
This method will attempt both static and runtime reflection. This is the
recommended way of using reflection.
Returns:
Type of 'name', or protocol.AnyType.
Caveat:
... | Reflect 'name' starting with local scope all the way up to global.
This method will attempt both static and runtime reflection. This is the
recommended way of using reflection.
Returns:
Type of 'name', or protocol.AnyType.
Caveat:
The type of 'name' does not ne... | entailment |
def reflect_runtime_member(self, name):
"""Reflect 'name' using ONLY runtime reflection.
You most likely want to use ScopeStack.reflect instead.
Returns:
Type of 'name', or protocol.AnyType.
"""
for scope in reversed(self.scopes):
try:
re... | Reflect 'name' using ONLY runtime reflection.
You most likely want to use ScopeStack.reflect instead.
Returns:
Type of 'name', or protocol.AnyType. | entailment |
def reflect_static_member(cls, name):
"""Reflect 'name' using ONLY static reflection.
You most likely want to use ScopeStack.reflect instead.
Returns:
Type of 'name', or protocol.AnyType.
"""
for scope in reversed(cls.scopes):
try:
return... | Reflect 'name' using ONLY static reflection.
You most likely want to use ScopeStack.reflect instead.
Returns:
Type of 'name', or protocol.AnyType. | entailment |
def get_hostmap(profile):
'''
We abuse the profile combination to also derive a pilot-host map, which
will tell us on what exact host each pilot has been running. To do so, we
check for the PMGR_ACTIVE advance event in agent_0.prof, and use the NTP
sync info to associate a hostname.
'''
# F... | We abuse the profile combination to also derive a pilot-host map, which
will tell us on what exact host each pilot has been running. To do so, we
check for the PMGR_ACTIVE advance event in agent_0.prof, and use the NTP
sync info to associate a hostname. | entailment |
def get_hostmap_deprecated(profiles):
'''
This method mangles combine_profiles and get_hostmap, and is deprecated. At
this point it only returns the hostmap
'''
hostmap = dict() # map pilot IDs to host names
for pname, prof in profiles.iteritems():
if not len(prof):
conti... | This method mangles combine_profiles and get_hostmap, and is deprecated. At
this point it only returns the hostmap | entailment |
def run(self):
"""
**Purpose**: Run the application manager. Once the workflow and resource manager have been assigned. Invoking this
method will start the setting up the communication infrastructure, submitting a resource request and then
submission of all the tasks.
"""
... | **Purpose**: Run the application manager. Once the workflow and resource manager have been assigned. Invoking this
method will start the setting up the communication infrastructure, submitting a resource request and then
submission of all the tasks. | entailment |
def _setup_mqs(self):
"""
**Purpose**: Setup RabbitMQ system on the client side. We instantiate queue(s) 'pendingq-*' for communication
between the enqueuer thread and the task manager process. We instantiate queue(s) 'completedq-*' for
communication between the task manager and dequeuer... | **Purpose**: Setup RabbitMQ system on the client side. We instantiate queue(s) 'pendingq-*' for communication
between the enqueuer thread and the task manager process. We instantiate queue(s) 'completedq-*' for
communication between the task manager and dequeuer thread. We instantiate queue 'sync-to-mas... | entailment |
def _synchronizer(self):
"""
**Purpose**: Thread in the master process to keep the workflow data
structure in appmanager up to date. We receive pipelines, stages and
tasks objects directly. The respective object is updated in this master
process.
Details: Important to no... | **Purpose**: Thread in the master process to keep the workflow data
structure in appmanager up to date. We receive pipelines, stages and
tasks objects directly. The respective object is updated in this master
process.
Details: Important to note that acknowledgements of the type
... | entailment |
def categorize_metrics(self):
"""Called only on a valid form, this method will place the chosen
metrics in the given catgory."""
category = self.cleaned_data['category_name']
metrics = self.cleaned_data['metrics']
self.r.reset_category(category, metrics) | Called only on a valid form, this method will place the chosen
metrics in the given catgory. | entailment |
def _submit_resource_request(self):
"""
**Purpose**: Create and submits a RADICAL Pilot Job as per the user
provided resource description
"""
try:
self._prof.prof('creating rreq', uid=self._uid)
def _pilot_state_cb(pilot, state):
... | **Purpose**: Create and submits a RADICAL Pilot Job as per the user
provided resource description | entailment |
def _terminate_resource_request(self):
"""
**Purpose**: Cancel the RADICAL Pilot Job
"""
try:
if self._pilot:
self._prof.prof('canceling resource allocation', uid=self._uid)
self._pilot.cancel()
download_rp_profile = os.envir... | **Purpose**: Cancel the RADICAL Pilot Job | entailment |
def get_list(self, size=100, startIndex=0, searchText="", sortProperty="", sortOrder='ASC', status='Active,Pending'):
"""
Request service locations
Returns
-------
dict
"""
url = urljoin(BASEURL, "sites", "list")
params = {
'api_key': self.t... | Request service locations
Returns
-------
dict | entailment |
def match(self, f, *args):
"""Match grammar function 'f' against next token and set 'self.matched'.
Arguments:
f: A grammar function - see efilter.parsers.common.grammar. Must
return TokenMatch or None.
args: Passed to 'f', if any.
Returns:
I... | Match grammar function 'f' against next token and set 'self.matched'.
Arguments:
f: A grammar function - see efilter.parsers.common.grammar. Must
return TokenMatch or None.
args: Passed to 'f', if any.
Returns:
Instance of efilter.parsers.common.gram... | entailment |
def accept(self, f, *args):
"""Like 'match', but consume the token (tokenizer advances.)"""
match = self.match(f, *args)
if match is None:
return
self.tokenizer.skip(len(match.tokens))
return match | Like 'match', but consume the token (tokenizer advances.) | entailment |
def reject(self, f, *args):
"""Like 'match', but throw a parse error if 'f' matches.
This is useful when a parser wants to be strict about specific things
being prohibited. For example, DottySQL bans the use of SQL keywords as
variable names.
"""
match = self.match(f, *a... | Like 'match', but throw a parse error if 'f' matches.
This is useful when a parser wants to be strict about specific things
being prohibited. For example, DottySQL bans the use of SQL keywords as
variable names. | entailment |
def expect(self, f, *args):
"""Like 'accept' but throws a parse error if 'f' doesn't match."""
match = self.accept(f, *args)
if match:
return match
try:
func_name = f.func_name
except AttributeError:
func_name = "<unnamed grammar function>"
... | Like 'accept' but throws a parse error if 'f' doesn't match. | entailment |
def current_position(self):
"""Return a tuple of (start, end)."""
token = self.tokenizer.peek(0)
if token:
return token.start, token.end
return self.tokenizer.position, self.tokenizer.position + 1 | Return a tuple of (start, end). | entailment |
def ComplementEquivalence(*args, **kwargs):
"""Change x != y to not(x == y)."""
return ast.Complement(
ast.Equivalence(*args, **kwargs), **kwargs) | Change x != y to not(x == y). | entailment |
def ComplementMembership(*args, **kwargs):
"""Change (x not in y) to not(x in y)."""
return ast.Complement(
ast.Membership(*args, **kwargs), **kwargs) | Change (x not in y) to not(x in y). | entailment |
def ReverseComplementMembership(x, y, **kwargs):
"""Change (x doesn't contain y) to not(y in x)."""
return ast.Complement(
ast.Membership(y, x, **kwargs), **kwargs) | Change (x doesn't contain y) to not(y in x). | entailment |
def __solve_for_repeated(expr, vars):
"""Helper: solve 'expr' always returning an IRepeated.
If the result of solving 'expr' is a list or a tuple of IStructured objects
then treat is as a repeated value of IStructured objects because that's
what the called meant to do. This is a convenience helper so u... | Helper: solve 'expr' always returning an IRepeated.
If the result of solving 'expr' is a list or a tuple of IStructured objects
then treat is as a repeated value of IStructured objects because that's
what the called meant to do. This is a convenience helper so users of the
API don't have to create IRep... | entailment |
def __solve_for_scalar(expr, vars):
"""Helper: solve 'expr' always returning a scalar (not IRepeated).
If the output of 'expr' is a single value or a single RowTuple with a single
column then return the value in that column. Otherwise raise.
Arguments:
expr: Expression to solve.
vars: ... | Helper: solve 'expr' always returning a scalar (not IRepeated).
If the output of 'expr' is a single value or a single RowTuple with a single
column then return the value in that column. Otherwise raise.
Arguments:
expr: Expression to solve.
vars: The scope.
Returns:
A scalar v... | entailment |
def __solve_and_destructure_repeated(expr, vars):
"""Helper: solve 'expr' always returning a list of scalars.
If the output of 'expr' is one or more row tuples with only a single column
then return a repeated value of values in that column. If there are more
than one column per row then raise.
Thi... | Helper: solve 'expr' always returning a list of scalars.
If the output of 'expr' is one or more row tuples with only a single column
then return a repeated value of values in that column. If there are more
than one column per row then raise.
This returns a list because there's no point in wrapping the... | entailment |
def solve_var(expr, vars):
"""Returns the value of the var named in the expression."""
try:
return Result(structured.resolve(vars, expr.value), ())
except (KeyError, AttributeError) as e:
# Raise a better exception for accessing a non-existent member.
raise errors.EfilterKeyError(roo... | Returns the value of the var named in the expression. | entailment |
def solve_select(expr, vars):
"""Use IAssociative.select to get key (rhs) from the data (lhs).
This operation supports both scalars and repeated values on the LHS -
selecting from a repeated value implies a map-like operation and returns a
new repeated value.
"""
data, _ = __solve_for_repeated(... | Use IAssociative.select to get key (rhs) from the data (lhs).
This operation supports both scalars and repeated values on the LHS -
selecting from a repeated value implies a map-like operation and returns a
new repeated value. | entailment |
def solve_resolve(expr, vars):
"""Use IStructured.resolve to get member (rhs) from the object (lhs).
This operation supports both scalars and repeated values on the LHS -
resolving from a repeated value implies a map-like operation and returns a
new repeated values.
"""
objs, _ = __solve_for_re... | Use IStructured.resolve to get member (rhs) from the object (lhs).
This operation supports both scalars and repeated values on the LHS -
resolving from a repeated value implies a map-like operation and returns a
new repeated values. | entailment |
def solve_apply(expr, vars):
"""Returns the result of applying function (lhs) to its arguments (rest).
We use IApplicative to apply the function, because that gives the host
application an opportunity to compare the function being called against
a whitelist. EFILTER will never directly call a function ... | Returns the result of applying function (lhs) to its arguments (rest).
We use IApplicative to apply the function, because that gives the host
application an opportunity to compare the function being called against
a whitelist. EFILTER will never directly call a function that wasn't
provided through a p... | entailment |
def solve_bind(expr, vars):
"""Build a RowTuple from key/value pairs under the bind.
The Bind subtree is arranged as follows:
Bind
| First KV Pair
| | First Key Expression
| | First Value Expression
| Second KV Pair
| | Second Key Expression
| | Second Value Expression
Etc...
... | Build a RowTuple from key/value pairs under the bind.
The Bind subtree is arranged as follows:
Bind
| First KV Pair
| | First Key Expression
| | First Value Expression
| Second KV Pair
| | Second Key Expression
| | Second Value Expression
Etc...
As we evaluate the subtree, eac... | entailment |
def solve_repeat(expr, vars):
"""Build a repeated value from subexpressions."""
try:
result = repeated.meld(*[solve(x, vars).value for x in expr.children])
return Result(result, ())
except TypeError:
raise errors.EfilterTypeError(
root=expr, query=expr.source,
... | Build a repeated value from subexpressions. | entailment |
def solve_tuple(expr, vars):
"""Build a tuple from subexpressions."""
result = tuple(solve(x, vars).value for x in expr.children)
return Result(result, ()) | Build a tuple from subexpressions. | entailment |
def solve_ifelse(expr, vars):
"""Evaluate conditions and return the one that matches."""
for condition, result in expr.conditions():
if boolean.asbool(solve(condition, vars).value):
return solve(result, vars)
return solve(expr.default(), vars) | Evaluate conditions and return the one that matches. | entailment |
def solve_map(expr, vars):
"""Solves the map-form, by recursively calling its RHS with new vars.
let-forms are binary expressions. The LHS should evaluate to an IAssociative
that can be used as new vars with which to solve a new query, of which
the RHS is the root. In most cases, the LHS will be a Var ... | Solves the map-form, by recursively calling its RHS with new vars.
let-forms are binary expressions. The LHS should evaluate to an IAssociative
that can be used as new vars with which to solve a new query, of which
the RHS is the root. In most cases, the LHS will be a Var (var).
Typically, map-forms r... | entailment |
def solve_let(expr, vars):
"""Solves a let-form by calling RHS with nested scope."""
lhs_value = solve(expr.lhs, vars).value
if not isinstance(lhs_value, structured.IStructured):
raise errors.EfilterTypeError(
root=expr.lhs, query=expr.original,
message="The LHS of 'let' must... | Solves a let-form by calling RHS with nested scope. | entailment |
def solve_filter(expr, vars):
"""Filter values on the LHS by evaluating RHS with each value.
Returns any LHS values for which RHS evaluates to a true value.
"""
lhs_values, _ = __solve_for_repeated(expr.lhs, vars)
def lazy_filter():
for lhs_value in repeated.getvalues(lhs_values):
... | Filter values on the LHS by evaluating RHS with each value.
Returns any LHS values for which RHS evaluates to a true value. | entailment |
def solve_sort(expr, vars):
"""Sort values on the LHS by the value they yield when passed to RHS."""
lhs_values = repeated.getvalues(__solve_for_repeated(expr.lhs, vars)[0])
sort_expression = expr.rhs
def _key_func(x):
return solve(sort_expression, __nest_scope(expr.lhs, vars, x)).value
r... | Sort values on the LHS by the value they yield when passed to RHS. | entailment |
def solve_each(expr, vars):
"""Return True if RHS evaluates to a true value with each state of LHS.
If LHS evaluates to a normal IAssociative object then this is the same as
a regular let-form, except the return value is always a boolean. If LHS
evaluates to a repeared var (see efilter.protocols.repeat... | Return True if RHS evaluates to a true value with each state of LHS.
If LHS evaluates to a normal IAssociative object then this is the same as
a regular let-form, except the return value is always a boolean. If LHS
evaluates to a repeared var (see efilter.protocols.repeated) of
IAssociative objects the... | entailment |
def solve_cast(expr, vars):
"""Get cast LHS to RHS."""
lhs = solve(expr.lhs, vars).value
t = solve(expr.rhs, vars).value
if t is None:
raise errors.EfilterTypeError(
root=expr, query=expr.source,
message="Cannot find type named %r." % expr.rhs.value)
if not isinstan... | Get cast LHS to RHS. | entailment |
def solve_isinstance(expr, vars):
"""Typecheck whether LHS is type on the RHS."""
lhs = solve(expr.lhs, vars)
try:
t = solve(expr.rhs, vars).value
except errors.EfilterKeyError:
t = None
if t is None:
raise errors.EfilterTypeError(
root=expr.rhs, query=expr.sour... | Typecheck whether LHS is type on the RHS. | entailment |
def set_version(mod_root):
"""
mod_root
a VERSION file containes the version strings is created in mod_root,
during installation. That file is used at runtime to get the version
information.
"""
try:
version_base = None
version_detail = None
# ge... | mod_root
a VERSION file containes the version strings is created in mod_root,
during installation. That file is used at runtime to get the version
information. | entailment |
def makeDataFiles(prefix, dir):
""" Create distutils data_files structure from dir
distutil will copy all file rooted under dir into prefix, excluding
dir itself, just like 'ditto src dst' works, and unlike 'cp -r src
dst, which copy src into dst'.
Typical usage:
# install the contents of 'w... | Create distutils data_files structure from dir
distutil will copy all file rooted under dir into prefix, excluding
dir itself, just like 'ditto src dst' works, and unlike 'cp -r src
dst, which copy src into dst'.
Typical usage:
# install the contents of 'wiki' under sys.prefix+'share/moin'
... | entailment |
def visit((prefix, strip, found), dirname, names):
""" Visit directory, create distutil tuple
Add distutil tuple for each directory using this format:
(destination, [dirname/file1, dirname/file2, ...])
distutil will copy later file1, file2, ... info destination.
"""
files = []
# Iterate ... | Visit directory, create distutil tuple
Add distutil tuple for each directory using this format:
(destination, [dirname/file1, dirname/file2, ...])
distutil will copy later file1, file2, ... info destination. | entailment |
def isgood(name):
""" Whether name should be installed """
if not isbad(name):
if name.endswith('.py') or name.endswith('.json') or name.endswith('.tar'):
return True
return False | Whether name should be installed | entailment |
def _initialize_workflow(self):
"""
**Purpose**: Initialize the PST of the workflow with a uid and type checks
"""
try:
self._prof.prof('initializing workflow', uid=self._uid)
for p in self._workflow:
p._assign_uid(self._sid)
self._... | **Purpose**: Initialize the PST of the workflow with a uid and type checks | entailment |
def _enqueue(self, local_prof):
"""
**Purpose**: This is the function that is run in the enqueue thread. This function extracts Tasks from the
copy of workflow that exists in the WFprocessor object and pushes them to the queues in the pending_q list.
Since this thread works on the copy o... | **Purpose**: This is the function that is run in the enqueue thread. This function extracts Tasks from the
copy of workflow that exists in the WFprocessor object and pushes them to the queues in the pending_q list.
Since this thread works on the copy of the workflow, every state update to the Task, Stag... | entailment |
def _dequeue(self, local_prof):
"""
**Purpose**: This is the function that is run in the dequeue thread. This function extracts Tasks from the
completed queus and updates the copy of workflow that exists in the WFprocessor object.
Since this thread works on the copy of the workflow, ever... | **Purpose**: This is the function that is run in the dequeue thread. This function extracts Tasks from the
completed queus and updates the copy of workflow that exists in the WFprocessor object.
Since this thread works on the copy of the workflow, every state update to the Task, Stage and Pipeline is
... | entailment |
def _wfp(self):
"""
**Purpose**: This is the function executed in the wfp process. The function is used to simply create
and spawn two threads: enqueue, dequeue. The enqueue thread pushes ready tasks to the queues in the pending_q slow
list whereas the dequeue thread pulls completed task... | **Purpose**: This is the function executed in the wfp process. The function is used to simply create
and spawn two threads: enqueue, dequeue. The enqueue thread pushes ready tasks to the queues in the pending_q slow
list whereas the dequeue thread pulls completed tasks from the queues in the completed_q... | entailment |
def start_processor(self):
"""
**Purpose**: Method to start the wfp process. The wfp function
is not to be accessed directly. The function is started in a separate
process using this method.
"""
if not self._wfp_process:
try:
self._prof.prof... | **Purpose**: Method to start the wfp process. The wfp function
is not to be accessed directly. The function is started in a separate
process using this method. | entailment |
def terminate_processor(self):
"""
**Purpose**: Method to terminate the wfp process. This method is
blocking as it waits for the wfp process to terminate (aka join).
"""
try:
if self.check_processor():
self._logger.debug(
'Attempt... | **Purpose**: Method to terminate the wfp process. This method is
blocking as it waits for the wfp process to terminate (aka join). | entailment |
def workflow_incomplete(self):
"""
**Purpose**: Method to check if the workflow execution is incomplete.
"""
try:
for pipe in self._workflow:
with pipe.lock:
if pipe.completed:
pass
else:
... | **Purpose**: Method to check if the workflow execution is incomplete. | entailment |
def meld(*values):
"""Return the repeated value, or the first value if there's only one.
This is a convenience function, equivalent to calling
getvalue(repeated(x)) to get x.
This function skips over instances of None in values (None is not allowed
in repeated variables).
Examples:
me... | Return the repeated value, or the first value if there's only one.
This is a convenience function, equivalent to calling
getvalue(repeated(x)) to get x.
This function skips over instances of None in values (None is not allowed
in repeated variables).
Examples:
meld("foo", "bar") # => List... | entailment |
def getvalue(x):
"""Return the single value of x or raise TypError if more than one value."""
if isrepeating(x):
raise TypeError(
"Ambiguous call to getvalue for %r which has more than one value."
% x)
for value in getvalues(x):
return value | Return the single value of x or raise TypError if more than one value. | entailment |
def luid(self):
"""
Unique ID of the current task (fully qualified).
example:
>>> task.luid
pipe.0001.stage.0004.task.0234
:getter: Returns the fully qualified uid of the current task
:type: String
"""
p_elem = self.parent_pipeline.get('n... | Unique ID of the current task (fully qualified).
example:
>>> task.luid
pipe.0001.stage.0004.task.0234
:getter: Returns the fully qualified uid of the current task
:type: String | entailment |
def to_dict(self):
"""
Convert current Task into a dictionary
:return: python dictionary
"""
task_desc_as_dict = {
'uid': self._uid,
'name': self._name,
'state': self._state,
'state_history': self._state_history,
'pre... | Convert current Task into a dictionary
:return: python dictionary | entailment |
def from_dict(self, d):
"""
Create a Task from a dictionary. The change is in inplace.
:argument: python dictionary
:return: None
"""
if 'uid' in d:
if d['uid']:
self._uid = d['uid']
if 'name' in d:
if d['name']:
... | Create a Task from a dictionary. The change is in inplace.
:argument: python dictionary
:return: None | entailment |
def _assign_uid(self, sid):
"""
Purpose: Assign a uid to the current object based on the sid passed
"""
self._uid = ru.generate_id(
'task.%(item_counter)04d', ru.ID_CUSTOM, namespace=sid) | Purpose: Assign a uid to the current object based on the sid passed | entailment |
def _validate(self):
"""
Purpose: Validate that the state of the task is 'DESCRIBED' and that an executable has been specified for the
task.
"""
if self._state is not states.INITIAL:
raise ValueError(obj=self._uid,
attribute='state',
... | Purpose: Validate that the state of the task is 'DESCRIBED' and that an executable has been specified for the
task. | entailment |
def _process_tasks(self, task_queue, rmgr, logger, mq_hostname, port, local_prof, sid):
'''
**Purpose**: The new thread that gets spawned by the main tmgr process invokes this function. This
function receives tasks from 'task_queue' and submits them to the RADICAL Pilot RTS.
'''
... | **Purpose**: The new thread that gets spawned by the main tmgr process invokes this function. This
function receives tasks from 'task_queue' and submits them to the RADICAL Pilot RTS. | entailment |
def infer_type(expr, scope):
"""Try to infer the type of x[y] if y is a known value (literal)."""
# Do we know what the key even is?
if isinstance(expr.key, ast.Literal):
key = expr.key.value
else:
return protocol.AnyType
container_type = infer_type(expr.value, scope)
try:
... | Try to infer the type of x[y] if y is a known value (literal). | entailment |
def infer_type(expr, scope):
"""Try to infer the type of x.y if y is a known value (literal)."""
# Do we know what the member is?
if isinstance(expr.member, ast.Literal):
member = expr.member.value
else:
return protocol.AnyType
container_type = infer_type(expr.obj, scope)
try:
... | Try to infer the type of x.y if y is a known value (literal). | entailment |
def _tmgr(self, uid, rmgr, logger, mq_hostname, port, pending_queue, completed_queue):
"""
**Purpose**: Method to be run by the tmgr process. This method receives a Task from the pending_queue
and submits it to the RTS. Currently, it also converts Tasks into CUDs and CUs into (partially describe... | **Purpose**: Method to be run by the tmgr process. This method receives a Task from the pending_queue
and submits it to the RTS. Currently, it also converts Tasks into CUDs and CUs into (partially described) Tasks.
This conversion is necessary since the current RTS is RADICAL Pilot. Once Tasks are recov... | entailment |
def start_manager(self):
"""
**Purpose**: Method to start the tmgr process. The tmgr function
is not to be accessed directly. The function is started in a separate
thread using this method.
"""
if not self._tmgr_process:
try:
self._prof.prof... | **Purpose**: Method to start the tmgr process. The tmgr function
is not to be accessed directly. The function is started in a separate
thread using this method. | entailment |
def keyword(tokens, expected):
"""Case-insensitive keyword match."""
try:
token = next(iter(tokens))
except StopIteration:
return
if token and token.name == "symbol" and token.value.lower() == expected:
return TokenMatch(None, token.value, (token,)) | Case-insensitive keyword match. | entailment |
def multi_keyword(tokens, keyword_parts):
"""Match a case-insensitive keyword consisting of multiple tokens."""
tokens = iter(tokens)
matched_tokens = []
limit = len(keyword_parts)
for idx in six.moves.range(limit):
try:
token = next(tokens)
except StopIteration:
... | Match a case-insensitive keyword consisting of multiple tokens. | entailment |
def prefix(tokens, operator_table):
"""Match a prefix of an operator."""
operator, matched_tokens = operator_table.prefix.match(tokens)
if operator:
return TokenMatch(operator, None, matched_tokens) | Match a prefix of an operator. | entailment |
def infix(tokens, operator_table):
"""Match an infix of an operator."""
operator, matched_tokens = operator_table.infix.match(tokens)
if operator:
return TokenMatch(operator, None, matched_tokens) | Match an infix of an operator. | entailment |
def suffix(tokens, operator_table):
"""Match a suffix of an operator."""
operator, matched_tokens = operator_table.suffix.match(tokens)
if operator:
return TokenMatch(operator, None, matched_tokens) | Match a suffix of an operator. | entailment |
def token_name(tokens, expected):
"""Match a token name (type)."""
try:
token = next(iter(tokens))
except StopIteration:
return
if token and token.name == expected:
return TokenMatch(None, token.value, (token,)) | Match a token name (type). | entailment |
def match_tokens(expected_tokens):
"""Generate a grammar function that will match 'expected_tokens' only."""
if isinstance(expected_tokens, Token):
# Match a single token.
def _grammar_func(tokens):
try:
next_token = next(iter(tokens))
except StopIteration... | Generate a grammar function that will match 'expected_tokens' only. | entailment |
def set_metric(slug, value, category=None, expire=None, date=None):
"""Create/Increment a metric."""
get_r().set_metric(slug, value, category=category, expire=expire, date=date) | Create/Increment a metric. | entailment |
def metric(slug, num=1, category=None, expire=None, date=None):
"""Create/Increment a metric."""
get_r().metric(slug, num=num, category=category, expire=expire, date=date) | Create/Increment a metric. | entailment |
def expression(self, previous_precedence=0):
"""An expression is an atom or an infix expression.
Grammar (sort of, actually a precedence-climbing parser):
expression = atom [ binary_operator expression ] .
Args:
previous_precedence: What operator precedence should we st... | An expression is an atom or an infix expression.
Grammar (sort of, actually a precedence-climbing parser):
expression = atom [ binary_operator expression ] .
Args:
previous_precedence: What operator precedence should we start with? | entailment |
def atom(self):
"""Parse an atom, which is most things.
Grammar:
atom =
[ prefix ]
( select_expression
| any_expression
| func_application
| let_expr
| var
| literal
... | Parse an atom, which is most things.
Grammar:
atom =
[ prefix ]
( select_expression
| any_expression
| func_application
| let_expr
| var
| literal
| list
|... | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.