_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q251000
get_compounds
train
def get_compounds(identifier, namespace='cid', searchtype=None, as_dataframe=False, **kwargs): """Retrieve the specified compound records from PubChem. :param identifier: The compound identifier to use as a search query. :param namespace: (optional) The identifier type, one of cid, name, smiles, sdf, inchi...
python
{ "resource": "" }
q251001
get_substances
train
def get_substances(identifier, namespace='sid', as_dataframe=False, **kwargs): """Retrieve the specified substance records from PubChem. :param identifier: The substance identifier to use as a search query. :param namespace: (optional) The identifier type, one of sid, name or sourceid/<source name>. :p...
python
{ "resource": "" }
q251002
get_assays
train
def get_assays(identifier, namespace='aid', **kwargs): """Retrieve the specified assay records from PubChem. :param identifier: The assay identifier to use as a search query. :param namespace: (optional) The identifier type.
python
{ "resource": "" }
q251003
get_properties
train
def get_properties(properties, identifier, namespace='cid', searchtype=None, as_dataframe=False, **kwargs): """Retrieve the specified properties from PubChem. :param identifier: The compound, substance or assay identifier to use as a search query. :param namespace: (optional) The identifier type. :para...
python
{ "resource": "" }
q251004
deprecated
train
def deprecated(message=None): """Decorator to mark functions as deprecated. A warning will be emitted when the function is used.""" def deco(func): @functools.wraps(func) def wrapped(*args, **kwargs): warnings.warn( message or 'Call to deprecated function
python
{ "resource": "" }
q251005
_parse_prop
train
def _parse_prop(search, proplist): """Extract property value from record using the given urn search filter.""" props =
python
{ "resource": "" }
q251006
Atom.to_dict
train
def to_dict(self): """Return a dictionary containing Atom data.""" data = {'aid': self.aid, 'number': self.number, 'element': self.element} for coord in {'x', 'y', 'z'}: if getattr(self, coord) is not None:
python
{ "resource": "" }
q251007
Atom.set_coordinates
train
def set_coordinates(self, x, y, z=None): """Set all coordinate dimensions at once."""
python
{ "resource": "" }
q251008
Bond.to_dict
train
def to_dict(self): """Return a dictionary containing Bond data.""" data = {'aid1': self.aid1, 'aid2': self.aid2, 'order': self.order}
python
{ "resource": "" }
q251009
Compound._setup_atoms
train
def _setup_atoms(self): """Derive Atom objects from the record.""" # Delete existing atoms self._atoms = {} # Create atoms aids = self.record['atoms']['aid'] elements = self.record['atoms']['element'] if not len(aids) == len(elements): raise ResponsePa...
python
{ "resource": "" }
q251010
Compound._setup_bonds
train
def _setup_bonds(self): """Derive Bond objects from the record.""" self._bonds = {} if 'bonds' not in self.record: return # Create bonds aid1s = self.record['bonds']['aid1'] aid2s = self.record['bonds']['aid2'] orders = self.record['bonds']['order'] ...
python
{ "resource": "" }
q251011
Compound.from_cid
train
def from_cid(cls, cid, **kwargs): """Retrieve the Compound record for the specified CID. Usage:: c = Compound.from_cid(6819)
python
{ "resource": "" }
q251012
Compound.to_dict
train
def to_dict(self, properties=None): """Return a dictionary containing Compound data. Optionally specify a list of the desired properties. synonyms, aids and sids are not included unless explicitly specified using the properties parameter. This is
python
{ "resource": "" }
q251013
Compound.synonyms
train
def synonyms(self): """A ranked list of all the names associated with this Compound. Requires an extra request. Result is cached. """ if self.cid: results = get_json(self.cid,
python
{ "resource": "" }
q251014
Substance.from_sid
train
def from_sid(cls, sid): """Retrieve the Substance record for the specified SID. :param int sid: The PubChem Substance Identifier (SID). """
python
{ "resource": "" }
q251015
Substance.to_dict
train
def to_dict(self, properties=None): """Return a dictionary containing Substance data. If the properties parameter is not specified, everything except cids and aids is included. This is because the aids and cids properties each require an extra request to retrieve. :param properties: (o...
python
{ "resource": "" }
q251016
Assay.from_aid
train
def from_aid(cls, aid): """Retrieve the Assay record for the specified AID. :param int aid: The PubChem Assay Identifier (AID). """
python
{ "resource": "" }
q251017
Assay.to_dict
train
def to_dict(self, properties=None): """Return a dictionary containing Assay data. If the properties parameter is not specified, everything is included. :param properties: (optional) A list of the desired properties. """ if not properties:
python
{ "resource": "" }
q251018
_is_possible_token
train
def _is_possible_token(token, token_length=6): """Determines if given value is acceptable as a token. Used when validating tokens. Currently allows only numeric tokens no longer than 6 chars. :param token: token value to be checked :type token: int or str :param token_length: allowed length of...
python
{ "resource": "" }
q251019
get_hotp
train
def get_hotp( secret, intervals_no, as_string=False, casefold=True, digest_method=hashlib.sha1, token_length=6, ): """ Get HMAC-based one-time password on the basis of given secret and interval number. :param secret: the base32-encoded string acting as se...
python
{ "resource": "" }
q251020
get_totp
train
def get_totp( secret, as_string=False, digest_method=hashlib.sha1, token_length=6, interval_length=30, clock=None, ): """Get time-based one-time password on the basis of given secret and time. :param secret: the base32-encoded string acting as secret key :typ...
python
{ "resource": "" }
q251021
valid_hotp
train
def valid_hotp( token, secret, last=1, trials=1000, digest_method=hashlib.sha1, token_length=6, ): """Check if given token is valid for given secret. Return interval number that was successful, or False if not found. :param token: token being checked :typ...
python
{ "resource": "" }
q251022
valid_totp
train
def valid_totp( token, secret, digest_method=hashlib.sha1, token_length=6, interval_length=30, clock=None, window=0, ): """Check if given token is valid time-based one-time password for given secret. :param token: token which is being checked :typ...
python
{ "resource": "" }
q251023
parametrize
train
def parametrize(params): """Return list of params as params. >>> parametrize(['a']) 'a' >>> parametrize(['a', 'b'])
python
{ "resource": "" }
q251024
urlencode
train
def urlencode(params): """Urlencode a multidimensional dict.""" # Not doing duck typing here. Will make debugging easier. if not isinstance(params, dict): raise TypeError("Only dicts are supported.") params = flatten(params) url_params = OrderedDict() for param in params: valu...
python
{ "resource": "" }
q251025
find_matlab_root
train
def find_matlab_root(): """Look for matlab binary and return root directory of MATLAB installation. """ matlab_root = None path_dirs = os.environ.get("PATH").split(os.pathsep) for path_dir in path_dirs: candidate =
python
{ "resource": "" }
q251026
load_engine_and_libs
train
def load_engine_and_libs(matlab_root, options): """Load and return `libeng` and `libmx`. Start and return MATLAB engine. Returns ------- engine libeng libmx """ if sys.maxsize > 2**32: bits = '64bit' else: bits = '32bit' system = platform.system() if ...
python
{ "resource": "" }
q251027
check_python_matlab_architecture
train
def check_python_matlab_architecture(bits, lib_dir): """Make sure we can find corresponding installation of Python and MATLAB.""" if not os.path.isdir(lib_dir): raise RuntimeError("It seem that you are using
python
{ "resource": "" }
q251028
MatlabSession.eval
train
def eval(self, expression): """Evaluate `expression` in MATLAB engine. Parameters ---------- expression : str Expression is passed to MATLAB engine and evaluated. """ expression_wrapped = wrap_script.format(expression) ### Evaluate the expression ...
python
{ "resource": "" }
q251029
MatlabSession.get
train
def get(self, name): """Get variable `name` from MATLAB workspace. Parameters ---------- name : str Name of the variable in MATLAB workspace.
python
{ "resource": "" }
q251030
MatlabSession.put
train
def put(self, name, value): """Put a variable to MATLAB workspace. """
python
{ "resource": "" }
q251031
Cleanup.dirs
train
def dirs(self, before=time.time(), exited=True): """ Provider a generator of container state directories. If exited is None, all are returned. If it is False, unexited containers are returned. If it is True, only exited containers are returned. """ timestamp = is...
python
{ "resource": "" }
q251032
methods
train
def methods(): "Names of operations provided by containerizers, as a set."
python
{ "resource": "" }
q251033
stdio
train
def stdio(containerizer, *args): """Connect containerizer class to command line args and STDIN Dispatches to an appropriate containerizer method based on the first argument and parses the input using an appropriate Protobuf type. launch < containerizer::Launch update < containerizer::Updat...
python
{ "resource": "" }
q251034
construct
train
def construct(path, name=None): "Selects an appropriate CGroup subclass for the given CGroup path." name = name if name else path.split("/")[4] classes = {"memory": Memory, "cpu": CPU,
python
{ "resource": "" }
q251035
serialize
train
def serialize(cls, **properties): """ With a Protobuf class and properties as keyword arguments, sets all the properties on a new instance of the class
python
{ "resource": "" }
q251036
logger
train
def logger(height=1): # http://stackoverflow.com/a/900404/48251 """ Obtain a function logger for the calling function. Uses the inspect module to find the name of the calling function and its position in the module hierarchy. With the optional height argument, logs for caller's caller, a...
python
{ "resource": "" }
q251037
load_jupyter_server_extension
train
def load_jupyter_server_extension(nb_server_app): """Called by Jupyter when this module is loaded as a server extension.""" app = nb_server_app.web_app host_pattern = '.*$' app.add_handlers(host_pattern, [ (utils.url_path_join(app.settings['base_url'], '/http_over_websocket'), handlers.HttpOverWeb...
python
{ "resource": "" }
q251038
_validate_min_version
train
def _validate_min_version(min_version): """Validates the extension version matches the requested version. Args: min_version: Minimum version passed as a query param when establishing the connection. Returns: An ExtensionVersionResult indicating validation status. If there is a problem, the err...
python
{ "resource": "" }
q251039
_StreamingResponseEmitter.streaming_callback
train
def streaming_callback(self, body_part): """Handles a streaming chunk of the response. The streaming_response callback gives no indication about whether the received chunk is the last in the stream. The "last_response" instance variable allows us to keep track of the last received chunk of the resp...
python
{ "resource": "" }
q251040
lower_dict
train
def lower_dict(d): """Lower cases string keys in given dict.""" _d = {} for k, v in d.items(): try:
python
{ "resource": "" }
q251041
urlparse
train
def urlparse(d, keys=None): """Returns a copy of the given dictionary with url values parsed.""" d = d.copy() if keys is None:
python
{ "resource": "" }
q251042
prefix
train
def prefix(prefix): """Returns a dictionary of all environment variables starting with the given prefix, lower cased and stripped. """ d = {} e = lower_dict(environ.copy()) prefix = prefix.lower() for k, v in e.items(): try:
python
{ "resource": "" }
q251043
map
train
def map(**kwargs): """Returns a dictionary of the given keyword arguments mapped to their values from the environment, with input keys lower cased. """ d = {}
python
{ "resource": "" }
q251044
Load
train
def Load(file): """ Loads a model from specified file """
python
{ "resource": "" }
q251045
Block._AddInput
train
def _AddInput(self, variable): """ Add one more variable as an input of the block :param variable: variable (or signal as it is also a variable) """ if isinstance(variable, Variable): self.inputs.append(variable)
python
{ "resource": "" }
q251046
Block._AddOutput
train
def _AddOutput(self, variable): """ Add one more variable as an output of the block :param variable: variable (or signal as it is also a variable) """ if isinstance(variable, Variable):
python
{ "resource": "" }
q251047
Block.InputValues
train
def InputValues(self, it, nsteps=None): """ Returns the input values at a given iteration for solving the block outputs """ if nsteps == None: nsteps = self.max_input_order # print(self,it) # Provides values in inputs values for computing at iteration it ...
python
{ "resource": "" }
q251048
DynamicSystem._AddVariable
train
def _AddVariable(self, variable): """ Add a variable to the model. Should not be used by end-user """ if isinstance(variable, Signal): if not variable in self.signals: self.signals.append(variable) elif isinstance(variable, Variable):
python
{ "resource": "" }
q251049
DynamicSystem.VariablesValues
train
def VariablesValues(self, variables, t): """ Returns the value of given variables at time t. Linear interpolation is performed between two time steps. :param variables: one variable or a list of variables :param t: time of evaluation """ # TODO: put interpolatio...
python
{ "resource": "" }
q251050
JSONField.to_python
train
def to_python(self, value): """ Convert a string from the database to a Python value. """ if value == "": return None try: if isinstance(value, six.string_types): return self.deserializer(value)
python
{ "resource": "" }
q251051
JSONField.get_prep_value
train
def get_prep_value(self, value): """ Convert the value to a string so it can be stored in the database. """ if value == "": return None if isinstance(value,
python
{ "resource": "" }
q251052
render_to
train
def render_to(template=None, content_type=None): """ Decorator for Django views that sends returned dict to render_to_response function. Template name can be decorator parameter or TEMPLATE item in returned dictionary. RequestContext always added as context instance. If view doesn't return dic...
python
{ "resource": "" }
q251053
ajax_request
train
def ajax_request(func): """ If view returned serializable dict, returns response in a format requested by HTTP_ACCEPT header. Defaults to JSON if none requested or match. Currently supports JSON or YAML (if installed), but can easily be extended. example: @ajax_request def my_view...
python
{ "resource": "" }
q251054
autostrip
train
def autostrip(cls): """ strip text fields before validation example: @autostrip class PersonForm(forms.Form): name = forms.CharField(min_length=2, max_length=10) email = forms.EmailField() Author: nail.xx """ warnings.warn( "django-annoying autostrip is deprecat...
python
{ "resource": "" }
q251055
_patch_file
train
def _patch_file(path, content): """Will backup the file then patch it""" f = open(path) existing_content = f.read() f.close() if existing_content == content: # already patched log.warn('Already patched.') return False
python
{ "resource": "" }
q251056
_set_overlay_verify
train
def _set_overlay_verify(name, overlay_path, config_path): """ _set_overlay_verify - Function to load the overlay and verify it was setup properly """ global DEBUG # VERIFY PATH IS NOT THERE if os.path.exists(config_path): print("Config path already exists! Not moving forward") p...
python
{ "resource": "" }
q251057
load
train
def load(overlay, path=""): """ load - Load a DTB Overlay Inputs: overlay - Overlay Key: SPI2, PWM0, CUST path - Full Path to where the custom overlay is stored Returns: 0 - Successful Load 1 - Unsuccessful Load 2 - Overlay was previously set """ global DEBU...
python
{ "resource": "" }
q251058
Scheduler.run
train
def run(self): """ Continually monitors Jobs of the parent Dagobah. """ while not self.stopped: now = datetime.utcnow() for job in self.parent.jobs: if not job.next_run: continue if job.next_run >= self.last_check and job.next_r...
python
{ "resource": "" }
q251059
Dagobah.set_backend
train
def set_backend(self, backend): """ Manually set backend after construction. """ self.backend = backend self.dagobah_id = self.backend.get_new_dagobah_id() for job in self.jobs: job.backend = backend
python
{ "resource": "" }
q251060
Dagobah.from_backend
train
def from_backend(self, dagobah_id): """ Reconstruct this Dagobah instance from the backend. """ logger.debug('Reconstructing Dagobah instance from backend with ID {0}'.format(dagobah_id)) rec = self.backend.get_dagobah_json(dagobah_id) if not rec: raise
python
{ "resource": "" }
q251061
Dagobah._construct_from_json
train
def _construct_from_json(self, rec): """ Construct this Dagobah instance from a JSON document. """ self.delete() for required_key in ['dagobah_id', 'created_jobs']: setattr(self, required_key, rec[required_key])
python
{ "resource": "" }
q251062
Dagobah.add_job_from_json
train
def add_job_from_json(self, job_json, destructive=False): """ Construct a new Job from an imported JSON spec. """ logger.debug('Importing job from JSON document: {0}'.format(job_json)) rec = self.backend.decode_import_json(job_json) if destructive: try:
python
{ "resource": "" }
q251063
Dagobah._add_job_from_spec
train
def _add_job_from_spec(self, job_json, use_job_id=True): """ Add a single job to the Dagobah from a spec. """ job_id = (job_json['job_id'] if use_job_id else self.backend.get_new_job_id()) self.add_job(str(job_json['name']), job_id) job = self.get_job...
python
{ "resource": "" }
q251064
Dagobah.commit
train
def commit(self, cascade=False): """ Commit this Dagobah instance to the backend. If cascade is True, all child Jobs are commited as well. """ logger.debug('Committing
python
{ "resource": "" }
q251065
Dagobah.delete
train
def delete(self): """ Delete this Dagobah instance from the Backend. """ logger.debug('Deleting Dagobah
python
{ "resource": "" }
q251066
Dagobah.add_job
train
def add_job(self, job_name, job_id=None): """ Create a new, empty Job. """ logger.debug('Creating a new job named {0}'.format(job_name)) if not self._name_is_available(job_name): raise DagobahError('name %s is not available' % job_name) if not job_id: job_id = se...
python
{ "resource": "" }
q251067
Dagobah.get_host
train
def get_host(self, hostname): """ Returns a Host dict with config options, or None if none exists""" if hostname in self.get_hosts(): return self.load_ssh_conf().lookup(hostname)
python
{ "resource": "" }
q251068
Dagobah.get_job
train
def get_job(self, job_name): """ Returns a Job by name, or None if none exists. """ for job in self.jobs: if job.name == job_name: return job
python
{ "resource": "" }
q251069
Dagobah.delete_job
train
def delete_job(self, job_name): """ Delete a job by name, or error out if no such job exists. """ logger.debug('Deleting job {0}'.format(job_name)) for idx, job in enumerate(self.jobs): if job.name == job_name: self.backend.delete_job(job.job_id)
python
{ "resource": "" }
q251070
Dagobah.add_task_to_job
train
def add_task_to_job(self, job_or_job_name, task_command, task_name=None, **kwargs): """ Add a task to a job owned by the Dagobah instance. """ if isinstance(job_or_job_name, Job): job = job_or_job_name else: job = self.get_job(job_or_job_name) ...
python
{ "resource": "" }
q251071
Dagobah._name_is_available
train
def _name_is_available(self, job_name): """ Returns Boolean of whether the specified name is already
python
{ "resource": "" }
q251072
Dagobah._serialize
train
def _serialize(self, include_run_logs=False, strict_json=False): """ Serialize a representation of this Dagobah object to JSON. """ result = {'dagobah_id': self.dagobah_id, 'created_jobs': self.created_jobs,
python
{ "resource": "" }
q251073
Job.commit
train
def commit(self): """ Store metadata on this Job to the backend. """ logger.debug('Committing job {0}'.format(self.name))
python
{ "resource": "" }
q251074
Job.add_task
train
def add_task(self, command, name=None, **kwargs): """ Adds a new Task to the graph with no edges. """ logger.debug('Adding task with command {0} to job {1}'.format(command, self.name)) if not self.state.allow_change_graph:
python
{ "resource": "" }
q251075
Job.add_dependency
train
def add_dependency(self, from_task_name, to_task_name): """ Add a dependency between two tasks. """ logger.debug('Adding dependency from {0} to {1}'.format(from_task_name, to_task_name))
python
{ "resource": "" }
q251076
Job.delete_task
train
def delete_task(self, task_name): """ Deletes the named Task in this Job. """ logger.debug('Deleting task {0}'.format(task_name)) if not self.state.allow_change_graph: raise DagobahError("job's graph is immutable in its current state: %s"
python
{ "resource": "" }
q251077
Job.delete_dependency
train
def delete_dependency(self, from_task_name, to_task_name): """ Delete a dependency between two tasks. """ logger.debug('Deleting dependency from {0} to {1}'.format(from_task_name, to_task_name))
python
{ "resource": "" }
q251078
Job.schedule
train
def schedule(self, cron_schedule, base_datetime=None): """ Schedules the job to run periodically using Cron syntax. """ logger.debug('Scheduling job {0} with cron schedule {1}'.format(self.name, cron_schedule)) if not self.state.allow_change_schedule: raise DagobahError("job's sched...
python
{ "resource": "" }
q251079
Job.start
train
def start(self): """ Begins the job by kicking off all tasks with no dependencies. """ logger.info('Job {0} starting job run'.format(self.name)) if not self.state.allow_start: raise DagobahError('job cannot be started in its current state; ' + 'it is p...
python
{ "resource": "" }
q251080
Job.retry
train
def retry(self): """ Restarts failed tasks of a job. """ logger.info('Job {0} retrying all failed tasks'.format(self.name)) self.initialize_snapshot() failed_task_names = [] for task_name, log in self.run_log['tasks'].items(): if log.get('success', True) == False: ...
python
{ "resource": "" }
q251081
Job.terminate_all
train
def terminate_all(self): """ Terminate all currently running tasks. """ logger.info('Job {0} terminating all currently running tasks'.format(self.name))
python
{ "resource": "" }
q251082
Job.kill_all
train
def kill_all(self): """ Kill all currently running jobs. """ logger.info('Job {0} killing all currently running tasks'.format(self.name))
python
{ "resource": "" }
q251083
Job.edit
train
def edit(self, **kwargs): """ Change this Job's name. This will affect the historical data available for this Job, e.g. past run logs will no longer be accessible. """ logger.debug('Job {0} changing name to {1}'.format(self.name, kwargs.get('name'))) if not self.state.a...
python
{ "resource": "" }
q251084
Job.edit_task
train
def edit_task(self, task_name, **kwargs): """ Change the name of a Task owned by this Job. This will affect the historical data available for this Task, e.g. past run logs will no longer be accessible. """ logger.debug('Job {0} editing task {1}'.format(self.name, task_name)) ...
python
{ "resource": "" }
q251085
Job._complete_task
train
def _complete_task(self, task_name, **kwargs): """ Marks this task as completed. Kwargs are stored in the run log. """ logger.debug('Job {0} marking task {1} as completed'.format(self.name, task_name)) self.run_log['tasks'][task_name] = kwargs for node in self.downstream(task_name, sel...
python
{ "resource": "" }
q251086
Job._put_task_in_run_log
train
def _put_task_in_run_log(self, task_name): """ Initializes the run log task entry for this task. """ logger.debug('Job {0} initializing run log entry for task {1}'.format(self.name, task_name)) data = {'start_time':
python
{ "resource": "" }
q251087
Job._on_completion
train
def _on_completion(self): """ Checks to see if the Job has completed, and cleans up if it has. """ logger.debug('Job {0} running _on_completion check'.format(self.name)) if self.state.status != 'running' or (not self._is_complete()): return for job, results in self.run_log[...
python
{ "resource": "" }
q251088
Job._start_if_ready
train
def _start_if_ready(self, task_name): """ Start this task if all its dependencies finished successfully. """ logger.debug('Job {0} running _start_if_ready for task {1}'.format(self.name, task_name)) task = self.tasks[task_name] dependencies = self._dependencies(task_name, self.snapshot) ...
python
{ "resource": "" }
q251089
Job._commit_run_log
train
def _commit_run_log(self): """" Commit the current run log to the backend. """
python
{ "resource": "" }
q251090
Job._serialize
train
def _serialize(self, include_run_logs=False, strict_json=False): """ Serialize a representation of this Job to a Python dict object. """ # return tasks in sorted order if graph is in a valid state try: topo_sorted = self.topological_sort() t = [self.tasks[task]._serializ...
python
{ "resource": "" }
q251091
Job.initialize_snapshot
train
def initialize_snapshot(self): """ Copy the DAG and validate """ logger.debug('Initializing DAG snapshot for job {0}'.format(self.name)) if self.snapshot is not None: logging.warn("Attempting to initialize DAG snapshot without " + "first destroying old snapsh...
python
{ "resource": "" }
q251092
Task.reset
train
def reset(self): """ Reset this Task to a clean state prior to execution. """ logger.debug('Resetting task {0}'.format(self.name)) self.stdout_file = os.tmpfile() self.stderr_file = os.tmpfile() self.stdout = "" self.stderr = ""
python
{ "resource": "" }
q251093
Task.start
train
def start(self): """ Begin execution of this task. """ logger.info('Starting task {0}'.format(self.name)) self.reset() if self.hostname: host = self.parent_job.parent.get_host(self.hostname) if host: self.remote_ssh(host) else:
python
{ "resource": "" }
q251094
Task.remote_ssh
train
def remote_ssh(self, host): """ Execute a command on SSH. Takes a paramiko host dict """ logger.info('Starting remote execution of task {0} on host {1}'.format(self.name, host['hostname'])) try: self.remote_client = paramiko.SSHClient() self.remote_client.load_system_host...
python
{ "resource": "" }
q251095
Task.check_complete
train
def check_complete(self): """ Runs completion flow for this task if it's finished. """ logger.debug('Running check_complete for task {0}'.format(self.name)) # Tasks not completed if self.remote_not_complete() or self.local_not_complete(): self._start_check_timer() ...
python
{ "resource": "" }
q251096
Task.remote_not_complete
train
def remote_not_complete(self): """ Returns True if this task is on a remote channel, and on a remote machine, False if it is either not remote or not completed """ if self.remote_channel and not self.remote_channel.exit_status_ready(): self._timeout_check() ...
python
{ "resource": "" }
q251097
Task.local_not_complete
train
def local_not_complete(self): """ Returns True if task is local and not completed""" if self.process and self.process.poll() is None:
python
{ "resource": "" }
q251098
Task.completed_task
train
def completed_task(self): """ Handle wrapping up a completed task, local or remote""" # If its remote and finished running if self.remote_channel and self.remote_channel.exit_status_ready(): # Collect all remaining stdout/stderr while self.remote_channel.recv_ready(): ...
python
{ "resource": "" }
q251099
Task.terminate
train
def terminate(self): """ Send SIGTERM to the task's process. """ logger.info('Sending SIGTERM to task {0}'.format(self.name)) if hasattr(self, 'remote_client') and self.remote_client is not None: self.terminate_sent = True self.remote_client.close()
python
{ "resource": "" }