palletdatagenerator.utils module

Utility functions for PalletDataGenerator.

palletdatagenerator.utils.setup_logging(level: str = 'DEBUG', log_file: str = 'output.log') None[source]

Setup logging configuration.

Parameters:
  • level – Logging level (β€˜DEBUG’, β€˜INFO’, β€˜WARNING’, β€˜ERROR’)

  • log_file – Optional log file path

palletdatagenerator.utils.ensure_directory(path: str) Path[source]

Ensure directory exists, create if necessary.

Parameters:

path – Directory path to create

Returns:

Path object for the directory

palletdatagenerator.utils.load_config(config_path: str) dict[str, Any][source]

Load configuration from JSON or YAML file.

Parameters:

config_path – Path to configuration file

Returns:

Configuration dictionary

Raises:
palletdatagenerator.utils.save_config(config: dict[str, Any], config_path: str) None[source]

Save configuration to JSON file.

Parameters:
  • config – Configuration dictionary to save

  • config_path – Path to save configuration file

palletdatagenerator.utils.set_random_seed(seed: int) None[source]

Set random seed for reproducible results.

Parameters:

seed – Random seed value

palletdatagenerator.utils.validate_blender_environment() bool[source]

Validate that Blender environment is available and properly configured.

Returns:

True if Blender environment is valid, False otherwise

palletdatagenerator.utils.get_blender_version() tuple[int, int, int] | None[source]

Get Blender version information.

Returns:

Tuple of (major, minor, patch) version numbers or None if not available

palletdatagenerator.utils.format_file_size(size_bytes: int) str[source]

Format file size in human-readable format.

Parameters:

size_bytes – Size in bytes

Returns:

Formatted size string (e.g., β€œ1.5 MB”)

palletdatagenerator.utils.get_system_info() dict[str, Any][source]

Get system information for debugging and logging.

Returns:

Dictionary with system information

palletdatagenerator.utils.create_dataset_manifest(dataset_info: dict[str, Any], output_path: str) None[source]

Create a comprehensive dataset manifest file.

Parameters:
  • dataset_info – Dictionary containing dataset information

  • output_path – Path to save the manifest file

palletdatagenerator.utils.verify_dataset_integrity(dataset_dir: str) dict[str, Any][source]

Verify dataset integrity by checking file consistency.

Parameters:

dataset_dir – Path to dataset directory

Returns:

Dictionary with verification results

class palletdatagenerator.utils.ProgressTracker(total: int, description: str = 'Processing')[source]

Bases: object

Progress tracking utility for long-running operations.

__init__(total: int, description: str = 'Processing')[source]

Initialize progress tracker.

Parameters:
  • total – Total number of items to process

  • description – Description of the operation

start() None[source]

Start progress tracking.

update(increment: int = 1) None[source]

Update progress.

Parameters:

increment – Number of items processed since last update

finish() None[source]

Finish progress tracking.