Skip to content

svnv-svsv-jm/init-new-project

Repository files navigation

Start new Python project

Project is undergoing renovation. This was written before uv and just were a thing. I am currently updating it to what I more recently have been using.

This repository exists because every time I have to set up a new Python project, there is just too much I have to do. So here is a useful template for myself. Feel free to clone it or download it if you want.

The project contains a justfile so that useful but long commands can be run without too much thinking. Besides, mypy, ruff are also configured.

A .env file lets you choose the project's name, the Python version and more stuff. Check the file please.

This template is to develop a PyTorch project, but you can change it to whatever you want.

It is implied that you are on Mac/Linux. No Windows.

Installation via virtual environment

Pre-requisites

You need to install 2 main tools:

  • just (see here) commands to facilitate users and developers (also see how we use it);
  • uv for managing Python.

Please also note that you could install just via uv: uv tool install just. So we could say, in theory, that only uv is necessary to join the development of this project.

These tools will take care of everything for you. So make sure they are installed.

You can then do:

just install

Installation via Docker

Deprecated, work in progress...

Build project's image as follows:

docker build -t <project-name> -f Dockerfile .
# or alternatively
make build

The present folder will be mounted at /workdir.

More docker-related features

  • To start a Bash session in the container, run: make bash
  • To start a Jupyter Notebook (+ a Tensorboard), run: make up. Then run make down when you're done.
  • To run PyTest from the container, run: make pytest-image
  • To start a Python session in the container, run: make docker-python
  • To start a development container, run: make dev-container or make up (if you go for this one, you can then kill the container with make down). Make sure that you're not root in the container. To see if a user with your local username and userid exists inside the container, run cat /etc/passwd. Then, you can run su - <your-username> to change user insinde the dev container.

Please also note that our image's entrypoint is the script entrypoint.sh. This script solves common permission problems for developers who wish to mount their local source code directory on a container, as explained here. TL;DR: you will be logged into your container as your current user, thus avoinding any permission errors.

Usage

Please check the examples folder: here

Run experiments

Check the experiments folder: readme

Developer documentation

If you wish to contribute to the project, please see here

About

Template when developing a new Python project

Resources

License

Contributing

Stars

1 star

Watchers

1 watching

Forks

Packages

 
 
 

Contributors