eclipse-esmf / esmf-sdk

Load Aspect Models and their artifacts as Java code; share components to realize SAMM as code
https://eclipse-esmf.github.io/esmf-developer-guide/index.html
Mozilla Public License 2.0
25 stars 12 forks source link

[Task] SAMM CLI resolution: Make using Aspect Model files easier in the CLI #495

Open chris-volk opened 8 months ago

chris-volk commented 8 months ago

Is your task related to a problem? Please describe. Currently, when using the SAMM CLI with an individual Aspect Model (ttl file), an intuitive attempt is:

This attempt fails since the clearly given input file will not be used since it is not in a folder complying with the namespaces, see https://eclipse-esmf.github.io/esmf-developer-guide/tooling-guide/samm-cli.html#models-directory-structure . For explaining this better to new users, there is the issue https://github.com/eclipse-esmf/esmf-sdk/issues/421 . Still, the issue means that users have to restructure everything into a chain of subfolders.

Describe the solution you'd like What a user naively wants is clearly "this is my single file, why don't you just do it", and in a case of "this is my folder with all the files where one is my input file and the others may be referenced, why don't you just do it".

For experienced users, a custom model resolution via script is possible (also for inclusion in pipelines), see https://github.com/eclipse-esmf/esmf-sdk/issues/98 .

Things to consider for a solution:

  1. For simple cases, particular single files, it should just work by default (https://en.wikipedia.org/wiki/Convention_over_configuration)
  2. For a bit more complex cases with multiple models, maybe multiple versions, a config file may be used
  3. A fuzzy search (try first here, then there, use the parent parent folders and then traverse the folder tree) may be great, but could be hard to implement and lead to the issue of being non-deterministic and hard to predict (and security issues), it may also be hard to implement. One key of this issue is to find a good strategy and the right trade-off of helpfulness vs complexity.

Describe alternatives you've considered It may be a consideration to (apart from "single files should alway work") craft a dedicated solution for the typical solution of github, i.e. allow the input of a github url containing a file and resolve it along the github repository (only if done correctly according to https://eclipse-esmf.github.io/esmf-developer-guide/tooling-guide/samm-cli.html#models-directory-structure or also if messy? see fuzzy search above ...)

ysrbo commented 7 months ago

In cli version:2.2.2 - was added behavior - wen provided file contains all what required for define aspect - it can be loaded from folder without namespace rules. From version 2.4.1, we support a default namespace's folder - which means if the required file was placed in a folder that does not match the namespace's rules, Model Resolver takes this folder as default ":" namespace and will try to find any ":resources" in the folder. Other namespaces will be resolved as usual, starting from the folder. @chris-volk Is this the behavior that is expected here? Or something else?