-
Notifications
You must be signed in to change notification settings - Fork 10
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
Provide an API so that scripts can get user input while running #155
Comments
Oh yes, that would be really awesome. It would also enable to debug scripts with pdb or by embedding an IPython kernel with context to explore any runtime location. Debugging scripts that are run headless via the CLI extension of EASE (e. g. in a Docker container) is crucial. That would also become possible. I‘m afraid that this is not a trivial one with this Py4J bridging. I already spent a couple of evenings to get user input read in when I run a Python script in an EASE context. Even just in the Eclipse (PyDev) perspective (Eclipse console view) I had no luck with that and really hope to see that somebody knows how to do that! So far the only hacky thing I had success with was to inject an IPython kernel using gdb (GNU Debugger) in a Linux container. That way I was able to connect a Jupyter console client and land at a dedicated breakpoint position with all the context variables etc. loaded in the given EASE run. |
For the GUI part you ca check Building UIs with EASE. For an headless mode, depending on how you launch the container you can use the shell itself to prompt the user. The last point with Jupyter is interesting to us. I tried to make Python4Capella work Jupyter Notebook using the following project: But I was not able to make it work. |
When I put the following two scripts into one and the same folder:
breakpoint() and
#!/bin/bash
CAPELLA_EXE=/Applications/Capella_6.0.app/Contents/MacOS/capella
APP=org.eclipse.ease.runScript
$CAPELLA_EXE -consolelog -application $APP -script "file:$(realpath ./debug.py)" I see
Here, I demonstrate that I entered the command When I call the same script without Capella just directly using
Can you replay that and confirm that Eclipse/ Capella/ EASE really processes the user input and forwards it to
Will look at and reply to that to provide more details in a separate message later (latest by tomorrow). |
Hi @ylussaud! Could you quickly (max 5 minutes) try this tiny case? I'm really curious to know if stdin is being processed. By the way: You can also put the following code into the file print(input("Enter something to be printed: ")) You'll be able to enter a string but I 'm afraid that nothing will be printed (stdin is not processed). This is at least what I see. |
I have the same issue. I first though it was the Eclipse console that prevent reading from the input, but using the command line I get the same behavior. I guess it has something to do with EASE. |
Okay, thanks for trying and confirming that. Regarding the injection (via GDB) of an IPython kernel into a halted ( |
Hi! Sorry, it took a bit longer to prepare the promised example. Instead of just a couple of words copied from my notes I decided to prepare a demo project here: https://github.com/jamilraichouni/ease-ipython I hope Docker is fine. The project shows how one can run a Python script with Eclipse EASE and inject an IPython kernel into the running process. This happens with the help of the GNU Debugger (GDB) that attaches to the running Python process. GDB is used to inject the We can then connect a Jupyter console client and execute stuff like: from eclipse.system.resources import getWorkspace
getWorkspace().getLocation().toString() My example uses Eclipse and basic EASE instead of Capella with |
Thank you for your explanations and the demonstration repository. |
As a workaround you can check the tips and trick for user inputs. |
I also ran head-first into the issue of having no obvious way to debug python4capella scripts, but I managed to get a relatively simple solution working similar to @jamilraichouni 's approach. I'm accustomed to using A simple workaround I found is to use https://pypi.org/project/background-zmq-ipython/ (installable via Using the following little helper function, I can insert
I can resume the script execution by setting If you do want an asynchronous kernel (and your script doesn't immediately exit) you can also simply use |
While a script is running, it may require user input, like entering a text, making a choice (Yes/No), or selecting a model element from a list.
It would be great if the API would provide a way to do so.
The text was updated successfully, but these errors were encountered: