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

Lite: Disable the analytics function forcefully in the Wasm mode #4967

Closed
wants to merge 6 commits into from

Conversation

whitphx
Copy link
Member

@whitphx whitphx commented Jul 19, 2023

Description

Technically, the analytics doesn't work in the Wasm mode because it relies on the threading module that doesn't work on the Pyodide runtime.

🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.

Not adhering to this guideline will result in the PR being closed.

Tests & Changelog

  1. PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests: bash scripts/run_all_tests.sh

  2. You may need to run the linters: bash scripts/format_backend.sh and bash scripts/format_frontend.sh

  3. Unless the pull request is labeled with the "no-changelog-update" label by a maintainer of the repo, all pull requests must update the changelog located in CHANGELOG.md:

Please add a brief summary of the change to the Upcoming Release section of the CHANGELOG.md file and include
a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by [@myusername](link-to-your-github-profile) in [PR 11111](https://github.com/gradio-app/gradio/pull/11111)".

…n't make sense and it also technically doesn't work because it relies on the threading module
@vercel
Copy link

vercel bot commented Jul 19, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
gradio ✅ Ready (Inspect) Visit Preview Jul 31, 2023 3:25am

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Jul 19, 2023

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-4967-all-demos


You can install the changes in this PR by running:

pip install https://gradio-builds.s3.amazonaws.com/cca6239d52f8dc159cbe03276b4985884ca79203/gradio-3.39.0-py3-none-any.whl

@whitphx whitphx marked this pull request as ready for review July 19, 2023 03:10
@whitphx whitphx changed the title Disable the analytics function forcefully in the Wasm mode Lite: Disable the analytics function forcefully in the Wasm mode Jul 20, 2023
Copy link
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

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

Thanks @whitphx ! This looks good to me!!

@@ -0,0 +1,5 @@
---
Copy link
Member

Choose a reason for hiding this comment

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

Not sure why two changeset files were created. Maybe because the PR was renamed? But you can probably just delete both of them to reset the action

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, this is a mistake. Will delete one.

Comment on lines +723 to +727
if wasm_utils.IS_WASM and self.analytics_enabled:
self.analytics_enabled = False
warnings.warn(
"Analytics are not supported in the Wasm mode."
)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if wasm_utils.IS_WASM and self.analytics_enabled:
self.analytics_enabled = False
warnings.warn(
"Analytics are not supported in the Wasm mode."
)
if wasm_utils.IS_WASM:
self.analytics_enabled = False

Copy link
Member

Choose a reason for hiding this comment

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

That being said, it would be nice to know how much usage gradio-wasm is getting. We can get downloads from npm right?

Copy link
Member Author

Choose a reason for hiding this comment

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

That may be right, but the reason I disabled the analytics now is that the analytics feature does not work on Pyodide because it uses the threading module.

We can get downloads from npm right?

Yes. Also, the CDN jsDelivr should also provides such stats, while its page is not found somehow (I don't know why... maybe because the downloads are still few? For exmaple, my @stlite/mountable has its jsDelivr page and we can see the stats).

Copy link
Member Author

@whitphx whitphx Jul 28, 2023

Choose a reason for hiding this comment

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

So, I thought disabling the analytics is the simplest solution to make gradio-lite work,
but fixing the analytics module to be Wasm-compatible is another way if we think the analytics is important on gradio-lite too.

It would be fixing the code depending on thethreading module to depend on asyncio instead, and replacing the requests module with pyodide.http.pyfetch.

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

but fixing the analytics module to be Wasm-compatible is another way if we think the analytics is important on gradio-lite too.

It would be fixing the code depending on thethreading module to depend on asyncio instead, and replacing the requests module with pyodide.http.pyfetch.

This would be great! I do think analytics capturing the usage would be very valuable. We don't have to add them in this PR, but would be good to have before launch

Copy link
Member Author

Choose a reason for hiding this comment

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

I created another PR doing it: #5045

However let me ask one question:
While it is a higher-level discussion, should we enable the analytics feature on the Wasm ver too?
My concern is, though not 100% sure, users may expect the Wasm ver. is similar to being "standalone" and such external network access does not occur.

Copy link
Member Author

@whitphx whitphx Jul 31, 2023

Choose a reason for hiding this comment

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

My another concern is whether it is legally clear (sorry I'm not a legal expert though).
In the Wasm mode, the analytics telemetry including IP address is sent from users' devices, and it may conflict with something like GDPR (and Hugging Face has a legal entity in EU)?

Copy link
Member

Choose a reason for hiding this comment

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

Good question @whitphx I think its important to have analytics to get an idea to have usage of the wasm mode. We have an existing issue to make sure analytics is compliant with GDPR (#4226) but for now, any user can disable analytics pretty easily so I think it should be fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, thanks!

@abidlabs
Copy link
Member

Sorry for the delay in responding @whitphx! I made some suggestions, but overall change lgtm

This reverts commit a8409d3.
@abidlabs
Copy link
Member

abidlabs commented Aug 4, 2023

Closing in favor of #5045 -- good stuff @whitphx!

@abidlabs abidlabs closed this Aug 4, 2023
@whitphx whitphx deleted the wasm-disable-analytics branch August 4, 2023 14:02
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.

None yet

4 participants