ryansurf / cli-surf

Get surf and ocean data from the command line interface
MIT License
18 stars 30 forks source link

Streamlit adding surf #44

Closed ryansurf closed 4 months ago

ryansurf commented 5 months ago

@K-dash

Messed around with streamlit and got it working! (still a little rough)

It can now take a surf spot as input, and display a map that shows the spot along with a line graph of surf heights/swell periods

I think streamlit is what this project needed. This is also a draft PR, let me know what you think

example.webm

Edit: Updating this PR. In this update I enabled the user to use the GPT and added an option to hide the map

Here is a demo of the new functionality:

demo.webm

Also, is it best practice for me to update the PR like I just did, or perhaps create another PR/branch? Unsure

Summary by Sourcery

This pull request introduces a new Streamlit frontend for the project, allowing users to input a surf spot and view a map and forecast data. It also adds GPT response functionality and options to toggle the map display. The codebase has been refactored for better organization, and documentation has been updated accordingly.

github-actions[bot] commented 5 months ago

Coverage

Coverage Report
FileStmtsMissCoverMissing
src
   __init__.py00100% 
   api.py105694%30, 48, 70–71, 103–104
   art.py9367%24–25, 37
   cli.py25580%26, 37, 55–56, 60
   dev_streamlit.py37370%1–86
   gpt.py10640%16–21, 32–45
   helper.py1596062%53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 91, 102–106, 132, 134, 136, 145–155, 167, 180–181, 199–201, 211, 213–214, 237–238, 277–287, 294–302
   send_email.py24240%5–48
   server.py41410%5–82
   settings.py220100% 
   streamlit_helper.py33330%5–90
TOTAL46521554% 

Tests Skipped Failures Errors Time
9 0 :zzz: 0 :x: 0 :fire: 14.831s :stopwatch:
K-dash commented 5 months ago

I'm glad it seems to have worked well. Yeah, I think it's a good idea to adopt Streamlit! I'll list the things I think we should do in the future and the things that need to be considered, based on what comes to mind at this point.

Things I think we should do

Things that need to be considered

ryansurf commented 5 months ago

Allow users to input query parameters that were being sent from the Curl command as Streamlit input fields

I agree. Wondering if we should let the user input something similar to the cli args, like show_wave,color=purple,gpt etc. or we can use some toggles(like GPT=on/off)

Validation of input parameters (create a validation model in pydantic-settings)

Yep, its pretty easy to break the server at the moment

Visualization of weather forecast information

This would be the coolest feature imo. We have the pre-built map, but its not very useful. Something like this would be ideal (shows wind, wave height). I'm not sure how we would implement this ourselves

How to utilize GPT

I have an idea of how to do this. Simply have a on/off toggle for the GPT, and it its switched to "on" we can add gpt to the arguments, which is this line(64): surf_report = cli.run(args=["placeholder",f"{location}"]) -> surf_report = cli.run(args=["placeholder",f"{location}",gpt])

As for the name, I agree haha. Perhaps self-surf, selfHosted-surf or sh-surf?

K-dash commented 5 months ago

I agree. Wondering if we should let the user input something similar to the cli args, like show_wave,color=purple,gpt etc. or we can use some toggles(like GPT=on/off)

I have an idea of how to do this. Simply have a on/off toggle for the GPT, and it its switched to "on" we can add gpt to the arguments, which is this line(64): surf_report = cli.run(args=["placeholder",f"{location}"]) -> surf_report = cli.run(args=["placeholder",f"{location}",gpt])

I think it's good!

This would be the coolest feature imo. We have the pre-built map, but its not very useful. Something like this would be ideal (shows wind, wave height). I'm not sure how we would implement this ourselves

This seems like a great site that would be useful for surfers. It shows surf spots in Japan as well. I'm curious how they've accomplished that, but they likely have data on surf spots around the world. In any case, it would be difficult to implement similar functionality unless there is an API available to obtain information about surf spots...

As for the name, I agree haha. Perhaps self-surf, selfHosted-surf or sh-surf?

It's hard to decide on a name, isn't it? Haha. Maybe we can decide once the concept is more solidified!

K-dash commented 4 months ago

@ryansurf Long time no see! It seems you haven't been active on Github lately. Are you busy? I was curious about the progress of the Streamlit implementation, so I decided to check in here😎

ryansurf commented 4 months ago

@ryansurf Long time no see! It seems you haven't been active on Github lately. Are you busy? I was curious about the progress of the Streamlit implementation, so I decided to check in here😎

@K-dash welcome back! Indeed, work got a little busy so I haven't been active on GitHub as much lately.

A few months ago when we were working more consistently on this project I submitted a PR to have the project be added to the up for grabs website. The PR was approved about a week ago and now some more people are finding out about our project! I'm dedicating more time to work on it going forward

K-dash commented 4 months ago

@ryansurf Long time no see! It seems you haven't been active on Github lately. Are you busy? I was curious about the progress of the Streamlit implementation, so I decided to check in here😎

@K-dash welcome back! Indeed, work got a little busy so I haven't been active on GitHub as much lately.

A few months ago when we were working more consistently on this project I submitted a PR to have the project be added to the up for grabs website. The PR was approved about a week ago and now some more people are finding out about our project! I'm dedicating more time to work on it going forward

Good initiative! Please feel free to contact us if you need anything else:).

ryansurf commented 4 months ago

Hey @K-dash, I think we should merge this PR now.

The streamlit site is working well enough (definitely still needs some work), and I've updated the docs detailing how to run it.

At the moment I suppose we'll keep the other html/css frontend :flushed:

I've also made some slight updates to introduce the new make commands in the documentation, like make install, make lint and make format.

Let me know what you think! This PR might seem large but its mostly just the streamlit implementation

K-dash commented 4 months ago

Hey @K-dash, I think we should merge this PR now.

The streamlit site is working well enough (definitely still needs some work), and I've updated the docs detailing how to run it.

At the moment I suppose we'll keep the other html/css frontend 😳

I've also made some slight updates to introduce the new make commands in the documentation, like make install, make lint and make format.

Let me know what you think! This PR might seem large but its mostly just the streamlit implementation

I agree! I've commented on a few minor points. Thank you for merging the Makefile PR!

ryansurf commented 4 months ago

@K-dash , thanks for the review, I've implemented the fixes in https://github.com/ryansurf/cli-surf/pull/44/commits/103fdbb5f69c886a4432bd4823fb207277a33100.

I also resolved a merge conflict in https://github.com/ryansurf/cli-surf/pull/44/commits/77ab00bbd64e973f0404f8ed425940fd29e63422 and now I think we can merge the PR! Let me know what you think

ryansurf commented 4 months ago

@sourcery-ai review

sourcery-ai[bot] commented 4 months ago

Reviewer's Guide by Sourcery

This pull request introduces a Streamlit frontend for the surf forecasting application. It allows users to input a surf spot location and view a map of the spot along with a line graph displaying surf heights and swell periods. Additionally, it integrates GPT responses and provides options to toggle the map and GPT features. The changes also include refactoring and updates to helper functions, documentation, and tests.

File-Level Changes

Files Changes
src/cli.py
src/helper.py
tests/test_cli.py
Updated cli.run function to handle additional arguments and return GPT responses. Modified helper functions to support these changes and updated tests accordingly.
README.md
docs/cheat_sheet.md
docs/structure.md
docs/styling.md
CONTRIBUTING.md
Updated documentation to include instructions for the new Streamlit frontend and updated commands for running the linter and formatter.
src/streamlit_helper.py
src/dev_streamlit.py
Implemented the Streamlit frontend and created helper functions to support it.

Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - Continue your discussion with Sourcery by replying directly to review comments. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.
K-dash commented 4 months ago

@K-dash , thanks for the review, I've implemented the fixes in 103fdbb.

I also resolved a merge conflict in 77ab00b and now I think we can merge the PR! Let me know what you think

LGTM!