-
Notifications
You must be signed in to change notification settings - Fork 114
Annotation export example #584
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of the app but it seems to not be working for me:
annotation.mp4
examples/annotation-export/app.py
Outdated
path = Path(__file__).parent / "boulder_temp.csv" | ||
dataframe = pd.read_csv(path) | ||
dataframe["date"] = pd.to_datetime(dataframe["date"]) | ||
dataframe["annotation"] = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the CSV reading should happen outside of the server function, at the top level of the app, so that it's read only once. Otherwise it'll be read every time any user changes their copy of annotation_values
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call
examples/annotation-export/app.py
Outdated
selected = selected_data().copy() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this copy()
isn't needed.
Now that I think about it, how about updating this app to use copy on write? That should eliminate the need for using .copy()
.
#614
https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried a few things, and it turns out that moving some date time processing up in the script means that all of the copies can be removed without needing the pandas copy-on-modify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there's still a place where the reactive.Value
ts_data()
is being modified in place; the modified value is downloaded in download
, where it calls ts_data.to_csv()
. This results in the expected overall behavior for the app, but it relies on a dangerous modification-in-place. I'll make a fix.
@wch I think the app was working but maybe poorly documented. The idea was to show a table of annotated values, so if you don't add any annotations the table should be empty. I added a placeholder and heading to make that a bit clearer. |
I just pushed some small formatting fixes. Note that the |
* main: Add E2E tests for accordion and autoresize (#601) Add card test (#622) Add sidebar test (#631) Make card fullscreen icon a tooltip (#632) Pull in changes from rstudio/bslib#697 and rstudio/bslib#699 Changelog tweak. Followup to #629 Add experimental tooltip methods and example apps (#629) Use `blib::bs_theme(5,"shiny")` for py-shiny theme (#624) Rename shiny/examples to shiny/api-examples (and X/examples to X/api-examples) (#627) Make --app-path work with app file argument (#598) Don't eval example code block Fix example code blocks (#626) Annotation export example (#584) Add todo list example (#603)
This creates a slightly more real-world brushing example where the user can visually annotate a plot, and then download the annotated data.