Commit
•
8e8a9fc
1
Parent(s):
ed3130d
Adding diagram
Browse files- app.py +25 -1
- media/reddit_scraper.drawio.html +11 -0
app.py
CHANGED
@@ -1,7 +1,23 @@
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from rich.console import Console
|
3 |
from rich.syntax import Syntax
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
def log_file_to_html_string():
|
7 |
log_file = "mylog.log"
|
@@ -20,9 +36,17 @@ def log_file_to_html_string():
|
|
20 |
# body_background_fill="repeating-linear-gradient(45deg, *primary_800, *primary_800 10px, *primary_900 10px, *primary_900 20px)",
|
21 |
# body_background_fill_dark="repeating-linear-gradient(45deg, *primary_800, *primary_800 10px, *primary_900 10px, *primary_900 20px)",
|
22 |
# )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
with gr.Blocks() as demo:
|
25 |
-
name = gr.Markdown("
|
26 |
output = gr.HTML(log_file_to_html_string, every=1)
|
27 |
demo.load(None,
|
28 |
_js="""
|
|
|
1 |
+
import os
|
2 |
+
from pathlib import Path
|
3 |
+
|
4 |
import gradio as gr
|
5 |
from rich.console import Console
|
6 |
from rich.syntax import Syntax
|
7 |
|
8 |
+
proj_dir = Path(__name__).parent
|
9 |
+
|
10 |
+
subreddit = os.environ["SUBREDDIT"]
|
11 |
+
username = os.environ["USERNAME"]
|
12 |
+
dataset_name = f"{username}/dataset-creator-{subreddit}"
|
13 |
+
|
14 |
+
with open(proj_dir / "media/reddit_scraper.drawio.html", "r") as f:
|
15 |
+
html_string = f.read()
|
16 |
+
html_string.replace("SPACE_NAME", f"{username}/reddit-dataset-creator")
|
17 |
+
html_string.replace("SPACE_LINK", f"https://huggingface.co/spaces/{username}/reddit-dataset-creator")
|
18 |
+
html_string.replace("DATASET_NAME", f"{username}/dataset-creator-{subreddit}")
|
19 |
+
html_string.replace("DATASET_LINK", f"https://huggingface.co/datasets/{username}/dataset-creator-{subreddit}")
|
20 |
+
|
21 |
|
22 |
def log_file_to_html_string():
|
23 |
log_file = "mylog.log"
|
|
|
36 |
# body_background_fill="repeating-linear-gradient(45deg, *primary_800, *primary_800 10px, *primary_900 10px, *primary_900 20px)",
|
37 |
# body_background_fill_dark="repeating-linear-gradient(45deg, *primary_800, *primary_800 10px, *primary_900 10px, *primary_900 20px)",
|
38 |
# )
|
39 |
+
markdown = f"""
|
40 |
+
# Reddit Scraper
|
41 |
+
This is a reddit scraper which builds [{dataset_name}](https://huggingface.co/datasets/{dataset_name}).
|
42 |
+
|
43 |
+
See the diagram below:
|
44 |
+
|
45 |
+
{html_string}
|
46 |
+
"""
|
47 |
|
48 |
with gr.Blocks() as demo:
|
49 |
+
name = gr.Markdown("")
|
50 |
output = gr.HTML(log_file_to_html_string, every=1)
|
51 |
demo.load(None,
|
52 |
_js="""
|
media/reddit_scraper.drawio.html
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=5,IE=9" ><![endif]-->
|
2 |
+
<!DOCTYPE html>
|
3 |
+
<html>
|
4 |
+
<head>
|
5 |
+
<title>reddit_scraper</title>
|
6 |
+
<meta charset="utf-8"/>
|
7 |
+
</head>
|
8 |
+
<body><div class="mxgraph" style="max-width:100%;border:1px solid transparent;" data-mxgraph="{"highlight":"#0000ff","nav":true,"resize":true,"toolbar":"zoom layers tags lightbox","edit":"_blank","xml":"<mxfile host=\"app.diagrams.net\" modified=\"2023-04-14T12:12:14.014Z\" agent=\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36\" etag=\"puEjOIZigDmpONhGThsE\" version=\"21.1.7\" type=\"device\">\n <diagram name=\"Page-1\" id=\"14ddc1Tw5ZQC4xUkB2ri\">\n <mxGraphModel dx=\"1034\" dy=\"783\" grid=\"1\" gridSize=\"10\" guides=\"1\" tooltips=\"1\" connect=\"1\" arrows=\"1\" fold=\"1\" page=\"1\" pageScale=\"1\" pageWidth=\"850\" pageHeight=\"1100\" math=\"0\" shadow=\"0\">\n <root>\n <mxCell id=\"0\" />\n <mxCell id=\"1\" parent=\"0\" />\n <mxCell id=\"KhBTRBst3V2Bs5u7l5Na-3\" value=\"\" style=\"edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;\" edge=\"1\" parent=\"1\" source=\"KhBTRBst3V2Bs5u7l5Na-1\" target=\"KhBTRBst3V2Bs5u7l5Na-2\">\n <mxGeometry relative=\"1\" as=\"geometry\" />\n </mxCell>\n <mxCell id=\"KhBTRBst3V2Bs5u7l5Na-7\" value=\"HF API\" style=\"edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];\" vertex=\"1\" connectable=\"0\" parent=\"KhBTRBst3V2Bs5u7l5Na-3\">\n <mxGeometry x=\"-0.125\" y=\"1\" relative=\"1\" as=\"geometry\">\n <mxPoint as=\"offset\" />\n </mxGeometry>\n </mxCell>\n <mxCell id=\"KhBTRBst3V2Bs5u7l5Na-1\" value=\"HF SPACE&lt;br&gt;&lt;a href=&quot;SPACE_LINK&quot;&gt;SPACE_NAME&lt;/a&gt;\" style=\"rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;\" vertex=\"1\" parent=\"1\">\n <mxGeometry x=\"340\" y=\"360\" width=\"160\" height=\"80\" as=\"geometry\" />\n </mxCell>\n <mxCell id=\"KhBTRBst3V2Bs5u7l5Na-2\" value=\"HF DATASET &lt;br&gt;&lt;a href=&quot;DATASET_LINK&quot;&gt;DATASET_NAME&lt;/a&gt;\" style=\"rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;\" vertex=\"1\" parent=\"1\">\n <mxGeometry x=\"110\" y=\"360\" width=\"160\" height=\"80\" as=\"geometry\" />\n </mxCell>\n <mxCell id=\"KhBTRBst3V2Bs5u7l5Na-4\" value=\"&lt;a href=&quot;pushshift.io&quot;&gt;Pushshift.io&lt;/a&gt;&lt;br&gt;Hosts Reddit Data\" style=\"rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;\" vertex=\"1\" parent=\"1\">\n <mxGeometry x=\"590\" y=\"360\" width=\"160\" height=\"80\" as=\"geometry\" />\n </mxCell>\n <mxCell id=\"KhBTRBst3V2Bs5u7l5Na-8\" value=\"\" style=\"endArrow=classic;startArrow=classic;html=1;rounded=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;\" edge=\"1\" parent=\"1\" source=\"KhBTRBst3V2Bs5u7l5Na-1\" target=\"KhBTRBst3V2Bs5u7l5Na-4\">\n <mxGeometry width=\"50\" height=\"50\" relative=\"1\" as=\"geometry\">\n <mxPoint x=\"470\" y=\"530\" as=\"sourcePoint\" />\n <mxPoint x=\"520\" y=\"480\" as=\"targetPoint\" />\n </mxGeometry>\n </mxCell>\n <mxCell id=\"KhBTRBst3V2Bs5u7l5Na-9\" value=\"HTTP\" style=\"edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];\" vertex=\"1\" connectable=\"0\" parent=\"KhBTRBst3V2Bs5u7l5Na-8\">\n <mxGeometry x=\"0.225\" y=\"1\" relative=\"1\" as=\"geometry\">\n <mxPoint x=\"-9\" y=\"1\" as=\"offset\" />\n </mxGeometry>\n </mxCell>\n </root>\n </mxGraphModel>\n </diagram>\n</mxfile>\n"}"></div>
|
9 |
+
<script type="text/javascript" src="https://viewer.diagrams.net/js/viewer-static.min.js"></script>
|
10 |
+
</body>
|
11 |
+
</html>
|