How to make libraries available inb syside

Hi,

Currently, I can import a bunch of standard libraries (e.g. ScalarValues) without knowing where they are located or that the source code is visible to the modeler.

How can I achieve that with my own libraries.
Say, I create a library and want to distribute them.

I want the end-user just to be able to use it like ScalarValues.

How would I go about this?
How is sysand involved here.

Thanks,

Robert

Hi,

In Python, dependencies are used through Environment, and that includes the bundled standard library, see Environment.get_default(). For custom libraries, you will need to override the environment argument in load_model. Models have to_environment method inherited from BaseModel

my_lib_model, diagnostics = syside.load_model(...)
my_lib = my_lib_model.to_environment()
dependent_model, diagnostics = syside.load_model(..., environment=my_lib)

Thanks @Daumantas
Where do I put the custom libraries physically?

Hi Robert,

You can, of course, put your libraries whereever you like and pass those files to load_model function.

If you want to use Sysand and be more future-proof, you can use Sysand’s env command (sysand env - Sysand User Guide) to create a “Sysand Environment” (similar to venv in Python) and install packages into it. You can also use Sysand’s add command (sysand add - Sysand User Guide) to install packages as dependencies, but that assumes you want to create a full SysMLv2 project.

At the moment, you will still need to load files from Sysand Environment manually into Syside Automator, but we are working on streamlining that, either by making changes in Syside Automator API itself or by introducing the Sysand Python API.