Skip to content

Commit

Permalink
Devcontainer (#17)
Browse files Browse the repository at this point in the history
* chore: clean up Makefile

* chore: update poetry env

* chore: add devcontainer for CUDA version

* docs: add dev environment notes

* build: edit devcontainer environment

* docs: add notes tab to site

* ci: remove quarto ci/cd

* ci: add poetry --with cpu key

* chore: Update poetry install command to include dev dependencies
  • Loading branch information
vsheg authored Jun 28, 2024
1 parent baf26cb commit 351e3bb
Show file tree
Hide file tree
Showing 12 changed files with 1,681 additions and 1,361 deletions.
16 changes: 16 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "moll-cuda",
"dockerFile": "../Dockerfile.devcontainer",
"context": "../",
"remoteUser": "moll",
"runArgs": [
"--gpus=all"
],
"customizations": {
"vscode": {},
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"editor.tabSize": 4
}
}
}
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.pytest_cache/
.ruff_cache/
.venv/
29 changes: 0 additions & 29 deletions .github/workflows/docs-quarto.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: poetry
- run: poetry env use ${{ matrix.python-version }}
- run: poetry install -E cpu
- run: poetry install --with cpu,dev
- run: poetry run pytest
2 changes: 1 addition & 1 deletion .github/workflows/push-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ jobs:
python-version: '${{ vars.TARGET_PYTHON_VERSION }}'
cache: poetry
- run: poetry env use '${{ vars.TARGET_PYTHON_VERSION }}'
- run: poetry install -E cpu
- run: poetry install --with cpu,dev
- run: poetry run pytest
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
with:
python-version: "${{ vars.TARGET_PYTHON_VERSION }}"
cache: poetry
- run: poetry install -E cpu
- run: poetry install --with cpu,dev
- run: poetry build
- uses: actions/upload-artifact@v3
with:
Expand Down
16 changes: 16 additions & 0 deletions Dockerfile.devcontainer
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM mcr.microsoft.com/devcontainers/python:3.10 as base

ARG PROJECT_NAME=moll
ARG USER_NAME=$PROJECT_NAME
ARG SHELL=/bin/bash
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN userdel -r vscode \
&& groupadd --gid $USER_GID $USER_NAME \
&& useradd --uid $USER_UID --gid $USER_GID --shell $SHELL --create-home $USER_NAME \
&& echo $USER_NAME ALL=\(ALL\) NOPASSWD: ALL >> /etc/sudoers \
&& pipx install poetry \
&& apt-get install -y sudo

USER $USER_NAME
12 changes: 1 addition & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
render:
quarto render

prep_docs:
rsync -av notebooks/ docs/notebooks/
rsync -av README.md docs/index.md
Expand All @@ -17,17 +14,10 @@ notebooks:
clean:
rm -rf .venv .mypy* .pytest* .coverage* coverage.xml htmlcov **/__pycache__

cpu: clean
poetry install -E cpu

cuda12_local: clean
poetry install
poetry run pip install --upgrade "jax[cuda12_local]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html

metal: clean
# This is experimental
poetry env use 3.11
poetry install
poetry run pip install -U jax-metal==0.0.4 jax[cpu]==0.4.11 ml_dtypes==0.2.0 --extra-index-url https://storage.googleapis.com/jax-releases/jax_releases.html

.PHONY: render docs notebooks clean
.PHONY: docs notebooks clean
88 changes: 88 additions & 0 deletions docs/notes/02-dev.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Development Environment

## Requirements

- **JAX** is required to run the code.
- **Poetry** is used for dependency management.
- **NVIDIA Driver** and **NVIDIA Container Toolkit** are required for the CUDA version.



## Installation

### CPU Version

To install the CPU-only development environment, run the following command:

```bash
poetry install --with cpu,dev
```

### CUDA Version

1. Ensure the NVIDIA Driver is installed on your machine.
2. Install Docker and NVIDIA Container Toolkit.
3. Run the following command to install the GPU-supported development environment:

```bash
poetry install --with cuda,dev
```

### Manual JAX Installation

To use the local JAX installation, install without specifying additional dependencies:

```bash
poetry install --with dev
```



## Docker Container for Development

Optionally, you can run the development environment in a Docker container. Configuration files are `.devcontainer/*` and `Dockerfile.devcontainer`.

### CPU Version

To install the CPU version, run inside the devcontainer:

```bash
poetry install --with cpu,dev
```

### GPU Version

Install NVIDIA Container Toolkit and run the devcontainer. Then, run the following command:

```bash
poetry install --with cuda,dev
```



## Running Tests

To run the tests, use:

```bash
poetry run pytest
```



## Building Documentation

1. Install documentation-specific dependencies:

```bash
poetry install --with docs
```

2. Build the documentation:

```bash
make docs
```



1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ nav:
- B: notebooks/chembl-1-percent.ipynb
- C: notebooks/zinc20.ipynb
- API: api/
- Notes: notes/

theme:
name: material
Expand Down
Loading

0 comments on commit 351e3bb

Please sign in to comment.