Skip to content

mrc-6454 Replace Orderly Web with Packit #33

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

Draft
wants to merge 33 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0016010
new branch
EmmaLRussell Jun 12, 2025
4c7e3ce
remove orderly web install, fix docker compose
EmmaLRussell Jun 12, 2025
4cd2360
add basic packit client
EmmaLRussell Jul 3, 2025
93b3e99
add "publish"
EmmaLRussell Jul 7, 2025
1a6c7df
remove timeout - not supported by new runner
EmmaLRussell Jul 7, 2025
5b4c6e1
replace most references to "version" with "packet_id"
EmmaLRussell Jul 7, 2025
4704cc4
replace OW with packit in deps
EmmaLRussell Jul 8, 2025
b42f347
small deps tweaks and syntax fixes
EmmaLRussell Jul 8, 2025
fa89f7f
got a task running successfully, but messily
EmmaLRussell Jul 10, 2025
cb48cbe
specify commit when run report
EmmaLRussell Jul 11, 2025
0aa75e9
poll for packet before publish
EmmaLRussell Jul 11, 2025
d52cb05
packit client unit tests
EmmaLRussell Jul 14, 2025
750de03
more unit tests
EmmaLRussell Jul 14, 2025
d3cd758
more unit tests
EmmaLRussell Jul 15, 2025
bfddf84
fix first run report unit test
EmmaLRussell Jul 15, 2025
6608905
fix all run_reports unit tests
EmmaLRussell Jul 15, 2025
f410ce6
fix send diagnostic email unit tests
EmmaLRussell Jul 15, 2025
cbe6a1d
refresh git before attempting to get latest commit or run reports
EmmaLRussell Jul 16, 2025
45849eb
more test fixes
EmmaLRussell Jul 16, 2025
38ed60b
integration test fixes
EmmaLRussell Jul 16, 2025
d513733
update docker config
EmmaLRussell Jul 16, 2025
06a27b8
lint
EmmaLRussell Jul 16, 2025
8b96c89
tweak db startup time
EmmaLRussell Jul 16, 2025
396f6f4
try that again
EmmaLRussell Jul 16, 2025
bdc725e
add logging
EmmaLRussell Jul 16, 2025
a005b68
update python version
EmmaLRussell Jul 17, 2025
d15f84e
separate out run dev deps scripts
EmmaLRussell Jul 17, 2025
5da4c60
test fix
EmmaLRussell Jul 17, 2025
66eac4a
lint
EmmaLRussell Jul 17, 2025
a0d2ff4
more test fixes
EmmaLRussell Jul 17, 2025
b68e5f7
fix packit url in docker config
EmmaLRussell Jul 20, 2025
9e74440
lint
EmmaLRussell Jul 20, 2025
50a5d1c
remove all orderlyweb references
EmmaLRussell Jul 21, 2025
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
6 changes: 3 additions & 3 deletions .github/workflows/test-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ jobs:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.12

- name: Install dependencies
run: |
pip3 install pytest-cov pycodestyle codecov
pip3 install pytest-cov pycodestyle codecov hatch
pip3 install -r requirements.txt

- name: Run dependencies
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ execute tasks, coordinated by Celery. Celery supports various message brokers in
Clone the repo anywhere and install dependencies with (from the repo root):

```
pip3 install --user -r requirements.txt
hatch shell
pip3 install -r requirements.txt
```

## Development

Run dependencies (Montagu API and DB, OrderlyWeb and a local Redis message queue in docker) with `scripts/run-dependencies.sh`
Run dependencies (Montagu API and DB, Proxy, Packit and a local Redis message queue in docker) with `scripts/run-dev-dependencies.sh`

Dependencies also include a fake smtp server run from a [docker image](https://hub.docker.com/r/reachfive/fake-smtp-server)
to enable development and testing of email functionality. You can see a web front end for the emails 'sent' via this server
Expand Down Expand Up @@ -54,7 +55,7 @@ The worker expects to find a config file at `config/config.yml`.

The Dockerfile copies `config/docker_config.yml` to `config/config.yml`.
This allows the worker running on metal to use a broker on `localhost` while the worker in docker needs to use
`montagu_mq`, the container name of the broker, to access its port.
`montagu-mq`, the container name of the broker, to access its port.

Note that if a YouTrack token is not provided in the config the app will look for an environment variable called `YOUTRACK_TOKEN`.
This makes local and automated testing of the YouTrack integration possible.
Expand Down
16 changes: 11 additions & 5 deletions config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ servers:
url: http://localhost:8080
user: [email protected]
password: password
orderlyweb:
url: http://localhost:8888
packit:
url: https://localhost/packit
disable_certificate_verify: true
youtrack:
token: None
smtp:
Expand All @@ -27,17 +28,22 @@ tasks:
- [email protected]
- [email protected]
subject: "VIMC diagnostic report: {touchstone} - {group} - {disease}"
timeout: 300
assignee: a.hill
publish_roles:
- minimal.modeller
- Funders
- report_name: diagnostic-param
parameters:
nmin: 0
a: 1
b: 2
c: 3
success_email:
recipients:
- [email protected]
- [email protected]
subject: "New version of another Orderly report"
timeout: 1200
assignee: e.russell
publish_roles:
- other.modeller
archive_folder_contents:
min_file_age_seconds: 0
20 changes: 14 additions & 6 deletions config/docker_config.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
host: montagu_mq_1
host: montagu-mq-1
servers:
montagu:
url: http://montagu_api_1:8080
url: http://montagu-api-1:8080
user: [email protected]
password: password
orderlyweb:
url: http://montagu_orderly_web:8888
packit:
url: https://reverse-proxy:443/packit
disable_certificate_verify: true
youtrack:
token:
smtp:
host: montagu_smtp_server_1
host: montagu-smtp_server-1
port: 1025
from: [email protected]
tasks:
Expand All @@ -26,14 +27,21 @@ tasks:
- [email protected]
subject: "VIMC diagnostic report: {touchstone} - {group} - {disease}"
assignee: a.hill
publish_roles:
- minimal.modeller
- Funders
- report_name: diagnostic-param
parameters:
nmin: 0
a: 1
b: 2
c: 3
success_email:
recipients:
- [email protected]
- [email protected]
subject: "New version of another Orderly report"
assignee: e.russell
publish_roles:
- other.modeller
archive_folder_contents:
min_file_age_seconds: 0
15 changes: 11 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3'
services:
mq:
image: redis
Expand All @@ -9,8 +8,8 @@ services:
ports:
- "5555:5555"
environment:
- CELERY_BROKER_URL=redis://montagu_mq_1//
- CELERY_RESULT_BACKEND=redis://montagu_mq_1/0
- CELERY_BROKER_URL=redis://montagu-mq-1//
- CELERY_RESULT_BACKEND=redis://montagu-mq-1/0
- FLOWER_PORT=5555
api:
image: ${REGISTRY}/montagu-api:master
Expand All @@ -23,8 +22,16 @@ services:
ports:
- "5432:5432"
command: /etc/montagu/postgresql.test.conf
contrib:
image: ${REGISTRY}/montagu-contrib-portal:master
depends_on:
- api
admin:
image: ${REGISTRY}/montagu-admin-portal:master
depends_on:
- api
smtp_server:
image: reachfive/fake-smtp-server
ports:
- "1025:1025"
- "1080:1080"
- "1080:1080"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ celery[redis]
future
pyyaml
montagu>=0.0.2
orderlyweb-api>=1.0.0
git+https://github.com/reside-ic/youtrack-rest-python-library
constellation
requests-mock
2 changes: 2 additions & 0 deletions scripts/clear-docker.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
set -x

docker stop $(docker ps -aq)
docker rm $(docker ps -aq)
docker network prune --force
Expand Down
57 changes: 0 additions & 57 deletions scripts/orderly-web.yml

This file was deleted.

5 changes: 0 additions & 5 deletions scripts/orderlyweb_cli.sh

This file was deleted.

50 changes: 50 additions & 0 deletions scripts/packit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
container_prefix: montagu

protect_data: false

repo: ghcr.io/mrc-ide

network: montagu_default

volumes:
outpack: montagu_outpack_volume
packit_db: montagu_packit_db
orderly_library: montagu_orderly_library
orderly_logs: montagu_orderly_logs

outpack:
server:
name: outpack_server
tag: main
migrate:
name: outpack.orderly
tag: main

packit:
base_url: https://localhost
api:
name: packit-api
tag: main
app:
name: montagu-packit
tag: main
db:
name: packit-db
tag: main
user: packituser
password: changeme
auth:
enabled: true
auth_method: preauth
# We'll get this from the vault on production
jwt:
secret: "0b4g4f8z4mdsrhoxfde2mam8f00vmt0f"
expiry_days: 1

orderly-runner:
image:
name: orderly.runner
tag: main
git:
url: https://github.com/reside-ic/orderly2-example.git
workers: 1
62 changes: 46 additions & 16 deletions scripts/run-dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
#!/usr/bin/env bash
set -ex

here=$(dirname $0)
export REGISTRY=vimc

here=$(dirname $0)
./scripts/clear-docker.sh
docker network prune -f

export REGISTRY=vimc
export NETWORK=montagu_default

# Run the API and database
docker-compose pull
docker-compose --project-name montagu up -d
docker compose pull
docker compose --project-name montagu up -d

# Clear redis
docker exec montagu_mq_1 redis-cli FLUSHALL

# Install orderly-web
pip3 install constellation
pip3 install orderly-web
orderly-web start $here
docker exec montagu-mq-1 redis-cli FLUSHALL

# Start the APIs
docker exec montagu_api_1 mkdir -p /etc/montagu/api/
docker exec montagu_api_1 touch /etc/montagu/api/go_signal
docker exec montagu-api-1 mkdir -p /etc/montagu/api/
docker exec montagu-api-1 touch /etc/montagu/api/go_signal

# Wait for the database
docker exec montagu_db_1 montagu-wait.sh
docker exec montagu-db-1 montagu-wait.sh

# migrate the database
migrate_image=${REGISTRY}/montagu-migrate:master
Expand All @@ -40,6 +35,41 @@ $here/montagu_cli.sh add "Test User" test.user \

$here/montagu_cli.sh addRole test.user user

# Add user to orderlyweb
$here/orderlyweb_cli.sh add-users [email protected]
$here/orderlyweb_cli.sh grant [email protected] */reports.read */reports.run */reports.review
# Run packit
hatch env run pip3 install constellation
hatch env run pip3 install packit-deploy
# For some reason packit is emitting exit code 1 despite apparently succeeding. Allow this for now...
set +e
hatch env run -- packit start --pull $here
echo Packit deployed with exit code $?
set -e

docker exec montagu-packit-db wait-for-db

# Run the proxy here, not through docker compose - it needs packit to be running before it will start up
MONTAGU_PROXY_TAG=vimc/montagu-reverse-proxy:master
docker pull $MONTAGU_PROXY_TAG
docker run -d \
-p "443:443" -p "80:80" \
--name reverse-proxy \
--network montagu_default\
$MONTAGU_PROXY_TAG 443 localhost

# give packit api some time to migrate the db...
sleep 5

# create roles to publish to...
docker exec -i montagu-packit-db psql -U packituser -d packit --single-transaction <<EOF
insert into "role" (name, is_username) values ('Funders', FALSE);
insert into "role" (name, is_username) values ('minimal.modeller', FALSE);
insert into "role" (name, is_username) values ('other.modeller', FALSE);
EOF

# Add user to packit, as admin
USERNAME='test.user'
EMAIL='[email protected]'
DISPLAY_NAME='Test User'
ROLE='ADMIN'
docker exec montagu-packit-db create-preauth-user --username "$USERNAME" --email "$EMAIL" --displayname "$DISPLAY_NAME" --role "$ROLE"


22 changes: 22 additions & 0 deletions scripts/run-dev-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -ex

./scripts/run-dependencies.sh

# From now on, if the user presses Ctrl+C we should teardown gracefully
function cleanup() {
docker container stop reverse-proxy
docker container rm reverse-proxy -v
# Same exit code issue for packit stop as packit start....
set +e
hatch env run -- packit stop ./scripts
set -e
# remove db volume manually rather than --volumes flag to packit, to avoid requiring user confirmation
docker volume rm montagu_packit_db montagu_orderly_library montagu_outpack_volume montagu_orderly_logs
docker compose --project-name montagu down -v
}
trap cleanup EXIT

# Wait for Ctrl+C
echo "Ready to use. Press Ctrl+C to teardown."
sleep infinity
Loading