watertap.tools.oli_api package

Subpackages

Submodules

watertap.tools.oli_api.client module

class watertap.tools.oli_api.client.OLIApi(credential_manager, test=False)[source]

Bases: object

A class to wrap OLI Cloud API calls and access functions for interfacing with WaterTAP.

__init__(credential_manager, test=False)[source]

Constructs all necessary attributes for OLIApi class

Parameters:
  • credential_manager_class – class used to manage credentials

  • test – bool switch for automation during tests

call(function_name, dbs_file_id, json_input={}, poll_time=1.0, max_request=1000, tee=False)[source]

Calls a function in the OLI Engine API.

Parameters:
  • function_name – name of function to call

  • dbs_file_id – string ID of DBS file

  • json_input – calculation input JSON

  • poll_time – max delay between each call

  • max_request – maximum requests

  • tee – boolean argument to hide or display print messages

Returns:

dictionary containing result or error

dbs_file_cleanup(dbs_file_ids=None)[source]

Deletes all (or specified) DBS files on OLI Cloud.

Parameters:

dbs_file_ids – list of DBS files that should be deleted

get_dbs_file_id(chemistry_source=None, phases=None, model_name=None)[source]

Gets dbs_file_id for a given input.

Parameters:
  • chemistry_source – Path (str), dict, or state block containing chemistry info

  • phases – Container (dict) for chemistry model parameters

  • model_name – Name (str) of model OLI will use

Return dbs_file_id:

string name for DBS file ID

get_dbs_file_info(dbs_file_id='')[source]

Retrieves chemistry information from OLI Cloud.

Parameters:

dbs_file_id – string ID of DBS file

Return dbs_file_info:

dictionary containing information about the DBS file

get_flash_history(dbs_file_id, job_id=False)[source]

Retrieves history of flash information, e.g., input for a chemistry model.

Parameters:
  • dbs_file_id – string ID of DBS file

  • job_id – bool flag to return job ID for troubleshooting

Return flash_history:

dictionary containing array of submitted jobs OR just job ID if specified

get_user_dbs_files()[source]

Gets all DBS files on user’s cloud.

Return user_dbs_files:

dictionary containing a list of all user DBS files uploaded

get_user_summary()[source]

Gets information for all files on user’s cloud.

Return user_summary:

dictionary containing file information and flash history for each dbs file

watertap.tools.oli_api.conftest module

watertap.tools.oli_api.conftest.auth_credentials() dict[source]

Credentials that allow running tests with an authenticated client

watertap.tools.oli_api.credentials module

class watertap.tools.oli_api.credentials.CredentialManager(username='', password='', root_url='', auth_url='', config_file='./credentials.txt', encryption_key='', access_keys=[], test=False)[source]

Bases: object

A class to handle credentials for OLI Cloud.

__init__(username='', password='', root_url='', auth_url='', config_file='./credentials.txt', encryption_key='', access_keys=[], test=False)[source]

Manages credentials for OLIApi authentication requests.

Parameters:
  • username – user’s username

  • password – user’s password

  • root_url – root url

  • auth_url – authorization url

  • config_file – existing/desired path (absolute, or relative to the working directory) to encrypted oli_config_file

  • encryption_key – fernet key generated by credential manager object

  • access_keys – list of access keys generated by user

  • test – bool switch for automation during tests

delete_oliapi_access_key(api_key)[source]

Delete an access key for OLI Cloud.

Parameters:

api_key – The access key to delete.

Return string:

Response text containing the success message or an error message.

generate_oliapi_access_key()[source]

Generate an access key for OLI Cloud.

Return string:

Response text containing the access key information or an error message.

get_refresh_token()[source]

Uses refresh token to update access token.

Return boolean:

True on success, False on failure

login()[source]

Login into user credentials for the OLI Cloud.

Return boolean:

True on success, False on failure

request_auto_login(req_func=None)[source]

Gets a new access token if the request returns with an expired token error.

Parameters:

req_func – function to call

Return boolean:

True on success, False on failure

set_access_key()[source]

Allows access key to be selected from list if more than one is provided.

Module contents