Opened 11 years ago
Last modified 3 years ago
#2447 reopened enhancement
Let OM automatically load packages as specified in import statements
Reported by: | Dietmar Winkler | Owned by: | Per Östlund |
---|---|---|---|
Priority: | high | Milestone: | 1.19.0 |
Component: | New Instantiation | Version: | trunk |
Keywords: | Cc: |
Description
Currently, OMEdit (and omc I guess) does not automatically load a package that is specified in a import statement. In other tools (e.g., Dymola) it's normally enough to have the package that is listed in an import statement to be either present in the same working directory or in the MODELICAPATH
. Having to manually load those packages seems to be an unnecessary burden on the user and can be easily done by the tool.
I can't really think of any reason why this would *not* be a good feature to have.
Change History (37)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
So what drawback is it to also look for the package when it's specified in an import statement? I can't really think of an performance issue, right?
comment:3 by , 11 years ago
Are you sure you want a tool like Windows that does
things "magically" and loads wrong versions of packages
that appear as import?
Also, the Modelica Specification say nothing about this.
Of course we could support it and give a warning when
we load the package. But I'm not really convinced this
is a good thing to have.
comment:4 by , 11 years ago
Well. Do you want to look in imports of the class you click simulate on or all the classes that it references? The uses-annotation at top level is a lot faster.
If it is about OMEdit, maybe. Look at the imports as you expand one level in the library tree.
And Adrian, we already add notifications that we load libraries. However, it seems OMEdit does not detect this :)
model M annotation(uses(Buildings(version="latest"))); end M;
Scripting 22:19:55 0:0-0:0 Automatically loaded package Buildings 1.5 due to uses annotation.
It's not in the tree, so I try to load it and it tells me it won't add it because it already exists. But it won't appear in the tree anyway ;)
comment:5 by , 11 years ago
I know the Spec does not say anything about this. Hence I marked this as enhancement and not as defect ;)
You are probably right about the version issue though. But this should be documented in the user's Guide then (since it's not in the Spec). BTW, I just tested it with uses
but OMEdit does not look for the package in the current working directory it seems. Again, something that is very useful when developing libraries that should not (yet) be placed within MODELICAPATH
.
comment:6 by , 11 years ago
version="latest"
... never seen this before. Is this a OM thing. Could not find it in the Specs.
comment:7 by , 11 years ago
Well... If it should not be on the MODELICAPATH, they shouldn't be loaded, right? Regardless, OMEdit has no concept of working directory (being always in its tmp-dir)...
comment:8 by , 11 years ago
I have 2 versions of Buildings 1.5 :)
/usr/lib/omlibrary/Buildings 1.5/ /usr/lib/omlibrary/Buildings latest/
comment:9 by , 11 years ago
Ha, cheeky.
Well I guess I need to enhance this enhancement ticket then :) Let OMEdit also look for packages inside the directory a currently opened model is residing in when there is a uses
clause.
comment:10 by , 11 years ago
As for having to traverse through all the classes in order to identify the import statements ... well you have to do this anyway when checking/simulating. So the only thing left would be simply to also (in case it's not loaded yet) check if the package is available in the directory of the model (please) or MODELICAPATH
and then load the latest stable version as the spec suggests.
comment:11 by , 11 years ago
A bit late to the party, but the specification says in 13.2.4:
If a top-level name is not found at global scope, a Modelica translator shall look up additional classes in an ordered list of library roots, called MODELICAPATH.
I interpret this to mean that we should load libraries automatically if they are used anywhere in a model, not only in imports.
comment:12 by , 10 years ago
Milestone: | 1.9.1 → 1.9.2 |
---|
This ticket was not closed for 1.9.1, which has now been released. It was batch modified for milestone 1.9.2 (but maybe an empty milestone was more appropriate; feel free to change it).
comment:13 by , 10 years ago
Milestone: | 1.9.2 → 1.9.3 |
---|
Milestone changed to 1.9.3 since 1.9.2 was released.
comment:18 by , 8 years ago
Milestone: | 1.11.0 → 1.12.0 |
---|
Milestone changed to 1.12.0 since 1.11.0 was released.
comment:19 by , 7 years ago
Milestone: | 1.12.0 → 1.13.0 |
---|
comment:21 by , 5 years ago
Milestone: | 1.14.0 → 1.16.0 |
---|
Releasing 1.14.0 which is stable and has many improvements w.r.t. 1.13.2. This issue is rescheduled to 1.16.0
comment:23 by , 4 years ago
Milestone: | 1.17.0 → 1.18.0 |
---|
Retargeted to 1.18.0 because of 1.17.0 timed release.
comment:25 by , 3 years ago
Milestone: | → 1.19.0 |
---|
This was fixed a while ago in 8e7c3944. The new frontend now tries to find a library to load if it encounters a top level name it can't find, as specified in the Modelica specification.
follow-up: 27 comment:26 by , 3 years ago
Loading from current working directory still does not work in OMEdit. Even though "." is part of MODELICAPATH. So I would argue this is far from fixed.
comment:27 by , 3 years ago
Replying to dietmarw:
Loading from current working directory still does not work in OMEdit. Even though "." is part of MODELICAPATH. So I would argue this is far from fixed.
Did you add .
to the MODELICAPATH
yourself? We don't add it by default I think, at least it's not in my MODELICAPATH
(OMEdit shows it in Tools->Options->Libraries).
If you do have .
in your MODELICAPATH
and OM stills doesn't load libraries from it, then please open a new issue on GitHub since it's better to have a more focused ticket for that particular issue.
comment:28 by , 3 years ago
"." is specified in the User Libraries section but seems to get ignored. That was the whole reason for this ticket if I recall correctly.
comment:29 by , 3 years ago
No need to open a new one as this already exists as a broken import ticket ;-)
https://github.com/OpenModelica/OpenModelica/issues/2447
comment:30 by , 3 years ago
Component: | OMEdit → New Instantiation |
---|---|
Owner: | changed from | to
comment:32 by , 3 years ago
Sure. I never understood why Trac is still used when the _same_ ticket exists on GitHub as import.
comment:33 by , 3 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:34 by , 3 years ago
Resolution: | duplicate |
---|---|
Status: | closed → reopened |
@dietmarw, what @perost was asking is to please open a new ticket with a different number, that focused specifically on the problem of the modelicapath. We have a lot of very old, very long tickets with shifting subjects, that are difficult to manage and tend to linger around forever, so we are trying to come up with updated tickets that are really focused on as narrow an issue as possible.
I messed up myself as well, by not recognizing that the ticket number was the same; I thought you were referring to an imported ticket with another number, and I added content to that. Of course it was the same number, instead :)
Summing up:
- we had a plan to automatically migrate all trac tickets to GitHub, including their content
- as a first step, we set up placeholders, so that we could continue numbering new issues in GitHub without overlapping with old tickets in trac; that went well
- the actual content migration turned out to be more difficult than we thought (the devil is in the details), so we'll need to carry on with this duplication for a while. That is no big deal, as the people involved in old trac tickets are mostly developers and old-timers like you.
- of course the status of tickets with the same number should be the same.
So, I apologize for the mess and reopen this as well.
comment:36 by , 3 years ago
So could you please clarify if the issue should continue to get discussed here or on the GitHub ticket clone.
But we do consider the uses annotation... If a uses-annotation is on a package, it is loaded automatically. If a uses-annotation is on a model, it is loaded automatically. And that is often a bit annoying because Dymola adds the annotation even if the library is not used...