plate_model_manager.utils package
Submodules
plate_model_manager.utils.collect_update_model module
- plate_model_manager.utils.collect_update_model.collect_model(model_name, target_dir='.', source='https://repo.gplates.org/webdav/pmm/config/model_sources.json')[source]
- plate_model_manager.utils.collect_update_model.create_hex_hash_sidecar_files(model_path)[source]
Create SHA256 hash sidecar files for all .zip files in the given directory.
- plate_model_manager.utils.collect_update_model.upload_model(model_path, remote_target, identity_file)[source]
Upload a plate model folder to a remote server via SCP.
This function uploads all files in the specified model directory to a remote server. Before uploading, it creates SHA256 hash sidecar files for all .zip files in the directory. Existing files on the remote server are archived with a timestamp before the new files are uploaded.
- Parameters:
model_path – Path to the local model directory containing files to upload.
remote_target – Remote destination in the format ‘user@host:path’. The model name will be appended to the path automatically.
identity_file – Path to the SSH private key file for authentication.
- Raises:
RuntimeError – If no files are found in the model directory or if the SSH connection to the remote host fails.
AssertionError – If the remote_target format is invalid (must contain ‘:’).
Example
- upload_model(
“models/muller2022”, “ubuntu@example.com:/data/models”, “~/.ssh/id_rsa”
)
plate_model_manager.utils.download module
- class plate_model_manager.utils.download.FileDownloader(file_url: str, meta_filepath: str, dst_dir: str, filename: str | None = None, auto_unzip: bool = True, expire_hours=12, expiry_time_format='%Y/%m/%d, %H:%M:%S', large_file_hint=False, timeout=(None, None), http_client: HttpClient = HttpClient.REQUESTS)[source]
Bases:
objectclass for managing single file download
- check_if_file_need_update()[source]
Decide whether the target file should be downloaded again.
- Returns:
Truewhen the file should be downloaded/re-downloaded,Falsewhen the existing local file can be reused.- Return type:
- Decision flow:
If the metadata file is missing, return
True.If the stored
urldiffers fromself.file_url(or is missing), returnTrue.If the metadata
expiryis still valid, returnFalse.If expired (or expiry is invalid/missing), compare remote content state: - Prefer SHA-256 comparison when available. - Fall back to ETag comparison if SHA-256 cannot be obtained. - If neither reliable value is available, return
True.
plate_model_manager.utils.enums module
plate_model_manager.utils.layer_validation module
plate_model_manager.utils.misc module
- plate_model_manager.utils.misc.get_distribution_version()[source]
get the version string from the package metadata
- plate_model_manager.utils.misc.is_debug_mode()[source]
Check if the debug mode is enabled by checking the environment variable “PMM_DEBUG”.
export PMM_DEBUG=true to enable the debug mode.
plate_model_manager.utils.network module
- plate_model_manager.utils.network.get_etag(headers)[source]
return the etag in the headers. The return could be none if the server does not support etag.
- Parameters:
headers – call get_headers(url) to get headers
- plate_model_manager.utils.network.get_sha256(url, timeout=(None, None))[source]
Return the sha256 hash from the sidecar file name in a WebDAV/XML or HTML directory listing.
- Parameters:
timeout – a (connect_timeout, read_timeout) tuple for requests.get(). None keeps requests’ default behavior for that timeout component.
plate_model_manager.utils.unzip module
Module contents
Utility helpers for plate_model_manager.