open-simulation-platform / cosim-cli

Command-line interface for libcosim
https://open-simulation-platform.github.io/cosim
Mozilla Public License 2.0
10 stars 4 forks source link

Use a persistent cache for FMU contents #30

Closed kyllingstad closed 4 years ago

kyllingstad commented 4 years ago

Fixes #11.

~I've submitted a companion pull request for cse-core which must be merged first: open-simulation-platform/cse-core#388. Once that is accepted, I'll revert the channel change in conanfile.txt here.~

kyllingstad commented 4 years ago

Closing for the time being. Will pick up again later.

kyllingstad commented 4 years ago

Reopening now that open-simulation-platform/cse-core#388 is ready.

kyllingstad commented 4 years ago

I just discovered that this PR had bitrotted. I've updated it now, so it's ready for a new review. It's a rather long-standing one, so it would be good to get it done. :)

ljamt commented 4 years ago

This PR looks good to me. I've also tested it functionally. The cached fmus end up in localAppData/cse as expected, and the ´clean-cache` subcommand clears it.

When running the dp-ship example or inspecting the OSOM.fmu, I notice that we still create a "cse_guid" folder in localAppData/Temp. I think the importer in cse-core still extracts the fmu to the localAppData/Temp folder. Is it supposed to work like this?

kyllingstad commented 4 years ago

When running the dp-ship example or inspecting the OSOM.fmu, I notice that we still create a "cse_guid" folder in localAppData/Temp. I think the importer in cse-core still extracts the fmu to the localAppData/Temp folder. Is it supposed to work like this?

Weird, I can't reproduce this on my computer, neither on Windows nor Linux. Are you able to run cse inspect via a debugger and see when the folder gets created?

ljamt commented 4 years ago

Debugged inspect with different FMUs now. An empty cse_guid folder is created in localAppData/Temp when line inspect.cpp line 72 is executed:

const auto uriReference = to_uri(args["uri_or_path"].as<std::string>());

This folder contains the extracted fmu after line 73 has executed: const auto uriResolver = caching_model_uri_resolver();

All folders are deleted once the cse inspect command returns.

Sorry. Debugging outdated code. Will come back with more accurate info

ljamt commented 4 years ago

It is inpect.cpp line 74: const auto model = uriResolver->lookup_model(baseUri, uriReference); A cse_guid is created and contains only the ModelDescription.xml and is destroyed when the lookup_model returns.

Could it be the peek_model_description in importer.cpp?

kyllingstad commented 4 years ago

Could it be the peek_model_description in importer.cpp?

Yes. That is as expected, and as long as the directory gets deleted again afterwards, it's not a bug. Thanks for checking!