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

Shiny (Python) ML training example #105

Merged
merged 14 commits into from
Feb 6, 2024
Merged

Shiny (Python) ML training example #105

merged 14 commits into from
Feb 6, 2024

Conversation

neelasha23
Copy link
Contributor

@neelasha23 neelasha23 commented Feb 2, 2024

Add Shiny example


📚 Documentation preview 📚: https://ploomber-doc--105.org.readthedocs.build/en/105/

@neelasha23 neelasha23 marked this pull request as ready for review February 2, 2024 13:43
Copy link
Contributor

@edublancas edublancas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please deploy the app so I can test it

doc/_toc.yml Outdated Show resolved Hide resolved
doc/apps/shiny-core.md Outdated Show resolved Hide resolved
examples/docker/shiny-core/README.md Outdated Show resolved Hide resolved
examples/docker/shiny-core/README.md Outdated Show resolved Hide resolved
examples/docker/shiny-core/README.md Outdated Show resolved Hide resolved
examples/docker/shiny-core/README.md Outdated Show resolved Hide resolved
examples/docker/shiny-core/app-core.py Outdated Show resolved Hide resolved
examples/docker/shiny-core/app-core.py Outdated Show resolved Hide resolved
examples/docker/shiny-core/README.md Outdated Show resolved Hide resolved
examples/docker/shiny-core/app-core.py Outdated Show resolved Hide resolved
readme

zip

removed unused function

shiny doc

removed parallel function

shiny core toc

renamed folder

rename
@neelasha23 neelasha23 changed the title Shiny core example Shiny example Feb 2, 2024
@neelasha23
Copy link
Contributor Author

Addressed the comments. App is deployed here: https://crimson-glade-4646.ploomberapp.io/
After setting the MONGODB_CONNECTION_URI env variable in local u can run the two scripts as mentioned in Readme: python train.py --model model_1 --units 128 and python train.py --model model_2 --units 12
@edublancas

@neelasha23 neelasha23 requested a review from edublancas February 2, 2024 21:42
Copy link
Contributor

@lfunderburk lfunderburk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @neelasha23

Took a look at the app - but the plot is not showing up
Screenshot 2024-02-02 at 4 00 51 PM

@neelasha23
Copy link
Contributor Author

Hi @neelasha23

Took a look at the app - but the plot is not showing up <img alt="Screenshot 2024-02-02 at 4 00 51 PM" width="2000"

I have cleared the db because it's a realtime monitoring. you need to connect to ur mongodb account and run training scripts from local and view the plot in the dashboard. have added instructions in the README @lfunderburk

examples/docker/shiny/train.py Outdated Show resolved Hide resolved
@edublancas
Copy link
Contributor

the polling logic is off: I tried the app many times (both the ploomberapp.io one and locally) and I only got it one time to work. I debugged it by printing the value of last_modified and realized that even if I started training, the returned value was the same (I tried refreshing the browser after I started training).

I changed the last_modified function to this:

def last_modified():
    n = my_collection.count_documents({})
    return n

and it worked better: as soon as I started training, the plot started updating. but I found another issue: the values in the plot did not match the values printed from the terminal and when starting to train another model, the plot didn't show a new line:

2024-02-03.8.57.55.a.m.mp4

@edublancas edublancas changed the title Shiny example Shiny (Python) ML training example Feb 3, 2024
@neelasha23
Copy link
Contributor Author

I haven't been able to reproduce the timestamp not getting updated issue. Did you try with my account? I had selected an Indian server, so I'm doubting if that's causing a lag.
Can you please try once with a new account? If it still doesn't work I'll figure out what's happening
@edublancas

Screen.Recording.2024-02-05.at.8.27.21.PM.mov

@edublancas
Copy link
Contributor

@neelasha23 the problem is most likely the datetime.now(), such function returns the timestamp in your local timezone.

but there's no need to reproduce it since I already provided a fix:

def number_of_observations():
    n = my_collection.count_documents({})
    return n

this function will trigger an update as soon as there is a new element in the collection

@neelasha23
Copy link
Contributor Author

Fixed the polling function: https://github.com/ploomber/doc/pull/105/files#diff-c99010220192b232032cc417d9e26e799aa65a2dd2fbb5dd79b5595548293670R33-R38

Although I did not completely understand why polling the timestamp column would be an issue. Even if datetime generates in local timezone it will still get accurately stored in MongoDB. And the polling function keeps checking this stored timestamp to detect if any new row has been added. You also mentioned that even after changing the polling function the timestamps in the plot are not matching the training ones , but I don't see that happening in my local. Which is why I feel maybe there's a lag between the training and the storage/retrieval process in your case?
@edublancas

Screen.Recording.2024-02-06.at.10.50.53.AM.mov

@edublancas edublancas merged commit 43d1520 into main Feb 6, 2024
1 check passed
@edublancas edublancas deleted the shiny branch February 6, 2024 16:26
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