Skip to content

Commit 21d04ef

Browse files
committed
Improve dependency mangement with pyproject.toml and uv
1 parent f76e84f commit 21d04ef

File tree

11 files changed

+2918
-177
lines changed

11 files changed

+2918
-177
lines changed

.gitignore

Lines changed: 73 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,15 @@
1-
# added elements
2-
3-
.vscode
4-
last_repertoire
5-
*logs.csv
6-
7-
# Singularity generated files
8-
*.simg
9-
*.sif
10-
*.swp
11-
tmp.def
12-
13-
14-
# Figures and Videos
1+
# Generated files
2+
*.csv
153
*.pth
164
*.png
175
*.svg
186
*.pdf
197
*.mp4
208
*.gif
219

22-
# IDE configuration file
23-
.idea/
24-
25-
# Hydra outputs
26-
hydra_outputs/
27-
28-
29-
# Usual python .gitignore
30-
31-
# Mac OS X files
32-
.DS_Store
33-
3410
# Byte-compiled / optimized / DLL files
3511
__pycache__/
36-
*.py[cod]
12+
*.py[codz]
3713
*$py.class
3814

3915
# C extensions
@@ -79,7 +55,7 @@ htmlcov/
7955
nosetests.xml
8056
coverage.xml
8157
*.cover
82-
*.py,cover
58+
*.py.cover
8359
.hypothesis/
8460
.pytest_cache/
8561
cover/
@@ -127,7 +103,37 @@ ipython_config.py
127103
# install all needed dependencies.
128104
#Pipfile.lock
129105

130-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
106+
# UV
107+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
108+
# This is especially recommended for binary packages to ensure reproducibility, and is more
109+
# commonly ignored for libraries.
110+
#uv.lock
111+
112+
# poetry
113+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
114+
# This is especially recommended for binary packages to ensure reproducibility, and is more
115+
# commonly ignored for libraries.
116+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
117+
#poetry.lock
118+
#poetry.toml
119+
120+
# pdm
121+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
122+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
123+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
124+
#pdm.lock
125+
#pdm.toml
126+
.pdm-python
127+
.pdm-build/
128+
129+
# pixi
130+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
131+
#pixi.lock
132+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
133+
# in the .venv directory. It is recommended not to include this directory in version control.
134+
.pixi
135+
136+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
131137
__pypackages__/
132138

133139
# Celery stuff
@@ -139,6 +145,7 @@ celerybeat.pid
139145

140146
# Environments
141147
.env
148+
.envrc
142149
.venv
143150
env/
144151
venv/
@@ -170,5 +177,40 @@ dmypy.json
170177
# Cython debug symbols
171178
cython_debug/
172179

173-
# HTML files
174-
*.html
180+
# PyCharm
181+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
182+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
183+
# and can be added to the global gitignore or merged into this file. For a more nuclear
184+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
185+
#.idea/
186+
187+
# Abstra
188+
# Abstra is an AI-powered process automation framework.
189+
# Ignore directories containing user credentials, local state, and settings.
190+
# Learn more at https://abstra.io/docs
191+
.abstra/
192+
193+
# Visual Studio Code
194+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
195+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
196+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
197+
# you could uncomment the following to ignore the entire vscode folder
198+
# .vscode/
199+
200+
# Ruff stuff:
201+
.ruff_cache/
202+
203+
# PyPI configuration file
204+
.pypirc
205+
206+
# Cursor
207+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
208+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
209+
# refer to https://docs.cursor.com/context/ignore-files
210+
.cursorignore
211+
.cursorindexingignore
212+
213+
# Marimo
214+
marimo/_static/
215+
marimo/_lsp/
216+
__marimo__/

dev.Dockerfile

Lines changed: 44 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,32 @@
1-
FROM mambaorg/micromamba:1.5.1 as conda
1+
FROM python:3.11-slim as test-image
2+
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
3+
WORKDIR /app
24

3-
# Speed up the build, and avoid unnecessary writes to disk
4-
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 CONDA_DIR=/opt/conda
5-
ENV PIPENV_VENV_IN_PROJECT=true PIP_NO_CACHE_DIR=false PIP_DISABLE_PIP_VERSION_CHECK=1
6-
ENV PATH=${CONDA_DIR}/bin:${PATH}
7-
ENV MAMBA_ROOT_PREFIX="/opt/conda"
5+
# Minimal OS deps for tests
6+
RUN apt-get update && apt-get install -y --no-install-recommends \
7+
git curl \
8+
&& rm -rf /var/lib/apt/lists/*
89

9-
COPY requirements.txt /tmp/requirements.txt
10-
COPY requirements-dev.txt /tmp/requirements-dev.txt
11-
COPY environment.yaml /tmp/environment.yaml
10+
# Install uv
11+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
12+
ENV PATH="/root/.local/bin:$PATH"
1213

13-
RUN micromamba create -y --file /tmp/environment.yaml \
14-
&& micromamba clean --all --yes \
15-
&& find /opt/conda/ -follow -type f -name '*.pyc' -delete
14+
# Create venv and activate permanently
15+
RUN uv venv --clear --python 3.13
16+
ENV VIRTUAL_ENV="/app/.venv"
17+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
1618

17-
18-
FROM python as test-image
19-
ENV PATH=/opt/conda/envs/qdaxpy310/bin/:$PATH APP_FOLDER=/app
20-
ENV PYTHONPATH=$APP_FOLDER:$PYTHONPATH
21-
22-
COPY --from=conda /opt/conda/envs/. /opt/conda/envs/
23-
COPY requirements-dev.txt ./
24-
25-
RUN pip install -r requirements-dev.txt
19+
# Install the project with dev extras
20+
COPY pyproject.toml README.md ./
21+
COPY qdax ./qdax
22+
RUN uv pip install jax[cuda] .[dev]
2623

2724

2825
FROM nvidia/cuda:11.5.2-cudnn8-devel-ubuntu20.04 as cuda-image
29-
ENV PATH=/opt/conda/envs/qdaxpy310/bin/:$PATH APP_FOLDER=/app
30-
ENV PYTHONPATH=$APP_FOLDER:$PYTHONPATH
31-
32-
33-
ENV DISTRO ubuntu2004
34-
ENV CPU_ARCH x86_64
35-
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/$DISTRO/$CPU_ARCH/3bf863cc.pub
36-
37-
38-
COPY --from=conda /opt/conda/envs/. /opt/conda/envs/
39-
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.0/targets/x86_64-linux/lib
40-
41-
ENV TZ=Europe/Paris
42-
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
43-
RUN pip --no-cache-dir install jaxlib==0.4.16+cuda11.cudnn86 \
44-
-f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html \
45-
&& rm -rf /tmp/*
46-
47-
WORKDIR $APP_FOLDER
48-
49-
ARG USER_ID=1000
50-
ARG GROUP_ID=1000
51-
ENV USER=eng
52-
ENV GROUP=eng
53-
RUN groupadd --gid ${GROUP_ID} $GROUP && useradd -g $GROUP --uid ${USER_ID} --shell /usr/sbin/nologin -m $USER && chown -R $USER:$GROUP $APP_FOLDER
54-
USER $USER
26+
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
27+
WORKDIR /app
5528

56-
57-
FROM cuda-image as dev-image
58-
# The dev-image does not contain the any file, qdax is expected to be mounted
59-
# afterwards
60-
61-
USER root
29+
# System packages needed for examples/headless rendering and tooling
6230
RUN apt-get update && \
6331
apt-get install -y --no-install-recommends \
6432
curl \
@@ -70,8 +38,6 @@ RUN apt-get update && \
7038
libosmesa6-dev \
7139
patchelf \
7240
python3-opengl \
73-
python3-dev=3.10* \
74-
python3-pip \
7541
screen \
7642
sudo \
7743
tmux \
@@ -82,21 +48,33 @@ RUN apt-get update && \
8248
xvfb && \
8349
rm -rf /var/lib/apt/lists/*
8450

51+
# Install uv
52+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
53+
ENV PATH="/root/.local/bin:$PATH"
8554

86-
COPY requirements-dev.txt /tmp/requirements-dev.txt
87-
RUN pip --no-cache-dir install -r /tmp/requirements-dev.txt && rm -rf /tmp/*
88-
USER $USER
55+
# Create venv and activate permanently
56+
RUN uv venv --clear --python 3.13
57+
ENV VIRTUAL_ENV="/app/.venv"
58+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
8959

90-
FROM cuda-image as run-image
91-
# The run-image (default) is the same as the dev-image with the some files directly
92-
# copied inside
60+
# Install the project with dev and examples extras
61+
COPY pyproject.toml README.md ./
62+
COPY qdax ./qdax
63+
RUN uv pip install jax[cuda] .[dev,examples]
9364

94-
COPY qdax qdax
95-
COPY setup.py ./
96-
COPY README.md ./
9765

98-
RUN pip install .
66+
FROM cuda-image as dev-image
67+
# The dev-image already contains dependencies; repo can be mounted at /app for live dev
9968

100-
WORKDIR /
69+
ARG USER_ID=1000
70+
ARG GROUP_ID=1000
71+
ENV USER=eng
72+
ENV GROUP=eng
73+
RUN groupadd --gid ${GROUP_ID} $GROUP && useradd -g $GROUP --uid ${USER_ID} --shell /usr/sbin/nologin -m $USER && chown -R $USER:$GROUP /app
74+
USER $USER
10175

76+
77+
FROM cuda-image as run-image
78+
# Default run image
79+
WORKDIR /
10280
CMD ["python"]

environment.yaml

Lines changed: 0 additions & 12 deletions
This file was deleted.

mypy.ini

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)