Skip to content

New installations without Django, and image upload over /api/v1 for exact-sync - #1

Merged
maubreville merged 9 commits into
DeepMicroscopy:mainfrom
jonas-amme:new-instance-without-django
Nov 17, 2026
Merged

maubreville merged 9 commits into
DeepMicroscopy:mainfrom
jonas-amme:new-instance-without-django

Conversation

@jonas-amme

Copy link
Copy Markdown
Contributor

Summary

Two things in one branch:

  1. A new EXACT installation no longer needs Django. exact-cli migrate creates EXACT's own tables on an empty
    database, and exact-cli create-superuser makes the first account. A quickstart compose file gets a new user from
    zero to a running instance with one settings file and one command.
  2. exact-sync can upload images to the Rust server. POST /api/v1/images/images/ (what ImagesApi.create_image
    calls) answered 501 and now works as it does on Django.

Existing installations next to Django are not affected: migrate only creates EXACT's tables when the database has
none, and changes nothing otherwise.

New installations without Django

  • Schema bootstrap: crates/exact-db/bootstrap/exact_base_schema.sql is what EXACT's Django migrations create in an
    empty database, generated from a pinned EXACT commit by scripts/make-base-schema.sh. That includes django_migrations,
    content types, permissions and the seeded set tags, so the original EXACT can still be pointed at the database later.
    It is applied in one transaction. An empty database plus migrate matches baseline/schema-local-20261027.json (62 tables).
  • First account: exact-cli create-superuser takes the password from EXACT_ADMIN_PASSWORD or stdin, and with
    --team makes the user admin of that team. With --if-none it does nothing once a superuser exists; the container
    entrypoint uses that on first start and refuses the example password change-me.
  • Quickstart: deploy/quickstart.yml + quickstart.env.example is its own compose project next to the unchanged
    deploy/docker-compose.yml: no GPU, worker opt-in, data in Docker volumes.
  • Fixes found while trying it on Windows / Docker Desktop:
    • .gitattributes keeps shell scripts LF; with core.autocrlf=true the entrypoint got CRLF and the container
      failed with exec /app/docker-entrypoint.sh: no such file or directory.
    • The image store is mounted writable by default (IMAGE_MODE=rw). The read-only default made creating an image set
      fail with "Read-only file system". Set IMAGE_MODE=ro on the real files of an existing EXACT.
    • The server container checks on start that it can write to the image store, MEDIA_ROOT and the cache, and refuses
      to start with the fix, instead of every upload failing later with "Permission denied".
  • Docs: an Installation page that asks "do you already run EXACT?" and leads to Start from scratch or Moving from
    EXACT
    ; DEPLOY.md becomes the reference under it. README: "Get started" right after the screenshots, in six steps.

Image upload over /api/v1

Django's ImageViewSet.create: multipart with the files and image_set, ZIPs unpacked, duplicates (same name and
checksum) skipped. The answer is 200 with the new images as a page of the v1 list.

  • Field order: exact-sync sends the file before image_set, so uploads are staged as temporary .upload-* files
    in the image root until the set is known and checked. They are removed on every path, including refusals.
  • Routing: the path has its own route without a body limit, so slides stream to disk; the generic v1 handler
    buffers bodies. GET is still the generic list, and PUT/PATCH/DELETE answer 405 as before.
  • Shared code: the legacy (/images/image/upload/{set}/) and v2 uploads use the same refactored streaming and answer
    as before. A ZIP now reports all images it contained, not only the last.
  • Deliberate differences from Django (listed in docs/django-differences.md):
    • The caller needs the right to edit the unlocked set (403), as for the other uploads; Django only checks the
      add_image model permission.
    • A non-numeric image_set is a 400; Django answers 500.

Tests

  • New tests/conformance/test_v1_image_create.py (Rust only), 6 tests:
    • exact-sync's field order
    • several files and duplicates
    • ZIP
    • paging
    • refusals (no set, unknown set, not a number, outsider, anonymous, locked set), none leaving temporary files
    • the list's other methods unchanged
  • test_exact_sync.py: ImagesApi.move_image / list_move_targets over HTTP Basic auth (no session, no CSRF token).
    The image moves with its annotation; a target without the annotation type refuses with 409. The test skips itself when
    the installed exact-sync has no move_image; that is on the EXACT-Sync branch feature/move-image.
  • docs/api.md documents the endpoint with an exact-sync example.

How it was tested

  • On a dev instance created with migrate + create-superuser (Windows, Docker Desktop):
    • the new tests and the exact-sync move test pass
    • the existing v2/legacy upload and aux-file tests pass when pointed at an image set of that instance
    • exact-api unit tests (66) pass; clippy is clean for exact-api
  • Quickstart on Windows / Docker Desktop: the first start creates the tables, the admin and the team; a restart creates
    nothing; an image set created and a TIFF uploaded over the API land in the volume and get a thumbnail.
  • Not run: the full conformance suite against the restored test database, and the coexistence tests against Django.
    Please run make verify (or at least test_v1_image_create.py, test_v2_upload.py and test_exact_sync.py) before
    merging.

🤖 Generated with Claude Code

jonas-amme and others added 9 commits November 13, 2026 10:58
…ables on an empty database (crates/exact-db/bootstrap/exact_base_schema.sql, generated from a pinned EXACT commit by scripts/make-base-schema.sh); exact-cli create-superuser makes the first account

The schema file is what EXACT's Django migrations create in an empty database, including django_migrations, content types,
permissions and seeded set tags, so the original EXACT can still be pointed at the database later. It is applied in one
transaction and only when the schema public has no tables; existing databases are migrated as before. An empty database plus
`migrate` matches baseline/schema-local-20261027.json (62 tables).

create-superuser takes the password from EXACT_ADMIN_PASSWORD or standard input, adds the preferences row Django's post_save
signal would create and, with --team, makes the user admin of that team (created when missing).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Windows (core.autocrlf=true) deploy/docker-entrypoint.sh got CRLF and the server container failed with "exec /app/docker-entrypoint.sh: no such file or directory"

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o a new installation can create image sets; on the real files of an existing EXACT set IMAGE_MODE=ro (DEPLOY.md, exact.env.example); DEPLOY.md: cookie and passkey settings for a try-out without https

Before, the default was read-only (made for the beta on a copy of production), and creating an image set on a new
installation failed with "Read-only file system (os error 30)". The worker keeps its read-only mount.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, MEDIA_ROOT and the cache, and refuses to start with the fix (chown on Linux, a folder of your own on Windows/macOS) instead of failing uploads later; exact.env.example explains the host folders

On Docker Desktop the example's /srv/... paths do not exist on the host and were created inside Docker's VM owned by root, so
every upload failed with "Permission denied" (the browser only reported a failed connection). The image store is not checked
with IMAGE_MODE=ro; workers and one-off commands are not wrapped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…opy one settings file, set two passwords, `up -d --build`; no GPU, worker opt-in, data in Docker volumes, the first admin created on first start), existing EXACT installations follow docs/from-exact.md (copy, both on the same data, Django off)

- exact-cli create-superuser --if-none: nothing happens once a superuser exists; the container entrypoint uses it to create
  EXACT_ADMIN_USER / EXACT_ADMIN_PASSWORD (optionally EXACT_ADMIN_TEAM) on the first start, leaves restored EXACT databases alone,
  and refuses the example password change-me
- deploy/quickstart.yml + quickstart.env.example: its own compose project (exact-rust) next to the unchanged deploy/docker-compose.yml;
  the image folders /data/images and /data/media exist in the image owned by `exact`, so empty named volumes are writable
- docs: Installation page that asks "do you already run EXACT?", Start from scratch, Moving from EXACT; DEPLOY.md becomes the
  reference under it, coexistence moves under it; README, index and django-differences link to the two guides

Tested on Windows/Docker Desktop: first start creates the tables, the admin and the team; a restart creates nothing; an image set
created and a TIFF uploaded over the API land in the volume and get a thumbnail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…EXACT and to Docker: the two paths (new / existing EXACT), and a new installation in six steps (Docker Desktop, Download ZIP, a terminal in the folder, the settings file created and opened with one command per system, one start command, log in), with everyday use, updates and where to look when it fails

docs/quickstart.md offers the same ZIP download and editor commands. The ZIP download needs no git and keeps the repository's
LF line endings on Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-sync's ImagesApi.create_image does (multipart, files and image_set in any order, ZIPs unpacked, duplicates skipped; 200 with the new images as a v1 list page); was 501

exact-sync sends the file before image_set, so files are staged in the image root until the set is known and checked;
staged files are removed also when the request is refused. The route has no body limit (the generic v1 handler buffers
bodies); GET is the generic list, other methods answer 405 as before. The legacy and v2 uploads share the refactored
streaming (stage/process) and answer as before; a ZIP reports all images it contained. Unlike Django, the caller needs
the right to edit the unlocked set (docs/django-differences.md).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…HTTP Basic auth (no session, no CSRF token); the image moves with its annotation, a target without the annotation type refuses with 409; skipped when the installed exact_sync has no move_image

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@maubreville

Copy link
Copy Markdown
Contributor

LGTM

@maubreville
maubreville merged commit cfba449 into DeepMicroscopy:main Nov 17, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants