Skip to content

Commit

Permalink
merge main into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mathysgrapotte committed Feb 12, 2025
2 parents f925684 + ee5b4b5 commit 6335c37
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@ __pycache__/

# cursor
.cursorrules

# Ignore output directories from Titanic tests
/tests/test_data/titanic/ray_results/
/tests/test_data/titanic/test_results/

# Ignore output directories from Dream tests
/tutorials/dream/dream_train.csv
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- src.stimulus.data -> stimulus.data. ([b04546c](https://github.com/mathysgrapotte/stimulus-py/commit/b04546c2c9bcc1f6218c31d8f7132e57ea1dab91) by mgrapotte).
- src.stimulus.utils -> stimulus.utils. ([55d1fed](https://github.com/mathysgrapotte/stimulus-py/commit/55d1fed95950adc2782a73a90690783786c9fb85) by mgrapotte).

<!-- insertion marker -->

## [0.2.4](https://github.com/mathysgrapotte/stimulus-py/releases/tag/0.2.4) - 2025-02-07

<small>[Compare with 0.2.3](https://github.com/mathysgrapotte/stimulus-py/compare/0.2.3...0.2.4)</small>
Expand All @@ -114,3 +114,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- test were failing, made format to fix it. ([19dce1f](https://github.com/mathysgrapotte/stimulus-py/commit/19dce1f2f6fc069a24991a843249f7edc876bb43) by mgrapotte).


## [0.2.5](https://github.com/mathysgrapotte/stimulus-py/releases/tag/0.3.0) - 2025-02-12

<small>[Compare with 0.2.4](https://github.com/mathysgrapotte/stimulus-py/compare/0.2.4...0.3.0)</small>

### Features

- removed test results from git push. ([3f3f516](https://github.com/mathysgrapotte/stimulus-py/commit/3f3f5161e54dfc2d4db40ff59e5a2e924d30bfe4) by mgrapotte).
- added dockerfiles. ([c18489f](https://github.com/mathysgrapotte/stimulus-py/commit/c18489f59ba7e0f36c5f90a7ce51248c0bb49a07) by mgrapotte).

### Bug Fixes

- fixed duplicate in ruff config. ([eb9d3bf](https://github.com/mathysgrapotte/stimulus-py/commit/eb9d3bf566c7ab94c02f30b85d5a946b440711b9) by mgrapotte).
- update ruff config to ignore shadowing python typing. ([55d33be](https://github.com/mathysgrapotte/stimulus-py/commit/55d33be8a6068e3b4649275ec1bf3827c21ffb9a) by mgrapotte).
- renamed dockerfiles directory as it was causing ci to crash. ([6c19df4](https://github.com/mathysgrapotte/stimulus-py/commit/6c19df4589c2ff6e3a5ded53d561ba50dd4255f0) by mgrapotte).
- ray init needs to be called in the run command otherwise ray cluster is not found. ([c9526d6](https://github.com/mathysgrapotte/stimulus-py/commit/c9526d60c909ddc8d8dabd751380c5d5e16b8d44) by mgrapotte).
- ray init needs to be called in the run command, otherwise ray cluster is not found. ([4ebd495](https://github.com/mathysgrapotte/stimulus-py/commit/4ebd495ba348698252598d8e7a3575cead057593) by mgrapotte).


6 changes: 6 additions & 0 deletions config/ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ ignore = [
"PLR2004", # Magic value used in comparison
"S101", # Use of assert detected
]
"src/stimulus/typing/**" = [
"A005", # stimulus.typing is not shadowing typing
]
"tests/typing/**" = [
"A005", # stimulus.typing is not shadowing typing
]

# TODO temporary just until all unittests are passed to unittest
"tests/unittest_*.py" = ["ALL"]
Expand Down
38 changes: 38 additions & 0 deletions dockerfiles/stimulus-py-0.2.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# syntax=docker/dockerfile:1.9

FROM python:3.12-slim AS builder

# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
&& rm -rf /var/lib/apt/lists/*

# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv

# Set uv environment variables
ENV UV_LINK_MODE=copy \
UV_COMPILE_BYTECODE=1 \
UV_PYTHON_DOWNLOADS=never \
UV_SYSTEM_PYTHON=1

# Install stimulus-py
RUN uv pip install --system --no-build-isolation --compile --no-cache stimulus-py==0.2.2

# Create final image
FROM python:3.12-slim

RUN apt-get update && apt-get install -y procps && rm -rf /var/lib/apt/lists/*

# Copy installed packages from builder
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=builder /usr/local/bin/stimulus-* /usr/local/bin

# Create non-root user
RUN useradd -m -s /bin/bash app
USER app

# Set working directory
WORKDIR /app

CMD ["python3"]
60 changes: 60 additions & 0 deletions dockerfiles/stimulus-py-0.2.4.dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# syntax=docker/dockerfile:1.9

############################
# Stage 1: Builder #
############################
FROM python:3.12-slim AS builder

# Install build dependencies
RUN apt-get update && apt-get install -y build-essential \
&& rm -rf /var/lib/apt/lists/*

# Install uv from the official image
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv

# Set uv environment variables for optimized build
ENV UV_LINK_MODE=copy \
UV_COMPILE_BYTECODE=1 \
UV_PYTHON_DOWNLOADS=never \
UV_SYSTEM_PYTHON=1

# Set working directory for building
WORKDIR /src

# Copy the entire repository (source code, pyproject.toml, etc.) into the container
COPY . .

# Install build-system requirements for pdm backend
RUN uv pip install pdm-backend pdm

# Set fallback version for SCM
ENV PDM_BUILD_SCM_VERSION=0.2.4.dev

# Build and install stimulus-py from local source using uv pip install
RUN uv pip install --system --no-build-isolation --compile --no-cache .

############################
# Stage 2: Final Image #
############################
FROM python:3.12-slim

# Install minimal runtime dependency
RUN apt-get update && apt-get install -y procps \
&& rm -rf /var/lib/apt/lists/*

# Copy installed packages from builder
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages

# Copy stimulus CLI commands (stimulus-*) and the ray command
COPY --from=builder /usr/local/bin/stimulus-* /usr/local/bin/
COPY --from=builder /usr/local/bin/ray /usr/local/bin/ray

# Create a non-root user for running the app
RUN useradd -m -s /bin/bash app
USER app

# Set working directory
WORKDIR /app

# Default command
CMD ["python3"]
39 changes: 39 additions & 0 deletions dockerfiles/stimulus-py-0.2.4/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# syntax=docker/dockerfile:1.9

FROM python:3.12-slim AS builder

# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
&& rm -rf /var/lib/apt/lists/*

# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv

# Set uv environment variables
ENV UV_LINK_MODE=copy \
UV_COMPILE_BYTECODE=1 \
UV_PYTHON_DOWNLOADS=never \
UV_SYSTEM_PYTHON=1

# Install stimulus-py (ray will be installed as a dependency)
RUN uv pip install --system --no-build-isolation --compile --no-cache stimulus-py==0.2.4

# Create final image
FROM python:3.12-slim

RUN apt-get update && apt-get install -y procps && rm -rf /var/lib/apt/lists/*

# Copy installed packages from builder
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=builder /usr/local/bin/stimulus-* /usr/local/bin
COPY --from=builder /usr/local/bin/ray /usr/local/bin/ray

# Create non-root user
RUN useradd -m -s /bin/bash app
USER app

# Set working directory
WORKDIR /app

CMD ["python3"]
2 changes: 2 additions & 0 deletions src/stimulus/cli/check_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import argparse
import logging

import ray
import yaml
from torch.utils.data import DataLoader

Expand Down Expand Up @@ -189,6 +190,7 @@ def main(

def run() -> None:
"""Run the model checking script."""
ray.init(address="auto", ignore_reinit_error=True)
args = get_args()
main(
data_path=args.data,
Expand Down
2 changes: 2 additions & 0 deletions src/stimulus/cli/tuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pathlib import Path
from typing import Any

import ray
import yaml

from stimulus.data import loaders
Expand Down Expand Up @@ -225,6 +226,7 @@ def main(

def run() -> None:
"""Run the model checking script."""
ray.init(address="auto", ignore_reinit_error=True)
args = get_args()
main(
data_path=args.data,
Expand Down

0 comments on commit 6335c37

Please sign in to comment.