Skip to content

JeremieGince/PythonProject-Template

Repository files navigation

PythonProject-Template

Star on GitHub GitHub forks Python 3.6 downloads PyPI version License

Tests Workflow Dist Workflow Doc Workflow Code style: black Imports: isort

Description

This is a template for a Python project. It includes a basic project structure, a Dockerfile, a requirements.txt file a README.md file, etc. The goal of this template is to provide a starting point for a Python project. Once you have cloned this repository, you can start by changing the attributes of the project using the change_project_attributes.py script with the following command:

python change_project_attributes.py --help

Then you can start developing your project by adding your code to the src directory.

The project is constituted by the following parts:

  • /.github: This directory contains the GitHub Actions workflows that are responsible for
    • running the tests: .github/workflows/tests.yml
    • build the distribution: .github/workflows/build_dist.yml
    • build the documentation: .github/workflows/docs.yml
  • /data: This directory will contain the data that will be used and generated by the project.
  • /dist: This directory will contain the distribution of the project.
  • /docs: This directory will contain the documentation of the project.
  • /images: This directory will contain the images that will be used in the README.md file or in the documentation.
  • /sphinx: This directory contains the configuration of the Sphinx documentation.
  • /src: This directory will contain the source code of the project. This is where you will add your own sauce.
  • /tests: This directory will contain the tests of the project.
  • /docker_files: This directory contains the scripts that will help you build the docker image and run the project in a container.
  • Dockerfile: This file is responsible for building the docker image of the project.
  • .gitattributes: This file is responsible for setting the git attributes of the project.
  • .gitignore: This file is responsible for ignoring the files that you don't want to commit to the repository. A basic one is already provided and should be enough for most of the projects.
  • pyproject.toml: This file is responsible for listing the dependencies of the project and the configuration of the project.
  • README.md: This file is responsible for providing information about the project. A basic structure is provided after this little introduction.
  • change_project_attributes.py: This script is responsible for changing the attributes of the project. Feel free to remove it once you used it.
  • setup.py: This file is responsible for setting up the project.
  • LICENSE: This file is responsible for providing the license of the project.

README TEMPLATE

Installation

Development Dependencies

With uv installed, run the following commands to install the dependencies:

uv venv .venv
uv sync --dev

With python and pip installed, run the following commands to install the dependencies:

python -m venv .venv
source .venv/bin/activate
pip install uv
python -m uv sync --dev

With poetry installed, run the following commands to install the dependencies:

python -m venv .venv
source .venv/bin/activate
poetry install

Scripting Usage

To run a single training, you can run the following command:

python -m <package_name> <your_parameters>

and to know the parameters you can use the help command:

python -m <package_name> --help

Deployment

You will need to install Docker to run the trainings in a container. You can install Docker by following the instructions here.

To build the docker image of the project you can run the following command:

docker build -t <package_name>:latest .

The container can be run in two different modes:

  • release: This mode is responsible for running the main.py of the current package.
  • it: This is a development mode that is responsible for running the container in the interactive mode.

To run a mode <mode> you can run the following command:

docker run --name <package_name>-<phase> --detach --rm --volume=<data_path>:/<ROOT_DIR>/data -e "MODE=<mode>" <package_name>:latest <your_arguments>

where <data_path> is the absolute path in your local machine where you want to store the data generated by the phase. The <ROOT_DIR> is the root directory of the project.

There is another way you can do all of this. You can use the docker_files/build_image_and_run.py script. This script will build the image and run the mode you want. You can run the script with the following command:

python docker_files/build_image_and_run.py --mode=<mode>

References

License

Acknowledgements

Citation

About

Python Template with uv

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •