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[source]

Bases: Exception

Generic STU client error.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception schrodinger.test.stu.client.ClientValueError[source]

Bases: ValueError

Arguments to a client function are incorrect, or not fully determined.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

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)[source]
schrodinger.test.stu.client.retrieve(username, *args, **kwargs)[source]
schrodinger.test.stu.client.update(username, test, directory=None, upload=True)[source]
schrodinger.test.stu.client.delete(username, test)[source]
schrodinger.test.stu.client.download(username, test, directory=None, overwrite=True)[source]
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)[source]

Bases: object

Reporter that will upload results and files for a specific test run. (This is the report method.) Also marks runs as complete, with the option to send an email about test failures to the interested users (the completeRun method).

__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)[source]

Initialize self. See help(type(self)) for accurate signature.

report(test, upload=True, files=None)[source]

Report the result of ONE test and upload its files.

userRunURL()[source]

Return the URL where users can go to see details about this run.

completeRun(duration, email=False)[source]

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)[source]

Modify test data in-place to indicate a test failure to the STU API.

schrodinger.test.stu.client.raise_for_status(response)[source]

If response has 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)[source]

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)[source]

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)[source]

Bases: requests.auth.AuthBase

An authorization method that uses an api key.

__init__(username)[source]

Initialize self. See help(type(self)) for accurate signature.

class schrodinger.test.stu.client.TestClient(username=None, base_url=None, api_version=1)[source]

Bases: schrodinger.test.stu.client._BaseClient

Interact 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)[source]

Initialize self. See help(type(self)) for accurate signature.

create(test)[source]

Create a test.

retrieve(test_ids=None, products=None, components=None, priorities=None, tags=None, not_products=(), not_components=(), not_tags=())[source]

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)[source]

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)[source]

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)[source]

Update files and metadata for a test.

delete(test)[source]

Delete a test metadata and files.

download(test, directory=None, overwrite=True)[source]

Download and extract the files associated with test. Overwrites existing contents of the directory.

upload(test, directory=None)[source]

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)[source]

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()[source]

Set STU user to the current user calling this code