Skip to content
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

ST6RI-682 Implemented loading of models from repository #616

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

TheKorpos
Copy link
Contributor

@TheKorpos TheKorpos commented Feb 4, 2025

This PR adds basic model download capability using the standard API.

Overview

The model download functionality is can be used

  1. In Jupyter using magic commands
  2. In Eclipse IDE as a 'right click' action on projects
  3. As CLI java application

In Jupyter the downloaded models are stored in memory and can be used throughout the work session. The Eclipse and CLI versions serialize the model into seperate XMI files (.sysmlx). In Eclipse IDE .kerml and .sysml files are now added to the Xtext index so their content can be referenced using the textual syntax.

Common changes

  • .sysmlx and .kermlx parsing, indexing:
    • SysMLxRuntimeModule, SysMLxStandaloneSetup has been added
    • KerMLxRuntimeModule, KerMLxStandaloneSetup has been added
  • APIs for model download, JSON to EMF transformation
    • ProjectRepository: repository access, download
    • RepositoryContentFetcher: JSON to EMF transformation, XMI serialization (.sysmlx)

Jupyter changes

  • new magic commands have been added
    • %publications [-h][-help]
      Lists all projects names and their ids
    • %download <project name> [-h][-help]
      downloads the project and adds its contents to the xtext index.
    • %help has been updated
    • added help to new commands

Eclipse changes

  • SysMLv2 menu has been added to the popupmenu of projects
    • Generate Library Index has been moved into it
  • Registered .sysmlx and .kermlx
  • .sysmlx and .kermlx resources are added to the xtext index
  • Registered simple ecore editor for the extensions
  • References in text opens the ecore editor and jumps to the element
  • 'Pull model from API' right click action has been added:
    Downloads and saves models in .sysmlx
    • Prerequisites:
      .settings/org.omg.sysml.remote.properties exists with the following contents:
base.url=repository url
remote.projectId=project id

NOTE: the action shows up regardless for now. The file is needed to perform the operation.
NOTE: a specific tester was implemented to hide the action from projects without the required properties file. However, this tester is not called before the sysml.ui plugin is activated, e.g. before a sysml editor is opened.

CLI app

  • org.omg.sysml.xtext.util.SysMLRepositoryLoadUtil has been added
    • arguments:
      -p, -project: name of the project in the repository
      -l, -library: location of the standard library
      -t, -target: target location for saved resources
      -b, -base (optional): URL of the repository, default: http://localhost:9000

ujhelyiz and others added 3 commits February 4, 2025 16:52
 - Introduces a new SysMLv2 menu for all contributions
 - Renames repository upload feature
 - Command framework should check for the existence of repository
descriptor for showing the command
Copy link
Member

@seidewitz seidewitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Instead of %publications and %download use %projects and %load.
  • The %load command (and utility) should have an option to use the project ID instead of the name.

 - changed %publications to %projects
 - changed %download to %load

 - added optional arguments to %load
 	--id=<ID>
 	--name=<NAME>
 - changed SysMLRepositoryLoad util arguments
 	-n, -name to reference project by name
 	-id to reference project by id
@TheKorpos
Copy link
Contributor Author

TheKorpos commented Feb 5, 2025

  • Instead of %publications and %download use %projects and %load.
  • The %load command (and utility) should have an option to use the project ID instead of the name.

@seidewitz
I've changed the magic command names as you requested and added a load by id option.
The magic command %load works like this now
%load --id=<PROJECT ID> loads the model by id
%load --name=<PROJECT NAME>, %load <PROJECT NAME> loads the model by name

as for the utility project name is now passed with -n <PROJECT NAME> or -name <PROJECT NAME>.
alternatively -id <PROJECT ID> can be used

@hpdekoning
Copy link
Member

@TheKorpos
Hi Laszlo, just happened to scan through this PR, and have a minor comment w.r.t to long-names for options.

org.omg.sysml.xtext.util.SysMLRepositoryLoadUtil has been added
arguments:
-p, -project: name of the project in the repository
-l, -library: location of the standard library
-t, -target: target location for saved resources
-b, -base (optional): URL of the repository, default: http://localhost:9000/
as for the utility project name is now passed with -n or -name .
alternatively -id can be used

In my experience, most open source tools use the GNU convention for command line options is to use single hyphen like -n for single letter (short-name) options and double hyphen like --name for fully spelled out long-name options (two or more characters), which would also be in line with the magic commands. From documentation https://commons.apache.org/proper/commons-cli/ the org.apache.commons.cli package does support this. Or perhaps there is another reason not to stay with GNU conventions?

@TheKorpos
Copy link
Contributor Author

@TheKorpos Hi Laszlo, just happened to scan through this PR, and have a minor comment w.r.t to long-names for options.

org.omg.sysml.xtext.util.SysMLRepositoryLoadUtil has been added
arguments:
-p, -project: name of the project in the repository
-l, -library: location of the standard library
-t, -target: target location for saved resources
-b, -base (optional): URL of the repository, default: http://localhost:9000/
as for the utility project name is now passed with -n or -name .
alternatively -id can be used

In my experience, most open source tools use the GNU convention for command line options is to use single hyphen like -n for single letter (short-name) options and double hyphen like --name for fully spelled out long-name options (two or more characters), which would also be in line with the magic commands. From documentation https://commons.apache.org/proper/commons-cli/ the org.apache.commons.cli package does support this. Or perhaps there is another reason not to stay with GNU conventions?

@hpdekoning
Thanks for the pointing this out!

org.apache.commons.cli does have a GNUParser but it's marked deprecated. I used the suggested DefaultParser instead. This parser allows long-name options with both single and double hyphen. Intrestigely the dedicated GNUParser allows this behavior as well it seems.

There is a allowPartialMatching mode too. This is true by default. This allows partially spelled long-names as long as there is only one matching option. I think I should turn this off as it makes --n=something a valid option.

I'm not sure that allowing single hyphen long-names is a huge issue as long as it also accepts the GNU argument syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants