- class playmolecule.session.Session(token=None, wait_for_backend=False, server_ip=None, server_port=None, server_version='v1', server_protocol='http')#
The central class through which we control the PlayMolecule backend.
Starts a PlayMolecule session with a user token, each user has his own unique token. There are some operations which can only be performed by using the Admin token.
token (str) – The user token. If None it will try to read it from the config file.
wait_for_backend (bool) – If set to True, it will block execution until it manages to contact the PlayMolecule backend
server_ip (str) – The IP address of the backend server. If None it will try to read it from the config file.
server_port (int) – The port on which the backend server listens. If None it will try to read it from the config file.
server_version (str) – The API version of the backend server. If None it will try to read it from the config file.
server_protocol (str) – The protocol used by the backend server.
>>> s = Session("my_token") >>> s = Session("my_token", server_ip="127.0.0.1", server_port=8095, wait_for_backend=True)
- cancel_job(execid, _logger=True)#
Cancels a job.
This will set the status to ERROR and stop any running execution (children as well)
execid (str) – The execution ID of the job we wish to cancel
- change_password(email, old_pass, new_pass, admin_token=None)#
Change the password of a user
- delete_job(execid, _logger=True)#
Deletes a job and all associated data and metadata related to it from the backend. Cannot be undone.
- describe_app(appname, version=None, _logger=True)#
Describe the input parameters of an app.
Returns or prints the available apps.
The list of apps is printed if _logger is True else it’s returned
- get_job(execid=None, name=None, group=None, strict=True, _logger=True)#
Finds and returns a Job object
job – The job object with all it’s parameters set
- Return type
>>> job = s.get_job(execid="3cadd50b-b208-4a3d-8cf3-d991d22e858a")
- get_jobs(limit=None, group=None, appid=None, execid=None, count=False, in_status=None, not_in_status=None, newer_than=None, older_than=None, _logger=True)#
Returns or prints a list of submitted jobs.
limit (int) – Maximum number of jobs to be listed or returned
group (str) – The executions group to be returned
appid (str) – Specify the id of an app to return only executions of this app
execid (str) – Specify the execution ID of a job. It can accept a partial beginning of an execution ID or the whole execid
count (bool) – If True it will only return the number of jobs matching the above criteria
in_status (list) – A list of JobStatus codes. Jobs which are in any of the specified states will be returned
not_in_status (list) – A list of JobStatus codes. Only jobs which don’t belong to any of the specified states will be returned
newer_than (int) – Return only jobs more recent than newer_than seconds.
older_than (int) – Return only jobs more old than older_than seconds.
_logger (bool) – Set as True for printing the info and errors in sys.stdout. If False, it returns the same information as a list (default=True).
execs – A list of job executions
- Return type
Gets the current status of all PlayMolecule backend services
_logger (bool) – Set to False to return the status of the services instead of printing them to sys.stdout
Logs in a user retrieving the user token from the user name and password
Registers a new user in the backend
admin_token (str) – The admin user token
- retrieve_jobs(outdir='.', force=False, execid=None, name=None, group=None, recursive=False, _logger=True)#
Retrieve the results of several jobs.
outdir (str) – Path to which to retrieve the jobs
force (bool) – If force=True, the destination folder will be overwritten
execid – The id of the job to be retrieved.
name (str) – The name of an execution to be retrieved
group (str) – The group of an execution to be retrieved
recursive (bool) – Set to True to store the jobs in subfolders named by the job names
_logger (bool) – Set to False to reduce verbosity
>>> s.retrieve_jobs("./results", execid="3cadd50b-b208-4a3d-8cf3-d991d22e858a") >>> s.retrieve_jobs("./results", group="my_job_group") # Will retrieve all jobs of the group
- set_job_status(execid, status, error_info=None, _logger=True)#
Sets the status of a job
>>> s.set_job_status(execid="3cadd50b-b208-4a3d-8cf3-d991d22e858a", status=JobStatus.ERROR)
- start_app(appname, version=None, _logger=True)#
Returns a new job object of the specified app.
job – The new job object
- Return type
>>> job = s.start_app("ProteinPrepare") >>> job.pdbid = "3ptb" >>> job.submit()
Blocks execution until it’s able to contact the backend server