basyx-python-sdk icon indicating copy to clipboard operation
basyx-python-sdk copied to clipboard

Mypy import errors break CI pipeline

Open moritzsommer opened this issue 1 year ago • 4 comments

The CI test compliance-tool-static-analysis executes Run mypy ./aas_compliance_tool test. Due to occurring [import-not-found] errors from mypy, the pipeline fails:

Run mypy ./aas_compliance_tool test
aas_compliance_tool/state_manager.py:15: error: Cannot find implementation or library stub for module named "basyx.aas.examples.data._helper"  [import-not-found]
aas_compliance_tool/state_manager.py:74: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
aas_compliance_tool/compliance_check_xml.py:19: error: Cannot find implementation or library stub for module named "basyx.aas"  [import-not-found]
aas_compliance_tool/compliance_check_xml.py:20: error: Cannot find implementation or library stub for module named "basyx.aas.adapter.xml"  [import-not-found]
aas_compliance_tool/compliance_check_xml.py:21: error: Cannot find implementation or library stub for module named "basyx.aas.examples.data"  [import-not-found]
aas_compliance_tool/compliance_check_xml.py:22: error: Cannot find implementation or library stub for module named "basyx.aas.examples.data._helper"  [import-not-found]
aas_compliance_tool/compliance_check_json.py:19: error: Cannot find implementation or library stub for module named "basyx.aas"  [import-not-found]
aas_compliance_tool/compliance_check_json.py:20: error: Cannot find implementation or library stub for module named "basyx.aas.adapter.json"  [import-not-found]
aas_compliance_tool/compliance_check_json.py:21: error: Cannot find implementation or library stub for module named "basyx.aas.examples.data"  [import-not-found]
aas_compliance_tool/compliance_check_json.py:22: error: Cannot find implementation or library stub for module named "basyx.aas.examples.data._helper"  [import-not-found]
aas_compliance_tool/compliance_check_aasx.py:23: error: Cannot find implementation or library stub for module named "basyx.aas"  [import-not-found]
aas_compliance_tool/compliance_check_aasx.py:24: error: Cannot find implementation or library stub for module named "basyx.aas.adapter"  [import-not-found]
aas_compliance_tool/compliance_check_aasx.py:25: error: Cannot find implementation or library stub for module named "basyx.aas.adapter.xml"  [import-not-found]
aas_compliance_tool/compliance_check_aasx.py:26: error: Cannot find implementation or library stub for module named "basyx.aas.adapter.json"  [import-not-found]
aas_compliance_tool/compliance_check_aasx.py:27: error: Cannot find implementation or library stub for module named "basyx.aas.examples.data"  [import-not-found]
aas_compliance_tool/compliance_check_aasx.py:28: error: Cannot find implementation or library stub for module named "basyx.aas.examples.data._helper"  [import-not-found]
aas_compliance_tool/cli.py:20: error: Cannot find implementation or library stub for module named "basyx.aas.adapter"  [import-not-found]
aas_compliance_tool/cli.py:21: error: Cannot find implementation or library stub for module named "basyx.aas.adapter.xml"  [import-not-found]
aas_compliance_tool/cli.py:21: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
aas_compliance_tool/cli.py:25: error: Cannot find implementation or library stub for module named "basyx.aas.adapter.json"  [import-not-found]
aas_compliance_tool/cli.py:26: error: Cannot find implementation or library stub for module named "basyx.aas.examples.data"  [import-not-found]
test/test_state_manager.py:11: error: Cannot find implementation or library stub for module named "basyx.aas.examples.data._helper"  [import-not-found]
test/test_aas_compliance_tool.py:16: error: Cannot find implementation or library stub for module named "basyx.aas"  [import-not-found]
test/test_aas_compliance_tool.py:17: error: Cannot find implementation or library stub for module named "basyx.aas.adapter"  [import-not-found]
test/test_aas_compliance_tool.py:18: error: Cannot find implementation or library stub for module named "basyx.aas.adapter.json"  [import-not-found]
test/test_aas_compliance_tool.py:19: error: Cannot find implementation or library stub for module named "basyx.aas.adapter.xml"  [import-not-found]
test/test_aas_compliance_tool.py:20: error: Cannot find implementation or library stub for module named "basyx.aas.examples.data"  [import-not-found]
test/test_aas_compliance_tool.py:21: error: Cannot find implementation or library stub for module named "basyx.aas.examples.data._helper"  [import-not-found]
Found 26 errors in 7 files (checked 13 source files)
Error: Process completed with exit code 1.

This is not related to #390

moritzsommer avatar Jun 26 '25 21:06 moritzsommer

It seems like mypy doesn't recognize that our SDK is typed, even though we have the py.typed file. That is something that still needs investigation.

However, looking at the CI definition: https://github.com/eclipse-basyx/basyx-python-sdk/blob/a6a904af37f9cccddd1d31f6b2f1921bfded4256/.github/workflows/ci.yml#L250..L255

This should be adapted when we touch this:

    - name: Install Python dependencies
      # install the local sdk in editable mode so it does not get overwritten
      run: |
        python -m pip install --upgrade pip
        pip install ../sdk
        pip install .[dev]
  • There's no need to install the SDK via -e, since there shouldn't be any edits between time of install and time of use in a CI pipeline
  • The compliance tool should be able to run as independent tool, so cannot, by definition, need the [dev] dependencies of the SDK.

s-heppner avatar Jul 04 '25 07:07 s-heppner

Apparently, the original problem fixed itself. @zrgt merged a new PR into main, and the part of the pipeline that failed before is now passing. No changes to the functional code were made.

The only difference between #392, where the pipeline failed after merging it into main, and #415, where the pipeline passed, are the authors of the PR. While I am not an official Eclipse Committer, @s-heppner and @zrgt are. This means that the Eclipse ECA Validation was not executed after merging #415 into main. Although this seems to be the only difference between the two PRs, I find it hard to believe that it could cause any import errors.

What do you think about this?

moritzsommer avatar Oct 07 '25 19:10 moritzsommer

I also don't think that the ECA validation can lead to import errors, they're completely separate. Maybe it was cosmic rays? Or, on a scarier note, a compromised CI action?

I'd honestly just leave it as it is, if it is working now with no relevant changes from our side.

s-heppner avatar Oct 10 '25 07:10 s-heppner

This issue only appears in the push CI to main, not in the PR CI workflows, for some obscure reason. Both workflow definitions are exactly the same though, so it must have something to do with the way the code gets checked out.

s-heppner avatar Jan 20 '26 11:01 s-heppner