A collection of utility functions and tools to simplify common Python development tasks. This package provides various helper functions for logging, file operations, S3 interactions, and more.
- Logging: Easy-to-use logging setup with file handlers
- File Operations: Path checking and validation
- Decorators: Useful decorators for deprecation warnings and retry logic
- Image Verification: Validate and verify image files
- S3 Integration: Simplified AWS S3 file and directory operations
- Utilities: Various helper functions including timing and batching
Install the package using pip:
pip install mb_utilsfrom mb_utils.src.logging import logger
logger.info("This is an info message")
logger.error("This is an error message")from mb_utils.src.path_checker import check_path
check_path(path_list,max_workers=16)from mb_utils.src.retry_decorator import retry
@retry(max_retries=3, delay=1)
def might_fail():
passfrom mb_utils.src.s3 import upload_file, download_file, upload_dir, download_dir
# Upload a single file
upload_file('local_file.txt', 'bucket-name', 'remote_file.txt')
# Download a file
download_file('bucket-name', 'remote_file.txt', 'local_file.txt')| Module | Description | Import Path |
|---|---|---|
| logging | Logger setup with file handlers | from mb_utils.src.logging import logger |
| path_checker | Path validation utilities | from mb_utils.src.path_checker import * |
| deprecated | Function deprecation decorator | from mb_utils.src.deprecated import deprecated_func |
| verify_image | Image verification | from mb_utils.src.verify_image import verify_image |
| retry_decorator | Retry mechanism for functions | from mb_utils.src.retry_decorator import retry |
| s3 | AWS S3 operations | from mb_utils.src.s3 import * |
| extra | Additional utilities | from mb_utils.src.extra import * |
| profiler | Code profiling utilities | from mb_utils.src.profiler import * |
The profiler module provides utilities for performance analysis of your Python code.
from mb_utils.src.profiler import run_with_snakeviz
@run_with_snakeviz(save_only=False) # Opens SnakeViz automatically
def process_data(data):
pass
# Or use as context manager
with run_with_snakeviz():
passfrom mb_utils.src.profiler import line_profile
@line_profile
def process_item(item):
result = item * 2
return resultfrom mb_utils.src.profiler import time_it
@time_it
def expensive_operation():
passfrom mb_utils.src.profiler import MemoryProfiler
def process_large_data():
with MemoryProfiler() as mem:
data = [0] * 10**6from mb_utils.src.profiler import profile_function
@profile_function(
enable_line_profiling=True,
enable_memory_profiling=True
)
def analyze_data(data):
# Will run with multiple profiling tools
passverify_images_script: Utility script for image verification
This project is licensed under the MIT License - see the LICENSE file for details.