Skip to content

244 architecture resolve resource dependencies - #245

Merged
roryclaydon1994 merged 6 commits into
developfrom
244-architecture-resolve-resource-dependencies
Aug 24, 2026
Merged

244 architecture resolve resource dependencies#245
roryclaydon1994 merged 6 commits into
developfrom
244-architecture-resolve-resource-dependencies

Conversation

@jeipollack

@jeipollack jeipollack commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds resource dependency helpers to identify resources required by enabled
quality metrics, determine which required resources are ready to use and
which still require preparation.

Closes #244

What’s changed

  • Add resource.py module with a helper to determine resources required by enabled metrics
  • Add a helper to identify ready-to-use resources and resources requiring preparation
  • Add an orchestrator helper to resolve required resources and raise an error when resources are unavailable
  • Add resource_test.py with tests for both helpers
  • Remove resource dependency code from quality_control.config.py and config_test.py
  • Move the qc_config_factory fixture to a new conftest.py in the quality_control test package

How to test / verify

  • Check CI passes

Scope

Indicate the type of PR:

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

This PR is part of the larger quality control pipeline orchestration
milestone.

Changelog

Does this PR introduce user-visible changes? Not yet. The resource resolution functionality is an internal architectural component; user-facing behaviour will be introduced as the QC pipeline orchestration is developed.

  • Changelog fragment added (if applicable)

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)

Resource preparation is intentionally not implemented in this PR. The current resource module identifies missing resources so that a subsequent stage can determine how they should be prepared or supplied.

Jennifer Pollack added 2 commits August 20, 2026 13:22
- Add resource module with helper to determine resources required by enabled metrics
- Add helper to identify ready-to-use resources and those requiring preparation
- Add resource_test module with tests for both helpers
- Delete resource dependency related code from config and config test modules
- Move qc_config_factory fixture to new conftest.py in quality_control test package
@jeipollack jeipollack self-assigned this Aug 20, 2026
@jeipollack jeipollack added the enhancement New feature or request label Aug 20, 2026
@jeipollack jeipollack added this to the Outlier Removal milestone Aug 20, 2026
@jeipollack
jeipollack marked this pull request as ready for review August 20, 2026 11:48
@jeipollack
jeipollack marked this pull request as draft August 21, 2026 09:06
@jeipollack

Copy link
Copy Markdown
Contributor Author

@roryclaydon1994 I am going to switch to draft mode as I am about to add a new resource orchestration helper with some tests. I will ping you when it's ready for review

- Add helper to resolve resources required by enabled metrics
- Raise an explicit error when required resources are unavailable
- Add composition tests for resolved, missing, and unrequired resources
@jeipollack
jeipollack marked this pull request as ready for review August 21, 2026 09:15
@jeipollack

Copy link
Copy Markdown
Contributor Author

@roryclaydon1994 I added the new commits and updated the description. This PR is ready for review. thanks!

@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

Tests are very complete, good documentation and typing throughout.

In terms of design, it looks like resources.py could be condensed to one simple function or a class with method names that are easier to distinguish and could be overloaded in future if desired.

Re the Resources class my meaning is get_required_resources and resolve_required_resources become get_required/filter_enabled and resolve as the resource class already provides the fact it is related to resources.

Comment thread src/wf_psf/tests/test_quality_control/conftest.py
Comment thread src/wf_psf/quality_control/resources.py Outdated
Comment thread src/wf_psf/quality_control/resources.py Outdated
Comment on lines +34 to +39
return {
resource
for metric in config.metrics.values()
if metric.enabled
for resource in metric.required_resources
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can a metric be disabled in config, but passed in as provided?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, a resource can be passed in as provided even if it isn't required by any enabled metric. In the migrated code, the handling of this behaviour is covered by the get_required() tests in the updated implementation. The resolve() tests separately cover filtering the caller-provided resources against the required resources. For example, when psf_models.standard is required but both standard and oversampled are provided, only standard is returned as resolved.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What does it mean for a resource to be provided, but not required? Would it be used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see this primarily as allowing a caller to provide a broader set of resources than the current configuration requires, for example when setting up shared/default resources or testing different configurations. Resources that aren't required by any enabled metric are simply ignored by resolve() and therefore aren't used by the QC pipeline.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm not quite following, but I'm assuming examples will come in the next and MR, and at present, this seems like it will not cause an issue.

I think a compromise might be to add a quick debug logging call to the function to specify what was missing, what was resolved, and was provided but not required.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

okay, no p. I can add a debug logging call and will ping you when it's been committed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

pushed the new commit. No new test was added because the unused-resource scenario is already covered by the existing parameterized test.

- Define Resources class as the resource management API boundary
- Move and consolidate resource helpers into class methods
- Update resources unit test module
@jeipollack

Copy link
Copy Markdown
Contributor Author

Thanks @roryclaydon1994 again for your thoughtful review. I followed the suggestion in your feedback and introduced a Resources class to act a resource manager and moved and consolidated the resource helper methods. I am ready for you to take a second look.

@roryclaydon1994
roryclaydon1994 merged commit 9a6d935 into develop Aug 24, 2026
2 checks passed
@roryclaydon1994
roryclaydon1994 deleted the 244-architecture-resolve-resource-dependencies branch August 24, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Development

Successfully merging this pull request may close these issues.

2 participants