This repository template is specifically designed for scientific computing projects in Python. It provides a complete, production-ready structure that ensures reproducibility, portability, and maintainability of your research code.
Use this template when you need to:
- Develop a reusable Python package for your research
- Run reproducible experiments with configuration management
- Share your code with supervisors, peers, or the research community
- Maintain clean separation between core algorithms and experimental scripts
- Ensure your project works consistently across different environments
your-project-name/
βββ package-name/ # Your main Python package
β βββ __init__.py # Package initialization
β βββ core/ # Core algorithms and models
β β βββ __init__.py
β βββ utils/ # Utility functions and helpers
β β βββ some_utils.py
β βββ data/ # Small datasets and static files
β βββ some_data.txt
βββ scripts/ # Experiment and analysis scripts
β βββ experiments/ # Main experimental runs
β β βββ main.py # Entry point for experiments
β β βββ conf/ # Configuration files (Hydra)
β β β βββ config.yaml
β β βββ outputs/ # Experiment results (auto-generated)
β βββ sandbox/ # Development and testing scripts
β βββ dev.py
βββ tests/ # Unit tests for your package
β βββ test_module1.py
βββ requirements.txt # Python dependencies
βββ setup.py # Package installation configuration
βββ README.md # This file
βββ LICENSE # License information
package-name/: Your main Python package. Rename this to match your project name (e.g.,neural_networks,data_analysis,optimization_toolkit)core/: Contains your main algorithms, models, and core functionalityutils/: Helper functions, data processing utilities, visualization toolsdata/: Small datasets, configuration files, or reference data (< 10MB). Store large datasets elsewherescripts/experiments/: Your main experimental scripts using Hydra for configuration managementscripts/sandbox/: Quick testing, prototyping, and development scriptstests/: Unit tests to ensure your code works correctly
Of course, the structure may be adapted to the specific needs of the project.
Before you start, ensure you have:
- Python 3.8 or higher (check with
python --version) - Git for version control
- Basic command line knowledge
- A text editor or IDE (VS Code, PyCharm, etc.)
- Click "Use this template" at the top of this repository page
- Name your repository (e.g.,
sentiment-analysis-toolkit,optimization-algorithms) - Choose visibility (public for open research, private for confidential work)
- Clone your new repository:
git clone https://github.com/your-username/your-project-name.git cd your-project-name
-
Create and activate a virtual environment:
# Create virtual environment python -m venv .venv # Activate it (macOS/Linux) source .venv/bin/activate # Activate it (Windows) .venv\Scripts\activate
-
Customize your project configuration:
- Rename the package directory: Change
package-name/to your actual package name (e.g.,ml_toolkit/) - Edit
setup.py: Update the placeholder values:name='your_actual_package_name', # Match your renamed directory version='0.1.0', author='Your Full Name', author_email='your.email@university.edu', description='Brief description of your research project', url='https://github.com/your-username/your-project-name',
- Rename the package directory: Change
-
Install dependencies and your package:
# Install required packages pip install -r requirements.txt # Install your package in development mode pip install -e .
The
-eflag installs in "editable" mode, so changes to your code are immediately available. -
Verify installation:
# Test that you can import your package python -c "import your_package_name; print('Success!')"
- Add your core algorithms in
your_package_name/core/ - Add utility functions in
your_package_name/utils/ - Create experiments in
scripts/experiments/ - Write tests in
tests/(run withpytest) - Update
requirements.txtwhen you add new dependencies:pip freeze > requirements.txt
This template uses Hydra for experiment configuration management, which is essential for reproducible research.
- Configuration files are stored in
scripts/experiments/conf/ - Default config:
config.yamlcontains your base experiment settings - Override parameters from command line without editing files
- Automatic logging and output directory management
Here's an example of how hydra can be used to run and configure experiments from the command line.
The parameter names here are just for illustration though.
cd scripts/experiments
# Run with default configuration
python main.py
# Override specific parameters
python main.py learning_rate=0.001 batch_size=64
# Use a different config file
python main.py --config-name=experiment_2
# Combine multiple overrides
python main.py model=resnet data.augment=true optimizer.lr=0.01Hydra automatically creates timestamped output directories:
scripts/experiments/outputs/
βββ 2025-09-26/
βββ 17-23-46/
βββ main.log # Automatic logging
βββ .hydra/ # Configuration snapshots
βββ your_results/ # Your experiment outputs
# Clone and setup
git clone https://github.com/your-username/your-project-name.git
cd your-project-name
# Create environment and install
python -m venv .venv
source .venv/bin/activate # or .venv\Scripts\activate on Windows
pip install -r requirements.txt
pip install -e .
# Run experiments
cd scripts/experiments
python main.py# Run tests regularly
pytest
# Check test coverage
pytest --cov=your_package_name
# Add tests for critical functions
def test_model_accuracy():
model = YourModel()
result = model.predict(test_data)
assert result.accuracy > 0.8# If you can't import your package
pip install -e . # Reinstall in editable mode
# If tests can't find your package
export PYTHONPATH="${PYTHONPATH}:$(pwd)"# If packages conflict
pip freeze > old_requirements.txt
pip uninstall -r old_requirements.txt -y
pip install -r requirements.txt# If config files aren't found
cd scripts/experiments # Make sure you're in the right directory
python main.py --help # Check available configurations- Hydra Documentation - Configuration management
- pytest Documentation - Testing framework
- Python Packaging Guide - Package distribution
- Git Tutorial - Version control basics
- PEP 8 Style Guide - Python coding standards
This project is licensed under the MIT License.