Skip to content

fix(mf4): defer asammdf imports until reader/writer construction - #2123

Open
timothyanderson096-ocdealcheck wants to merge 1 commit into
hardbyte:mainfrom
timothyanderson096-ocdealcheck:fix/mf4-import-order-2122
Open

timothyanderson096-ocdealcheck wants to merge 1 commit into
hardbyte:mainfrom
timothyanderson096-ocdealcheck:fix/mf4-import-order-2122

Conversation

@timothyanderson096-ocdealcheck

Copy link
Copy Markdown

Summary of Changes

Importing asammdf first can re-enter can through canmatrix/canopen before asammdf is initialized. The optional-import guard then permanently treats an installed dependency as missing.

  • Load asammdf when an MF4 reader or writer is constructed.
  • Retain the optional-dependency message when asammdf itself is absent; preserve the original error for missing transitive dependencies.
  • Resolve writer dependency metadata before opening its output.
  • Add fresh-process reader/writer regressions for both native import orders and a deterministic circular import around the real asammdf loader. The deterministic case does not require canopen in upstream test dependencies.
  • Add missing-dependency/file-opening controls and a changelog fragment. Frame parsing and serialization are unchanged.

Related Issues / Pull Requests

Closes #2122. Thanks to @nehalkpatel for the reproduction and dependency-chain analysis.

Existing packed-error-frame PR #2115 is separate and is not included or stacked here.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactoring
  • Other

Checklist

  • I have followed the contribution guide.
  • I have added or updated tests as appropriate.
  • I have added or updated documentation as appropriate.
  • I have added a news fragment.
  • All checks and tests pass (tox).

Validation and limits

Tested on Linux / CPython 3.12.14 with asammdf 8.7.2, canmatrix 1.2 and canopen 2.4.1. Published commit 2c0bb48693d1e96332ef8cb9df74bc9e363e41ed has the exact tested complete tree de8a6291bdd23d56b96df7ffe9baefd09a9a52f3, based on unchanged upstream b4f82abede25ff83376be793a2935c41f81c3869.

  • Identical new regressions on the original source: four reader/writer import-order subcases and the transitive-error case fail. Candidate: all three test methods and six subtests pass.
  • Focused MF4 checks: 7 passed, 1 existing unsupported-append skip, 6 subtests passed.
  • Full local suite: baseline 33 failed, 505 passed, 98 skipped, 31 subtests passed; candidate 28 failed, 506 passed, 98 skipped, 35 subtests passed. The remaining 28 failures are the same IPv4/IPv6 multicast socket configuration failures in both trees. There are no new failing test identities; the full local suite is not green.
  • Project-wide Ruff and Black pass. Project mypy targets 3.10–3.14 pass all 65 source files in a lint environment without MF4 extras. Changed-source Pylint and complete-patch whitespace pass.
  • An additional mypy diagnostic with the real MF4 dependencies installed retains seven existing-source diagnostics, compared with 16 on the baseline. No type checks or thresholds were weakened.
  • Independent coding-agent inspection identified and resolved the initial regression-environment gap; final inspection found no remaining material issue.

No hosted CI, hardware, other OS/interpreter execution, minimum asammdf 6 validation, full tox/docs run or whole-project Pylint result is claimed. Black emits an inferred Python 3.15 target warning under this Python 3.12 runtime; explicit Python 3.10 changed-file checks also pass.

Prepared with OpenAI Codex assistance. Maintainer review remains requested.

Timothy Anderson — Spotted Ridge Engineering / OC Labs · Independent software verification · GDN (Global Decision Network)
timothyanderson096@gmail.com · Engineering evidence

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T15:09:54.382157Z 2c0bb48 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

MF4Writer reports "asammdf package was not found" when asammdf is imported before can

1 participant