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
10 changes: 2 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,27 @@ jobs:
shell: bash -l {0}
run: |
uv run coverage erase
uv run pytest -vv --cov=ord_interface --durations=20 --ignore=ord_interface/editor
uv run pytest -vv --cov=ord_interface --durations=20
uv run coverage report

test_app:
strategy:
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14"]
# NOTE(skearnes): Docker is not supported on macOS GitLab runners.
# NOTE(skearnes): ubuntu-latest AppArmor doesn't play nicely with puppeteer.
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
- name: actions-setup-redis
uses: shogo82148/actions-setup-redis@59cda539fd5cc9be4c42bb07e4b28156951f37d6 # v1.55.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
- name: Install ord-interface
run: uv sync --frozen
- name: Install non-python test dependencies
run: |
cd "${GITHUB_WORKSPACE}/ord_interface"
npm install puppeteer
- name: Run tests
run: |
cd "${GITHUB_WORKSPACE}/ord_interface"
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Web interface and FastAPI server for the [Open Reaction Database](https://open-r
- `api/` — FastAPI server (search, view, queries)
- `client/` — utilities for building the Postgres + rdkit-cartridge database
- `visualization/` — Jinja filters and helpers for rendering reactions and molecules
- `editor/` — legacy reaction-submission UI (being removed)

The React frontend talks to the FastAPI server, so both processes need to be running for the UI to work. On Windows, use WSL.

Expand Down Expand Up @@ -47,7 +46,6 @@ rest of the steps.
```shell
cd ord_interface
./build_test_database.sh
# Apple silicon: append `--build-arg="ARCH=aarch_64"`.
docker build --file Dockerfile -t openreactiondatabase/ord-interface ..
docker compose up
```
Expand Down
36 changes: 1 addition & 35 deletions ord_interface/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,21 @@

FROM python:3.11

# default-jre is required for running the closure compiler linter.
# For this next line, see:
# https://github.com/geerlingguy/ansible-role-java/issues/64#issuecomment-597132394
RUN mkdir -p /usr/share/man/man1/
RUN apt-get update \
&& apt-get install -y \
build-essential \
default-jre \
nginx \
npm \
procps \
unzip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Fetch and build editor dependencies.
# Fetch the Ketcher distribution served by the SPA.
# NOTE(kearnes): Do this before COPYing the local state so it can be cached.
WORKDIR /app/ord-interface/ord_interface
RUN wget https://github.com/epam/ketcher/releases/download/v2.5.1/ketcher-standalone-2.5.1.zip \
&& unzip ketcher-standalone-2.5.1.zip
WORKDIR /app/ord-interface/ord_interface/editor
RUN wget https://github.com/google/closure-library/archive/v20200517.tar.gz \
&& tar -xzf v20200517.tar.gz \
&& rm v20200517.tar.gz
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protobuf-js-3.14.0.tar.gz \
&& tar -xzf protobuf-js-3.14.0.tar.gz \
&& rm protobuf-js-3.14.0.tar.gz
ARG ARCH=x86_64
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-linux-${ARCH}.zip \
&& unzip protoc-3.14.0-linux-${ARCH}.zip
ENV PATH="/app/ord-interface/ord_interface/editor/bin:${PATH}"
RUN wget https://raw.githubusercontent.com/google/closure-compiler/master/contrib/externs/jquery-3.3.js \
&& mkdir -p externs \
&& mv jquery-3.3.js externs
RUN npm install google-closure-compiler@20220803
WORKDIR /app
RUN wget https://github.com/open-reaction-database/ord-schema/archive/refs/tags/v0.3.93.zip \
&& unzip v0.3.93.zip \
&& rm v0.3.93.zip \
&& mv ord-schema-0.3.93 ord-schema

# Install dependencies.
WORKDIR /app/ord-interface
Expand All @@ -68,12 +43,6 @@ ENV UV_PROJECT_ENVIRONMENT=/usr/local \
COPY pyproject.toml uv.lock README.md ./
RUN uv sync --frozen --no-dev --no-install-project

# Copy the local state.
COPY ord_interface/editor/js/ ord_interface/editor/js/
COPY ord_interface/editor/build.sh ord_interface/editor
WORKDIR /app/ord-interface/ord_interface/editor
RUN ./build.sh
WORKDIR /app/ord-interface
# Build the SPA (React + TypeScript + Vite).
COPY app/ app/
WORKDIR /app/ord-interface/app
Expand All @@ -88,10 +57,7 @@ RUN cp -r /app/ord-interface/ord_interface/standalone/ /app/ord-interface/app/pu
&& npm run build \
&& mv dist/ /app/ord-interface/spa
WORKDIR /app/ord-interface
# Copy the rest of the editor files.
COPY ord_interface/editor/ ord_interface/editor/
# Now copy everything else.
COPY ord_interface/interface.py ord_interface/
COPY ord_interface/api/ ord_interface/api/
COPY ord_interface/visualization/ ord_interface/visualization/
RUN uv sync --frozen --no-dev
Expand Down
4 changes: 1 addition & 3 deletions ord_interface/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"""Open Reaction Database API."""

import os
import re
from contextlib import asynccontextmanager

from fastapi import FastAPI
Expand All @@ -33,8 +32,7 @@ async def lifespan(*args, **kwargs):
from testing.postgresql import Postgresql

with Postgresql() as postgres:
url = re.sub("postgresql://", "postgresql+psycopg://", postgres.url())
setup_test_postgres(url)
setup_test_postgres(postgres.url())
os.environ["ORD_INTERFACE_POSTGRES"] = postgres.url()
yield
else:
Expand Down
14 changes: 11 additions & 3 deletions ord_interface/api/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,28 @@
from ord_schema.message_helpers import load_message
from ord_schema.orm.database import add_dataset, prepare_database, update_derived_data
from ord_schema.proto import dataset_pb2
from sqlalchemy import create_engine
from sqlalchemy import create_engine, make_url
from sqlalchemy.orm import Session


def setup_test_postgres(url: str) -> None:
"""Adds test data to a postgres database."""
"""Adds test data to a postgres database.

Args:
url: Postgres connection URL. Any driver it names is replaced with
psycopg (v3), the only Postgres driver we install; SQLAlchemy would
otherwise reach for psycopg2 on a bare ``postgresql://`` URL.
"""
datasets = [
load_message(filename, dataset_pb2.Dataset)
for filename in glob(
os.path.join(os.path.dirname(__file__), "testdata", "*.pb.gz")
)
]
assert datasets
engine = create_engine(url, future=True)
engine = create_engine(
make_url(url).set(drivername="postgresql+psycopg"), future=True
)
rdkit_cartridge = prepare_database(engine)
with Session(engine) as session:
for dataset in datasets:
Expand Down
6 changes: 0 additions & 6 deletions ord_interface/build_test_database.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ while [ $? -ne 0 ]; do
done
set -e

# Editor.
cd editor
psql -p 5432 -h localhost -U postgres -f schema.sql
python py/migrate.py
cd ..

# Client.
psql -p 5432 -h localhost -U postgres -c 'CREATE DATABASE ord;'
python client/build_database.py
Expand Down
2 changes: 0 additions & 2 deletions ord_interface/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ services:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DATABASE=ord
- GH_CLIENT_ID=${GH_CLIENT_ID}
- GH_CLIENT_SECRET=${GH_CLIENT_SECRET}
image: "openreactiondatabase/ord-interface:latest"
ports:
- "8080:8080"
141 changes: 0 additions & 141 deletions ord_interface/editor/README.md

This file was deleted.

Loading
Loading