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

Add server video stream tutorial #6727

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

MarcSkovMadsen
Copy link
Collaborator

@MarcSkovMadsen MarcSkovMadsen commented Apr 14, 2024

Adds a ServerVideoStream tutorial motivated by questions on discourse. For example in https://discourse.holoviz.org/t/best-practice-for-displaying-high-resolution-camera-images-captured-on-server/4285 and https://discourse.holoviz.org/t/streaming-local-video/6929.

As this tutorial uses manual threading I would also like to fix #6724.

@MarcSkovMadsen MarcSkovMadsen linked an issue Apr 14, 2024 that may be closed by this pull request
Copy link

codecov bot commented Apr 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.20%. Comparing base (76c911a) to head (9bfd4d9).
Report is 30 commits behind head on main.

❗ Current head 9bfd4d9 differs from pull request most recent head 3e65612. Consider uploading reports for the commit 3e65612 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6727      +/-   ##
==========================================
- Coverage   40.01%   37.20%   -2.82%     
==========================================
  Files         313      313              
  Lines       46194    46224      +30     
==========================================
- Hits        18486    17197    -1289     
- Misses      27708    29027    +1319     
Flag Coverage Δ
ui-tests 37.20% <ø> (-2.82%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MarcSkovMadsen MarcSkovMadsen marked this pull request as ready for review April 17, 2024 18:36
@MarcSkovMadsen
Copy link
Collaborator Author

MarcSkovMadsen commented Apr 17, 2024

This PR can be reviewed. It can work for users.

But it would be much stronger if #6724 was first addressed and this PR updated accordingly.

@philippjfr
Copy link
Member

this PR updated accordingly.

I'm not sure what you mean by that, are you saying that this guide currently does not use best practices?

@MarcSkovMadsen
Copy link
Collaborator Author

this PR updated accordingly.

I'm not sure what you mean by that, are you saying that this guide currently does not use best practices?

No i'm saying I don't know what best practice is. It would be great to get that established in the how-to guide and then apply here.

@philippjfr
Copy link
Member

Got you, thanks!

@MarcSkovMadsen
Copy link
Collaborator Author

MarcSkovMadsen commented Apr 18, 2024

Got you, thanks!

This use case is not described in the how-to guide. It explains how to setup a worker thread for each session in a served file.

This use case sets up a shared worker thread in a separate module. All sessions listen/ subscribe/ take the same frame. Currently shared via a parameter on a Parameterized class.

For example right now each time the app is autoreloaded a new worker thread is started and the old not stopped. Your comment in other issue about using on_session_destroyed does not apply here as that only works for sessions.

I've needed this architecture many times for streaming use cases. How do you ingest and share some shared data globally? It could be from video camera, a data base, Kafka etc. Can I safely share the PIL Image, DataFrame, hvPlot plot, Plotly Figure or even a HoloViews or Plotly pane. For efficiency reasons as much as possible should be shared. Should I push to the session? Or should the session regularly pull shared objects?

What I've seen described so far is how each session loads data separately and pushes it to plots, tables and other components in the session.

@philippjfr
Copy link
Member

For example right now each time the app is autoreloaded a new worker thread is started and the old not stopped. Your comment in other issue about using on_session_destroyed does not apply here as that only works for sessions.

I don't follow, autoreload creates new sessions.

@philippjfr
Copy link
Member

Ah sorry, I guess I'm following you. You're saying this guide demonstrates the shared worker thread and you want each session to subscribe and unsubscribe. That still should still be done via on_session_destroyed handlers though, so I'm not entirely following this point "on_session_destroyed does not apply here as that only works for sessions".

@philippjfr
Copy link
Member

I guess, the missing piece is that you need a --setup script to start the worker thread.

@MarcSkovMadsen
Copy link
Collaborator Author

MarcSkovMadsen commented Apr 18, 2024

But i dont want that friction. I just want to panel serve as normal such that the component can be imported and used as other component even though its shared.

It gives less to explain. It makes deployment easier if you are not in control of deployment.

@philippjfr
Copy link
Member

You can use the cache to to share the thread instance. I appreciate the pursuit of "reducing friction" but you can't reduce all friction for every conceivable complex use case.

@MarcSkovMadsen
Copy link
Collaborator Author

MarcSkovMadsen commented Apr 18, 2024

The session is not the problem. The problem is that the external module is reimported on autoreload - thus starting another thread. I dont know where the Old module and thread lives - But its still there.

@philippjfr
Copy link
Member

The session is not the problem. The problem is that the external module is reimported on autoreload - thus starting another thread.

Got it, that makes sense. I guess another reason to use the cache.

@MarcSkovMadsen
Copy link
Collaborator Author

The cache is a good idea. Did not Think about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set up Manual Threading how-to guide is highly problematic
2 participants