Spaces:
Running
on
A100
Running
on
A100
feat(oauth): add config for gradio oauth and demo app
Browse files- README.md +12 -0
- app.py +27 -0
- poetry.lock +0 -0
- pyproject.toml +17 -0
README.md
CHANGED
@@ -9,6 +9,18 @@ app_file: app.py
|
|
9 |
pinned: false
|
10 |
license: apache-2.0
|
11 |
short_description: Demonstration of basic usage of the data model curator tool
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
---
|
13 |
|
14 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
9 |
pinned: false
|
10 |
license: apache-2.0
|
11 |
short_description: Demonstration of basic usage of the data model curator tool
|
12 |
+
|
13 |
+
hf_oauth: true
|
14 |
+
# optional, default duration is 8 hours/480 minutes. Max duration is 30 days/43200 minutes.
|
15 |
+
hf_oauth_expiration_minutes: 480
|
16 |
+
# optional, see "Scopes" below. "openid profile" is always included.
|
17 |
+
hf_oauth_scopes:
|
18 |
+
- read-repos
|
19 |
+
- inference-api
|
20 |
+
# optional, restrict access to members of specific organizations
|
21 |
+
# hf_oauth_authorized_org:
|
22 |
+
# - ORG_NAME1
|
23 |
+
# - ORG_NAME2
|
24 |
---
|
25 |
|
26 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from __future__ import annotations
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
from huggingface_hub import whoami
|
5 |
+
|
6 |
+
|
7 |
+
def hello(profile: gr.OAuthProfile | None) -> str:
|
8 |
+
if profile is None:
|
9 |
+
return "I don't know you."
|
10 |
+
return f"Hello {profile.name}"
|
11 |
+
|
12 |
+
|
13 |
+
def list_organizations(oauth_token: gr.OAuthToken | None) -> str:
|
14 |
+
if oauth_token is None:
|
15 |
+
return "Please deploy this on Spaces and log in to list organizations."
|
16 |
+
org_names = [org["name"] for org in whoami(oauth_token.token)["orgs"]]
|
17 |
+
return f"You belong to {', '.join(org_names)}."
|
18 |
+
|
19 |
+
|
20 |
+
with gr.Blocks() as demo:
|
21 |
+
gr.LoginButton()
|
22 |
+
m1 = gr.Markdown()
|
23 |
+
m2 = gr.Markdown()
|
24 |
+
demo.load(hello, inputs=None, outputs=m1)
|
25 |
+
demo.load(list_organizations, inputs=None, outputs=m2)
|
26 |
+
|
27 |
+
demo.launch()
|
poetry.lock
ADDED
The diff for this file is too large to render.
See raw diff
|
|
pyproject.toml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[project]
|
2 |
+
name = "data-model-curator-demo"
|
3 |
+
version = "0.1.0"
|
4 |
+
description = ""
|
5 |
+
authors = []
|
6 |
+
license = {text = "Apache 2.0"}
|
7 |
+
readme = "README.md"
|
8 |
+
requires-python = ">=3.10"
|
9 |
+
dependencies = [
|
10 |
+
"gradio (>=5.37.0,<6.0.0)"
|
11 |
+
]
|
12 |
+
package-mode = false
|
13 |
+
|
14 |
+
|
15 |
+
[build-system]
|
16 |
+
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
17 |
+
build-backend = "poetry.core.masonry.api"
|