Closed trentmc closed 3 months ago
How to organize all of this towards updating plots in a backend process + serving this via FE webapp
process 1 - etl.py - fetch + etl + update plots
process 2 - sim.py - running sim + updating plots
process 3 - streamlit frontend w/ different pages serving data + artifacts
> page a - predictoor net income
> page b - sim
process 1 - etl.py - fetch + etl + update plots
This can run as part of sim_engine.py, as it does now. No need to make things more complicated. KISS.
Also: page a & b should be switched. It's the order that the user does things.
And: it shouldn't be "predictoor net income", it should be "predictoor", where net income is the top level metric.
Therefore, how I see it:
process 1 - sim.py - running sim + updating plots
process 2 - streamlit frontend w/ different pages serving data + artifacts
> page 1 - sim
> page 2 - predictoor
@calina-c fyi I have completed the pre-requisite (refactor sim plot code)
There is a fork that we have to decide on:
Options:
We want interactive.
It's ok to move away from matplotlib interface.
Current behaviour:
Static full-size image generated with matplotlib, containing multiple subplots
Difficult to separate and analyse the graphs, everything is displayed in one single picture and the user must zoom in and out
No possibility for real-time updates, i.e. see the changes instantaneously during the simulation
No interactivity with the data itself, the scale, etc.
Advantages:
Downsides:
Advantages:
Disadvantages:
https://github.com/oceanprotocol/pdr-backend/assets/4101015/96579e90-0ebd-4405-9ea9-be58bb822bfd
https://github.com/oceanprotocol/pdr-backend/assets/4101015/f31fb54a-288a-4a85-9421-81648acc5b4f
(to quote Peter Falk's well-known character)
To run with streamlit, we need to modify commands, i.e. we can not run just pdr. For sim, it would be streamlit run pdr -- sim my_ppss.yaml
instead of pdr sim my_ppss.yaml
. Is that an issue? I couldn't find another way to start the streamlit server.
keep matplotlib figures for now and rework them piecemeal later, converting each plot to a native streamlit plot, as we go. It will prevent conflict resolution issues and it's still an improvement to real-time display and the canvas itself.
Sounds good to me
To run with streamlit, we need to modify commands, i.e. we can not run just pdr. For sim, it would be
streamlit run pdr -- sim my_ppss.yaml
instead ofpdr sim my_ppss.yaml
. Is that an issue? I couldn't find another way to start the streamlit server.
That hurts ux for perhaps the most commonly-called command.
Let's think about ways where can we can preserve pdr run __
. Eg maybe right after installation, the user defines a bash-level alias mapping "pdr" -> "streamlit run pdr"?
To run with streamlit, we need to modify commands, i.e. we can not run just pdr. For sim, it would be
streamlit run pdr -- sim my_ppss.yaml
instead ofpdr sim my_ppss.yaml
. Is that an issue? I couldn't find another way to start the streamlit server.That hurts ux for perhaps the most commonly-called command.
I was thinking about that, yes. That's why I thought to ask.
But we can't alias every pdr run
, because not all commands need streamlit. Plus, streamlit opens a port and runs the server. Users should take note of that and how to close/kill those processes when they finish using them.
I will check if I can mimic the functionality of streamlit run inside pdr-backend, if possible. I will also look into some sort of aliasing, but if possible just for sim.
I have moved the discussions around altair and plotly from here, to this other ticket. https://github.com/oceanprotocol/pdr-backend/issues/842
This will enable us to close this ticket and move forward with the altair/plotly discussions separately.
Background / motivation
We're on a path to output predictoor analytics plots to webapp, using streamlit + plotly.
Currently the sim engine plots are output on-the-fly directly to the desktop using matplotlib defaults. They're not going to the browser. This was a fine enough starting point.
But there are issues:
The solution: use streamlit.
That will address the issues above, and, a bonus: it helps us prototype for the analytics dapp. (We could even have them all in the same dapp. Pros and cons to this, decision is still TBD.)
Pre-requisites
TODO
Resources
Key ref: https://plotly.com/python/creating-and-updating-figures/
Maybe useful: https://github.com/Paulescu/real-time-data-pipelines-in-python/tree/main