Repository navigation
Conversation
1951153 to
39a2d37
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2165 +/- ##
==========================================
+ Coverage 62.64% 62.82% +0.17%
==========================================
Files 165 171 +6
Lines 20792 20867 +75
Branches 3621 3627 +6
==========================================
+ Hits 13026 13109 +83
+ Misses 6886 6877 -9
- Partials 880 881 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
JeanChristopheMorinPerso
left a comment
There was a problem hiding this comment.
I think I'm generally good with this but would like to see some changes before we merge this. I think it's going in the right direction. Note that this review was a manual review from me with no LLM assistance.
| Use this when runtime configuration (e.g. REZ_PACKAGE_ORDERERS_JSON) | ||
| has changed and you want the new config to take effect. Note that | ||
| the config-level cache must also be cleared via | ||
| ``config._uncache("package_orderers")``. |
There was a problem hiding this comment.
config._uncache("package_orderers")
This makes me feel uneasy as it's a private method. Also, why is this method needed? Are we doing something similar in other places and this just keeps things consistent? API users have access to rez.config.config.copy/override/remove_override to change the condig at runtime...
There was a problem hiding this comment.
Addressed, but, in addressing it, I note/noticed that PackageFilterList has an identical cached-singleton-over-a-config-setting pattern, but doesn't have any invalidation story, so once .singleton gets touched, config.override("package_filter", ...) is invisible for the process lifetime. We might want to follow-up / re-validate config-backed singleton invalidations for a cohesive approach.
Leaving this conversation marked un-resolved so that it serves as a stub for a potential investigation/issue-creation before resolving fully, even though the code-level comment is addressed.
|
Oh, I'm also wondering if we should deprecate |
b80ba21 to
540b0d8
Compare
Add tests for: - from_pod module-level function round-trip (the code path the plugin refactor will change) - isinstance checks against imported class names (will catch function-shim breakage) - get_orderer default fallback to SortedOrder(descending=True) Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…ySoftwareFoundation#1787) Move the five built-in package orderers (NullPackageOrder, SortedOrder, PerFamilyOrder, VersionSplitPackageOrder, TimestampPackageOrder) from src/rez/package_order.py into src/rezplugins/package_order/ as proper rez plugins. Register PackageOrderPluginType in plugin_managers.py. Replace PR AcademySoftwareFoundation#1787's function shims with lazy module-level __getattr__ aliases (PEP 562) so isinstance, from_pod, and type(x) is checks all work, while avoiding circular imports at module load time. Keep _orderers dict and register_orderer() as legacy fallback, marked with deprecation comments. Original work by Robert Minsk (PR AcademySoftwareFoundation#1787). Rebased, conflicts resolved, and fixed by Stephen Mackenzie. Signed-off-by: Robert Minsk <robertminsk@yahoo.com> Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
Add tests for: - Plugin system loads all five built-in orderers - to_pod/from_pod round-trip through the plugin system - Legacy register_orderer fallback - REZ_PACKAGE_ORDERERS_JSON end-to-end configuration (simulated via config.override since the test framework uses a locked config) - Cache invalidation for config changes - Test-only kwarg-orderer validates the AcademySoftwareFoundation#1706/AcademySoftwareFoundation#1709 pattern Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
Add documentation for: - REZ_PACKAGE_ORDERERS_JSON environment variable configuration - Plugin-based custom orderer approach (preferred over register_orderer) - Cache invalidation for runtime config changes Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
Update plugin files to match main's post-AcademySoftwareFoundation#1761 code: - Add type annotations (Version, SupportsLessThan, Package, etc.) - Add missing imports (each plugin now self-contained) - Use 'is' instead of '==' for type comparisons (no E721) - Fix E203 whitespace before ':' in soft_timestamp.py slice - Match __eq__, to_pod, from_pod, __init__ signatures from main Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…r resets test_plugin_manager resets the plugin manager between test runs, which deletes rezplugins.* from sys.modules and re-registers all plugin types. This creates new class objects for orderer plugins. Tests that imported orderer classes at module level (from rez.package_order import SortedOrder) were bound to stale class objects, causing isinstance and __eq__ failures when the full test suite ran in CI. Fix: resolve orderer classes in setUp() via _find_orderer() so each test method gets the current class objects. Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…methods Covers: sort_key with VersionRange/None/invalid types, FallbackComparable fallback path, _find_orderer with unknown name, __getattr__ AttributeError, register_orderer valid/invalid, PackageOrderList dirty-flag methods, to_pod/from_pod round-trip, PerFamilyOrder sort_key_implementation with default_order fallback and RuntimeError path. Raises orderer test coverage from 85% to 97%. Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…gin docs Addresses review threads on package_order.py: the legacy registry dict was defined twice (the second definition silently reset nothing but confused readers), and the register_orderer docstring now cross-references the plugin documentation properly. Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
get_plugin_class now raises PluginNotFoundError (a RezPluginError subclass) instead of the generic RezPluginError, so callers can distinguish a missing plugin from other plugin-system failures without breaking existing broad handlers. package_order._find_orderer uses the specific class for its registry-fallback logic, and the unknown-name test asserts both the specific class and the subclass relationship. Addresses review feedback suggesting a more specific plugin error class. Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
540b0d8 to
cdade03
Compare
PackageOrderList.singleton caches a snapshot of config.package_orderers,
and runtime changes need both the singleton snapshot AND the config-level
cache invalidated. The two runtime pathways differ:
- config.override()/remove_override() invalidate the config-level cache
themselves;
- the environment-variable pathway (REZ_PACKAGE_ORDERERS_JSON set after
first access) has no public invalidation hook - only the private
config._uncache() reaches it (verified: clear-only left a stale list).
clear_singleton_cache() now calls config._uncache("package_orderers")
internally, so users have a single public entry point covering both
pathways and never touch the private API. Verified end-to-end for both
the API-override and env-var pathways.
Addresses review concern about requiring a private API for runtime
reconfiguration.
Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…ntation PR AcademySoftwareFoundation#2189 added generic documentation for the REZ_XXX_JSON configuration pathway (configuring_rez.rst, environment.rst), so the package-orderers page now links to it instead of re-documenting the mechanism, keeping only an orderer-specific example. The runtime note now points at PackageOrderList.clear_singleton_cache() as the single invalidation entry point. Addresses review feedback about documenting JSON environment variables. Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
The legacy module-level aliases (NullPackageOrder, PerFamilyOrder, SortedOrder, TimestampPackageOrder, VersionSplitPackageOrder) now emit a RezDeprecationWarning when accessed, nudging users towards the plugin system - as requested in review. This was blocked by the AcademySoftwareFoundation#2230 circular import (importing rez.deprecations from package_order's lazy __getattr__ broke under REZ_LOG_DEPRECATION_WARNINGS=1); AcademySoftwareFoundation#2238 fixed that, and this was verified warning-and-import clean on the rebased branch. Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
cdade03 to
748797f
Compare
Summary
Rebases and fixes #1787 by @cfxegbert
Moves the 5 built-in package-orderers from
src/rez/package_order.pytosrc/rezplugins/package_order/as proper rez plugins.Adds runtime configuration support via
REZ_PACKAGE_ORDERERS_JSONand cache invalidation, creating a platform for PRs #1706 + #1709 to land in a usable manner with minimal changes.What changed (on top of the PR #1787 rebase+fixing)
PackageOrderPluginTypeinplugin_managers.py__getattr__lazy aliases, soisinstance,from_pod,type(x) ischecks all work against the imported class names, while avoiding a circular import that module-level aliases would cause (plugin files import from package_order.py, which would call_find_orderer-> plugin system at load time)register_orderer()and the_orderersdict as a means to subclass/apply orderers programmatically.Runtime configuration of Package Orderers
REZ_PACKAGE_ORDERERS_JSONworks end-to-end using the existing_JSONenv-var configuration pathway that then feeds intoconfig.package_orderers->PackageOrderList.singleton->from_pod()PackageOrderList.clear_singleton_cache()classmethod to invalidate the cached singleton, so runtime config changes can take effect without restarting, or API-based-usage of the feature can be correctly managed.Documentation
REZ_PACKAGE_ORDERERS_JSONusage section todocs/source/package_orderers.rstregister_orderer()Design Notes
SortedOrder = _find_orderer('sorted')at module level, but this causes a circular import (package_order.py->_find_orderer()-> plugin system ->rezplugins/package_order/sorted.py->from rez.package_order import PackageOrder-> still importing). The__getattr__approach defers resolution to the first attribute access, breaking the cycle.REZ_PACKAGE_ORDERERS_JSONpath by parsing JSON and usingconfig.override()which is what the_JSONpath does internally.Testing
from_podround-trip,isinstanceagainst imported classes,get_ordererdefault fallbackto_pod/from_podround-trip through the plugin system, legacyregister_ordererfallback, runtime config viaconfig.override(simulating the_JSONpath), cache invalidation, and a test-only kwarg-orderer that validates the pattern used in Add a package orderer that matches Python's version specifier spec (PEP440) #1706 / Added CustomPackageOrder #1709 (constructor kwargs configured at runtime).Credit
Original refactor by @cfxegbert . Rebased on to current main, conflicts resolved, backward-compat shims fixed, and runtime configuration support added by me.
Follow-on work (not here)
PackageOrderclass names (and other namings/imports/etc) toPackageOrdererfor making-more-sense?rezpluginsto join the rest.Disclosure: This PR was assisted by GLM-5.2 for docstrings, documentation, and test generation.