schrodinger.test.stu.common module¶
Functions that are used in one or more modules. Reduces danger of circular dependencies.
@copyright: Schrodinger, Inc. All rights reserved.
- schrodinger.test.stu.common.BASE_URL = 'https://stu.schrodinger.com'¶
Address of STU server
- schrodinger.test.stu.common.DATE_RE = '^\\d\\d\\d\\d-\\d\\d-\\d\\d$'¶
The date format that our NBs use.
- schrodinger.test.stu.common.BUILD_ID_RE = re.compile('build(?:\\d{2}\\b|-\\d{3}\\b)')¶
Updated build_id naming scheme.
- class schrodinger.test.stu.common.FileInfo(path: str, size: int)[source]¶
Bases:
object
- path: str¶
- size: int¶
- __init__(path: str, size: int) None ¶
- exception schrodinger.test.stu.common.ZipError[source]¶
Bases:
Exception
Error while zipping up files.
- __init__(*args, **kwargs)¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- schrodinger.test.stu.common.str2list(string)[source]¶
Takes a string which can be a comma- or space-separated collection of positive integers and ranges and returns an ordered list of numbers.
- Parameters
input_string (str) – A comma-separated string of positive integers and ranges
- Returns
An ordered list of integers
- Return type
list(int)
- schrodinger.test.stu.common.str2strlist(string)[source]¶
Split a string into a list of strings. Used in parser.
- schrodinger.test.stu.common.get_api_key()[source]¶
Get the user’s API key. Uses caching. Also ensures that the user’s API key is only readable by self - raises RuntimeError if anyone else has read permission.
- Return type
str
- Returns
User’s API key from disk.
- schrodinger.test.stu.common.assert_build_id_matches(buildtype, build_id)[source]¶
Check that the build_id is appropriate for the buildtype
- schrodinger.test.stu.common.verify_zip(fileobj)[source]¶
Attempt to open fileobj as a zipfile.ZipFile and check it for errors using ZipFile.testzip() (file headers and CRC32 check for all files).
- Raises
ZipError – If ZipFile.testzip() retuns a non-None value, indicating a corrupted file.
- schrodinger.test.stu.common.zip_files(fileobj, relative_to, filenames)[source]¶
Zip a list of files into an archive. Relative paths are relative to
relative_to
.
- schrodinger.test.stu.common.prune_largest_files(files: Iterable[str]) List[str] [source]¶
Remove largest files first, one by one off the back, until total file list size is beneath the size_threshold.
- Parameters
files – List of absolute paths to files to be pruned until total file list size is within size_threshold
- Returns
List of absolute paths of files to be zipped.
- schrodinger.test.stu.common.zip_directory(zip_root: str, fileobj: Optional[Union[str, BinaryIO]] = None, skipped_files: Optional[Set[str]] = None)[source]¶
Zip the contents of a directory. File names will be relative to the directory name. Preserves symlinks.
- Parameters
zip_root – Directory to be zipped
fileobj – Filename or file-like object for the output zipfile. If not specified, the basename of zip_root + .zip is used.
skipped_files – Names of files that should be excluded from the zip archive.