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

Functionality: Using Python Code for Interactive AGVis Web Sessions #32

Open
jinningwang opened this issue Mar 29, 2023 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@jinningwang
Copy link
Member

jinningwang commented Mar 29, 2023

Using Python Code for Interactive AGVis Web Sessions

The functionality of interaction through Python code will improve the applicability. The main use of AGVis can be classified into two aspects: 1) starting, and 2) visualizing.
AGVis web is hosted using Python http.server. The visualization part is using the Leaflet. The data exchange between ANDES and AGVis is through a socket file using DiME.

It is possible to let AGVis interact with the web and the Python code through the socket file, namely, DiME client and DiME server.

Starting

Description

The modules cli and system module (available at cli and system) allows users to launch AGVis from either the command line or IPython as showing below:

Command line:

agvis run --host 127.0.0.1 --port 8810

IPython:

import agvis

web = agvis.webapp()
web.run(open_browser=True)

Update on 04/28/2023

We have developed two modules, cli and web, which enhance the starting process of AGVis web. For more information on how to use the command line interface, please refer to our documentation on Command line usage.

In this implementation, we use http.server and socketserver.TCPServer to host the web application in the background. However, Flask can be a better choice for its flexibility and usability to allow interactive usage.

Reference: https://flask.palletsprojects.com/en/2.3.x/

Visualizing

Description

After starting a web using the following code:

web = agvis.webapp()
web.run(open_browser=True)

The further interaction can be:

web.load(agvis.get_case('ieee39.xlsx'))  # Load topology into the web
web.play(andes_case='ieee39.xlsx', andes_output='ieee39_out.csv')  # play the animation with given input

web.refresh()  # Refresh the web

...

web.stop()

One possible approach for integration is to use DiME, which can start and run a DiME server backend for communication between ANDES and AGVis. However, this approach may require the packaging of DiME. See CURENT/dime#47 for more discussion.

Then, this improvement makes it possible to integrate AGVis as a built-in visualizer for ANDES and AMS in the future.

@jinningwang jinningwang added the enhancement New feature or request label Mar 29, 2023
@jinningwang jinningwang changed the title Interactive use through Python code Using Python Code for Interactive AGVis Web Sessions Apr 28, 2023
@jinningwang jinningwang changed the title Using Python Code for Interactive AGVis Web Sessions Functionality: Using Python Code for Interactive AGVis Web Sessions Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant