Ben Burtenshaw commited on
Commit
e36e778
1 Parent(s): 39e6ae5

rename main to app

Browse files
Files changed (3) hide show
  1. .vscode/launch.json +15 -0
  2. app.py +53 -3
  3. main.py +0 -57
.vscode/launch.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "name": "MAIN",
9
+ "type": "debugpy",
10
+ "request": "launch",
11
+ "program": "app.py",
12
+ "console": "integratedTerminal"
13
+ }
14
+ ]
15
+ }
app.py CHANGED
@@ -1,7 +1,57 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
  demo.launch()
 
1
  import gradio as gr
2
+ from gradio_log import Log
3
 
4
+ from pipeline import run
5
+
6
+ log_file = "out-file.txt"
7
+
8
+
9
+ def run():
10
+ import subprocess
11
+ import sys
12
+
13
+ with open("out-file.txt", "w") as f:
14
+ proc = subprocess.Popen(
15
+ [f"{sys.executable}", "pipeline.py", "burtenshaw/yoga_nistra"],
16
+ stdout=subprocess.PIPE,
17
+ )
18
+
19
+ content = ""
20
+
21
+ for line in proc.stdout:
22
+ content = content.split("\n")
23
+ content.append(line.decode("utf-8"))
24
+ content = content[-10:]
25
+ content = "\n".join(content)
26
+ yield content
27
+
28
+
29
+ import gradio as gr
30
+ from huggingface_hub import whoami
31
+
32
+
33
+ def hello(profile: gr.OAuthProfile | None) -> str:
34
+ if profile is None:
35
+ return "I don't know you."
36
+ return f"Hello {profile.name}"
37
+
38
+
39
+ def list_organizations(oauth_token: gr.OAuthToken | None) -> str:
40
+ if oauth_token is None:
41
+ return "Please log in to list organizations."
42
+ org_names = [org["name"] for org in whoami(oauth_token.token)["orgs"]]
43
+ return f"You belong to {', '.join(org_names)}."
44
+
45
+
46
+ with gr.Blocks() as demo:
47
+ gr.LoginButton()
48
+ m1 = gr.Markdown()
49
+ m2 = gr.Markdown()
50
+ demo.load(hello, inputs=None, outputs=m1)
51
+ demo.load(list_organizations, inputs=None, outputs=m2)
52
+
53
+ button = gr.Button("Run pipeline")
54
+ output = gr.Code(label="Terminal output", interactive=False)
55
+ button.click(run, outputs=output)
56
 
 
57
  demo.launch()
main.py DELETED
@@ -1,57 +0,0 @@
1
- import gradio as gr
2
- from gradio_log import Log
3
-
4
- from pipeline import run
5
-
6
- log_file = "out-file.txt"
7
-
8
-
9
- def run():
10
- import subprocess
11
- import sys
12
-
13
- with open("out-file.txt", "w") as f:
14
- proc = subprocess.Popen(
15
- [f"{sys.executable}", "pipeline.py", "burtenshaw/yoga_nistra"],
16
- stdout=subprocess.PIPE,
17
- )
18
-
19
- content = ""
20
-
21
- for line in proc.stdout:
22
- content = content.split("\n")
23
- content.append(line.decode("utf-8"))
24
- content = content[-10:]
25
- content = "\n".join(content)
26
- yield content
27
-
28
-
29
- import gradio as gr
30
- from huggingface_hub import whoami
31
-
32
-
33
- def hello(profile: gr.OAuthProfile | None) -> str:
34
- if profile is None:
35
- return "I don't know you."
36
- return f"Hello {profile.name}"
37
-
38
-
39
- def list_organizations(oauth_token: gr.OAuthToken | None) -> str:
40
- if oauth_token is None:
41
- return "Please log in to list organizations."
42
- org_names = [org["name"] for org in whoami(oauth_token.token)["orgs"]]
43
- return f"You belong to {', '.join(org_names)}."
44
-
45
-
46
- with gr.Blocks() as demo:
47
- gr.LoginButton()
48
- m1 = gr.Markdown()
49
- m2 = gr.Markdown()
50
- demo.load(hello, inputs=None, outputs=m1)
51
- demo.load(list_organizations, inputs=None, outputs=m2)
52
-
53
- button = gr.Button("Run pipeline")
54
- output = gr.Code(label="Terminal output", interactive=False)
55
- button.click(run, outputs=output)
56
-
57
- demo.launch()