-
Notifications
You must be signed in to change notification settings - Fork 1
Fix URI path parsing bug in FMU C++ template - preserve leading slash on Unix #111
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: ClaasRostock <48752696+ClaasRostock@users.noreply.github.com>
Co-authored-by: ClaasRostock <48752696+ClaasRostock@users.noreply.github.com>
Co-authored-by: ClaasRostock <48752696+ClaasRostock@users.noreply.github.com>
Co-authored-by: ClaasRostock <48752696+ClaasRostock@users.noreply.github.com>
|
@copilot Checks are failing because |
Co-authored-by: magkri <17215215+magkri@users.noreply.github.com>
Fixed in commit 75b70ea. Updated sourcery version constraint to |
|
@copilot Resolve all linting errors reported by |
Co-authored-by: magkri <17215215+magkri@users.noreply.github.com>
Description
The
formatOnnxPathfunction in the FMU C++ template incorrectly stripped 8 characters when removingfile://URI prefixes, causing loss of the leading/in Unix absolute paths. This prevented FMU instantiation when libraries like fmpy pass paths asfile:///tmp/path/model.onnx.Root cause: Checked for
"file:///"(8 chars) but stripped 8 chars, removing one char too many.Fix: Check for and strip
"file://"(7 chars) to preserve the leading/.Changes
C++ Template (
src/mlfmu/fmu_build/templates/onnx_fmu/onnxFmu.cpp):L"file:///"→L"file://"Test (
tests/test_uri_path_handling.py):ruff formatDependency Fix (
pyproject.toml):>=1.22to>=1.40,!=1.41.1Example
How Has This Been Tested?
Screenshots (if appropriate)
N/A
Developer Checklist (before requesting PR review)
I have:
Reviewer checklist
I have:
Original prompt
This section details on the original issue you should resolve
<issue_title>URI Path Parsing Bug in Generated FMU C++ Code - Missing Leading Slash on Unix</issue_title>
<issue_description>## Summary
MLFMU generates FMUs with a C++ path parsing bug that causes FMU instantiation to fail on Unix systems when using absolute paths. The bug is in the
formatOnnxPathfunction which incorrectly strips URI prefixes.Root Cause
In
mlfmu/fmu_build/templates/onnx_fmu/onnxFmu.cpp, theformatOnnxPathfunction has incorrect substring logic around lines 44-46:Problem Description
When
fmpy(and other FMU libraries) pass absolute paths to the FMU, they convert them tofile://URIs:file:///tmp/extracted_fmu/resources/model.onnx/tmp/extracted_fmu/resources/model.onnxtmp/extracted_fmu/resources/model.onnx❌ (missing leading/)This causes ONNX model loading to fail with:
Reproduction Case