Skip to content

Conversation

@NeejWeej
Copy link
Collaborator

@NeejWeej NeejWeej commented Oct 2, 2025

This PR now adds
"update_from_base",
"from_python",

functions. update_from_base starts with a base object, applies updates, and then optionally converts to another class. from_python is a utility function to allow instantiating arbitrary python objects in hydra.

Original (outdated)

Add PathKeyResolverMixin which allows specifying some key/value pairs from python code via a PyObjectPath. This allows offloading some of the configuration to python, getting benefits from:
easier testability, cohesiveness of related configurations, and deduplication.

One specific workflow this helps with, is that partial functions can be constructed by taking a general CallableModel, and specializing (specifying specific/partial configuration options) it for various use-cases. The default resolved_wins, provides a (overrideable) check that pre-defined configurations in the code are not accidentally overwritten, and reduces the surface area exposed that could be overriden via yaml.

This functionality is opt-in, since base ccflow.BaseModel classes do not inherit from it via default.

Motivation (including in docs file added):

image

@github-actions
Copy link
Contributor

github-actions bot commented Oct 2, 2025

Test Results

468 tests  +25   464 ✅ +25   41s ⏱️ +2s
  1 suites ± 0     4 💤 ± 0 
  1 files   ± 0     0 ❌ ± 0 

Results for commit 4f7254d. ± Comparison against base commit 907c06a.

♻️ This comment has been updated with latest results.

@codecov
Copy link

codecov bot commented Oct 2, 2025

Codecov Report

❌ Patch coverage is 98.78049% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.20%. Comparing base (907c06a) to head (4f7254d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
ccflow/tests/utils/test_compose_hydra.py 93.33% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #128      +/-   ##
==========================================
+ Coverage   95.08%   95.20%   +0.11%     
==========================================
  Files         126      130       +4     
  Lines        7281     7524     +243     
  Branches      481      491      +10     
==========================================
+ Hits         6923     7163     +240     
- Misses        237      240       +3     
  Partials      121      121              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ptomecek
Copy link
Collaborator

This is a relatively big change, and I have to think about other ways of accomplishing this.

For example, instead of the configs referencing python paths of other configs, if those other configs were in the registry already, then the existing mechanisms would work to reference them. Then the question becomes how to take some model instances that are defined in python and add them as named objects to the registry. I think this may be doable leveraging hydra's _call_ abilities (i.e. instead of _target_) - i.e. you call a function in python that returns you some object and stick that in the registry under a given name. Then other registry objects can reference it as usual, and the logic for instantiating those objects just lives in python functions...

@NeejWeej
Copy link
Collaborator Author

NeejWeej commented Nov 1, 2025

This is a relatively big change, and I have to think about other ways of accomplishing this.

For example, instead of the configs referencing python paths of other configs, if those other configs were in the registry already, then the existing mechanisms would work to reference them. Then the question becomes how to take some model instances that are defined in python and add them as named objects to the registry. I think this may be doable leveraging hydra's _call_ abilities (i.e. instead of _target_) - i.e. you call a function in python that returns you some object and stick that in the registry under a given name. Then other registry objects can reference it as usual, and the logic for instantiating those objects just lives in python functions...

Good point. I added a function from_python that can be called with _target_ and just pulls an object from python (and since it's in hydra, we get it added to the registry for free)

Signed-off-by: Nijat Khanbabayev <[email protected]>
@NeejWeej NeejWeej changed the title Add mixin to allow pulling key-value pairs from python objects Provide utility functions to load an object from python into the regsitry, add model_copy_update to shallow copy and update a model Nov 1, 2025
Signed-off-by: Nijat Khanbabayev <[email protected]>
Signed-off-by: Nijat Khanbabayev <[email protected]>
@NeejWeej NeejWeej changed the title Provide utility functions to load an object from python into the regsitry, add model_copy_update to shallow copy and update a model Provide utility functions for calling from hydra Nov 2, 2025
@NeejWeej NeejWeej added the type: enhancement Minor improvements label Nov 2, 2025
Signed-off-by: Nijat Khanbabayev <[email protected]>
@NeejWeej NeejWeej requested a review from ptomecek November 3, 2025 20:09
@ptomecek ptomecek merged commit b496339 into main Nov 4, 2025
6 checks passed
@ptomecek ptomecek deleted the nk/add_mixin branch November 4, 2025 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement Minor improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants