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

importSnapshot in Python bindings not implemented #1209

Open
sturmk opened this issue Feb 28, 2023 · 7 comments
Open

importSnapshot in Python bindings not implemented #1209

sturmk opened this issue Feb 28, 2023 · 7 comments

Comments

@sturmk
Copy link

sturmk commented Feb 28, 2023

Description

Despite being contained in the documentation, "oms.importSnapshot" is not available in the Python bindings for OMSimulator.

Steps to reproduce the behavior

#!/usr/bin/env python3
import OMSimulator as oms
[...]
status = oms.importSnapshot('root', snapshot)

AttributeError: module 'OMSimulator' has no attribute 'importSnapshot'

Expected behavior

A call to the underlying C-function which executes importSnapshot should happen.

@sturmk sturmk changed the title importSnapshot not implemented importSnapshot in Python bindings not implemented Feb 28, 2023
@arun3688
Copy link
Contributor

@sturmk The API is indeed available, You are using older version of OMSimulator, please update OMSimulator package if you are using pip otherwise update from github master, see the example in the testsuite https://github.com/OpenModelica/OMSimulator/blob/master/testsuite/simulation/snapshot.py

@sturmk
Copy link
Author

sturmk commented Feb 28, 2023

@arun3688

#!/usr/bin/env python3
import OMSimulator as oms
oms.version

'OMSimulator v2.1.1.post190-gcfb740c-linux'

@arun3688
Copy link
Contributor

@sturmk can you post your ful python script

@sturmk
Copy link
Author

sturmk commented Feb 28, 2023

@arun3688 it's not about the script. even typing oms.imp in an interactive python session and using TAB-completion only yields oms.importFile(.
Looking into the source, neither NewAPI.py, nor OMSimulator.py contain a definition for importSnapshot.

@arun3688
Copy link
Contributor

@sturmk with the new API format i think you need to create the model or system instances and use the API, see the example here
https://github.com/OpenModelica/OMSimulator/blob/master/testsuite/simulation/equationPair.py, But could you adapt your example with the old style and see it works example snapshot.py

@sturmk
Copy link
Author

sturmk commented Feb 28, 2023

@arun3688 That's why I created this issue. I use it exactly like the example you mention.
The Python3 interpreter is not aware of any existence of "importSnapshot" because it is not defined in OMSimulator.py nor NewAPI.py.
I'm not the most advanced Python scripter, but I'll try to fix it and send a PR when done.

@arun3688
Copy link
Contributor

@sturmk The API is already available otherwise our testsuite will not work, The API is added in the file capi.py in OMSimulatorPython folder

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

No branches or pull requests

2 participants