Development Guide
This guide provides information for developers who want to contribute to or extend Transfer Learning.Project Structure
The Transfer Learning project follows a modular architecture with clear separation of concerns:Development Setup
Installation Scripts
Transfer Learning provides automated installation scripts in thescripts directory:
install.sh- For Unix-based systems (Linux, macOS)install.bat- For Windows systems
- Verify Python version compatibility (3.9+)
- Create and activate a virtual environment
- Install UV package manager
- Install project dependencies
- Set up required directories (data, logs, metrics, cache)
- Create a default
.envconfiguration file - Install development dependencies (optional)
- Edit
scripts/install.shorscripts/install.bat - Update the directory creation in the
create_directoriesfunction - Modify the default configuration in the
create_env_filefunction - Add new dependencies or setup steps as needed
1
Clone the Repository
2
Set Up Virtual Environment
3
Install Development Dependencies
Transfer Learning uses UV as the package manager for faster, more reliable dependency management. UV provides significant performance improvements over traditional pip, especially for large dependency trees.
4
Set Up Environment Variables
Create a
.env file in the project root directory:Development Workflow
Running Tests
Running Tests
Run the test suite to ensure your changes don’t break existing functionality:Run tests with coverage report:
Code Style
Code Style
Check code style with Ruff:Format code with Black:
Running the CLI
Running the CLI
Run the CLI in development mode:Or use the installed entry point:You can also use the convenient The
tl command alias:tl command is available through shell scripts in the scripts directory:scripts/tlfor Unix-like systems (macOS/Linux)scripts/tl.batfor Windows
Extending Transfer Learning
Adding a New Command
To add a new command to the CLI:- Open
src/transfer_learning/cli.py - Add a new function with the
@app.command()decorator:
Adding a New Module
To add a new module:- Create a new Python file in the appropriate directory
- Implement your module functionality
- Import and use it in the CLI or other modules
Enhancing Monitoring
To add new metrics to the monitoring system:- Open
src/transfer_learning/monitoring/metrics.py - Add new fields to the
ProcessingMetricsdataclass - Update the
to_dictmethod to include the new fields - Use the new metrics in your code
Documentation
Transfer Learning uses Mintlify for documentation. To update the documentation:- Edit the MDX files in the
docsdirectory - Preview the documentation locally:
- Submit a pull request with your documentation changes
Contribution Guidelines
Code Style
- Follow PEP 8 guidelines
- Use type hints for all functions
- Write docstrings for all modules, classes, and functions
- Keep functions small and focused
Testing
- Write tests for all new functionality
- Ensure all tests pass before submitting a PR
- Aim for high test coverage
- Include both unit and integration tests
Documentation
- Update documentation for all new features
- Include examples in docstrings
- Keep the README and docs in sync
- Document configuration options
Pull Requests
- Create a feature branch for your changes
- Keep PRs focused on a single feature or fix
- Include a clear description of changes
- Reference any related issues
Development Checklist
Use this checklist when developing new features:- Implement the feature
- Write tests
- Update documentation
- Check code style
- Run the test suite
- Update the README if necessary
- Submit a pull request
Monitoring and Logging
Transfer Learning includes a comprehensive monitoring and logging system:- Metrics
- Logging
The
MetricsTracker class in src/transfer_learning/monitoring/metrics.py provides metrics collection:Performance Optimization
When developing performance-critical components:- Use asynchronous processing for I/O-bound operations
- Implement batching for API calls
- Use caching to avoid redundant processing
- Monitor memory usage and optimize as needed