Skip to content

add support for _call_ = False in config_to_dict (so bare function or class)#3

Closed
thomasloux wants to merge 4 commits intomainfrom
feat/support-function-config-to-dict
Closed

add support for _call_ = False in config_to_dict (so bare function or class)#3
thomasloux wants to merge 4 commits intomainfrom
feat/support-function-config-to-dict

Conversation

@thomasloux
Copy link
Copy Markdown

No description provided.

@thomasloux thomasloux changed the title add support for _call_ = False (so bare function) add support for _call_ = False in config_to_dict (so bare function or class) Jan 26, 2026
@thomasloux thomasloux requested a review from acecchini January 26, 2026 15:06
@thomasloux
Copy link
Copy Markdown
Author

@acecchini I need this code for my auto generation of config for Matune. But it also actually solves a TODO that was in comments in your code

@acecchini
Copy link
Copy Markdown
Owner

Ok I'll take care of this ASAP

@thomasloux
Copy link
Copy Markdown
Author

thomasloux commented Jan 26, 2026

I should add tests, but that's for later I think. Here is an example:

from math import sqrt
import fiddledyn
class Test:
  def __init__(self, fn):
    self.fn = fn

import fiddle
a = fiddle.Config(Test, fn=sqrt)
print(a)
b = fiddledyn.config_to_dict(a)
print(b)
c = fiddledyn.dict_to_config(b)
print(c)
d = fiddle.build(c)
assert a.fn == d.fn # assert passes

Which give

<Config[Test(fn=<built-in function sqrt>)]>
{'_target_': '__main__.Test', 'fn': {'_target_': 'math.sqrt', '_call_': False}}
<Config[Test(fn=<built-in function sqrt>)]>

@acecchini
Copy link
Copy Markdown
Owner

I have updated fiddledyn, the code has undergone substantial refactoring. A new test suite was developed and all tests pass now. Please check out the updated README.md and the new public API.

In particular parse_cli has now a as_dict option (which is by default set to False).

Furthermore, when setting include_defaults=True in config_to_dict method, fiddledyn will now check for manually unbound arguments which have a default value and will fetch the WHOLE subgraph found in the default value (so all of its nested callables will be interpreted as nested subgraphs in nested and will be wrapped in{fiddle, nemo_run}.{Config, Partial} objects).

Finally, nemo-run is now optional to reduce dependency graph of the repo. If you ever need nemo-run config objects please add it into your pyproject.toml with the square bracket syntax, i.e. fiddledyn[nemo]. Everything is expalined in the README.md

@acecchini acecchini closed this Jan 26, 2026
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.

2 participants