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

Enables PIXL DB to operate as a service separate from Orthanc Raw #593

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

tomaroberts
Copy link
Contributor

@tomaroberts tomaroberts commented Jan 14, 2025

Description

Fixes #517:

Adds the means to create two postgres services. Previously, PIXL DB was used by both Orthanc Raw and for storing patient metadata.

Now it is possible to have separate databases for Orthanc Raw and PIXL DB. By default and in keeping with previous design, the root ./docker-compose.yml brings up a single postgres service, shared by both Orthanc Raw and PIXL DB.

With this PR, test/docker-compose.yml now contains a new postgres service demonstrating how to bring up a separate service for PIXL DB.

Type of change

Please delete options accordingly to the description.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Suggested Checklist

  • I have performed a self-review of my own code.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have passed on my local host device. (see further details at the CONTRIBUTING document)
  • Make sure your branch is up-to-date with main branch. See CONTRIBUTING for a general example to syncronise your branch with the main branch.
  • I have requested review to this PR.
  • I have addressed and marked as resolved all the review comments in my PR.
  • Finally, I have selected squash and merge

Copy link

codecov bot commented Jan 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.41%. Comparing base (dca65ca) to head (502f27e).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #593   +/-   ##
=======================================
  Coverage   87.41%   87.41%           
=======================================
  Files          76       76           
  Lines        3425     3425           
=======================================
  Hits         2994     2994           
  Misses        431      431           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@p-j-smith p-j-smith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking very nice!

I think the docs could do with updating in a couple of places:

And possibly some more places too. Which makes me wonder whether it would be worth describing all the environment variables in a single README rather than across the repo (as a separate PR)?

Also, if we use an external postgres instance, would we need to change how we handle alembic migrations? Currently we run them when the container is started, but I guess we'd need to apply them manually if postgres is running elsewhere?

Copy link
Contributor

@stefpiatek stefpiatek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, thanks for getting this in 🎉 . Agree with Paul on the documentation places. Happy for you to merge once you've added that in (without another review) and resolved the other comments to your liking.

Currently we run them when the container is started, but I guess we'd need to apply them manually if postgres is running elsewhere?

I think its fine for us to still run migrations on imaging api going up, because it'll still need to check the migrations have happened anyway.

# Exposed ports
HASHER_API_PORT=
POSTGRES_PORT=
POSTGRES_PIXL_DB_PORT=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth moving this elsewhere in the file as this port isn't necessarily what we're exposing it to (we can override this in the system test files, where we are exposing it).

POSTGRES_HOST=localhost
POSTGRES_PORT=7001
POSTGRES_PIXL_DB_HOST=localhost
POSTGRES_PIXL_DB_PORT=7001
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about EXTERNAL_PIXL_DB_HOST or CLI_PIXL_DB_HOST etc?

@@ -29,7 +37,7 @@ RABBITMQ_ADMIN_PORT=7009
FTP_PORT=20021

# PIXL Export API
POSTGRES_HOST=localhost
POSTGRES_PIXL_DB_HOST=localhost
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it wasn't you but should this move? Feels like its not to do with the export api

POSTGRES_DB: ${PIXL_DB_NAME}
PGTZ: ${TZ:-Europe/London}
env_file:
- ../docker/common.env
Copy link
Contributor

@stefpiatek stefpiatek Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imagine you've seen but from CI: /home/runner/work/PIXL/docker/common.env: no such file or directory. I'm guessing because we've set the context to be ../ then it can just be ./docker...

@tomaroberts
Copy link
Contributor Author

tomaroberts commented Jan 20, 2025

A note: my last commit removed the env_file: line from test/docker-compose.yml and now the system test is passing. But that's slightly unexpected?

Two thoughts:

  1. I think the original problem was due to relative file paths. See here for a similar issue around relative paths and env-file:. I think the context: attribute is only applied to build: rather than the location of the file associated with env-file: attribute.
  2. Reading the DC docs, there is some level of inheritance of env variables across compose files – this might explain the tests passing now because a) the env variables already exist and b) by removing the lines in 502f27e we remedy the broken file pathing.

@stefpiatek
Copy link
Contributor

  1. think the original problem was due to relative file paths. See here for a similar issue around relative paths and env-file:. I think the context: attribute is only applied to build: rather than the location of the file associated with env-file: attribute.

Yeah I think that's right - IIRC we have to do the test docker compose up --build in two steps because of this

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.

Allow PIXL DB to be run on a different database
3 participants