Skip to content

Add test weight and propagate to service#264

Merged
ArthurCRodrigues merged 3 commits intomainfrom
263-bug-penaltyweight-field-lost-during-configuration-retrieval
Apr 10, 2026
Merged

Add test weight and propagate to service#264
ArthurCRodrigues merged 3 commits intomainfrom
263-bug-penaltyweight-field-lost-during-configuration-retrieval

Conversation

@matheusmra
Copy link
Copy Markdown
Member

This pull request introduces support for assigning a weight to each test in the autograder configuration, allowing for more granular scoring or prioritization of tests. The main changes add a weight field to the TestConfig model and ensure this value is passed through to where tests are constructed.

Test configuration and scoring improvements:

  • Added a weight field (defaulting to 100.0, must be non-negative) to the TestConfig model in autograder/models/config/test.py, allowing each test to specify its relative importance.
  • Updated the test parsing logic in autograder/services/criteria_tree_service.py to pass the new weight field when constructing a test node, ensuring the weight is used in downstream processing.

Introduce a weight field on TestConfig (default 100.0, non-negative) to allow tests to be weighted. Pass the configured weight into CriteriaTreeService when constructing tests so downstream logic can account for test importance.
@matheusmra matheusmra linked an issue Apr 9, 2026 that may be closed by this pull request
Copilot AI review requested due to automatic review settings April 9, 2026 23:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a per-test weight to the autograder configuration and threads it into criteria tree construction so downstream scoring/prioritization can account for relative test importance.

Changes:

  • Added weight (default 100.0, non-negative) to TestConfig.
  • Updated criteria tree parsing to pass TestConfig.weight into TestNode construction.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
autograder/models/config/test.py Introduces the weight field on TestConfig with validation/defaults.
autograder/services/criteria_tree_service.py Propagates TestConfig.weight into constructed TestNode instances.

Comment on lines 101 to 107
test = TestNode(
config.name,
test_function,
config.get_kwargs_dict() or {},
file_target,
config.weight,
)
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

config.weight is now stored on TestNode, but it doesn’t appear to affect scoring because GraderService.process_test() currently creates TestResultNode without copying test.weight (it defaults to 100). This makes per-test weights effectively ignored downstream (including focus/scoring). Propagate the criteria TestNode.weight into the corresponding TestResultNode.weight (or otherwise ensure balancing/scoring uses the configured weight).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@matheusmra does this apply?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@matheusmra does this apply?

Yes! I just commited this

Comment on lines 21 to 25
parameters: Optional[List[ParameterConfig]] = Field(
None, description="Named parameters for the test function"
)
weight: float = Field(100.0, ge=0, description="Weight of this test")

Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

The new weight field is part of the public config surface but there are no unit tests asserting its default (100.0) and validation (reject negative values). Please extend the existing config model tests (e.g., tests/unit/test_config_models.py) to cover these behaviors so regressions are caught.

Copilot uses AI. Check for mistakes.
@matheusmra matheusmra removed the request for review from ArthurCRodrigues April 9, 2026 23:41
@ArthurCRodrigues
Copy link
Copy Markdown
Member

@matheusmra joao was the last one to work on this and as far as i remember tests already had weights.

@jaoppb can you take a look here?

@ArthurCRodrigues
Copy link
Copy Markdown
Member

@matheusmra nevermind! Just read the issue description.

@ArthurCRodrigues ArthurCRodrigues merged commit 8e5746f into main Apr 10, 2026
2 checks passed
@ArthurCRodrigues ArthurCRodrigues deleted the 263-bug-penaltyweight-field-lost-during-configuration-retrieval branch April 10, 2026 00:24
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.

Bug: Penalty/Weight field lost during configuration retrieval

3 participants