Skip to main content

Module helpers

Function get_hydra_mode

View Source

get_hydra_mode() -> UnionType[str, None]

Get the Hydra run mode (NORMAL or MULTIRUN).

This function retrieves the current Hydra execution mode. Hydra has two main modes:

  • NORMAL: Single configuration run
  • MULTIRUN: Multiple configurations run in parallel or sequence

Returns: str | None: The name of the Hydra mode ('NORMAL' or 'MULTIRUN'), or None if mode cannot be determined

Function get_minio_backend

View Source

get_minio_backend() -> UnionType[str, None]

Get the MinIO S3 host backend address for data storage.

This function determines the MinIO server address either from environment variables or based on the local hostname. It supports different configurations for various deployment environments (local development, GPU server, etc.).

Returns: str | None: The MinIO host address in format 'hostname:port', e.g., '192.168.10.101:10000' for GPU server or 'viopsy-pc:10000' for local development.

Raises: ValueError: If the hostname is not recognized and MINIO_HOST environment variable is not set.

Function get_task_and_logger

View Source

get_task_and_logger(project_name: UnionType[str, None] = None, task_name: UnionType[str, None] = None, add_datetime: bool = False, reuse_last_task_id: UnionType[str, None] = None, logging_level: int = 20) -> tuple[Task, Logger]

Get the clearml task and logger for experiment tracking and logging

This function initializes or reuses a ClearML task and its associated logger. It handles both new task creation and continuation of existing tasks, with support for Hydra's multirun mode and customizable logging levels.

Args: project_name (str, optional): Name of the project in ClearML. Required when not reusing an existing task. Defaults to None. task_name (str, optional): Name of the specific task/experiment. Required when not reusing an existing task. Defaults to None. add_datetime (bool, optional): If True, appends current timestamp to task name for unique identification. Defaults to True. reuse_last_task_id (str, optional): ID of existing task to continue. If provided, project_name and task_name are ignored. Defaults to None. logging_level (int, optional): Python logging level for the logger. Controls verbosity of log messages. Defaults to logging.INFO.

Returns: tuple[Task, ClearmlLogger]: Tuple containing:

  • Task: Initialized ClearML task object for experiment tracking
  • ClearmlLogger: Associated logger for metrics and debug info

Function setup_python_logger

View Source

setup_python_logger(logging_level: int) -> None

Setup Python's logging system with customized configuration.

This function configures the root logger and sets specific logging levels for different modules. It ensures proper log formatting and sets logging level of various third-party libraries to Warning.

Args: logging_level (int): The logging level to set for vify modules. Common values include logging.DEBUG (10), logging.INFO (20), logging.WARNING (30), logging.ERROR (40), logging.CRITICAL (50).