Skip to content

Commit

Permalink
Release: Add Amelie's fork of Chai-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Liana64 committed Dec 9, 2024
1 parent a65400f commit 6be3de1
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 0 deletions.
77 changes: 77 additions & 0 deletions apps/chai-amelie/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
FROM docker.io/library/python:3.12-slim-bookworm

LABEL \
maintainer="Liana64" \
org.opencontainers.image.source="https://github.com/amelie-iska/chai-lab"

ARG TARGETPLATFORM
ARG VERSION
ARG CHANNEL
ARG DEBIAN_FRONTEND=noninteractive

ENV \
NVIDIA_DRIVER_CAPABILITIES="compute,video,utility,graphics" \
PATH="/opt/venv/bin:$PATH" \
UMASK="0002" \
LANG=C.UTF-8 \
TZ="Etc/UTC" \
USERNAME=rare \
UID=900 \
GID=900 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONFAULTHANDLER=1 \
PIP_ROOT_USER_ACTION=ignore \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_BREAK_SYSTEM_PACKAGES=1 \
UV_HTTP_TIMEOUT=1000

USER root
WORKDIR /app

RUN \
groupadd --gid ${GID} ${USERNAME} \
&& useradd --uid ${UID} --gid ${GID} --create-home --shell /bin/bash ${USERNAME} \
&& apt-get update && apt-get install -y --no-install-recommends \
curl unzip build-essential catatonit jq \
gnupg ca-certificates lsb-release \
nano vim tree git \
# -----------------------------------
# TODO: Build images with extras
# -----------------------------------
# htop tmux psmisc \
# socat rsync aria2 openssh-server \
# -----------------------------------
# TODO: Build images with RDMA & InfiniBand
# -----------------------------------
# libibverbs1 librdmacm1 \
# -----------------------------------
&& git clone https://github.com/amelie-iska/chai-lab.git /tmp/chai \
&& cp -R /tmp/chai/LICENSE /app \
&& cp -R /tmp/chai/assets /app \
&& cp -R /tmp/chai/examples /app \
&& cp -R /tmp/chai/tests /app \
&& printf "UpdateMethod=docker\nBranch=master\nPackageVersion=%s\nPackageAuthor=[RareCompute](https://github.com/RareCompute)\n" "${VERSION}" > /app/package_info \
&& chown -R ${UID}:${GID} /app && chmod -R 755 /app \
&& curl -LsSf https://astral.sh/uv/0.5.6/install.sh | sh \
&& . $HOME/.local/bin/env \
&& uv venv --no-python-downloads /opt/venv \
&& . /opt/venv/bin/activate \
&& cd /tmp/chai \
&& uv pip install -r /tmp/chai/requirements.in \
&& uv pip install . \
&& chown -R ${UID}:${GID} /opt/venv && chmod -R 755 /opt/venv \
&& apt-get purge -y build-essential \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /root/.cache /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& chsh -s /bin/bash

COPY --chown=${UID}:${GID} ./apps/chai/entrypoint.sh /entrypoint.sh
RUN chmod -R 755 /entrypoint.sh

USER ${USERNAME}
WORKDIR /app

ENTRYPOINT ["/usr/bin/catatonit", "--", "/entrypoint.sh"]
18 changes: 18 additions & 0 deletions apps/chai-amelie/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Chai

Amelie's fork of Chai-1, from the [upstream repository](https://github.com/amelie-iska/chai-lab):

> Chai-1 is a multi-modal foundation model for molecular structure prediction that performs at the state-of-the-art across a variety of benchmarks. Chai-1 enables unified prediction of proteins, small molecules, DNA, RNA, glycosylations, and more.
## Environment variables

You can configure the docker image using the below environment variables

| Environment Variable | CLI Flag | Type | Default Value | Description |
| -------------------- | ------------------ | --------- | ---------------- | ----------------------------------------------- |
| `USERNAME` | N/A | `STR` | `rare` | Username for the container |
| `UID` | N/A | `INTEGER` | `900` | UID for the container |
| `GID` | N/A | `INTEGER` | `900` | GID for the container |
| `CHAI_DOWNLOADS_DIR` | N/A | `PATH` | `/tmp/downloads` | The path where downloads will be cached. |
| `USE_MSA_SERVER` | `--use-msa-server` | `BOOLEAN` | `False` | Whether to use the MSA server to generate MSAs. |
| `MSA_SERVER_URL` | `--msa-server-url` | `STR` | N/A | Use a custom MSA server |
7 changes: 7 additions & 0 deletions apps/chai-amelie/ci/goss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/goss-org/goss/master/docs/schema.yaml
file:
/opt/venv/bin/chai:
exists: true
/app/LICENSE:
exists: true
7 changes: 7 additions & 0 deletions apps/chai-amelie/ci/latest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
git clone --quiet https://github.com/amelie-iska/chai-lab.git /tmp/chai
pushd /tmp/chai > /dev/null || exit
version=$(git rev-list --count --first-parent HEAD)
popd > /dev/null || exit
rm -rf /tmp/chai
printf "1.0.%d" "${version}"
23 changes: 23 additions & 0 deletions apps/chai-amelie/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

EXTRA_FLAGS=""
declare -A FLAG_MAP=(
[USE_MSA_SERVER]="--use-msa-server"
[MSA_SERVER_URL]="--msa-server-url"
)

for VAR in "${!FLAG_MAP[@]}"; do
if [ -n "${!VAR}" ]; then
VALUE_LOWER=$(echo "${!VAR}" | tr '[:upper:]' '[:lower:]')
if [[ "$VALUE_LOWER" == "true" ]]; then
EXTRA_FLAGS+=" ${FLAG_MAP[$VAR]}"
elif [[ "$VALUE_LOWER" != "false" ]]; then
EXTRA_FLAGS+=" ${FLAG_MAP[$VAR]} ${!VAR}"
fi
fi
done

exec \
chai \
"$@" \
$EXTRA_FLAGS
11 changes: 11 additions & 0 deletions apps/chai-amelie/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
#yamllint disable
app: chai-amelie
semver: true
channels:
- name: stable
platforms: ["linux/amd64", "linux/arm64"]
stable: true
tests:
enabled: false
type: cli

0 comments on commit 6be3de1

Please sign in to comment.