-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Hi,
I have been looking through the code a bit in import_fmu_to_modelica.py and I have a couple of suggestions in terms of enhancements. Feel free to disagree to these since these are just my personal opinions:
- Currently on line 49 we have
makedirs(unzipdir, exist_ok=True), but if anything fails after this part there still will be files created from the failed import. It would be good to wrap this in a try/finally in order to clean-up anything was generated before the failure. - I find the name of the second argument
model_patha bit confusing, i.e.def import_fmu_to_modelica(fmu_path, model_path, interface_type):. Would it make more sense if this was named something in line withlibrary_pathorpackage_path? I.e. a user chooses the FMU, and the Modelica library to import to. And there could be a default value for the generated mo-file, where the default name is based on the FMU. - There does not seem to be any error handling for long paths on Windows environments. Note that the directories created on line 49 with
makedirscan cause issues on Windows since there is a maximum path limit. This can be accounted for in Python but even if that is done, a user might have issues when trying to remove/edit these directories (if you create an extremely long path in Windows and try to delete it, it usually doesn't work). - There is a lot of hardcoded
/in the code, I would suggest constructing paths solely usingos.path.join(a,b, ...). It might not matter but I wouldn't be surprised if there is some odd corner case where '/' fails andos.path.joinis considered a safer approach. - In the generated mo-file it would be good if it can include some metadata as description/annotation documentation, for example:
Model generated by modelica-fmi version .... - Parameters such as
communicationStepSize,toleranceand others (parameters added by the import and not from the FMU) could be annotated or named such that it is clear to a user that they come from the package itself and not from the imported FMU. I remember this was already the case inFMPyfor exampleparameter Real tolerance = 0.0 annotation(Dialog(tab="FMI", group="Parameters"));but perhaps those could be clarified even more?
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request