Closed WeiweiAi closed 1 year ago
@WeiweiAi, please use the right tags when you insert some code. I have edited your comment and you might want to check it to see what I mean. Without the right tags, you just get some plain code while here we have syntax highlighting which makes it much easier to read.
Thank you, @agarny
With the latest development codebase I am getting the same output:
The import source is valid.
no unresolved imports.
The import source is not valid.
You are not holding onto the importer reference when you call:
resolve_imports(model, model_path, True) #If this line is commented out, The method "validate_model" found 1 issues: - Cyclic units exist: 'fmol' -> 'fmol'.
If you do instead:
importer = resolve_imports(model, model_path, True) #If this line is commented out, The method "validate_model" found 1 issues: - Cyclic units exist: 'fmol' -> 'fmol'.
Your code will work. By not holding onto the importer you let go of the imported sources and the Python garbage collection tidies up at some point releasing the imported model.
libcellml==0.4.0
I was trying to reuse importSource to import units for different models. I noticed that after resolving the import of the model, I can not access the units model by calling importSource.model(). I think I should set up import every time when I want to import the units instead of reusing it. Anyway, I attached the Python code for the record.
The code will print out:
The last line indicates that importSource.model() is None, which is described above.