modelforge.utils.misc

Module of miscellaneous utilities.

Functions

check_file_lock(file_handle)

Checks if the file stream is locked using fcntl.

extract_tarred_file(input_path_dir, ...[, mode])

Extract the contents of the tar file.

list_files(directory, extension)

Returns a list of files in a directory with a given extension.

load_configs_into_pydantic_models(...)

lock_file(file_handle)

Locks the file stream for exclusive access using fcntl.

lock_with_attribute(attribute_name)

Decorator for locking a method using a lock file path stored in an instance attribute.

seed_random_number(seed)

Seed the random number generator for reproducibility.

str_to_float(x)

Converts a string to a float, changing Mathematica style scientific notion to python style.

ungzip_file(input_path_dir, file_name, ...)

unlock_file(file_handle)

Unlocks the file stream using fcntl.

Classes

OpenWithLock(file_path[, mode])

Context manager for opening a file that also locks the file for exclusive access.

Welford()

Implements Welford's online algorithm for computing running variance and standard deviation incrementally.