schrodinger.test.stu.client module¶
Client for communication with STU server. The core functionality is in
TestClient and ResultReporter, but most is accessible from the module
level convenience functions create, retrieve, update, delete, and
download, which allow modification of the tests in the database.
@copyright: (c) Schrodinger, LLC. All rights reserved.
- exception schrodinger.test.stu.client.ClientError¶
Bases:
ExceptionGeneric STU client error.
- __init__(*args, **kwargs)¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception schrodinger.test.stu.client.ClientValueError¶
Bases:
ValueErrorArguments to a client function are incorrect, or not fully determined.
- __init__(*args, **kwargs)¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- schrodinger.test.stu.client.create(username, test, directory=None, upload=True)¶
- schrodinger.test.stu.client.retrieve(username, *args, **kwargs)¶
- schrodinger.test.stu.client.update(username, test, directory=None, upload=True)¶
- schrodinger.test.stu.client.delete(username, test)¶
- schrodinger.test.stu.client.download(username, test, directory=None, overwrite=True)¶
- class schrodinger.test.stu.client.ResultReporter(buildtype, build_id, mmshare, local_system, remote_system, username=None, release=None, build_log_address=None, comment=None, base_url=None, api_version=1)¶
Bases:
objectReporter that will upload results and files for a specific test run. (This is the
reportmethod.) Also marks runs as complete, with the option to send an email about test failures to the interested users (thecompleteRunmethod).- __init__(buildtype, build_id, mmshare, local_system, remote_system, username=None, release=None, build_log_address=None, comment=None, base_url=None, api_version=1)¶
- report(test, upload=True, files=None)¶
Report the result of ONE test and upload its files.
- userRunURL()¶
Return the URL where users can go to see details about this run.
- completeRun(duration, email=False)¶
Record that the run is complete, and include the total duration. If email is True, trigger an email about test failures.
- property localhost¶
- property remotehost¶
- schrodinger.test.stu.client.set_failure_data(data, error_name, error_message)¶
Modify test data in-place to indicate a test failure to the STU API.
- schrodinger.test.stu.client.raise_for_status(response)¶
If
responsehas a bad status, raise an Exception. First, however, be sure to print any data available from the exception.- Parameters
response (requests.models.Response) – Response to check for exit status problems.
- schrodinger.test.stu.client.check_status(response, required_statuses)¶
Raise an error if the status does not match
required_status. :type required_status: int :param required_status: Status to match
- schrodinger.test.stu.client.fatal_status(exception)¶
This method should return True only if exception is an HTTPError, and the status code is NOT retriable.
- class schrodinger.test.stu.client.ApiKeyAuth(username)¶
Bases:
requests.auth.AuthBaseAn authorization method that uses an api key.
- __init__(username)¶
- class schrodinger.test.stu.client.TestClient(username=None, base_url=None, api_version=1)¶
Bases:
schrodinger.test.stu.client._BaseClientInteract with the Test server. Create, Retrieve, Update, and Delete tests. Also upload and download the associated files.
- __init__(username=None, base_url=None, api_version=1)¶
- create(test)¶
Create a test.
- retrieve(test_ids=None, products=None, components=None, priorities=None, tags=None, not_products=(), not_components=(), not_tags=())¶
Retrieve tests based on some limiting criteria. The only method that operates on more than one test at a time. A bit weird?
- find_one(criteria)¶
Find a single STU test that matches the search criteria.
- Parameters
criteria (dict) – Search criteria, uses the exact names of parameters on the server. (does not interpret them in the way that retrieve does)
- Raises
ClientError – If more than one test is found.
IndexError – If no tests are found.
- get_or_create(search_criteria, creation_data=None)¶
Find a test corresponding to search_criteria. If no test is found, create a test using creation_data.
- Parameters
search_criteria (dict) – Search criteria.
creation_data (dict) – Data to be used to create the test if none exists.
- update(test)¶
Update files and metadata for a test.
- delete(test)¶
Delete a test metadata and files.
- download(test, directory=None, overwrite=True)¶
Download and extract the files associated with
test. Overwrites existing contents of the directory.
- upload(test, directory=None)¶
Upload a directory to the server. If the test has a directory attribute, use that. Otherwise, based on the test number.
- property auth¶
- property fullapi¶
- get(uri, **kwargs)¶
- getResourceURI(response=None)¶
Get an API rooted address from a full address.
- classmethod instance(username, base_url=None, api_version=1)¶
- item_uri(item)¶
- list2str(items)¶
- patch(uri, required_statuses=(202,), **kwargs)¶
- post(uri, required_statuses=(201,), **kwargs)¶
- put(uri, **kwargs)¶
- safename(oldname)¶
Ensure that the name is safe and that path separators are consistent on Linux and Windows.
- Parameters
oldname (str) – String to be protected
- Return type
str
- Returns
String with with all path separators replaced by / and all non-URL-safe characters protected.
- schrodinger.test.stu.client.has_scival_tags(test_tags)¶
Inspect a test’s tags to see if the test is a Scival test.
- Parameters
tags (list of str) – Tags for a STU test
- Return type
bool
- schrodinger.test.stu.client.get_stu_username()¶
Set STU user to the current user calling this code