Spaces:
Running
Running
emoji fix
Browse files
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
-
title: Croissant Checker
|
3 |
-
emoji:
|
4 |
colorFrom: yellow
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
|
|
1 |
---
|
2 |
+
title: Croissant Checker - Dev
|
3 |
+
emoji: ππ₯
|
4 |
colorFrom: yellow
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
app.py
CHANGED
@@ -30,7 +30,7 @@ def process_file(file):
|
|
30 |
|
31 |
def create_ui():
|
32 |
with gr.Blocks(theme=gr.themes.Soft()) as app:
|
33 |
-
gr.Markdown("# Croissant JSON-LD Validator for NeurIPS")
|
34 |
gr.Markdown("""
|
35 |
Upload your Croissant JSON-LD file or enter a URL to validate if it meets the requirements for NeurIPS submission.
|
36 |
The validator will check:
|
@@ -39,55 +39,75 @@ def create_ui():
|
|
39 |
3. If records can be generated within a reasonable time
|
40 |
""")
|
41 |
|
42 |
-
# Create containers for validation results - moved up for cleaner flow
|
43 |
-
validation_results = gr.HTML(visible=False)
|
44 |
-
upload_progress = gr.HTML(
|
45 |
-
"""<div class="progress-container">
|
46 |
-
<div class="progress-status">Ready for validation</div>
|
47 |
-
</div>""", visible=True)
|
48 |
-
|
49 |
# Track the active tab for conditional UI updates
|
50 |
active_tab = gr.State("upload") # Default to upload tab
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
)
|
62 |
-
fetch_btn = gr.Button("Fetch and Validate", variant="primary")
|
63 |
|
64 |
-
#
|
|
|
|
|
|
|
|
|
|
|
65 |
gr.HTML("""
|
66 |
<style>
|
|
|
67 |
.gradio-container {
|
68 |
-
max-width:
|
69 |
-
margin: 0 auto;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
}
|
|
|
|
|
71 |
.validation-step {
|
72 |
-
margin-bottom:
|
73 |
-
border: 1px solid var(--border-color-primary,
|
74 |
border-radius: 8px;
|
75 |
overflow: hidden;
|
76 |
}
|
|
|
77 |
.step-header {
|
78 |
padding: 10px 15px;
|
79 |
-
background-color: var(--background-fill-secondary, #f5f5f5);
|
80 |
display: flex;
|
81 |
align-items: center;
|
|
|
82 |
cursor: pointer;
|
|
|
83 |
}
|
|
|
84 |
.step-left {
|
85 |
display: flex;
|
86 |
align-items: center;
|
87 |
-
|
88 |
}
|
|
|
|
|
89 |
.step-status {
|
90 |
-
margin-right: 10px;
|
91 |
width: 24px;
|
92 |
height: 24px;
|
93 |
border-radius: 50%;
|
@@ -96,43 +116,53 @@ def create_ui():
|
|
96 |
justify-content: center;
|
97 |
font-weight: bold;
|
98 |
color: white !important;
|
99 |
-
font-size: 16px;
|
100 |
-
text-shadow: 0px 0px 1px rgba(0,0,0,0.5);
|
101 |
-
}
|
102 |
-
.arrow-indicator {
|
103 |
-
margin-left: 10px;
|
104 |
-
font-size: 16px;
|
105 |
-
transition: transform 0.3s ease;
|
106 |
-
}
|
107 |
-
.arrow-down {
|
108 |
-
transform: rotate(90deg);
|
109 |
}
|
|
|
110 |
.status-success {
|
111 |
-
background-color: #4caf50;
|
112 |
}
|
|
|
113 |
.status-error {
|
114 |
-
background-color: #f44336;
|
115 |
}
|
116 |
-
|
117 |
-
|
|
|
|
|
118 |
}
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
}
|
124 |
-
|
125 |
-
|
|
|
|
|
|
|
126 |
}
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
|
|
131 |
}
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
|
|
|
|
|
|
|
|
136 |
}
|
137 |
</style>
|
138 |
""")
|
@@ -141,29 +171,19 @@ def create_ui():
|
|
141 |
def on_tab_change(evt: gr.SelectData):
|
142 |
tab_id = evt.value
|
143 |
if tab_id == "Upload File":
|
144 |
-
return "upload", """<div class="progress-
|
145 |
-
<div class="progress-status">Ready for upload</div>
|
146 |
-
</div>""", gr.update(visible=False)
|
147 |
else:
|
148 |
-
return "url", """<div class="progress-
|
149 |
-
<div class="progress-status">Enter a URL to fetch</div>
|
150 |
-
</div>""", gr.update(visible=False)
|
151 |
|
152 |
def on_file_upload(file):
|
153 |
if file is None:
|
154 |
-
return """<div class="progress-
|
155 |
-
<div class="progress-status">Ready for upload</div>
|
156 |
-
</div>""", gr.update(visible=False)
|
157 |
|
158 |
-
return """<div class="progress-
|
159 |
-
<div class="progress-status">β
File uploaded successfully</div>
|
160 |
-
</div>""", gr.update(visible=False)
|
161 |
|
162 |
def fetch_from_url(url):
|
163 |
if not url:
|
164 |
-
return """<div class="progress-
|
165 |
-
<div class="progress-status">Please enter a URL</div>
|
166 |
-
</div>""", gr.update(visible=False)
|
167 |
|
168 |
try:
|
169 |
# Fetch JSON from URL
|
@@ -172,9 +192,7 @@ def create_ui():
|
|
172 |
json_data = response.json()
|
173 |
|
174 |
# Show success message
|
175 |
-
progress_html = """<div class="progress-
|
176 |
-
<div class="progress-status">β
JSON fetched successfully from URL</div>
|
177 |
-
</div>"""
|
178 |
|
179 |
# Validate the fetched JSON
|
180 |
results = []
|
@@ -193,19 +211,13 @@ def create_ui():
|
|
193 |
|
194 |
except requests.exceptions.RequestException as e:
|
195 |
error_message = f"β Error fetching URL: {str(e)}"
|
196 |
-
return f"""<div class="progress-
|
197 |
-
<div class="progress-status">{error_message}</div>
|
198 |
-
</div>""", gr.update(visible=False)
|
199 |
except json.JSONDecodeError as e:
|
200 |
error_message = f"β URL did not return valid JSON: {str(e)}"
|
201 |
-
return f"""<div class="progress-
|
202 |
-
<div class="progress-status">{error_message}</div>
|
203 |
-
</div>""", gr.update(visible=False)
|
204 |
except Exception as e:
|
205 |
error_message = f"β Unexpected error: {str(e)}"
|
206 |
-
return f"""<div class="progress-
|
207 |
-
<div class="progress-status">{error_message}</div>
|
208 |
-
</div>""", gr.update(visible=False)
|
209 |
|
210 |
def build_results_html(results):
|
211 |
# Build validation results HTML
|
|
|
30 |
|
31 |
def create_ui():
|
32 |
with gr.Blocks(theme=gr.themes.Soft()) as app:
|
33 |
+
gr.Markdown("# ππ₯ Croissant JSON-LD Validator for NeurIPS")
|
34 |
gr.Markdown("""
|
35 |
Upload your Croissant JSON-LD file or enter a URL to validate if it meets the requirements for NeurIPS submission.
|
36 |
The validator will check:
|
|
|
39 |
3. If records can be generated within a reasonable time
|
40 |
""")
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
# Track the active tab for conditional UI updates
|
43 |
active_tab = gr.State("upload") # Default to upload tab
|
44 |
|
45 |
+
# Create a container for the entire input section
|
46 |
+
with gr.Group():
|
47 |
+
# Input tabs
|
48 |
+
with gr.Tabs() as tabs:
|
49 |
+
with gr.TabItem("Upload File", id="upload_tab"):
|
50 |
+
file_input = gr.File(label="Upload Croissant JSON-LD File", file_types=[".json", ".jsonld"])
|
51 |
+
validate_btn = gr.Button("Validate Uploaded File", variant="primary")
|
52 |
+
|
53 |
+
with gr.TabItem("URL Input", id="url_tab"):
|
54 |
+
url_input = gr.Textbox(
|
55 |
+
label="Enter Croissant JSON-LD URL",
|
56 |
+
placeholder="e.g. https://huggingface.co/api/datasets/facebook/natural_reasoning/croissant"
|
57 |
+
)
|
58 |
+
fetch_btn = gr.Button("Fetch and Validate", variant="primary")
|
59 |
|
60 |
+
# Change initial message to match upload tab
|
61 |
+
upload_progress = gr.HTML(
|
62 |
+
"""<div class="progress-status">Ready for upload</div>""",
|
63 |
+
visible=True)
|
|
|
|
|
64 |
|
65 |
+
# Now create the validation results section in a separate group
|
66 |
+
with gr.Group():
|
67 |
+
# Validation results
|
68 |
+
validation_results = gr.HTML(visible=False)
|
69 |
+
|
70 |
+
# Define CSS for the validation UI
|
71 |
gr.HTML("""
|
72 |
<style>
|
73 |
+
/* Set max width and center the app */
|
74 |
.gradio-container {
|
75 |
+
max-width: 750px !important;
|
76 |
+
margin: 0 auto !important;
|
77 |
+
}
|
78 |
+
|
79 |
+
/* Make basic containers transparent */
|
80 |
+
.gr-group, .gr-box, .gr-panel, .gradio-box, .gradio-group {
|
81 |
+
background-color: var(--body-background-fill) !important;
|
82 |
+
border: none !important;
|
83 |
+
box-shadow: none !important;
|
84 |
}
|
85 |
+
|
86 |
+
/* Style for expandable validation steps */
|
87 |
.validation-step {
|
88 |
+
margin-bottom: 12px;
|
89 |
+
border: 1px solid var(--border-color-primary, rgba(128, 128, 128, 0.2));
|
90 |
border-radius: 8px;
|
91 |
overflow: hidden;
|
92 |
}
|
93 |
+
|
94 |
.step-header {
|
95 |
padding: 10px 15px;
|
|
|
96 |
display: flex;
|
97 |
align-items: center;
|
98 |
+
justify-content: space-between;
|
99 |
cursor: pointer;
|
100 |
+
background-color: rgba(0, 0, 0, 0.03) !important;
|
101 |
}
|
102 |
+
|
103 |
.step-left {
|
104 |
display: flex;
|
105 |
align-items: center;
|
106 |
+
gap: 10px;
|
107 |
}
|
108 |
+
|
109 |
+
/* Force text color to white in status indicators */
|
110 |
.step-status {
|
|
|
111 |
width: 24px;
|
112 |
height: 24px;
|
113 |
border-radius: 50%;
|
|
|
116 |
justify-content: center;
|
117 |
font-weight: bold;
|
118 |
color: white !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
}
|
120 |
+
|
121 |
.status-success {
|
122 |
+
background-color: #4caf50 !important;
|
123 |
}
|
124 |
+
|
125 |
.status-error {
|
126 |
+
background-color: #f44336 !important;
|
127 |
}
|
128 |
+
|
129 |
+
.step-details {
|
130 |
+
padding: 12px 15px;
|
131 |
+
background-color: var(--body-background-fill) !important;
|
132 |
}
|
133 |
+
|
134 |
+
/* User hints styling - italic, smaller, better positioned */
|
135 |
+
.progress-status {
|
136 |
+
font-style: italic;
|
137 |
+
font-size: 0.9em;
|
138 |
+
color: var(--body-text-color-subdued);
|
139 |
+
padding: 8px 0;
|
140 |
+
margin-top: 5px;
|
141 |
+
width: 100%;
|
142 |
+
background: none !important;
|
143 |
+
border: none !important;
|
144 |
+
text-align: center;
|
145 |
}
|
146 |
+
|
147 |
+
/* Override input containers to match page background */
|
148 |
+
.gr-input-container, .gr-form, .gr-input, .gr-box, .gr-panel,
|
149 |
+
.file-preview, .file-preview > div {
|
150 |
+
background-color: var(--body-background-fill) !important;
|
151 |
}
|
152 |
+
|
153 |
+
/* Ensure buttons have proper styling */
|
154 |
+
button.primary, button[data-testid="primary-button"] {
|
155 |
+
background-color: var(--primary-500) !important;
|
156 |
+
color: white !important;
|
157 |
}
|
158 |
+
|
159 |
+
/* Arrow indicator for expandable sections */
|
160 |
+
.arrow-indicator {
|
161 |
+
font-size: 14px;
|
162 |
+
transition: transform 0.3s ease;
|
163 |
+
}
|
164 |
+
.arrow-down {
|
165 |
+
transform: rotate(90deg);
|
166 |
}
|
167 |
</style>
|
168 |
""")
|
|
|
171 |
def on_tab_change(evt: gr.SelectData):
|
172 |
tab_id = evt.value
|
173 |
if tab_id == "Upload File":
|
174 |
+
return "upload", """<div class="progress-status">Ready for upload</div>""", gr.update(visible=False)
|
|
|
|
|
175 |
else:
|
176 |
+
return "url", """<div class="progress-status">Enter a URL to fetch</div>""", gr.update(visible=False)
|
|
|
|
|
177 |
|
178 |
def on_file_upload(file):
|
179 |
if file is None:
|
180 |
+
return """<div class="progress-status">Ready for upload</div>""", gr.update(visible=False)
|
|
|
|
|
181 |
|
182 |
+
return """<div class="progress-status">β
File uploaded successfully</div>""", gr.update(visible=False)
|
|
|
|
|
183 |
|
184 |
def fetch_from_url(url):
|
185 |
if not url:
|
186 |
+
return """<div class="progress-status">Please enter a URL</div>""", gr.update(visible=False)
|
|
|
|
|
187 |
|
188 |
try:
|
189 |
# Fetch JSON from URL
|
|
|
192 |
json_data = response.json()
|
193 |
|
194 |
# Show success message
|
195 |
+
progress_html = """<div class="progress-status">β
JSON fetched successfully from URL</div>"""
|
|
|
|
|
196 |
|
197 |
# Validate the fetched JSON
|
198 |
results = []
|
|
|
211 |
|
212 |
except requests.exceptions.RequestException as e:
|
213 |
error_message = f"β Error fetching URL: {str(e)}"
|
214 |
+
return f"""<div class="progress-status">{error_message}</div>""", gr.update(visible=False)
|
|
|
|
|
215 |
except json.JSONDecodeError as e:
|
216 |
error_message = f"β URL did not return valid JSON: {str(e)}"
|
217 |
+
return f"""<div class="progress-status">{error_message}</div>""", gr.update(visible=False)
|
|
|
|
|
218 |
except Exception as e:
|
219 |
error_message = f"β Unexpected error: {str(e)}"
|
220 |
+
return f"""<div class="progress-status">{error_message}</div>""", gr.update(visible=False)
|
|
|
|
|
221 |
|
222 |
def build_results_html(results):
|
223 |
# Build validation results HTML
|