-
Notifications
You must be signed in to change notification settings - Fork 41
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
Allocate MCP number for "Generalized Modelica URIs for external resources" #2387
Conversation
Given that it is impossible for Dymola to deal with a resolution of Modelica URIs based on how a library is stored in the package directory hierarchy, there seems to be two main areas for improving the specification of Modelica URIs for external resources:
Both of these should be addressed by this MCP. Other potential MCP topics that were also discussed in the email thread, but that is outside the scope of this MCP include:
|
For those who didn't follow the lengthy discussion in the email thread, one attempt at improving the Modelica URIs for external resources is as follows.
|
I do not like option 1 at all because of the need to wrap it in a function. This is a declarative approach, we should just use the URI. Browsers don't require us to wrap function call syntax around a URI, JSON APIs that return URIs don't have function syntax. Tacking on such evaluation semantics is, to me, a very bad idea. 2.i - Definitely needs to be deprecated (sooner the better, as far as I'm concerned). 2.ii - Doesn't this encourage a "kitchen sink" approach to resources? Won't everything end up in "Modelica 3.2.1/Resources". That doesn't seem like a good idea at all. The MSL should, at some point, get broken up and this just makes more work for untangling all this stuff. 2.iii - I don't really like relative paths. As far as I am concerned, all Modelica packages should (ultimately) have an implied Option 3 is interesting to me because it means that you can, a priori, determine all class names that can appear in Keep in mind that there are use cases that are completely external to a Modelica tool where we might want to reference resources. So don't assume it is a Modelica tool that is resolving these things. That is my biggest beef with option 1. Who says the |
The way you describe it does not work, because in a non-file based storage there is no corresponding package.mo. In addition the discussion in modelica/ModelicaStandardLibrary#2975 would be complicated if changing storage of a package would impact the resources. |
@HansOlsson every storage mechanism will have to define its own mapping. I am speaking here only about file based storage. I don't see anything in what I'm saying that prevents a non-file based storage system from doing whatever it wants...do you? If so, it then seems irrelevant to me what non-file based systems do. Can you explain why you think it is relevant? With respect to file based approaches, I'm not sure how much the issue you point out impacts things. I would be perfectly happy if the specification said that |
Yes, this is for the kitchen sink approach currently embraced by the MSL. It is only included in the proposal to get the MSL developers on-board. However, I hear you also mentioning the relation to encapsulated classes, and it makes me think (and maybe this is what you were proposing) that having a dedicated way to refer to the enclosing encapsulation barrier is actually more important than having a dedicated way to refer to the top level package. In fact, having a convenient way to bypass the encapsulation border seems to defy the purpose of encapsulation. Hence, I'd like to change 2.ii as follow for this discussion (if we decide to allocate an MCP number, this sort of change could have been made in-place in a markdown file describing what we want out of the MCP):
|
Really more work? Does not sound too hard for me to collect Modelica/Resources/Data/Electrical, Modelica/Resources/Documentation/Electrical and Modelica/Resources/Images/Electrical for a future Electrical library with separated resources. |
The
Note that the use of encapsulation barriers is making the same sort of assumption about a class tree context as the lookup-based rule. Let's call these together the class tree based Modelica URIs. I should perhaps stress some of the reasons for using class tree based Modelica URIs when in the context of a Modelica class tree:
|
I'm not sure if I like the idea of having relative URIs. They are skipped for file:// URIs for good reason. And in Modelica it would be quite annoying to duplicate a class and having it not work because the corresponding resources were not copied as well. So I think your statement is wrong; the current structure makes maintenance quite easy (unless you want to move files in the resources directory as that is not backwards compatible). |
I agree, and I'm also worried that we are discussing large changes here, when we have many opened issues and MCPs that need work. Obviously we should deprecate "modelica://A/B/d" due to the host-name being case-insensitive in later RFC - but we could just introduce "modelica:///A.B/d" and "modelica:///A/B/d" as alternatives and say that they all map to the same resources if "A" and "A.B" are classes, and then rewrite the text to be more readable. |
If you didn't want the resource to be copied, I'd say you placed it too far down in the package hierarchy. If placed at the right level of the hierarchy, I think it would actually make sense to also make a copy of the external resource when making a copy of the class. |
It is very true that there are many other opened issues and MCPs that also need work. Perhaps we could settle with some things to be specified now, while still making sure that we don't close the door for further improving the handling of external resources in the future. For example, if we omit the relative classnames now, I would like the new URIs to only allow fully qualified names (that is, "modelica:///.Modelica/…", not "modelica:///Modelica/…"). Also note that the proposal, as presented above, doesn't really change anything (except, perhaps, for deprecating the current form). The important part of the proposal is the things that it adds by giving meaning to URIs that didn't have a meaning before. |
I'm generally in favor of simply cleaning up what we have. However, I think that is easier said than done with the current semantics. If I have a URL It is for this reason that I really like the idea that any Bottom line...if we want to just cleanup what we have by deprecating |
P.S. - I don't really care for the relative URIs either. |
See also #1623. |
That seems odd (and a bit excessive) as URIs with a specified scheme normally contain fully qualified names (for file:/// and http://). Thus I would say that the natural interpretation is that they are absolute - similarly as for "import Modelica.Electrical;" (which is also a fully qualified name). |
I agree with Hans, I don't see the need for the leading |
The purpose of the leading It's not like a Modelica URI such as "modelica:///Modelica.Mechanics/c.jpg" would be universal just because the classname is always required to be absolute; you still need a Modelica environment with loaded libraries of selected versions in order to resolve the URI. Given this, I don't see why it would be such a big deal to let this resolution of classnames be a little bit more clever and take the current context into consideration. Then, I can understand that different people like to organize their projects in different ways, but just because @GallLeo (see email thread) and I are the only ones who can currently relate to the benefit of keeping external resources close to the Modelica sources, it shouldn't lead to standardization of something that works against it. If it was standardized that the classname of "modelica:///Modelica.Mechanics/c.jpg" is absolute (without being a fully qualified name), can someone show what would be a natural way to handle relative classnames if we would change our mind about embracing local storage of external resources in the future? |
@henrikt-ma I think you have it a bit backward here. Modelica is unusual in that it uses path separators that are dots, not (back)slashes. As such, I think leaving off the leading
i.e., dropping the leading slash not only still allows for relative paths, it actually makes them easier to identify and it is more intuitive. Compare this to:
I would argue that, intuitively, these look backwards. But if I understand your proposal, they are exactly as you intend. To my eye, the former is much more intuitive and easier to see very clearly what is relative and what is absolute (and it doesn't prevent relative paths). |
I think you may have misunderstood what I mean by relative. I don't mean relative in the sense of a relative file path, which is resolved by concatenating it to the current working directory (or the directory of the current file, or some similar reference directory). I mean relative in the sense that the meaning of a classname depends on where in the class tree (abstract syntax tree) is it resolved. For example, take your URI "modelica:///./Analog/C.jpg", and resolve it from What I mean by "modelica:///../Electrical/B.jpg" is then to first move one level up in the class tree, and then do the lookup of "Electrical". This form will rarely be of importance; the important form is when you omit the classname, as in "modelica:///..//B.jpg", which resolves to Modelica 3.2.3/Modelica/Electrical/Analog/Examples/package-resources/C.jpg (one level up from |
They only look backwards if you disregard the Modelica syntax. In Modelica, To me, the most important aspect is the ability to use relative classnames, not the URI syntax for doing it. However, I would really be in favor of a syntax that isn't totally backwards compared to Modelica syntax, such as "modelica:///.Analog/C.jpg". While the "modelica:///./Analog/C.jpg" that you proposed isn't my favorite, I find it acceptable, in particular in view of also allowing the "../" form. |
Ineed, they only look backwards if you disregard Modelica syntax. But these are URIs which often leverage "file path" like semantics (even when references resources served by an HTTP server). Furthermore, there is no getting around the fact that the file path (not the Modelica class) follows "file path" semantics. So while I completely understand your point about |
I guess you're referring to the leading fully qualified marker specifically, and not the classname separators in general? What I don't quite follow then is that your proposal doesn't use a leading '/' to indicate a fully qualified classname. Do you mean that we should sacrifice consistency for the sake of readability? As long as we make this tradeoff clear, I agree that it's an interesting alternative. |
My proposal is that there is no host name. The first element in the path should be the fully qualified Modelica class name using |
Yes, I don't think there is anyone in favor of using the host name, except for some form of backwards compatibility variant. Our proposals only differ in the interpretation of the first element in the path:
To me, it seems that the only thing we could be able to agree on regarding the form of the new Modelica URIs boils down to what you are proposing. It leaves us with the other two of the main items:
Would it be easier to agree on the need for Regarding package-resources (that I'd rather call resources.d for brevity) for the mapping to a file system, I don't recall seeing any real objections. Should we simply collect more candidate directory names and poll? |
@henrikt-ma I'm wondering since there is still this personal branch (should really been done on your personal fork) present if the MCP 0034 should be allocated (and hence the branch merged and deleted) |
@dietmarw, the whole purpose of this PR is to decide whether an MCP number should be allocated or not. As soon as we have decided that we want an MCP for Generalized Modelica URIs for external resources, there will be a branch for it in the central repository that will be used for developing the MCP further. Until there is such a decision, we don't even know that the number will be 0034. |
@henrikt-ma I understand that, but hence this branch should be on your fork and not he central repository. Otherwise the Modelica Specification repository has soon loads for different WIP branches from different contributors. |
Yes, that's a valid point. On the other hand, I'm not sure we have the solution at the moment, since we've agreed that MCP work should be done in the central repository, not personal forks. Say we had allocated the MCP number without thinking so much. Then we would have had the MCP branch set up more or less from the start of this discussion, and an MCP working group should have had this discussion around the first iterations of formulating the more detailed goals for the MCP. However, with so much disagreement about what we want, it would have made sense to actually come up with proposals for this somewhere else than on the main MCP branch. If we would have followed the rule that MCP work should be carried out in the central repository, this would be very similar to what we have now, with the only difference that the PR would be targeted towards the MCP branch (which could be named according to which MCP it belongs to, like MCP/0034+scope) rather than master. It seems a little bit better, but not a whole lot better, and certainly not solving your problem with too much going on in the central repository. |
I've now merged with master (resolving the conflict, of course). According to today's web meeting, when should then merge this so that we can get rid of the branch for this PR, and then continue the discussion under the actual MCP. |
When making that comment, I forgot to re remove the Draft status to reflect the intention of getting it merged. It's been removed now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok to allocate the MCP-number.
Too bad I forgot to add this to the milestone for yesterday's phone meeting. |
Hmm.. seemed I messed up the merging. will redo. |
…rces" Cherry-picked 3f1f738 and updated number.
811e34b
to
5d757b8
Compare
Ok, restored. |
Please not that there still hasn't been any language group decision on allocating this MCP number. This is why it was scheduled for today's phone meeting. |
Phone meeting retroactively allocated this. |
…ca#2387 This is just the starting point. In the following commits, later comments of modelica#2387 will be considered and possibly incorporated.
The email thread Problems with section 13.2.3 initiated by @mtiller is becoming too long to remain outside the tracking system. Opening this draft PR so that we can continue the discussion whether to initiate a new MCP here.