adaptivemd.PythonTask

class adaptivemd.PythonTask(generator=None)[source]

A special task that does a RPC python calls

Variables:
  • then_func_name (str or None) – the name of the function of the TaskGenerator to be called with the resulting output
  • store_output (bool) – if True then the result from the RPC called function will also be stored in the database. It can later be retrieved using the .output attribute on the task completed successfully
__init__(generator=None)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

Methods

__init__([generator]) x.__init__(…) initializes x; see help(type(x)) for signature
add_cb(event, cb) Add a custom callback
add_conda_env(name) Add loading a conda env to all tasks of this resource
add_files(files) Add additional files to the task execution
add_path(path)
param path:a (list of) path(s) to be added to the $PATH variable before task execution
append(cmd) Append a command to this task
args() Return a list of args of the __init__ function of a class
backup_output_json(target) Add an action that will copy the resulting JSON file to the given path
base() Return the most parent class actually derived from StorableMixin
call(command, **kwargs) Set the python function to be called with its arguments
cancel() Mark a task as cancelled if it it not running or has been halted
descendants() Return a list of all subclassed objects
fire(event, scheduler) Fire an event like success or failed.
from_dict(dct) Reconstruct an object from a dictionary representation
get(f[, name]) Get a file and make it available to the task in the main directory
get_uuid() Create a new unique ID :returns: the unique number for an object in the project :rtype: long
has_failed() Check if the task is done executing and has failed
idx(store) Return the index which is used for the object in the given store.
is_done() Check if the task is done executing.
link(f[, name]) Add an action to create a link to a file (under a new name)
named(name) Attach a .name property to an object
objects() Returns a dictionary of all storable objects
prepend(cmd) Append a command to this task
put(f, target) Put a file back and make it persistent
remove(f) Add an action to remove a file or folder
restart() Mark a task as being runnable if it was stopped or failed before
setenv(key, value) Set an environment variable for the task
then(func_name) Set the name of the function to be called from the generator after success
to_dict() Convert object into a dictionary representation
touch(f) Add an action to create an empty file or folder at a given location
was_successful() Check if the task is done executing and was successful

Attributes

ACTIVE_LONG
CREATION_COUNT
FINAL_STATES
INSTANCE_UUID
RESTARTABLE_STATES
RUNNABLE_STATES
additional_files list of Location return the list of files created other than taken care of by actions.
base_cls Return the base class
base_cls_name Return the name of the base class
cls Return the class name as a string
dependency_okay Check if all dependency tasks are successful
description Return a lengthy description of the task for debugging and information
environment dict str – str the dict of environment variables and their assigned value
main
modified_files A set of all input files whose names match output names and hence will be overwritten
new_files Return a set of all files the will be newly created by this task
output Return the data contained in the output file
pre_add_paths list of str the list of added paths to the $PATH variable by this task
pre_exec
ready Check if this task is ready to be executed
script list of str or Action the full script of this task.
source_locations Return a set of all required file urls
sources Return a set of all required input files
staged_files Set of all staged files by the tasks generator
state
stderr
stdout
target_locations Return a set of all new and overwritten file urls
targets Return a set of all new and overwritten files
then_func
unstaged_input_files Return a set of File objects that are used but are not part of the generator stage
worker
backup_output_json(target)[source]

Add an action that will copy the resulting JSON file to the given path

Parameters:target (Location) – the place to copy the resulting output.json file to
output

Return the data contained in the output file

Returns:
Return type:object
then(func_name)[source]

Set the name of the function to be called from the generator after success

Parameters:func_name (str) – the function name to be called after success
call(command, **kwargs)[source]

Set the python function to be called with its arguments

Parameters:
  • command (function) – a python function defined inside a package or a function. If in a package then the package needs to be installed on the cluster to be called. A function defined in a local file can be called as long as dependencies are installed.
  • kwargs (**kwargs) – named arguments to the function