Skip to content

Commit 7c3a9e1

Browse files
committed
add dockerfile and workflow to build a marimo
1 parent 65de776 commit 7c3a9e1

File tree

6 files changed

+239
-2
lines changed

6 files changed

+239
-2
lines changed

.github/workflows/docker-jupyter-image.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: ghcr
1+
name: ghcr-jupyter
22
on:
33
push:
44
# branches: [ "main" ]
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: ghcr-marimo
2+
on:
3+
push:
4+
# branches: [ "main" ]
5+
# pull_request:
6+
# branches: [ "main" ]
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
packages: write
12+
contents: read
13+
steps:
14+
- name: 'clone the repo'
15+
uses: actions/checkout@v4
16+
- name: 'login to ghcr'
17+
uses: docker/login-action@v3
18+
with:
19+
registry: ghcr.io
20+
username: ${{github.actor}}
21+
password: ${{secrets.GITHUB_TOKEN}}
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Build and push Docker image
26+
uses: docker/build-push-action@v5
27+
with:
28+
context: ./containers
29+
file: ./containers/Dockerfile.marimo
30+
push: true
31+
tags: |
32+
ghcr.io/stfc/janus-core/marimo:${{ github.sha }}
33+
ghcr.io/stfc/janus-core/marimo:latest

containers/Dockerfile.marimo

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
FROM python:3.12-slim
2+
3+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
4+
5+
LABEL maintainer="Alin Elena <[email protected]>"
6+
ARG UID="1001"
7+
ARG GID="100"
8+
9+
ENV user=drFaustroll
10+
ENV group=drFaustroll
11+
RUN useradd -m ${user}
12+
WORKDIR /app
13+
14+
USER root
15+
16+
ENV DEBIAN_FRONTEND=noninteractive
17+
RUN apt update --yes && \
18+
apt upgrade --yes && \
19+
apt install --yes --no-install-recommends \
20+
ca-certificates \
21+
locales \
22+
sudo \
23+
tini \
24+
wget bzip2 curl git gcc g++ make cmake && \
25+
apt clean && rm -rf /var/lib/apt/lists/* && \
26+
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
27+
locale-gen
28+
29+
30+
ARG marimo_version=0.14.16
31+
ENV MARIMO_SKIP_UPDATE_CHECK=1
32+
ENV UV_SYSTEM_PYTHON=1
33+
RUN uv pip install --no-cache-dir marimo==${marimo_version} && \
34+
mkdir -p /app/data && \
35+
chown -R ${user}:${group} /app
36+
37+
COPY --chown=${user}:${group} assets/tutorials tutorials
38+
39+
ENV PORT=8842
40+
EXPOSE $PORT
41+
42+
ENV HOST=0.0.0.0
43+
44+
RUN uv pip install --no-cache-dir marimo[recommended,lsp,sql] altair pandas python-lsp-server websockets \
45+
duckdb \
46+
sqlglot \
47+
vegafusion vl-convert-python \
48+
ruff \
49+
openai \
50+
nbformat \
51+
pytest
52+
RUN uv pip install --no-cache-dir 'janus-core[all]@git+https://github.com/stfc/janus-core.git@main'
53+
RUN uv pip install --no-cache-dir cuequivariance==0.5.1 \
54+
cuequivariance-torch==0.5.1 \
55+
cuequivariance-ops-torch-cu12==0.5.1 \
56+
torchvision \
57+
pack-mm \
58+
seaborn \
59+
data-tutorials \
60+
pymatviz \
61+
opentsne \
62+
pymatgen \
63+
pymatviz \
64+
git+https://github.com/imagdau/aseMolec@main
65+
66+
CMD marimo edit --no-token -p $PORT --host $HOST
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
from __future__ import annotations
2+
3+
import marimo
4+
5+
__generated_with = "0.14.16"
6+
app = marimo.App(width="medium")
7+
8+
9+
@app.cell
10+
def _():
11+
from ase.build import bulk
12+
from ase.io import read, write
13+
import marimo as mo
14+
from pymatgen.io.ase import AseAtomsAdaptor
15+
import pymatviz as view
16+
17+
from janus_core.calculations.geom_opt import GeomOpt
18+
19+
return AseAtomsAdaptor, GeomOpt, bulk, mo, read, view, write
20+
21+
22+
@app.cell
23+
def _(bulk, write):
24+
device = "cpu"
25+
a = 6.0
26+
NaCl = bulk(
27+
"NaCl", crystalstructure="rocksalt", cubic=True, orthorhombic=True, a=a
28+
) * (2, 2, 2)
29+
NaCl.rattle(stdev=0.1, seed=2042)
30+
write("NaCl.extxyz", NaCl)
31+
return (NaCl,)
32+
33+
34+
@app.cell
35+
def _(AseAtomsAdaptor, NaCl, view):
36+
struct = AseAtomsAdaptor().get_structure(NaCl)
37+
38+
s_widget = view.StructureWidget(
39+
structure=struct, show_bonds=True, bonding_strategy="nearest_neighbor"
40+
)
41+
s_widget
42+
return
43+
44+
45+
@app.cell
46+
def _(mo):
47+
# Create a form with multiple elements
48+
form = (
49+
mo.md("""
50+
**Geomtry Optimisation**
51+
52+
Upload Structure {structure}
53+
54+
optimize {optimize}
55+
56+
{fmax}
57+
58+
ML model :{model}
59+
""")
60+
.batch(
61+
structure=mo.ui.file(label="Structure"),
62+
fmax=mo.ui.number(label="fmax", value=0.01),
63+
optimize=mo.ui.radio(
64+
options={"Just coordinates": 1, "Cell vectors only": 2, "Full": 3},
65+
value="Full", # initial value
66+
label="choose a methood",
67+
),
68+
model=mo.ui.dropdown(
69+
options={
70+
"MACE_MP-small": ("mace_mp", "small"),
71+
"MACE_MP-medium": ("mace_mp", "medium"),
72+
},
73+
value="MACE_MP-small",
74+
),
75+
)
76+
.form(
77+
show_clear_button=True,
78+
bordered=True,
79+
submit_button_disabled=False,
80+
submit_button_tooltip="start the calculation",
81+
)
82+
)
83+
form
84+
return (form,)
85+
86+
87+
@app.cell
88+
def _(form):
89+
settings = form.value
90+
print(settings)
91+
return (settings,)
92+
93+
94+
@app.cell
95+
def _(GeomOpt, form, mo, read, settings):
96+
mo.stop(form.value is None, mo.md("Upload a file and submit"))
97+
98+
from io import BytesIO
99+
100+
x = settings["structure"][0]
101+
m = read(BytesIO(x.contents), format="cif")
102+
103+
model = settings["model"]
104+
optimized_NaCl = GeomOpt(
105+
struct=m,
106+
model=model[1],
107+
arch=model[0],
108+
fmax=settings["fmax"],
109+
optimizer="FIRE",
110+
write_traj=True,
111+
)
112+
113+
optimized_NaCl.run()
114+
return (m,)
115+
116+
117+
@app.cell
118+
def _(m):
119+
m
120+
return
121+
122+
123+
if __name__ == "__main__":
124+
app.run()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from __future__ import annotations
2+
3+
import marimo
4+
5+
app = marimo.App()
6+
7+
8+
@app.cell
9+
def __():
10+
return
11+
12+
13+
if __name__ == "__main__":
14+
app.run()

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ pythonpath = ["."]
171171
source=["janus_core"]
172172

173173
[tool.ruff]
174-
exclude = ["conf.py", "*ipynb"]
174+
exclude = ["conf.py", "*ipynb","containers/assets/tutorials/*.py"]
175175
target-version = "py310"
176176

177177
[tool.ruff.lint]

0 commit comments

Comments
 (0)