From 4fcb5761260ace5dd3fa1b5c6c5fdbde7d3b33ea Mon Sep 17 00:00:00 2001 From: Phoevos Kalemkeris Date: Thu, 26 Jun 2025 14:41:13 +0100 Subject: [PATCH 1/2] chore: Update CI to use 'main' instead of 'master' Signed-off-by: Phoevos Kalemkeris --- .github/workflows/api-docs.yaml | 8 ++++---- .github/workflows/docker-extra.yaml | 6 +++--- .github/workflows/docker.yaml | 6 +++--- .github/workflows/main.yaml | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/api-docs.yaml b/.github/workflows/api-docs.yaml index b9bcf2e..261a2af 100644 --- a/.github/workflows/api-docs.yaml +++ b/.github/workflows/api-docs.yaml @@ -2,16 +2,16 @@ name: api-docs on: push: - branches: [ master ] + branches: [ main ] pull_request: - branches: [ master ] + branches: [ main ] jobs: build: if: | github.repository == 'CogStack/CogStack-ModelServe' && - github.ref == 'refs/heads/master' && + github.ref == 'refs/heads/main' && github.event_name == 'push' runs-on: ubuntu-latest strategy: @@ -57,7 +57,7 @@ jobs: exit 0 fi - name: Update OpenAPI docs - uses: ad-m/github-push-action@master + uses: ad-m/github-push-action@main with: branch: gh-pages github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/docker-extra.yaml b/.github/workflows/docker-extra.yaml index 5fad479..e8be4ac 100644 --- a/.github/workflows/docker-extra.yaml +++ b/.github/workflows/docker-extra.yaml @@ -3,11 +3,11 @@ name: docker extra on: workflow_dispatch: push: - branches: [ master ] + branches: [ main ] paths: - 'docker/mlflow/**' pull_request: - branches: [ master ] + branches: [ main ] paths: - 'docker/mlflow/**' @@ -29,7 +29,7 @@ jobs: needs: lint if: | github.repository == 'CogStack/CogStack-ModelServe' && - github.ref == 'refs/heads/master' && + github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') runs-on: ubuntu-latest permissions: diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index b2e14b5..bcf1956 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -3,9 +3,9 @@ name: docker on: workflow_dispatch: push: - branches: [ master ] + branches: [ main ] pull_request: - branches: [ master ] + branches: [ main ] env: REGISTRY: docker.io @@ -25,7 +25,7 @@ jobs: needs: lint if: | github.repository == 'CogStack/CogStack-ModelServe' && - github.ref == 'refs/heads/master' && + github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') runs-on: ubuntu-latest permissions: diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 1774702..f44c5a9 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -2,9 +2,9 @@ name: build on: push: - branches: [ master ] + branches: [ main ] pull_request: - branches: [ master ] + branches: [ main ] jobs: build: From 668e5b3fb5863b4b4cc885fc9998192db4ca12ee Mon Sep 17 00:00:00 2001 From: Phoevos Kalemkeris Date: Thu, 26 Jun 2025 13:38:49 +0100 Subject: [PATCH 2/2] api: Include labels in DeID service model card Extend the base model card schema to allow passing a mapping of labels, i.e. concept IDs (e.g. CUIs) to names. This is particularly useful when using the MedCAT model DeID service, which is typically configured to serve models with a relatively small CDB that can be exposed in its entirety as part of the model card. This information can be interesting to the user (or client application), providing insight into the concepts that the model is capable of identifying and by extension enabling them to decide and control which of them should be redacted. The 'labels' field is always included in the API's responses when the '/info' endpoint is called, but is only populated with the mapping in a dict format when the CMS instance is configured to use the MedCAT model DeID service. Signed-off-by: Phoevos Kalemkeris --- app/domain.py | 1 + app/model_services/medcat_model_deid.py | 1 + tests/app/api/test_serving_common.py | 1 + tests/app/api/test_serving_hf_ner.py | 1 + tests/app/api/test_serving_trf.py | 2 ++ 5 files changed, 6 insertions(+) diff --git a/app/domain.py b/app/domain.py index ff25bfd..0e414ef 100644 --- a/app/domain.py +++ b/app/domain.py @@ -138,6 +138,7 @@ class ModelCard(BaseModel): model_type: ModelType = Field(description="The type of the served model") model_description: Optional[str] = Field(description="The description about the served model") model_card: Optional[dict] = Field(default=None, description="The metadata of the served model") + labels: Optional[Dict[str, str]] = Field(default=None, description="The mapping of CUIs to names") class Entity(BaseModel): diff --git a/app/model_services/medcat_model_deid.py b/app/model_services/medcat_model_deid.py index bf428f3..ce1594a 100644 --- a/app/model_services/medcat_model_deid.py +++ b/app/model_services/medcat_model_deid.py @@ -69,6 +69,7 @@ def info(self) -> ModelCard: model_type=ModelType.ANONCAT, api_version=self.api_version, model_card=model_card, + labels=self.model.cdb.cui2preferred_name, ) def annotate(self, text: str) -> List[Annotation]: diff --git a/tests/app/api/test_serving_common.py b/tests/app/api/test_serving_common.py index 71d84ae..9992a62 100644 --- a/tests/app/api/test_serving_common.py +++ b/tests/app/api/test_serving_common.py @@ -345,6 +345,7 @@ def test_train_unsupervised_with_hf_hub_dataset(model_service, client): "model_description": "huggingface_ner_model_description", "model_type": ModelType.MEDCAT_SNOMED, "model_card": None, + "labels": None, }) model_service.info.return_value = model_card model_service.train_unsupervised.return_value = (True, "experiment_id", "run_id") diff --git a/tests/app/api/test_serving_hf_ner.py b/tests/app/api/test_serving_hf_ner.py index 3c6daa5..c995565 100644 --- a/tests/app/api/test_serving_hf_ner.py +++ b/tests/app/api/test_serving_hf_ner.py @@ -42,6 +42,7 @@ def test_train_unsupervised_with_hf_hub_dataset(model_service, client): "model_description": "huggingface_ner_model_description", "model_type": ModelType.HUGGINGFACE_NER, "model_card": None, + "labels": None, }) model_service.info.return_value = model_card model_service.train_unsupervised.return_value = (True, "experiment_id", "run_id") diff --git a/tests/app/api/test_serving_trf.py b/tests/app/api/test_serving_trf.py index 73a7c29..e15077f 100644 --- a/tests/app/api/test_serving_trf.py +++ b/tests/app/api/test_serving_trf.py @@ -37,6 +37,7 @@ def test_readyz(model_service, client): "model_description": "deid_model_description", "model_type": ModelType.TRANSFORMERS_DEID, "model_card": None, + "labels": None, }) model_service.info.return_value = model_card @@ -49,6 +50,7 @@ def test_info(model_service, client): "model_description": "deid_model_description", "model_type": ModelType.TRANSFORMERS_DEID, "model_card": None, + "labels": None, }) model_service.info.return_value = model_card