Skip to content

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 can be used

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

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

Common

  • .kermlx parsing and indexing:
    • Added org.omg.kerml.xtext.xmi, org.omg.kerml.xtext.ui.xmi
  • .sysmlx parsing and indexing:
    • Added org.omg.sysml.xtext.xmi, org.omg.sysml.xtext.ui.xmi
  • APIs for model download, JSON to EMF transformation
    • org.omg.sysml.util.repository.ProjectRepository: repository access, download
    • org.omg.sysml.xtext.ui.util.RepositoryContentFetcher: JSON to EMF transformation, XMI serialization (.sysmlx)

Jupyter

New magic commands:

%projects

Print the name and identifier of all projects in the repository.
%load [--id=<PROJECT ID>] [--name=<NAME>] [--branchid=<BRANCH ID>] [--branch=<BRANCH_NAME>] [<NAME>]

Download previously published models from a project in the repository. (Use %projects to view repository contents.)
Named elements of the downloaded models may then be referenced by models in the notebook.
<NAME> is the full name of the project.
If <PROJECT ID> is given, then the project with that UUID is loaded. In this case, the <NAME> must not be given.
If <BRANCH NAME> or <BRANCH ID> is given, then the model is loaded from this branch of the project.
If no <BRANCH NAME> or <BRANCH ID> is given, the default branch is used.
If <BRANCH ID> is given, then a <BRANCH NAME> must not be given.

Eclipse

  • Added SysMLv2 menu to the popup menu for projects, with the following options:
    • Generate Library Index: moved under SysMLv2 menu.
    • Pull model from API: download models from a repository and saves in .sysmlx
      • Requires that .settings/org.omg.sysml.remote.properties exists with the following contents:
        base.url=repository url
        remote.projectId=project id
        remote.branchId=branch id
        
        (remote.branchId is optional; if not provided, the default branch is used)

NOTE:
A specific tester was implemented to hide the "Pull model from API" action from projects that don't have the required properties file (org.omg.sysml.remote.properties). However, the sysml.ui plugin must be activated for this tester to take effect. The plugin activation happens the first time the sysml editor is opened.

Command Line Application

  • org.omg.sysml.xtext.util.SysMLRepositoryLoadUtil
    • 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): base 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

@seidewitz
Copy link
Member

@TheKorpos

The PR description contains the following:

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.

I don't really understand this note. Could you please removed the crossed-out line and clarify the remaining note?

@seidewitz
Copy link
Member

When I try to pull a model from the API in Eclipse using the following settings:

base.url=https://sysml2-dev.intercax.com:9000
remote.projectId=02336c2a-4c7b-4518-b980-addb71d9d378

I get the following exception:

java.util.ConcurrentModificationException
	at org.eclipse.emf.common.util.AbstractEList$EIterator.checkModCount(AbstractEList.java:751)
	at org.eclipse.emf.common.util.AbstractEList$EIterator.doNext(AbstractEList.java:699)
	at org.eclipse.emf.common.util.AbstractEList$EIterator.next(AbstractEList.java:685)
	at org.eclipse.xtext.resource.SynchronizedXtextResourceSet$1$SynchronizedEIterator.next(SynchronizedXtextResourceSet.java:196)
	at org.eclipse.xtext.resource.SynchronizedXtextResourceSet$1$SynchronizedEIterator.next(SynchronizedXtextResourceSet.java:1)
	at org.omg.sysml.util.repository.EObjectUUIDTracker.trackUUIDSFromResources(EObjectUUIDTracker.java:69)
	at org.omg.sysml.util.repository.EObjectUUIDTracker.trackLibraryUUIDs(EObjectUUIDTracker.java:55)
	at org.omg.sysml.xtext.ui.handlers.PullRepositoryProject.tryPullRemoteFor(PullRepositoryProject.java:130)
	at org.omg.sysml.xtext.ui.handlers.PullRepositoryProject$1.runInWorkspace(PullRepositoryProject.java:97)
	at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

@TheKorpos
Copy link
Contributor Author

Hi @seidewitz

java.util.ConcurrentModificationException
at org.eclipse.emf.common.util.AbstractEList$EIterator.checkModCount(AbstractEList.java:751)
at org.eclipse.emf.common.util.AbstractEList$EIterator.doNext(AbstractEList.java:699)
at org.eclipse.emf.common.util.AbstractEList$EIterator.next(AbstractEList.java:685)
at org.eclipse.xtext.resource.SynchronizedXtextResourceSet$1$SynchronizedEIterator.next(SynchronizedXtextResourceSet.java:196)
at org.eclipse.xtext.resource.SynchronizedXtextResourceSet$1$SynchronizedEIterator.next(SynchronizedXtextResourceSet.java:1)
at org.omg.sysml.util.repository.EObjectUUIDTracker.trackUUIDSFromResources(EObjectUUIDTracker.java:69)
at org.omg.sysml.util.repository.EObjectUUIDTracker.trackLibraryUUIDs(EObjectUUIDTracker.java:55)
at org.omg.sysml.xtext.ui.handlers.PullRepositoryProject.tryPullRemoteFor(PullRepositoryProject.java:130)
at org.omg.sysml.xtext.ui.handlers.PullRepositoryProject$1.runInWorkspace(PullRepositoryProject.java:97)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

I couldn't reproduce this issue. I do get some erros sometimes when the library is not properly built but this time around I cound't break it enough to get an error like this.

Https doens't work right now but I can reach the repo through http.

TheKorpos and others added 10 commits May 15, 2025 11:07
Previously loading required using UUID or name to reference projects and
their branches but there were no interface that allowed mixing the two
e.g reference the project by UUID and the branch by name.

This rework makes load parameterization more flexible to allow more
cases to be covered.
- Also corrected the incrementing of "counter" in the %projects and
%load commands.
- The "next" method should only be used to create a resource for a
model entered in a Jupyter notebook cell.
@seidewitz
Copy link
Member

I couldn't reproduce this issue. I do get some erros sometimes when the library is not properly built but this time around I couldn't break it enough to get an error like this.

Https doesn't work right now but I can reach the repo through http.

Oops, I knew that the Intercax repo deployment didn't work with https. The pull from repository works when I change the URL to http.

@seidewitz
Copy link
Member

seidewitz commented May 19, 2025

I also updated EMFModelDelta (on the ST6RI-178 branch, PR #633) to use the declared name of a root element (if there is one) as the name of the .sysmlx file created when pulling a project from the repository.

seidewitz added 3 commits May 19, 2025 17:42
ST6RI-178 Implement versioned publishing
- org.omg.kerml.xmi -> org.omg.kerml.xtext.xmi
- org.omg.sysml.xmi -> org.omg.sysml.xtext.xmi
- org.omg.sysml.xtext.ui.utilities -> org.omg.sysml.xtext.ui.util
@TheKorpos
Copy link
Contributor Author

I've moved the .gitignores to the new packages (of course I mistyped the issue number...) and updated the package exports in the manifest

@seidewitz
Copy link
Member

I've moved the .gitignores to the new packages (of course I mistyped the issue number...) and updated the package exports in the manifest

It turns out that I actually had already added the new package exports to the manifests, but I had somehow forgotten to delete the old packages that were replaced. While I don't think having redundant exports causes any real problems, I just removed the redundancies for clarity.

@seidewitz seidewitz merged commit f2dfa92 into master May 20, 2025
2 checks passed
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.

4 participants