Skip to content

Changes to FmuBuilder.build_FMU. 1. Unload the script module after th… #247

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

Merged
merged 2 commits into from
Jul 3, 2025

Conversation

eisDNV
Copy link
Contributor

@eisDNV eisDNV commented Jul 3, 2025

…e FMU is built to avoid that the cached script is used when using the FMU 2. Optionally allow non-default names for the resulting FMU file 3. Check that the script file is not among the project files 4. Add a documentation text to the function.

…e FMU is built to avoid that the cached script is used when using the FMU 2. Optionally allow non-default names for the resulting FMU file 3. Check that the script file is not among the project files 4. Add a documentation text to the function.
Copy link
Collaborator

@Jorgelmh Jorgelmh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just need to correct a conditional and we're good to merge

@Jorgelmh Jorgelmh merged commit 2926cca into NTNU-IHB:master Jul 3, 2025
9 checks passed
Comment on lines +338 to +339
if newargs is not None:
sys.modules.pop(Path(script_file).stem) # otherwise old script may be active when loading the FMU!
Copy link

@davidhjp01 davidhjp01 Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

module syntax can be aaa.bbb.ccc. Path.stem seems to only return filename without the final suffix - but I don't recall we ever put the main script file in some nested module, so probably this is okay?

Comment on lines +281 to +282
assert file_.name != script_file.name, ( # avoid the inclusion of the script in project files
"It seems that the script file is included a second time in the project_files")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we want to only check the name of the file for deciding the assertion. The file name be same in different python modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants