Skip to content

Generalise rejection policy configuration - #248

Merged
roryclaydon1994 merged 6 commits into
developfrom
247-generalise-rejection-policy-configuration
Aug 26, 2026
Merged

Generalise rejection policy configuration#248
roryclaydon1994 merged 6 commits into
developfrom
247-generalise-rejection-policy-configuration

Conversation

@jeipollack

@jeipollack jeipollack commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR generalises the rejection policy configuration section by replacing the hard-coded threshold field with a generic policy mapping. The current hard-coded representation limits the configuration model as additional policy types (e.g. quantile-based policies) may require different parameters.

Closes #247

What’s changed

  • Replace the hard-coded threshold field with a generic policy mapping
  • Update RejectionPolicyConfig to support policy-specific parameters
  • Update parse_rejection_policy_config()
  • Update the YAML configuration examples and fixtures
  • Update rejection-policy tests
  • Use backticks in error messages to highlight configuration parameter names

How to test / verify

  • Check CI tests pass.

Scope

Indicate the type of PR:

  • Feature
  • Bug fix
  • Hotfix
  • Documentation / process change
  • Internal / refactor
  • Release

Optionally, note if this PR is part of a larger milestone or set of related PRs.

Changelog

  • Changelog fragment added (if applicable)

No changelog fragment is added because the final user-facing configuration structure is still being developed. The changelog entry will be added with the PR that finalises the configuration structure.

Reviewer Checklist

Reviewers should confirm the following before approving and merging:

  • The PR targets the correct base branch (develop, or main for release PRs)
  • The PR is assigned to the developer
  • Appropriate labels are applied
  • The PR is included in relevant projects and/or milestones
  • Description clearly explains what has changed
  • Issue references included, if applicable
  • Code and documentation adhere to current standards (ruff)
  • Documentation updates included, if relevant
  • CI tests are passing
  • All reviewer comments have been addressed

Next Steps / Notes (if applicable)

Continue development of the pipeline orchestration PR, incorporating the generalised rejection policy configuration into rejection policy instantiation.

- Replace the hard-coded threshold field with a generic policy mapping
- Update RejectionPolicyConfig to support policy-specific parameters
- Update parse_rejection_policy_config()
- Update the YAML configuration examples and fixtures
- Update rejection-policy tests
- Use backticks in error messages to highlight configuration parameter names

@roryclaydon1994 roryclaydon1994 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Feedback

Changes look good, consistently good documentation throughout. Design is flexible and the type enforcement is likely to limit the error space.

In terms of design, I'm wondering if the constraint of one policy per metric could be relaxed such that one pass through the data could handle multiple outputs, one per policy? Also, given that the typing is strong, perhaps reading the configs to a dataclass first to handle the type handling would give a consistent API to the configs and would allow the parsing functions to focus on the policy extraction?

Comment thread src/wf_psf/quality_control/config.py Outdated
Comment thread src/wf_psf/quality_control/config.py Outdated
Comment thread src/wf_psf/quality_control/config.py Outdated
Comment thread src/wf_psf/quality_control/config.py
@jeipollack

jeipollack commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, @roryclaydon1994 for the review!

I agree that having the configuration represented as typed dataclasses as early as possible would provide a cleaner API. My current understanding is that this would require either a typed representation of the full YAML configuration before section parsing, or moving the mapping-to-dataclass conversion into the individual configuration classes. I'd like to explore that separately rather than introduce that architectural change into this PR, since the current parsers provide the boundary between the raw YAML mappings and the validated QualityControlConfig.

For multiple policies per metric, I think enforcing one policy for now keeps the configuration and execution model simple. If a concrete use case emerges for multiple policies, we can revisit the configuration and combine the policy outputs at that point.

I will now address each individual conversation thread :-)

Done! Ready for you to have a second pass

Jennifer Pollack added 5 commits August 25, 2026 17:57
- Raise ValueError when the policy field is missing
- Extract policy from the configuration mapping
- Add unit tests for missing policy and invalid policy types
- Remove duplicate rejection configuration mapping test
@roryclaydon1994
roryclaydon1994 merged commit 01ef410 into develop Aug 26, 2026
2 checks passed
@roryclaydon1994
roryclaydon1994 deleted the 247-generalise-rejection-policy-configuration branch August 26, 2026 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Development

Successfully merging this pull request may close these issues.

2 participants