FastSurferCNN.version¶
- class FastSurferCNN.version.VersionDict[source]¶
Dictionary with keys ‘version_line’, ‘version’, ‘git_hash’, ‘git_branch’, ‘checkpoints’, ‘git_status’, and ‘pypackages’. The last 3 are optional and may be missing depending on the content of the file.
Methods
clear()copy()fromkeys(iterable[, value])Create a new dictionary with keys from iterable and values set to value.
get(key[, default])Return the value for key if key is in the dictionary, else default.
items()keys()pop(key[, default])If the key is not found, return the default if given; otherwise, raise a KeyError.
popitem(/)Remove and return a (key, value) pair as a 2-tuple.
setdefault(key[, default])Insert key with a value of default if key is not in the dictionary.
update([E, ]**F)If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
- FastSurferCNN.version.filter_git_status(git_process)[source]¶
Filter the output of a running git status process.
- Parameters:
- git_process
FastSurferCNN.utils.run_tools.Popen The Popen process object that will return the git status output.
- git_process
- Returns:
strThe git status string filtered to exclude lines containing “__pycache__”.
- FastSurferCNN.version.get_default_version_info()[source]¶
Get the blank version information.
- Returns:
VersionDictA dictionary with blank version information.
- FastSurferCNN.version.has_git()[source]¶
Determine whether FastSurfer is installed as a git directory.
- Returns:
boolWhether git commands on the FastSurfer dir likely work.
- FastSurferCNN.version.main(sections='', project_file=None, build_cache=None, file=None, prefer_cache=False)[source]¶
Print version info to stdout or file.
Prints/writes version info of FastSurfer in the style:
` <version number>[+<git hash>][ (<git active branch>)] [========== checkpoints: ========== <md5sum> <file> ...] [========== git status: ========== <git status text>] [========== python packages: ========== Package Version Location [Installer] <package name> <version> <path> <pip|conda> ...] `$PROJECT_ROOT is the root directory of the project determined as the parent to this file’s directory.
- Parameters:
- sections
str String describing which sections the output should include. Can be ‘all’ or a concatenated list of ‘+branch’, ‘+checkpoints’, ‘+git’, and ‘+pip’, e.g. ‘+git+checkpoints’. The order does not matter, ‘+checkpoints’, ‘+git’ or ‘+pip’ also implicitly activate ‘+branch’.
- project_file
TextIO,optional A file-like object to read the projects toml file, with the ‘[project]’ section with a ‘version’ attribute. Defaults to $PROJECT_ROOT/pyproject.toml.
- build_cache
False,TextIO,optional A file-like object to read cached version information, the format should be formatted like the output of
main. Defaults to $PROJECT_ROOT/BUILD.info. If build_cache is False, it is ignored.- file
TextIO,optional A file-like object to write the output to, defaults to stdout if None or not passed.
- prefer_cache
bool, default=False Whether to prefer information from the
build_cacheover online generation.
- sections
- Returns:
- FastSurferCNN.version.make_parser()[source]¶
Generate the argument parser for the version script.
- Returns:
argparse.ArgumentParserThe argument parser for the version script.
- FastSurferCNN.version.parse_build_file(build_file)[source]¶
Read and parse a build file (same as output of
main).Read and parse a file with version information in the format that is also the output of the
mainfunction. The format is documented inmain.- Parameters:
- build_file
TextIO,optional File-like object, will be closed.
- build_file
- Returns:
VersionDictDictionary with keys ‘version_line’, ‘version’, ‘git_hash’, ‘git_branch’, ‘checkpoints’, ‘git_status’, and ‘pypackages’. The last 3 are optional and may be missing depending on the content of the file.
Notes
See also main.
- FastSurferCNN.version.print_build_file(version, git_hash='', git_branch='', git_status='', checkpoints='', pypackages='', file=None)[source]¶
Format and print the build file.
- Parameters:
- version
str The version number to print.
- git_hash
str,optional The git hash associated with the build, may be empty.
- git_branch
str,optional The git branch associated with the build, may be empty.
- git_status
str,optional The md5sums of the checkpoint files, leave empty to skip.
- checkpoints
str,optional The md5sums of the checkpoint files, leave empty to skip.
- pypackages
str,optional The md5sums of the checkpoint files, leave empty to skip.
- file
TextIO,optional A file-like object to write the build file to, default: stdout.
- version
Notes
See also main.
- FastSurferCNN.version.read_and_close_version(project_file=None)[source]¶
Read and close the version from the pyproject file. Also fill default.
Always closes the file pointer.
- Parameters:
- project_file
TextIO,optional Project file.
- project_file
- Returns:
strThe version read from the pyproject file.
Notes
See also FastSurferCNN.version.read_version_from_project_file
- FastSurferCNN.version.read_version_from_project_file(project_file)[source]¶
Read the version entry from the pyproject file.
Searches for the [project] section in project_file, therein the version attribute. Extracts the Value. The file pointer is right after the version attribute at return time.