Chenglu-She commited on
Commit
1f1f651
1 Parent(s): a57b46d

Upload folder using huggingface_hub

Browse files
Files changed (7) hide show
  1. README.md +2 -2
  2. app.py +6 -3
  3. space.py +6 -3
  4. src/README.md +6 -3
  5. src/demo/app.py +6 -3
  6. src/demo/space.py +6 -3
  7. src/pyproject.toml +1 -1
README.md CHANGED
@@ -2,8 +2,8 @@
2
  ---
3
  tags: [gradio-custom-component,gradio-template-SimpleTextbox,log,gradio_log,gradio_log_component,gradio_print_log]
4
  title: gradio_log V0.0.2
5
- colorFrom: blue
6
- colorTo: yellow
7
  sdk: docker
8
  pinned: false
9
  license: apache-2.0
 
2
  ---
3
  tags: [gradio-custom-component,gradio-template-SimpleTextbox,log,gradio_log,gradio_log_component,gradio_print_log]
4
  title: gradio_log V0.0.2
5
+ colorFrom: pink
6
+ colorTo: purple
7
  sdk: docker
8
  pinned: false
9
  license: apache-2.0
app.py CHANGED
@@ -1,6 +1,7 @@
1
  from pathlib import Path
2
  import logging
3
  import gradio as gr
 
4
 
5
  from gradio_log import Log
6
 
@@ -33,7 +34,9 @@ class CustomFormatter(logging.Formatter):
33
 
34
  formatter = CustomFormatter()
35
 
36
- ch = logging.FileHandler("./test.log")
 
 
37
  ch.setLevel(logging.DEBUG)
38
  ch.setFormatter(formatter)
39
 
@@ -57,7 +60,7 @@ def create_log_handler(level):
57
  return l
58
 
59
 
60
- Path("./test.log").touch()
61
 
62
  with gr.Blocks() as demo:
63
  text = gr.Textbox(label="Enter text to write to log file")
@@ -65,7 +68,7 @@ with gr.Blocks() as demo:
65
  for l in ["debug", "info", "warning", "error", "critical"]:
66
  button = gr.Button(f"log as {l}")
67
  button.click(fn=create_log_handler(l), inputs=text)
68
- Log("./test.log")
69
 
70
 
71
  if __name__ == "__main__":
 
1
  from pathlib import Path
2
  import logging
3
  import gradio as gr
4
+ import tempfile
5
 
6
  from gradio_log import Log
7
 
 
34
 
35
  formatter = CustomFormatter()
36
 
37
+ log_file = tempfile.mktemp(suffix=".log")
38
+
39
+ ch = logging.FileHandler(log_file)
40
  ch.setLevel(logging.DEBUG)
41
  ch.setFormatter(formatter)
42
 
 
60
  return l
61
 
62
 
63
+ Path(log_file).touch()
64
 
65
  with gr.Blocks() as demo:
66
  text = gr.Textbox(label="Enter text to write to log file")
 
68
  for l in ["debug", "info", "warning", "error", "critical"]:
69
  button = gr.Button(f"log as {l}")
70
  button.click(fn=create_log_handler(l), inputs=text)
71
+ Log(log_file)
72
 
73
 
74
  if __name__ == "__main__":
space.py CHANGED
@@ -41,6 +41,7 @@ pip install gradio_log
41
  from pathlib import Path
42
  import logging
43
  import gradio as gr
 
44
 
45
  from gradio_log import Log
46
 
@@ -73,7 +74,9 @@ class CustomFormatter(logging.Formatter):
73
 
74
  formatter = CustomFormatter()
75
 
76
- ch = logging.FileHandler("./test.log")
 
 
77
  ch.setLevel(logging.DEBUG)
78
  ch.setFormatter(formatter)
79
 
@@ -97,7 +100,7 @@ def create_log_handler(level):
97
  return l
98
 
99
 
100
- Path("./test.log").touch()
101
 
102
  with gr.Blocks() as demo:
103
  text = gr.Textbox(label="Enter text to write to log file")
@@ -105,7 +108,7 @@ with gr.Blocks() as demo:
105
  for l in ["debug", "info", "warning", "error", "critical"]:
106
  button = gr.Button(f"log as {l}")
107
  button.click(fn=create_log_handler(l), inputs=text)
108
- Log("./test.log")
109
 
110
 
111
  if __name__ == "__main__":
 
41
  from pathlib import Path
42
  import logging
43
  import gradio as gr
44
+ import tempfile
45
 
46
  from gradio_log import Log
47
 
 
74
 
75
  formatter = CustomFormatter()
76
 
77
+ log_file = tempfile.mktemp(suffix=".log")
78
+
79
+ ch = logging.FileHandler(log_file)
80
  ch.setLevel(logging.DEBUG)
81
  ch.setFormatter(formatter)
82
 
 
100
  return l
101
 
102
 
103
+ Path(log_file).touch()
104
 
105
  with gr.Blocks() as demo:
106
  text = gr.Textbox(label="Enter text to write to log file")
 
108
  for l in ["debug", "info", "warning", "error", "critical"]:
109
  button = gr.Button(f"log as {l}")
110
  button.click(fn=create_log_handler(l), inputs=text)
111
+ Log(log_file)
112
 
113
 
114
  if __name__ == "__main__":
src/README.md CHANGED
@@ -16,6 +16,7 @@ pip install gradio_log
16
  from pathlib import Path
17
  import logging
18
  import gradio as gr
 
19
 
20
  from gradio_log import Log
21
 
@@ -48,7 +49,9 @@ class CustomFormatter(logging.Formatter):
48
 
49
  formatter = CustomFormatter()
50
 
51
- ch = logging.FileHandler("./test.log")
 
 
52
  ch.setLevel(logging.DEBUG)
53
  ch.setFormatter(formatter)
54
 
@@ -72,7 +75,7 @@ def create_log_handler(level):
72
  return l
73
 
74
 
75
- Path("./test.log").touch()
76
 
77
  with gr.Blocks() as demo:
78
  text = gr.Textbox(label="Enter text to write to log file")
@@ -80,7 +83,7 @@ with gr.Blocks() as demo:
80
  for l in ["debug", "info", "warning", "error", "critical"]:
81
  button = gr.Button(f"log as {l}")
82
  button.click(fn=create_log_handler(l), inputs=text)
83
- Log("./test.log")
84
 
85
 
86
  if __name__ == "__main__":
 
16
  from pathlib import Path
17
  import logging
18
  import gradio as gr
19
+ import tempfile
20
 
21
  from gradio_log import Log
22
 
 
49
 
50
  formatter = CustomFormatter()
51
 
52
+ log_file = tempfile.mktemp(suffix=".log")
53
+
54
+ ch = logging.FileHandler(log_file)
55
  ch.setLevel(logging.DEBUG)
56
  ch.setFormatter(formatter)
57
 
 
75
  return l
76
 
77
 
78
+ Path(log_file).touch()
79
 
80
  with gr.Blocks() as demo:
81
  text = gr.Textbox(label="Enter text to write to log file")
 
83
  for l in ["debug", "info", "warning", "error", "critical"]:
84
  button = gr.Button(f"log as {l}")
85
  button.click(fn=create_log_handler(l), inputs=text)
86
+ Log(log_file)
87
 
88
 
89
  if __name__ == "__main__":
src/demo/app.py CHANGED
@@ -1,6 +1,7 @@
1
  from pathlib import Path
2
  import logging
3
  import gradio as gr
 
4
 
5
  from gradio_log import Log
6
 
@@ -33,7 +34,9 @@ class CustomFormatter(logging.Formatter):
33
 
34
  formatter = CustomFormatter()
35
 
36
- ch = logging.FileHandler("./test.log")
 
 
37
  ch.setLevel(logging.DEBUG)
38
  ch.setFormatter(formatter)
39
 
@@ -57,7 +60,7 @@ def create_log_handler(level):
57
  return l
58
 
59
 
60
- Path("./test.log").touch()
61
 
62
  with gr.Blocks() as demo:
63
  text = gr.Textbox(label="Enter text to write to log file")
@@ -65,7 +68,7 @@ with gr.Blocks() as demo:
65
  for l in ["debug", "info", "warning", "error", "critical"]:
66
  button = gr.Button(f"log as {l}")
67
  button.click(fn=create_log_handler(l), inputs=text)
68
- Log("./test.log")
69
 
70
 
71
  if __name__ == "__main__":
 
1
  from pathlib import Path
2
  import logging
3
  import gradio as gr
4
+ import tempfile
5
 
6
  from gradio_log import Log
7
 
 
34
 
35
  formatter = CustomFormatter()
36
 
37
+ log_file = tempfile.mktemp(suffix=".log")
38
+
39
+ ch = logging.FileHandler(log_file)
40
  ch.setLevel(logging.DEBUG)
41
  ch.setFormatter(formatter)
42
 
 
60
  return l
61
 
62
 
63
+ Path(log_file).touch()
64
 
65
  with gr.Blocks() as demo:
66
  text = gr.Textbox(label="Enter text to write to log file")
 
68
  for l in ["debug", "info", "warning", "error", "critical"]:
69
  button = gr.Button(f"log as {l}")
70
  button.click(fn=create_log_handler(l), inputs=text)
71
+ Log(log_file)
72
 
73
 
74
  if __name__ == "__main__":
src/demo/space.py CHANGED
@@ -41,6 +41,7 @@ pip install gradio_log
41
  from pathlib import Path
42
  import logging
43
  import gradio as gr
 
44
 
45
  from gradio_log import Log
46
 
@@ -73,7 +74,9 @@ class CustomFormatter(logging.Formatter):
73
 
74
  formatter = CustomFormatter()
75
 
76
- ch = logging.FileHandler("./test.log")
 
 
77
  ch.setLevel(logging.DEBUG)
78
  ch.setFormatter(formatter)
79
 
@@ -97,7 +100,7 @@ def create_log_handler(level):
97
  return l
98
 
99
 
100
- Path("./test.log").touch()
101
 
102
  with gr.Blocks() as demo:
103
  text = gr.Textbox(label="Enter text to write to log file")
@@ -105,7 +108,7 @@ with gr.Blocks() as demo:
105
  for l in ["debug", "info", "warning", "error", "critical"]:
106
  button = gr.Button(f"log as {l}")
107
  button.click(fn=create_log_handler(l), inputs=text)
108
- Log("./test.log")
109
 
110
 
111
  if __name__ == "__main__":
 
41
  from pathlib import Path
42
  import logging
43
  import gradio as gr
44
+ import tempfile
45
 
46
  from gradio_log import Log
47
 
 
74
 
75
  formatter = CustomFormatter()
76
 
77
+ log_file = tempfile.mktemp(suffix=".log")
78
+
79
+ ch = logging.FileHandler(log_file)
80
  ch.setLevel(logging.DEBUG)
81
  ch.setFormatter(formatter)
82
 
 
100
  return l
101
 
102
 
103
+ Path(log_file).touch()
104
 
105
  with gr.Blocks() as demo:
106
  text = gr.Textbox(label="Enter text to write to log file")
 
108
  for l in ["debug", "info", "warning", "error", "critical"]:
109
  button = gr.Button(f"log as {l}")
110
  button.click(fn=create_log_handler(l), inputs=text)
111
+ Log(log_file)
112
 
113
 
114
  if __name__ == "__main__":
src/pyproject.toml CHANGED
@@ -43,7 +43,7 @@ classifiers = [
43
  dev = ["build", "twine"]
44
 
45
  [tool.hatch.build]
46
- artifacts = ["/backend/gradio_log/templates", "*.pyi", "backend/gradio_log/templates", "backend/gradio_log/templates", "backend/gradio_log/templates", "backend/gradio_log/templates"]
47
 
48
  [tool.hatch.build.targets.wheel]
49
  packages = ["/backend/gradio_log"]
 
43
  dev = ["build", "twine"]
44
 
45
  [tool.hatch.build]
46
+ artifacts = ["/backend/gradio_log/templates", "*.pyi", "backend/gradio_log/templates", "backend/gradio_log/templates", "backend/gradio_log/templates", "backend/gradio_log/templates", "backend/gradio_log/templates"]
47
 
48
  [tool.hatch.build.targets.wheel]
49
  packages = ["/backend/gradio_log"]