-
Notifications
You must be signed in to change notification settings - Fork 9
cleanup(medcat-demo):CU-869c8r073 Remove demo keep model distribution #351
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
Merged
mart-r
merged 39 commits into
main
from
cleanup/medcat-demo/CU-869c8r073-remove-demo-keep-model-distribution
Feb 27, 2026
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
ecac728
CU-869c8r073: Remove uploaded text model
mart-r 96f6b2d
CU-869c8r073: Remove demo parts from views
mart-r 4f01650
CU-869c8r073: Cleanup imports
mart-r d87f9db
CU-869c8r073: Remove medcat requirement
mart-r 38d3f84
CU-869c8r073: Remove installation of local medcat
mart-r 0e7da75
CU-869c8r073: Update base template for non-demo header
mart-r ad754fc
CU-869c8r073: Remove unnecessary URL
mart-r f391b47
CU-869c8r073: Add requests to requirements
mart-r efe077f
CU-869c8r073: Add migration to delete unnecessary model
mart-r 63a27dd
CU-869c8r073: Remove installation of spacy model (unneeded)
mart-r 8d7b380
CU-869c8r073: Remove CPU-only torch options (unnecessary)
mart-r 0881493
CU-869c8r073: Remove tests for demo
mart-r 9639c99
CU-869c8r073: Some whitespace improvements
mart-r 00e4bef
CU-869c8r073: Improve compose files (remove version)
mart-r 118a52b
CU-869c8r073: Add health endpoint
mart-r 23a0d6b
CU-869c8r073: Add some simple(ish) integration tests
mart-r c7e22c9
CU-869c8r073: Fix permission issue
mart-r e8443b2
CU-869c8r073: Fix workflow file missing input for tests
mart-r eabaa82
CU-869c8r073: Hide test time fake API key to keep the automated check…
mart-r 1049cfc
CU-869c8r073: Hide test time fake API key to keep the automated check…
mart-r 333952e
CU-869c8r073: Hide test time fake API key to keep the automated check…
mart-r 0c126c8
CU-869c8r073: Rename demo app to model distributor
mart-r e9af974
CU-869c8r073: Rename demo app workflow
mart-r 9d6eb3f
CU-869c8r073: Use renamed paths in model distributor workflow
mart-r 13f7f06
CU-869c8r073: Hide test time fake API key to keep the automated check…
mart-r ca30a6a
CU-869c8r073: Hide test time fake API key to keep the automated check…
mart-r 95e5bb6
CU-869c8r073: Remove unnecessary medcat core lib copy step
mart-r 2a6c318
CU-869c8r073: Remove env var in workflow
mart-r b7d7c6b
CU-869c8r073: Add workflow job to build and push image to docker hub
mart-r a1ffe74
CU-869c8r073: Make compose file use image rather than build form source
mart-r 3c65cb2
CU-869c8r073: Potential fix for code scanning alert no. 176: Workflow…
mart-r e6b75d5
CU-869c8r073: Minor worklfow wording fix
mart-r 9b45103
CU-869c8r073: Try another file during tests
mart-r 3627985
CU-869c8r073: Update test script
mart-r 2221ce8
CU-869c8r073: Try and fix the test file / path
mart-r e12a380
Merge branch 'main' into cleanup/medcat-demo/CU-869c8r073-remove-demo…
mart-r 81e43cf
CU-869c8r073: Separate container init script
mart-r 7b148ef
CU-869c8r073: Separate verification logic during tests
mart-r 3ad09ff
CU-869c8r073: Remove unused and unnecessary test script
mart-r File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| name: medcat-model-distributor - Test | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| tags: | ||
| - 'medcat-model-distributor/v*.*.*' | ||
| pull_request: | ||
| paths: | ||
| - 'medcat-model-distributor/**' | ||
| - 'medcat-v2/**' | ||
| - '.github/workflows/medcat-model-distributor**' | ||
| defaults: | ||
| run: | ||
| working-directory: ./medcat-model-distributor | ||
|
|
||
| jobs: | ||
| integration-test: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: 🧹 Free up disk space | ||
| run: | | ||
| df -h # Optional: Check space before build | ||
| # Remove large, unnecessary packages/tools | ||
| sudo rm -rf /usr/share/dotnet | ||
| sudo rm -rf /usr/local/lib/android | ||
| sudo rm -rf /usr/share/swift | ||
| sudo rm -rf /usr/share/rust | ||
| sudo rm -rf /usr/share/powershell | ||
| # Remove cached tools and files | ||
| sudo apt-get clean | ||
| df -h # Optional: Check space before build | ||
|
|
||
| - name: Set up Docker Compose | ||
| run: sudo apt-get update && sudo apt-get install -y docker-compose | ||
|
|
||
| - name: Build and start containers | ||
| run: docker-compose -f docker-compose-test.yml up -d --build | ||
|
|
||
| - name: Run integration test | ||
| run: ./tests/test_integration.sh --model-file webapp/manage.py | ||
|
|
||
| - name: Check container logs for errors | ||
| run: | | ||
| docker-compose logs medcatweb | ||
| # NOTE: ignore line "Applying auth.0007_alter_validators_add_error_messages" - not an error | ||
| docker-compose logs medcatweb | grep -v "Applying auth.0007_alter_validators_add_error_messages" | grep -i 'error' && exit 1 || true | ||
|
|
||
| - name: Tear down | ||
| run: docker-compose -f docker-compose-test.yml down | ||
|
|
||
| publish-to-docker-hub: | ||
| runs-on: ubuntu-latest | ||
| if: startsWith(github.ref, 'refs/tags/') | ||
| needs: integration-test | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Log in to Docker Hub | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Extract metadata (tags, labels) for Docker medcat-model-distributor | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: cogstacksystems/medcat-model-distributor | ||
| tags: | | ||
| # Include all default tags | ||
| type=schedule | ||
| type=ref,event=branch | ||
| type=ref,event=tag | ||
| type=ref,event=pr | ||
| type=sha | ||
| # Create version tag based on tag prefix | ||
| type=match,pattern=medcat-model-distributor/v(\d+\.\d+\.\d+),group=1 | ||
| flavor: latest=false | ||
|
|
||
| - name: Build and push Docker medcat-model-distributor image | ||
| id: docker_build | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: ./medcat-model-distributor/webapp | ||
| push: true | ||
| allow: network.host | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| cache-from: type=registry,ref=cogstacksystems/medcat-model-distributor:buildcache | ||
| cache-to: type=registry,ref=cogstacksystems/medcat-model-distributor:buildcache,mode=max | ||
| build-args: | | ||
| REINSTALL_CORE_FROM_LOCAL=true | ||
|
|
||
| - name: Image digest | ||
| run: echo ${{ steps.docker_build.outputs.digest }} | ||
| working-directory: "./" | ||
|
||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
4 changes: 0 additions & 4 deletions
4
medcat-demo-app/docker-compose-test.yml → ...model-distributor/docker-compose-test.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 1 addition & 5 deletions
6
medcat-demo-app/docker-compose.yml → medcat-model-distributor/docker-compose.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
53 changes: 53 additions & 0 deletions
53
medcat-model-distributor/tests/setup/setup_in_container.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import sys, os, secrets | ||
| import django | ||
| from django.core.files import File | ||
| from django.utils import timezone | ||
| from datetime import timedelta | ||
|
|
||
| os.environ.setdefault("DJANGO_SETTINGS_MODULE", "webapp.settings") | ||
| django.setup() | ||
|
|
||
| # ── Import models ───────────────────────────────────────────────────────────── | ||
| try: | ||
| from demo.models import MedcatModel, APIKey | ||
| except ImportError as e: | ||
| print(f"[SEED] ImportError: {e}", file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
| def main(model_path: str, model_name: str, model_display_name: str, | ||
| model_description: str, api_key_identifier: str): | ||
| # ── MedcatModel ─────────────────────────────────────────────────────────────── | ||
| if not os.path.exists(model_path): | ||
| print(f"[SEED] ERROR: model file not found in container: {model_path}", file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
| obj, created = MedcatModel.objects.get_or_create( | ||
| model_name=model_name, | ||
| defaults={ | ||
| "model_display_name": model_display_name, | ||
| "model_description": model_description, | ||
| }, | ||
| ) | ||
| if created or not obj.model_file: | ||
| with open(model_path, "rb") as f: | ||
| obj.model_file.save(os.path.basename(model_path), File(f), save=True) | ||
| print(f"[SEED] MedcatModel created: {obj.model_name}", file=sys.stderr) | ||
| else: | ||
| print(f"[SEED] MedcatModel already exists: {obj.model_name}", file=sys.stderr) | ||
|
|
||
| # ── APIKey ──────────────────────────────────────────────────────────────────── | ||
| key_value = secrets.token_hex(32) # 64-char hex, fits max_length=64 | ||
| APIKey.objects.create( | ||
| key=key_value, | ||
| identifier=api_key_identifier, | ||
| expires_at=timezone.now() + timedelta(hours=1), | ||
| is_active=True, | ||
| ) | ||
| print(f"[SEED] APIKey created for identifier: {api_key_identifier}", file=sys.stderr) | ||
|
||
|
|
||
| # Print ONLY the key to stdout so the shell can capture it cleanly | ||
| print(key_value) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main(*sys.argv[1:]) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.