idmtools_platform_container.utils.general module#

Here we implement the ContainerPlatform utils.

Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.

idmtools_platform_container.utils.general.normalize_path(path: str | Path)[source]#

Normalize the binding path to handle case insensitivity and path separators for Windows. :param path: The path to normalize. :type path: str

Returns:

The normalized path.

Return type:

str

idmtools_platform_container.utils.general.map_container_path(source_binding, destination_binding, source_path) str[source]#

Map a source path to its corresponding destination path within the container. :param source_binding: The source directory in the binding (e.g., /abc/my_path). :type source_binding: str :param destination_binding: The destination directory in the container (e.g., /home/my_path). :type destination_binding: str :param source_path: The source file or folder path to map (e.g., /abc/my_path/file_or_folder_path). :type source_path: str

Returns:

The corresponding destination path within the container (e.g., /home/my_path/file_or_folder_path).

Return type:

str

Raises:

ValueError – If the source path does not start with the source binding path.

idmtools_platform_container.utils.general.parse_iso8601(date_str)[source]#

Convert an ISO 8601 format string to a datetime object. :param date_str: time string in ISO 8601 format

Returns:

datetime object

idmtools_platform_container.utils.general.format_timestamp(timestamp) str[source]#

Format the timestamp to a human-readable format. :param timestamp: timestamp in ISO 8601 format

Returns:

Human-readable timestamp

idmtools_platform_container.utils.general.is_valid_uuid(uuid_to_test, version=4) bool[source]#

Check if the provided string is a valid UUID. :param uuid_to_test: UUID string to test :param version: test against a specific UUID version

Returns:

True/False

idmtools_platform_container.utils.general.convert_byte_size(size_bytes: int) str[source]#

Convert byte size to human-readable. :param size_bytes: byte site in integer

Returns:

human-readable size

Return type:

str