Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretest dependencies #1075

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Pretest dependencies #1075

wants to merge 2 commits into from

Conversation

Riolku
Copy link
Contributor

@Riolku Riolku commented Nov 5, 2022

This PR changes the previous "batch dependencies" in a few ways:

  1. Dependencies can now be specified on any top-level unit, case or batch.
  2. Dependencies are specified with YAML alias notation, not numbers.

It also implements pretests, including a PRETEST-END IPC packet.

dmoj/judge.py Show resolved Hide resolved
dmoj/problem.py Outdated Show resolved Hide resolved
@Xyene
Copy link
Member

Xyene commented Nov 5, 2022

We'll need an accompanying site-side PR to not crash the bridge when we send it PRETEST-{BEGIN,END} packets.

https://github.com/DMOJ/online-judge/blob/f3cd24e3ecad89c2492917df9229009c2634baed/judge/bridge/judge_handler.py#L40-L54

dmoj/judge.py Outdated Show resolved Hide resolved
@Riolku
Copy link
Contributor Author

Riolku commented Nov 5, 2022

Also have dependencies always be a set instead of a list that gets coerced to a set over and over.

dmoj/graders/base.py Outdated Show resolved Hide resolved
dmoj/judge.py Outdated Show resolved Hide resolved
dmoj/judge.py Outdated Show resolved Hide resolved
dmoj/problem.py Outdated Show resolved Hide resolved
dmoj/judge.py Outdated Show resolved Hide resolved
dmoj/judge.py Outdated Show resolved Hide resolved
dmoj/judge.py Outdated Show resolved Hide resolved
dmoj/judge.py Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Nov 13, 2022

Codecov Report

Base: 80.75% // Head: 53.87% // Decreases project coverage by -26.87% ⚠️

Coverage data is based on head (5001269) compared to base (ae6b204).
Patch coverage: 79.01% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #1075       +/-   ##
===========================================
- Coverage   80.75%   53.87%   -26.88%     
===========================================
  Files         134      134               
  Lines        4770     4850       +80     
===========================================
- Hits         3852     2613     -1239     
- Misses        918     2237     +1319     
Impacted Files Coverage Δ
dmoj/judge.py 32.56% <72.80%> (-20.77%) ⬇️
dmoj/problem.py 91.72% <92.85%> (+1.10%) ⬆️
dmoj/graders/base.py 89.79% <94.73%> (+11.74%) ⬆️
dmoj/config.py 82.71% <100.00%> (+0.21%) ⬆️
dmoj/executors/C.py 0.00% <0.00%> (-100.00%) ⬇️
dmoj/executors/D.py 0.00% <0.00%> (-100.00%) ⬇️
dmoj/executors/GO.py 0.00% <0.00%> (-100.00%) ⬇️
dmoj/executors/ADA.py 0.00% <0.00%> (-100.00%) ⬇️
dmoj/executors/AWK.py 0.00% <0.00%> (-100.00%) ⬇️
dmoj/executors/C11.py 0.00% <0.00%> (-100.00%) ⬇️
... and 83 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Riolku Riolku force-pushed the pretest-dependencies branch 2 times, most recently from fe77c24 to 1fe64ba Compare November 13, 2022 08:02
dmoj/judge.py Outdated Show resolved Hide resolved
This commit changes the previous "batch dependencies" in a few ways:
1. Dependencies can now be specified on any top-level unit, case or batch.
2. Dependencies are specified with YAML alias notation, not numbers.

It also implements pretests, including a `PRETEST-END` IPC packet.
)
else:
self.main_case += 1
report(ansi_style('%sTest case %2d %-3s %s' % (case_padding, self.main_case, colored_codes[0], case_info)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This string is almost identical to the one used for pretests. Can we make "Test case" and "Pretest case" substituted in with another %s?

Same comment below for batches.

@@ -194,11 +196,25 @@ def _ipc_compile_message(self, _report, compile_message: str) -> None:
self.packet_manager.compile_message_packet(compile_message)

def _ipc_grading_begin(self, _report, is_pretested: bool) -> None:
self.in_pretests = False
self.pretest_batch = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a single set of batch/case variables, and reset them when we end pretests? That way we don't have dangling state after pretests finish.

class GradingAbort(Exception):
pass

def grade(case: AbstractTestCase) -> Result:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def grade(case: AbstractTestCase) -> Result:
def grade_single(case: AbstractTestCase) -> Result:

To match the naming of the rest of the functions.

# output. So, we trim it here so we don't run out of memory in the controller.
result.proc_output = result.output
yield IPC.RESULT, (batch_number, case_number, result)
failed_pretests: Set[int] = set()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than have this state here captured by the closure in should_run_main_test, what if we took it as the first parameter to should_run_main_test, and then applied it with partial(...?

failed_pretests, pretest_result = yield from grade_many(pretests, should_run_pretest)
yield IPC.PRETEST_END, ()
if not self.grader.run_pretests_only:
if pretest_result == GradeManyResult.SKIP_ALL:
Copy link
Member

@Xyene Xyene Jan 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this ever happen without len(failed_pretests) != 0? Do we need this extra enum, or does nonzero failed_pretests already imply SKIP_ALL here?

failed = True
yield from skip_toplevel(test)
elif isinstance(test, Batch):
yield IPC.BATCH_BEGIN, (test.batch,)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move these yields into grade_batched_cases? It's a little weird that the case results come from within it, but the batch begin/end markers don't.

result = self.grader.grade(case)
result = grade(test)
failed = result.result_flag & Result.WA
yield IPC.RESULT, (None, test.position, result)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this yield into grade?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants