Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 13 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Build Package

on: [push, pull_request]

env:
UV_SYSTEM_PYTHON: 1

jobs:
build:

Expand All @@ -10,31 +13,22 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up Python 3.10
- name: Set up Python 3.12
id: setup-python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-path: ~/.virtualenvs
python-version: "3.12"

- name: Cache Poetry virtualenv
uses: actions/cache@v4
id: cache
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
path: ~/.virtualenvs
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
# Install a specific version of uv.
version: "0.8.24"
enable-cache: true

- name: Install dependencies
run: |
poetry install # --no-interaction --no-ansi -vvv # add this for local debugs with "act"
if: steps.cache.outputs.cache-hit != 'true'
- name: Install the project
run: uv sync --locked --all-extras --dev

- name: Test with pytest
run: |
poetry run pytest tests
uv run pytest tests
1 change: 1 addition & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- '[0-9]+.[0-9]+.[0-9]+' # Exclude pre-releases
branches:
- main
workflow_dispatch:

jobs:
docker:
Expand Down
27 changes: 17 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# Stage 1: Development stage for Python dependencies
FROM python:3.10-slim AS dep-stage
FROM python:3.12-slim AS dep-stage

ENV UV_COMPILE_BYTECODE=1
ENV UV_LINK_MODE=copy
ENV UV_PYTHON_DOWNLOADS=0
ENV VIRTUAL_ENV=/app/venv

# Set up app dir
WORKDIR /tmp

# Copy project files over
COPY ./pyproject.toml ./poetry.lock ./
COPY ./pyproject.toml ./uv.lock ./

# Install system prereq packages
RUN apt-get update && \
Expand All @@ -15,7 +20,7 @@ RUN apt-get update && \
# these are for h5py in sdss_explorer
curl libhdf5-dev pkg-config \
# these are for vaex
libpcre3 libpcre3-dev gcc g++ libboost-all-dev \
gcc g++ libboost-all-dev \
libffi-dev python3-dev libxml2-dev libxslt-dev \
libpq-dev zlib1g-dev \
&& apt-get clean \
Expand All @@ -35,18 +40,20 @@ ENV PIP_FIND_LINKS=https://github.com/ddelange/vaex/releases/expanded_assets/cor
RUN pip install --force-reinstall vaex
ENV PIP_FIND_LINKS=

# Install poetry and project dependencies
RUN pip install poetry && \
poetry config virtualenvs.create false && \
poetry install -E solara --no-root && \
rm -rf ~/.cache
# Installing uv and then project dependencies
RUN pip install uv
RUN uv venv /app/venv # make venv
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-install-project --no-dev --extra solara


# Stage 2: Development stage for the project
FROM dep-stage AS dev-stage

# Copy the main project files over and install
COPY ./ ./
RUN poetry install -E solara --only main
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev --extra solara

# Create dir for socket and logs
RUN mkdir -p /tmp/webapp
Expand All @@ -72,4 +79,4 @@ LABEL org.opencontainers.image.description="valis production image"
EXPOSE 8000

# Start the FastAPI app for production
CMD ["poetry", "run", "gunicorn", "-c", "python/valis/wsgi_conf.py", "valis.wsgi:app"]
CMD ["uv", "run", "gunicorn", "-c", "python/valis/wsgi_conf.py", "valis.wsgi:app"]
26 changes: 17 additions & 9 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
# Stage 1: Development stage for Python dependencies
FROM python:3.10-slim as dep-stage
FROM python:3.12-slim as dep-stage

# Set up app dir
WORKDIR /tmp

# Copy project files over
COPY ./pyproject.toml ./poetry.lock ./
COPY ./pyproject.toml ./uv.lock ./

# Install build-essential package
# Install system prereq packages
RUN apt-get update && \
apt-get install -y \
build-essential \
git \
# these are for h5py in sdss_explorer
curl libhdf5-dev pkg-config \
# these are for vaex
gcc g++ libboost-all-dev \
libffi-dev python3-dev libxml2-dev libxslt-dev \
libpq-dev zlib1g-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Install poetry and project dependencies
RUN pip install poetry && \
poetry config virtualenvs.create false && \
poetry install -E solara --no-root && \
rm -rf ~/.cache
# Installing uv and then project dependencies
RUN pip install uv
RUN uv venv /app/venv # make venv
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-install-project --no-dev --extra solara

# Stage 2: Development stage for the project
FROM dep-stage as dev-stage

# Copy the main project files over and install
COPY ./ ./
RUN poetry install -E solara --only main
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev --extra solara

# setting environment variables
# these can be manually overridden
Expand Down
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,44 @@

the SDSS API for delivering and accessing remote information.

This API is built using the [FastAPI](https://fastapi.tiangolo.com/) web server. Python depdendices are managed with [poetry](https://python-poetry.org/).
This API is built using the [FastAPI](https://fastapi.tiangolo.com/) web server. Python depdendices are managed with [uv](https://docs.astral.sh/uv/).

See [uv Features](https://docs.astral.sh/uv/getting-started/features/) for what can be done with `uv`. See their [Project Guide](https://docs.astral.sh/uv/guides/projects/) for an intro to working on python projects.

## Installation
First, follow the [uv installation instructions](https://docs.astral.sh/uv/getting-started/installation/).

It is recommended to work within an isolated virtual environment like `conda` or `venv`. You can create a uv venv with `uv venv valis --python 3.12`. See [uv Environments](https://docs.astral.sh/uv/pip/environments/) for more info.

### Developer Install
```
git clone https://github.com/sdss/valis valis
cd valis
poetry install
uv pip install
```

### Solara Dependencies

The default install does not install any of the Solara dependencies for Jdaviz and the SDSS DataView Explorer. To install these dependencies, run
```
poetry install -E solara
uv pip install --extra solara
```

### Updating Dependencies with Poetry
To update poetry itself, run
### Updating Dependencies with uv
To update uv itself, run
```
poetry self update
uv self update
```

To update the package dependencies for `valis`, run
```
poetry update [package]
uv lock --upgrade-package [package]
```
This will update all the packages, or the specified `[package]`, resolve all dependencies, and update the `poetry.lock` file.
This will update all the packages, or the specified `[package]`, resolve all dependencies, and update the `uv.lock` file.

To install new packages and add them to the `pyproject.toml` and `poetry.lock` files, run
To install new packages and add them to the `pyproject.toml` and `uv.lock` files, run
```
poetry install [package]
uv add [package]
```

### Local Development
Expand Down
Loading