NathanRoll commited on
Commit
5a55625
·
verified ·
1 Parent(s): 7b83067

Allow no-record submissions through n100

Browse files
Files changed (2) hide show
  1. README.md +2 -1
  2. app.py +18 -7
README.md CHANGED
@@ -44,7 +44,8 @@ packing-verifier verify solution.json --json
44
 
45
  The local command checks geometry and reports the same metric used by the
46
  Space. The live Space still applies the record gate: existing cases must
47
- improve the current top metric by at least `0.0001`.
 
48
 
49
  ## Persistence
50
 
 
44
 
45
  The local command checks geometry and reports the same metric used by the
46
  Space. The live Space still applies the record gate: existing cases must
47
+ improve the current top metric by at least `0.0001`; cases with no current
48
+ record can be submitted through `n = 100`.
49
 
50
  ## Persistence
51
 
app.py CHANGED
@@ -40,6 +40,7 @@ FAVICON_PATH = SPACE_ROOT / "assets" / "favicon.svg"
40
  HYDRATE_STATUS = maybe_hydrate_from_dataset(DATA_DIR)
41
  STORE = SolutionStore(DATA_DIR)
42
  SUBMISSION_MIN_IMPROVEMENT = 1.0e-4
 
43
  VERIFIER_REPO_URL = "https://github.com/Nathan-Roll1/packing-verifier"
44
 
45
 
@@ -1658,7 +1659,7 @@ EXAMPLES_MD = f"""### How Submission Works
1658
 
1659
  Paste one canonical coordinate JSON object, click **Verify**, then click **Submit Entry** if it passes.
1660
 
1661
- The geometry tolerance is fixed by the evaluator and is not user-selectable. For an existing case, a submission must improve the current top metric by at least `0.0001` to be accepted as a new record. In these tables, smaller metric values are better.
1662
 
1663
  ### Test Locally With The Open Verifier
1664
 
@@ -1687,9 +1688,10 @@ This prefilled example is a verified `triincir@3` coordinate layout and a good s
1687
  - Use radians for `rotation_radians`.
1688
  - Click **Verify** before submitting; the preview is rendered from the same canonical JSON that is archived.
1689
  - Existing cases must beat the current top metric by at least `0.0001`.
 
1690
  """
1691
 
1692
- SCHEMA_DOCS_MD = """### Canonical Fields
1693
 
1694
  Required top-level fields:
1695
 
@@ -1708,7 +1710,7 @@ Supported shape specs:
1708
  - `circle`: `radius` or `diameter`
1709
  - `rectangle`: `width` and `height`
1710
 
1711
- The verifier uses a fixed geometry tolerance. Existing cases must improve the current top metric by at least `0.0001` before they can be submitted as records.
1712
  """ + f"""
1713
 
1714
  ### Four Circles In A Square
@@ -2771,7 +2773,7 @@ def submit_schema_intro_html() -> str:
2771
  <div>
2772
  <h2>Submit Entry</h2>
2773
  <p class="section-note">
2774
- Paste one canonical coordinate JSON object. Existing cases must beat the current top metric by at least 0.0001.
2775
  The open-source local verifier is available at <a href="{esc(VERIFIER_REPO_URL)}" target="_blank" rel="noopener noreferrer">github.com/Nathan-Roll1/packing-verifier</a>.
2776
  </p>
2777
  </div>
@@ -2825,12 +2827,21 @@ def submitted_metric_for_result(result: dict[str, Any], current: dict[str, Any]
2825
  def submission_gate(result: dict[str, Any]) -> tuple[bool, str]:
2826
  if not result.get("ok"):
2827
  return False, "Geometry verification failed."
 
 
 
 
2828
  current = current_top_for_case(str(result.get("case") or ""))
2829
  symbol, submitted_metric = submitted_metric_for_result(result, current)
2830
  if submitted_metric is None:
2831
  return False, "The evaluator could not compute a submitted metric."
2832
  if current is None:
2833
- return True, "No current top record exists for this case; a valid geometry can be submitted."
 
 
 
 
 
2834
  current_symbol = str(current.get("metric_symbol") or symbol)
2835
  if current_symbol != symbol:
2836
  return False, f"Submitted metric symbol {symbol!r} does not match current record metric symbol {current_symbol!r}."
@@ -2880,7 +2891,7 @@ def result_markdown(result: dict[str, Any], gate: tuple[bool, str] | None = None
2880
 
2881
 
2882
  def empty_report_markdown() -> str:
2883
- return "### Ready To Verify\n\nPaste canonical JSON, then run the verifier. Existing cases must improve the current top metric by at least `0.0001`."
2884
 
2885
 
2886
  def empty_preview_html() -> str:
@@ -2992,7 +3003,7 @@ with gr.Blocks(
2992
  with gr.Column(scale=7, elem_classes=["submit-editor"]):
2993
  with gr.Group(elem_classes=["submit-panel"]):
2994
  gr.HTML('<div class="submit-panel-title">Paste JSON</div>')
2995
- gr.HTML('<p class="submit-panel-note">Paste one canonical coordinate JSON object. The evaluator uses a fixed tolerance and requires a 0.0001 metric improvement for existing cases.</p>')
2996
  json_code = gr.Textbox(
2997
  **supported_gradio_kwargs(
2998
  gr.Textbox,
 
40
  HYDRATE_STATUS = maybe_hydrate_from_dataset(DATA_DIR)
41
  STORE = SolutionStore(DATA_DIR)
42
  SUBMISSION_MIN_IMPROVEMENT = 1.0e-4
43
+ SUBMISSION_MAX_NEW_CASE_N = 100
44
  VERIFIER_REPO_URL = "https://github.com/Nathan-Roll1/packing-verifier"
45
 
46
 
 
1659
 
1660
  Paste one canonical coordinate JSON object, click **Verify**, then click **Submit Entry** if it passes.
1661
 
1662
+ The geometry tolerance is fixed by the evaluator and is not user-selectable. For an existing case, a submission must improve the current top metric by at least `0.0001` to be accepted as a new record. Cases with no current record can be submitted through `n = {SUBMISSION_MAX_NEW_CASE_N}`. In these tables, smaller metric values are better.
1663
 
1664
  ### Test Locally With The Open Verifier
1665
 
 
1688
  - Use radians for `rotation_radians`.
1689
  - Click **Verify** before submitting; the preview is rendered from the same canonical JSON that is archived.
1690
  - Existing cases must beat the current top metric by at least `0.0001`.
1691
+ - Cases with no current record can be submitted when `n <= {SUBMISSION_MAX_NEW_CASE_N}`.
1692
  """
1693
 
1694
+ SCHEMA_DOCS_MD = f"""### Canonical Fields
1695
 
1696
  Required top-level fields:
1697
 
 
1710
  - `circle`: `radius` or `diameter`
1711
  - `rectangle`: `width` and `height`
1712
 
1713
+ The verifier uses a fixed geometry tolerance. Existing cases must improve the current top metric by at least `0.0001` before they can be submitted as records. Cases with no current record can be submitted through `n = {SUBMISSION_MAX_NEW_CASE_N}`.
1714
  """ + f"""
1715
 
1716
  ### Four Circles In A Square
 
2773
  <div>
2774
  <h2>Submit Entry</h2>
2775
  <p class="section-note">
2776
+ Paste one canonical coordinate JSON object. Existing cases must beat the current top metric by at least 0.0001; new no-record cases are accepted through n={SUBMISSION_MAX_NEW_CASE_N}.
2777
  The open-source local verifier is available at <a href="{esc(VERIFIER_REPO_URL)}" target="_blank" rel="noopener noreferrer">github.com/Nathan-Roll1/packing-verifier</a>.
2778
  </p>
2779
  </div>
 
2827
  def submission_gate(result: dict[str, Any]) -> tuple[bool, str]:
2828
  if not result.get("ok"):
2829
  return False, "Geometry verification failed."
2830
+ try:
2831
+ submitted_n = int(result.get("n") or 0)
2832
+ except (TypeError, ValueError):
2833
+ return False, "The evaluator could not determine the number of submitted items."
2834
  current = current_top_for_case(str(result.get("case") or ""))
2835
  symbol, submitted_metric = submitted_metric_for_result(result, current)
2836
  if submitted_metric is None:
2837
  return False, "The evaluator could not compute a submitted metric."
2838
  if current is None:
2839
+ if submitted_n > SUBMISSION_MAX_NEW_CASE_N:
2840
+ return (
2841
+ False,
2842
+ f"No current top record exists for this case, and new no-record cases are accepted only through n={SUBMISSION_MAX_NEW_CASE_N}.",
2843
+ )
2844
+ return True, f"No current top record exists for this case; valid new cases can be submitted through n={SUBMISSION_MAX_NEW_CASE_N}."
2845
  current_symbol = str(current.get("metric_symbol") or symbol)
2846
  if current_symbol != symbol:
2847
  return False, f"Submitted metric symbol {symbol!r} does not match current record metric symbol {current_symbol!r}."
 
2891
 
2892
 
2893
  def empty_report_markdown() -> str:
2894
+ return f"### Ready To Verify\n\nPaste canonical JSON, then run the verifier. Existing cases must improve the current top metric by at least `0.0001`; cases with no current record can be submitted through `n = {SUBMISSION_MAX_NEW_CASE_N}`."
2895
 
2896
 
2897
  def empty_preview_html() -> str:
 
3003
  with gr.Column(scale=7, elem_classes=["submit-editor"]):
3004
  with gr.Group(elem_classes=["submit-panel"]):
3005
  gr.HTML('<div class="submit-panel-title">Paste JSON</div>')
3006
+ gr.HTML(f'<p class="submit-panel-note">Paste one canonical coordinate JSON object. The evaluator uses a fixed tolerance, requires a 0.0001 metric improvement for existing cases, and accepts new no-record cases through n={SUBMISSION_MAX_NEW_CASE_N}.</p>')
3007
  json_code = gr.Textbox(
3008
  **supported_gradio_kwargs(
3009
  gr.Textbox,