tcc package¶
tcc.client¶
Class structures for communicating with the API server over HTTP
-
class
tcc.client.Client(user=None, api_key=None, url='http://localhost:80', engine='TeraChem', verbose=False)[source]¶ Bases:
objectMain class for communication with the TeraChem Cloud API server
-
compute(geom, options, sleep_seconds=1, max_poll=20)[source]¶ Convenience routine for synchronous use.
Check self.poll_for_results() for recommended way to check for job completion.
Parameters: - geom ((num_atom, 3) ndarray) – Geometry to consider
- options (dict) – Job options to pass to TeraChem Cloud server
- sleep_seconds (int) – Number of seconds to wait between poll loops for self.poll_for_results()
- max_poll (int) – Number of poll loops for self.poll_for_results()
- **kwargs – TCC configuration passed to self.submit()
Returns: Job results from TCC server
Return type: dict
-
compute_bulk(geoms, options, sleep_seconds=1, max_poll=20)[source]¶ Convenience routine for multiple geometries.
Check self.poll_for_bulk_results() for recommended way to check for job completion.
Parameters: - geoms (list of (num_atom, 3) ndarray) – Geometries to consider
- options (dict) – Job options to pass to TeraChem Cloud server
- sleep_seconds (int) – Number of seconds to wait between poll loops for self.poll_for_bulk_results()
- max_poll (int) – Number of poll loops for self.poll_for_bulk_results()
- **kwargs – TCC configuration passed to self.submit()
Returns: List of Job results from TCC server
Return type: list
-
get_results(job_id)[source]¶ Query API for results of calculations.
Recommended way to check for job completion:
results = client.get_results(job_id) finished = client.is_finished(results)
Parameters: job_id (str) – Job id to check status of Returns: Result dictionary from TCC server with job_id added for posterity Return type: dict
-
is_finished(results)[source]¶ Helper function to test whether a job is finished.
Parameters: results (dict) – Job results from self.get_results() Returns: True if job succeeded/failed, False if job is running/submitted/pending Return type: bool
-
poll_for_bulk_results(job_ids, sleep_seconds=1, max_poll=20)[source]¶ Send http request every sleep_seconds seconds until a finished job is returned or max_poll requests have been sent.
Recommended way to check for job completion:
results_list = client.poll_for_bulk_results(job_ids) finished = [client.is_finished(r) for r in results_list]
Parameters: - job_ids (list) – Job ids to poll for
- sleep_seconds (int) – Number of seconds to wait between poll loops
- max_poll (int) – Number of poll loops
Returns: List of results dicts as given by self.get_results()
Return type: list
-
poll_for_results(job_id, sleep_seconds=1, max_poll=20)[source]¶ Send http request every sleep_seconds seconds until a finished job is returned or max_poll requests have been sent.
Recommended way to check for job completion:
results = client.poll_for_results(job_id) finished = client.is_finished(results)
Parameters: - job_id (str) – Job id to poll for
- sleep_seconds (int) – Number of seconds to wait between poll loops
- max_poll (int) – Number of poll loops
Returns: Results dict as given by self.get_results()
Return type: dict
-
submit(geom, options)[source]¶ Pack and send the current tc_config dict as a POST request to the Tornado API server This function returns a job_id and a message
Parameters: - geom (np.ndarray or list) – Cartesian geometry at which to perform the calculation
- options (dict) – Job options to pass to TeraChem Cloud server
Returns: Job id dict: Results
Return type: str
-
tcc.exceptions¶
Exception handling for tcc package
See https://docs.python.org/3/tutorial/errors.html#user-defined-exceptions
-
exception
tcc.exceptions.HTTPCommunicationError(msg, orig_exc)[source]¶ Bases:
tcc.exceptions.TCCErrorWrapping exceptions from requests
See https://julien.danjou.info/python-exceptions-guide under Wrapping Exceptions
-
exception
tcc.exceptions.ServerError(request)[source]¶ Bases:
tcc.exceptions.TCCErrorRaised when receive not 200 from server
400: Probably something wrong with payload (e.g. option validation) 401: Authentication Should not get anything else…