Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix critical regression in tiled serve directory #701

Merged
merged 7 commits into from
Mar 28, 2024

Conversation

danielballan
Copy link
Member

The CLI had no unit tests (see #518) because there were some subtle issues to think through about how to do that. This enabled a critical regression to slip though in #661 that fully broke tiled serve directory .... The regression was not immediately noticed because tiled serve directory is kind of a "toy" entrypoint: it doesn't scale, but it's really great for demos and for early users trying out tiled.

In #661, the process of registering external files with Tiled changed from being a server-side activity, with direct access to the SQL database, to a client-side activity, performed via HTTP requests. The tiled serve directory ... CLI entrypoint was not correctly updated to account for this change.

In this PR, the regression is fixed. Additionally, some basic unit tests are added to protect against future regressions. More unit tests should be added in follow-up PRs, but this provides a framework. The critical thing is enabling the tests to start a server on a high random free port, specified by the OS, extract which port is being used, and run a basic HTTP GET to confirm that the server is alive.

Additionally, interactive tests:

$ tiled serve directory files/
Creating catalog database at /tmp/tmp5mvp19yd/catalog.db

    Navigate a web browser or connect a Tiled client to:

    http://127.0.0.1:8000?api_key=649b0deb311915915fbc4d219edc97ea58568916af3e6b29ce41113bf6101a05


INFO:     Started server process [1906101]
INFO:     Waiting for application startup.
Tiled version 0.1.0a117.dev40+g7af28d15
OBJECT CACHE: Will use up to 4_996_978_483 bytes (15% of total physical RAM)
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     127.0.0.1:38548 - "GET /api/v1/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:38564 - "GET /api/v1/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:38564 - "GET /api/v1/metadata/?include_data_sources=false HTTP/1.1" 200 OK
Server is up. Indexing files in files/...
INFO:     127.0.0.1:38564 - "DELETE /api/v1/nodes/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:38564 - "POST /api/v1/register/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:38564 - "POST /api/v1/register/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:38564 - "POST /api/v1/register/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:38564 - "POST /api/v1/register/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:38564 - "POST /api/v1/register/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:38564 - "POST /api/v1/metadata/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:38564 - "GET /api/v1/metadata/more HTTP/1.1" 200 OK
INFO:     127.0.0.1:38564 - "POST /api/v1/register/more HTTP/1.1" 200 OK
INFO:     127.0.0.1:38564 - "POST /api/v1/metadata/more HTTP/1.1" 200 OK
INFO:     127.0.0.1:38564 - "GET /api/v1/metadata/more/even_more HTTP/1.1" 200 OK
INFO:     127.0.0.1:38564 - "POST /api/v1/register/more/even_more HTTP/1.1" 200 OK
INFO:     127.0.0.1:38564 - "POST /api/v1/register/more/even_more HTTP/1.1" 200 OK
Indexing complete.
$ tiled serve directory files/ --verbose
Creating catalog database at /tmp/tmp0wtk0cbc/catalog.db

    Navigate a web browser or connect a Tiled client to:

    http://127.0.0.1:8000?api_key=6fd7ad132eafc2c826c31046c9f9e72dd83123489129314c6f566396e684cba4


INFO:     Started server process [1906240]
INFO:     Waiting for application startup.
Tiled version 0.1.0a117.dev40+g7af28d15
OBJECT CACHE: Will use up to 4_996_978_483 bytes (15% of total physical RAM)
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     127.0.0.1:55062 - "GET /api/v1/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:55074 - "GET /api/v1/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:55074 - "GET /api/v1/metadata/?include_data_sources=false HTTP/1.1" 200 OK
Server is up. Indexing files in files/...
  Overwriting '/'
INFO:     127.0.0.1:55074 - "DELETE /api/v1/nodes/ HTTP/1.1" 200 OK
  Walking 'files'
    Resolved mimetype 'image/tiff' with adapter for 'files/c.tif'
INFO:     127.0.0.1:55074 - "POST /api/v1/register/ HTTP/1.1" 200 OK
    Resolved mimetype 'image/tiff' with adapter for 'files/b.tif'
INFO:     127.0.0.1:55074 - "POST /api/v1/register/ HTTP/1.1" 200 OK
    Resolved mimetype 'image/tiff' with adapter for 'files/a.tif'
INFO:     127.0.0.1:55074 - "POST /api/v1/register/ HTTP/1.1" 200 OK
    Resolved mimetype 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' with adapter for 'files/tables.xlsx'
INFO:     127.0.0.1:55074 - "POST /api/v1/register/ HTTP/1.1" 200 OK
    Resolved mimetype 'text/csv' with adapter for 'files/another_table.csv'
INFO:     127.0.0.1:55074 - "POST /api/v1/register/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:55074 - "POST /api/v1/metadata/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:55074 - "GET /api/v1/metadata/more HTTP/1.1" 200 OK
  Walking 'files/more'
    Resolved mimetype 'image/tiff' with adapter for 'files/more/d.tif'
INFO:     127.0.0.1:55074 - "POST /api/v1/register/more HTTP/1.1" 200 OK
INFO:     127.0.0.1:55074 - "POST /api/v1/metadata/more HTTP/1.1" 200 OK
INFO:     127.0.0.1:55074 - "GET /api/v1/metadata/more/even_more HTTP/1.1" 200 OK
  Walking 'files/more/even_more'
    Resolved mimetype 'image/tiff' with adapter for 'files/more/even_more/e.tif'
INFO:     127.0.0.1:55074 - "POST /api/v1/register/more/even_more HTTP/1.1" 200 OK
    Resolved mimetype 'image/tiff' with adapter for 'files/more/even_more/f.tif'
INFO:     127.0.0.1:55074 - "POST /api/v1/register/more/even_more HTTP/1.1" 200 OK
Indexing complete.
$ tiled serve directory files/ --api-key=secret
Creating catalog database at /tmp/tmp2al810dj/catalog.db
INFO:     Started server process [1906388]
INFO:     Waiting for application startup.
Tiled version 0.1.0a117.dev40+g7af28d15
OBJECT CACHE: Will use up to 4_996_978_483 bytes (15% of total physical RAM)
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     127.0.0.1:51766 - "GET /api/v1/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:51778 - "GET /api/v1/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:51778 - "GET /api/v1/metadata/?include_data_sources=false HTTP/1.1" 200 OK
Server is up. Indexing files in files/...
INFO:     127.0.0.1:51778 - "DELETE /api/v1/nodes/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:51778 - "POST /api/v1/register/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:51778 - "POST /api/v1/register/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:51778 - "POST /api/v1/register/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:51778 - "POST /api/v1/register/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:51778 - "POST /api/v1/register/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:51778 - "POST /api/v1/metadata/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:51778 - "GET /api/v1/metadata/more HTTP/1.1" 200 OK
INFO:     127.0.0.1:51778 - "POST /api/v1/register/more HTTP/1.1" 200 OK
INFO:     127.0.0.1:51778 - "POST /api/v1/metadata/more HTTP/1.1" 200 OK
INFO:     127.0.0.1:51778 - "GET /api/v1/metadata/more/even_more HTTP/1.1" 200 OK
INFO:     127.0.0.1:51778 - "POST /api/v1/register/more/even_more HTTP/1.1" 200 OK
INFO:     127.0.0.1:51778 - "POST /api/v1/register/more/even_more HTTP/1.1" 200 OK
Indexing complete.

@danielballan danielballan requested a review from genematx March 28, 2024 17:43
@danielballan danielballan merged commit 487e30f into bluesky:main Mar 28, 2024
8 checks passed
@danielballan danielballan deleted the tiled-serve-directory branch March 28, 2024 18:25
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