Michael Rabinovich commited on
Commit ·
9e84592
1
Parent(s): f571140
submit: drop the agree checkbox, meta.json is the only consent gate
Browse filesThe Submit tab had both an "I agree" checkbox and required
meta.json to carry "agree_to_publish": true. Two gates expressing
the same intent, neither covering a case the other didn't, and
the UI half doesn't extend to programmatic submitters
(gradio_client, future REST API).
Drop the UI checkbox. meta.json["agree_to_publish"] stays the
single consent gate, uniform across browser + programmatic
submission. handle_submit signature shrinks to (zip_file).
Submit form is now: zip upload + Submit button.
app.py
CHANGED
|
@@ -75,19 +75,16 @@ and stripped to a single line. Shown in the per-submission detail view,
|
|
| 75 |
not in the main leaderboard table.
|
| 76 |
|
| 77 |
All five fields come from `meta.json` inside the zip, no separate
|
| 78 |
-
form to fill in.
|
| 79 |
-
|
| 80 |
"""
|
| 81 |
)
|
| 82 |
zip_in = gr.File(label="Submission ZIP", file_types=[".zip"])
|
| 83 |
-
agree_in = gr.Checkbox(
|
| 84 |
-
label="I agree to publish this result on the public leaderboard."
|
| 85 |
-
)
|
| 86 |
submit_btn = gr.Button("Submit", variant="primary")
|
| 87 |
submit_out = gr.Markdown()
|
| 88 |
submit_btn.click(
|
| 89 |
fn=handle_submit,
|
| 90 |
-
inputs=[zip_in
|
| 91 |
outputs=submit_out,
|
| 92 |
)
|
| 93 |
|
|
|
|
| 75 |
not in the main leaderboard table.
|
| 76 |
|
| 77 |
All five fields come from `meta.json` inside the zip, no separate
|
| 78 |
+
form to fill in. Setting `agree_to_publish: true` in `meta.json` is
|
| 79 |
+
your consent to publish on the public leaderboard.
|
| 80 |
"""
|
| 81 |
)
|
| 82 |
zip_in = gr.File(label="Submission ZIP", file_types=[".zip"])
|
|
|
|
|
|
|
|
|
|
| 83 |
submit_btn = gr.Button("Submit", variant="primary")
|
| 84 |
submit_out = gr.Markdown()
|
| 85 |
submit_btn.click(
|
| 86 |
fn=handle_submit,
|
| 87 |
+
inputs=[zip_in],
|
| 88 |
outputs=submit_out,
|
| 89 |
)
|
| 90 |
|
submit.py
CHANGED
|
@@ -9,14 +9,13 @@ forever until later chunks add the background thread.
|
|
| 9 |
|
| 10 |
Validation gates, in order:
|
| 11 |
|
| 12 |
-
1. Form-level: a file was attached
|
| 13 |
2. Zip safety: parseable as a zip, no absolute / parent-traversing
|
| 14 |
entry names, no symlinks.
|
| 15 |
3. ``meta.json`` schema: required keys present, types sane,
|
| 16 |
-
``agree_to_publish`` is literally ``true``
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
carries the zip and the in-UI agree checkbox.
|
| 20 |
4. Fixture-set match: the set of folders inside the zip equals the
|
| 21 |
set of fixture directories in :func:`cadgenbench.common.paths.data_inputs_dir`
|
| 22 |
(no missing, no extras).
|
|
@@ -93,19 +92,19 @@ class _HubWriteError(Exception):
|
|
| 93 |
"""Raised when a Hub upload fails after validation succeeded."""
|
| 94 |
|
| 95 |
|
| 96 |
-
def handle_submit(zip_file
|
| 97 |
"""Validate a submission upload and return a markdown UI message.
|
| 98 |
|
| 99 |
Returns one of:
|
| 100 |
- An error string starting with ``**Error:**`` for form-level
|
| 101 |
-
rejects (
|
| 102 |
- A rejection string starting with ``**Submission rejected.**``
|
| 103 |
for any of the deeper validation gates or Hub-write failures.
|
| 104 |
- A success string starting with ``**Queued.**`` carrying the
|
| 105 |
minted ``submission_id`` once the pending row + zip are on
|
| 106 |
the Hub.
|
| 107 |
"""
|
| 108 |
-
form_err = _validate_form(zip_file
|
| 109 |
if form_err is not None:
|
| 110 |
return form_err
|
| 111 |
|
|
@@ -140,11 +139,9 @@ def handle_submit(zip_file, agree: bool) -> str:
|
|
| 140 |
)
|
| 141 |
|
| 142 |
|
| 143 |
-
def _validate_form(zip_file
|
| 144 |
if zip_file is None:
|
| 145 |
return "**Error:** please attach a submission zip."
|
| 146 |
-
if not agree:
|
| 147 |
-
return "**Error:** you must agree to publish before submitting."
|
| 148 |
return None
|
| 149 |
|
| 150 |
|
|
|
|
| 9 |
|
| 10 |
Validation gates, in order:
|
| 11 |
|
| 12 |
+
1. Form-level: a file was attached.
|
| 13 |
2. Zip safety: parseable as a zip, no absolute / parent-traversing
|
| 14 |
entry names, no symlinks.
|
| 15 |
3. ``meta.json`` schema: required keys present, types sane,
|
| 16 |
+
``agree_to_publish`` is literally ``true`` (the sole consent
|
| 17 |
+
gate; no separate UI checkbox), ``notes`` is non-empty when
|
| 18 |
+
present and within the per-submission cap.
|
|
|
|
| 19 |
4. Fixture-set match: the set of folders inside the zip equals the
|
| 20 |
set of fixture directories in :func:`cadgenbench.common.paths.data_inputs_dir`
|
| 21 |
(no missing, no extras).
|
|
|
|
| 92 |
"""Raised when a Hub upload fails after validation succeeded."""
|
| 93 |
|
| 94 |
|
| 95 |
+
def handle_submit(zip_file) -> str:
|
| 96 |
"""Validate a submission upload and return a markdown UI message.
|
| 97 |
|
| 98 |
Returns one of:
|
| 99 |
- An error string starting with ``**Error:**`` for form-level
|
| 100 |
+
rejects (no zip attached).
|
| 101 |
- A rejection string starting with ``**Submission rejected.**``
|
| 102 |
for any of the deeper validation gates or Hub-write failures.
|
| 103 |
- A success string starting with ``**Queued.**`` carrying the
|
| 104 |
minted ``submission_id`` once the pending row + zip are on
|
| 105 |
the Hub.
|
| 106 |
"""
|
| 107 |
+
form_err = _validate_form(zip_file)
|
| 108 |
if form_err is not None:
|
| 109 |
return form_err
|
| 110 |
|
|
|
|
| 139 |
)
|
| 140 |
|
| 141 |
|
| 142 |
+
def _validate_form(zip_file) -> str | None:
|
| 143 |
if zip_file is None:
|
| 144 |
return "**Error:** please attach a submission zip."
|
|
|
|
|
|
|
| 145 |
return None
|
| 146 |
|
| 147 |
|