Skip to content

Conversation

@mart-r
Copy link
Collaborator

@mart-r mart-r commented Dec 2, 2025

Currently, can't even import the base medcat package from a raw install due to it importing medcat.utils.check_for_updates which in turn uses packaging which isn't listed as a dep, let alone a core one.

Going further than that, there's a few other deps that are missing:

  • medcat.utils.downloads_scripts needs requests
  • medcat.utils.legacy.convert_meta_cat needs to explicitly specify it needs MetaCAT
  • medcat.utils.legacy.convert_rel_cat needs to explicitly specify it needs RelCAT
  • medcat.utils.regression.checking and medcat.utils.regression.regression_checker need pyyaml

So this PR does the following:

  • Adds explicit checks for installed optional dependencies to medcat.utils.legacy.convert_meta_cat and medcat.utils.legacy.convert_rel_cat
  • Add missing core dependencies
    • packaging
    • pyyaml
    • requets
  • Adds a script that checks each import and categorises it
    • Importable in default / no-extras install
    • Explicitly raise the medcat.utils.MissingDependenciesError upon import
    • Failed to import due to some other error (if any exist, exits with non-zero exit status)
  • Adds a workflow job that runs the check from above
    • Expects a zero exit status
    • Still provides the output

@tomolopolis
Copy link
Member

Comment on lines 15 to 32
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
# NOTE: using oldest supported python version
- name: Install uv for Python 3.10
uses: astral-sh/setup-uv@v7
with:
python-version: 3.10
enable-cache: true
cache-dependency-glob: "medcat-v2/uv.lock"
- name: Install the project
run: |
uv sync # NO extras
- name: Check that all packages / modules can be imported with default / no-extras install
run: |
uv run python tests/other/check_base_install_can_import_all.py medcat
types-lints-tests-regression:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI about 12 hours ago

To resolve this issue, add a permissions: block specifying the minimum required permissions to either the root of the workflow file or to each job. Since neither job requires write access to the repository or other privileged resources, a root-level block with contents: read is sufficient. This will apply contents: read to all jobs unless overridden. The change should be placed immediately after the name: and before the on: block (commonly, after line 1).

Suggested changeset 1
.github/workflows/medcat-v2_main.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/medcat-v2_main.yml b/.github/workflows/medcat-v2_main.yml
--- a/.github/workflows/medcat-v2_main.yml
+++ b/.github/workflows/medcat-v2_main.yml
@@ -1,4 +1,6 @@
 name: medcat-v2 - Test
+permissions:
+  contents: read
 
 on:
   push:
EOF
@@ -1,4 +1,6 @@
name: medcat-v2 - Test
permissions:
contents: read

on:
push:
Copilot is powered by AI and may make mistakes. Always verify output.
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.

3 participants