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 dashboard support #17

Merged
merged 29 commits into from
Jul 17, 2023
Merged

Add dashboard support #17

merged 29 commits into from
Jul 17, 2023

Conversation

AyushExel
Copy link
Contributor

@hardikdava @onuralpszr this is how I want to implement it. the user can launch the dashboard by running exp.dash

exp = Explorer("coco128.yaml")
exp.build_embeddings()
exp.dash()

The cli launch script seems to be broken in some streamlit update. streamlit.cli moved to streamlit.web.cli but even on updating that it doesn't work so maybe the API has changed more than just the name. Can you guys think of another way to make this work?

@onuralpszr
Copy link
Contributor

Minimal how to run via "python file"

import sys
import streamlit.web.cli as stcli

def run_streamlit_app():
    sys.argv = ["streamlit", "run", "dash.py"]
    stcli.main()

if __name__ == "__main__":
    run_streamlit_app()

This works fine and I also did some changes sending very soon too ( I just wanted to share info quicker )

chore(gitignore): 🧹 update gitignore and clean up egg folder from repository
@AyushExel
Copy link
Contributor Author

Hmm.. would this work if I want to initialize the the state with the explorer object like I'm doing in this PR?
I think when running thr file through subprocess the explorer object will be undefined, no ?

@onuralpszr
Copy link
Contributor

Hmm.. would this work if I want to initialize the the state with the explorer object like I'm doing in this PR? I think when running thr file through subprocess the explorer object will be undefined, no ?

That is what I am testing too. but should be "defined"

@AyushExel
Copy link
Contributor Author

Okay 👍 let me know if it works for you

@onuralpszr
Copy link
Contributor

Hmm.. would this work if I want to initialize the the state with the explorer object like I'm doing in this PR? I think when running thr file through subprocess the explorer object will be undefined, no ?

I was able to run but you were right It does undefine keys, I need to either move or I need to pull some trick based on this

https://docs.streamlit.io/library/get-started/multipage-apps (If you okay with it)

I will have multiple app run but just one page

@hardikdava
Copy link
Contributor

@onuralpszr did you get it working?

@onuralpszr
Copy link
Contributor

@onuralpszr did you get it working?

UI yes but I need keys and datas

@AyushExel
Copy link
Contributor Author

Hmm.. would this work if I want to initialize the the state with the explorer object like I'm doing in this PR? I think when running thr file through subprocess the explorer object will be undefined, no ?

I was able to run but you were right It does undefine keys, I need to either move or I need to pull some trick based on this

https://docs.streamlit.io/library/get-started/multipage-apps (If you okay with it)

I will have multiple app run but just one page

As long as it doesn't interfere with user directly, I think it should be fine. Let's just get it working and then try to refine it..

@AyushExel
Copy link
Contributor Author

This is also why I was a bit skeptical about using dashboards. Maybe in the long run the best thing would be to build our own dashboard from scratch using react/js

@hardikdava
Copy link
Contributor

@AyushExel should we continue working on dashboard or some other issue?

@AyushExel
Copy link
Contributor Author

It really depends on whether it works. @onuralpszr is trying to get it working. If it works we can continue with it for a while.

@hardikdava
Copy link
Contributor

@AyushExel Why don't we initialize state in runtime? In that way, we can use same app for another session. User does not have stop and restart session. What do you think?

start dash without explorer
allow user to chose required option to initialize `explorer`
DO FURTHER

@hardikdava
Copy link
Contributor

@AyushExel @onuralpszr It is natural that you can not pass state objects without creating app. I analyzed the code from dash branch. Technically you can not pass state object across many apps. First you have to initialize the app and later you can set explorer object using other methods like callback, etc. But that is not the case currently.

@onuralpszr
Copy link
Contributor

@AyushExel @onuralpszr It is natural that you can not pass state objects without creating app. I analyzed the code from dash branch. Technically you can not pass state object across many apps. First you have to initialize the app and later you can set explorer object using other methods like callback, etc. But that is not the case currently.

I was already aware that but problem is "not" what you said. Problem is when we use "cli" tricks I had to create new "process" which means "ANYTHING" we create in current process will be not accessible. So for that reason I am trying to change that behaviour via creating multi page or if it is too hacky, I am also considering to change to something else as well.

@onuralpszr
Copy link
Contributor

@AyushExel Why don't we initialize state in runtime? In that way, we can use same app for another session. User does not have stop and restart session. What do you think?

start dash without explorer
allow user to chose required option to initialize `explorer`
DO FURTHER

We do that too but same reason what I wrote above also cancel that variable too

@hardikdava
Copy link
Contributor

hardikdava commented Jul 14, 2023

@AyushExel Why don't we initialize state in runtime? In that way, we can use same app for another session. User does not have stop and restart session. What do you think?

start dash without explorer
allow user to chose required option to initialize `explorer`
DO FURTHER

We do that too but same reason what I wrote above also cancel that variable too
@AyushExel @onuralpszr
First thing we need to make clear that we can not make instance of Explorer then pass it to streamlit app, unless we use any inmemory database that we do not want. So solution is that we start streamlit app then create exp =Explorer()(This was tested and worked as intended) .To get all the args, I suggest following solution.

Solution-1 (Not recommended):
save all args required to make exp =Explorer() as environmental variable.

Solution-2:
save all args required to make exp =Explorer() in a temporary file and read all data from there when we create an instance of Explorer

@AyushExel
Copy link
Contributor Author

Not sure. I'd prefer to keep the experience intuitive. Maybe there's a way, I'm not sure.
@hardikdava can you implement solution 2 and make a PR on this branch.
Meanwhile I'll try to explore plotly dash and react material ui

@AyushExel
Copy link
Contributor Author

@onuralpszr @hardikdava okay guys if this blocker isn't resolved, I think the way forward would be to build a js dashboard form scratch :(

@onuralpszr
Copy link
Contributor

@onuralpszr @hardikdava okay guys if this blocker isn't resolved, I think the way forward would be to build a js dashboard form scratch :(

I had a irl (workday) i will look before close but if you want to go js/ts sure

@AyushExel
Copy link
Contributor Author

@onuralpszr ohh okay. Let me know if you make some progress. I'm also trying something hacky, but if I can't get it working before going to bed, I'll probably try js from tomorrow

@onuralpszr
Copy link
Contributor

Consider gradio and others before go js we have other good options too

@AyushExel
Copy link
Contributor Author

Gradio might have the same problem related to state management. It's for simple input - output experiences I'd say not multi stage apps. But yes plotly dash might be an alternative..

@AyushExel
Copy link
Contributor Author

@onuralpszr @hardikdava ok guys, I think I made some progress. Now the problem is that streamlit accepts custom cmd line args like this -- -- but for some reason when invoking it like you mentioned @onuralpszr it doesn't doesn't accept that..

Error: No such option: -- --info

I think if this issue is solved we'll have a working solution

@hardikdava
Copy link
Contributor

@AyushExel I just tested the update. It is throwing the error you mentioned about info.

@AyushExel
Copy link
Contributor Author

AyushExel commented Jul 14, 2023

YOOO GUYSSS!!!
EDIT: nvm I ran through cmdline :)

Screenshot 2023-07-14 at 11 48 23 PM

@onuralpszr
Copy link
Contributor

image

@onuralpszr
Copy link
Contributor

[]
[]
['images/cat1.jpeg']
['images/cat1.jpeg', 'https://bagongkia.github.io/react-image-picker/0759b6e526e3c6d72569894e58329d89.jpg']
['images/cat1.jpeg', 'https://bagongkia.github.io/react-image-picker/0759b6e526e3c6d72569894e58329d89.jpg', <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=130x200 at 0x138CD3310>]
[]
[]
['images/cat1.jpeg']
[]
['https://bagongkia.github.io/react-image-picker/0759b6e526e3c6d72569894e58329d89.jpg']
['images/cat1.jpeg', 'https://bagongkia.github.io/react-image-picker/0759b6e526e3c6d72569894e58329d89.jpg']
[]
[]
['images/cat1.jpeg', 'https://bagongkia.github.io/react-image-picker/0759b6e526e3c6d72569894e58329d89.jpg', <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=130x200 at 0x138CD3D30>]
['images/cat1.jpeg', 'https://bagongkia.github.io/react-image-picker/0759b6e526e3c6d72569894e58329d89.jpg', <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=130x200 at 0x138BC9390>, array([[[252, 249, 244],
        [252, 249, 242],
        [253, 248, 242],
        ...,
        [ 96,  91,  85],
        [ 98,  93,  87],
        [ 99,  94,  88]],

       [[252, 249, 244],
        [252, 249, 242],
        [253, 248, 242],
        ...,
        [ 97,  92,  86],
        [ 99,  94,  88],
        [100,  95,  89]],

       [[253, 248, 244],
        [253, 248, 242],
        [253, 248, 242],
        ...,
        [ 98,  93,  87],
        [ 99,  94,  88],
        [100,  95,  89]],

       ...,

       [[156, 135,  92],
        [164, 143, 100],
        [169, 148, 105],
        ...,
        [ 97,  94,  89],
        [ 97,  94,  89],
        [ 96,  93,  88]],

       [[159, 138,  95],
        [165, 144, 101],
        [168, 147, 104],
        ...,
        [ 97,  94,  89],
        [ 97,  94,  89],
        [ 96,  93,  88]],

       [[162, 141,  98],
        [166, 145, 102],
        [166, 145, 102],
        ...,
        [ 96,  93,  88],
        [ 96,  93,  88],
        [ 96,  93,  88]]], dtype=uint8)]

@onuralpszr
Copy link
Contributor

@AyushExel

https://pypi.org/project/streamlit-dash/

For demo test

https://github.com/onuralpszr/streamlit-dash/blob/main/demo/streamlit_app.py

I change lib name so be aware that too.

@AyushExel
Copy link
Contributor Author

Perfect. I'll try it in an hour

@onuralpszr
Copy link
Contributor

onuralpszr commented Jul 16, 2023

Perfect. I'll try it in an hour

Awesome let me know how is it goes.

@onuralpszr
Copy link
Contributor

@AyushExel I guess it works ? (since you sent a push ? )

@AyushExel
Copy link
Contributor Author

Oh yeahh. I was building other things on top of it like query and search.. that is also done

@onuralpszr
Copy link
Contributor

onuralpszr commented Jul 17, 2023

Oh yeahh. I was building other things on top of it like query and search.. that is also done

Awesome :) I am glad it work but we gonna replace once original repo people merge that feature right ?

@AyushExel
Copy link
Contributor Author

@onuralpszr nah I think let's keep developing our version and add new features when needed. We can't reply on folks merging changes forever

@onuralpszr
Copy link
Contributor

onuralpszr commented Jul 17, 2023

@onuralpszr nah I think let's keep developing our version and add new features when needed. We can't reply on folks merging changes forever

okay I am breaking fork and change name and readme for avoid confusion for name conflicts

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

Successfully merging this pull request may close these issues.

3 participants