{"id":4534,"library":"fiddle","title":"Fiddle: A Python-first configuration library","description":"Fiddle is a Python-first configuration library designed particularly for machine learning applications. It enables deep configurability of parameters in a program, allowing configurations to be expressed in readable and maintainable Python code. It aims to reduce boilerplate and provides good error messages. The library is currently at version 0.3.0 and is actively developed by Google.","status":"active","version":"0.3.0","language":"python","source_language":"en","source_url":"https://github.com/google/fiddle","tags":["configuration","machine learning","dependency injection","config-management"],"install":[{"cmd":"pip install fiddle","lang":"bash","label":"Basic Installation"},{"cmd":"pip install fiddle[flags]","lang":"bash","label":"With CLI Flag Support (absl-py)"}],"dependencies":[{"reason":"Provides command-line flag support when installed with the 'flags' extra.","package":"absl-py","optional":true}],"imports":[{"note":"The official documentation and examples consistently use the `fdl` alias for `fiddle`.","symbol":"fiddle","correct":"import fiddle as fdl"},{"symbol":"Config","correct":"from fiddle import Config"}],"quickstart":{"code":"import fiddle as fdl\n\ndef create_greeting(prefix: str, name: str = \"World\", punctuation: str = \"!\"):\n    return f\"{prefix} {name}{punctuation}\"\n\n# Create a Fiddle configuration for the function\ncfg = fdl.Config(create_greeting, prefix=\"Hello\", name=\"Fiddle\")\n\n# Build the configured function to get the result\nresult = fdl.build(cfg)\nprint(f\"Original Fiddle build: {result}\")\n\n# Modify the configuration\ncfg.punctuation = \"!!\"\nresult_modified = fdl.build(cfg)\nprint(f\"Modified Fiddle build: {result_modified}\")\n\n# Demonstrate fdl.Partial, which returns a functools.partial object\npartial_cfg = fdl.Partial(create_greeting, prefix=\"Hi\")\npartial_func = fdl.build(partial_cfg) # This returns a functools.partial object\nresult_partial = partial_func(name=\"Python\") # Call the partial function\nprint(f\"Partial Fiddle build: {result_partial}\")","lang":"python","description":"This quickstart demonstrates how to define configurations for Python callables using `fdl.Config` and `fdl.Partial`, and then build them using `fdl.build()`. `fdl.Config` directly builds the callable with the specified arguments, while `fdl.Partial` returns a `functools.partial` object that can be called later."},"warnings":[{"fix":"Be prepared for API adjustments and refer to release notes when upgrading. Consider pinning minor versions in production environments.","message":"Fiddle is currently in 'Development Status :: 3 - Alpha'. This means the API is not yet stable, and breaking changes may occur in future releases.","severity":"breaking","affected_versions":"0.x.x (especially pre-1.0.0)"},{"fix":"Always use `None` as a default argument, and then initialize the mutable object inside the function if `None` is passed. Example: `def func(arg=None): arg = arg or []`.","message":"Using mutable default arguments (e.g., lists, dictionaries) in functions configured by Fiddle can lead to unexpected shared state across different configurations or calls. Python evaluates default arguments once when the function is defined.","severity":"gotcha","affected_versions":"All Python versions, relevant for Fiddle configurations"},{"fix":"Understand the distinction: use `fdl.Config` when you want the immediate result of the callable's execution, and `fdl.Partial` when you want a configurable, pre-filled callable that can be invoked later with additional arguments.","message":"`fdl.Config` and `fdl.Partial` behave differently when `fdl.build()` is called. `fdl.Config` directly invokes the callable and returns its result, while `fdl.Partial` returns a `functools.partial` object that needs to be called separately to get the final result.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'0.3.0':58 'activ':61 'aim':43 'allow':31 'applic':21 'boilerpl':46 'code':41 'config':71 'config-manag':70 'configur':6,14,25,32,65 'current':55 'deep':24 'depend':68 'design':16 'develop':62 'enabl':23 'error':50 'express':35 'fiddl':1,8 'first':5,13 'good':49 'googl':64 'inject':69 'learn':20,67 'librari':7,15,53 'machin':19,66 'maintain':39 'manag':72 'messag':51 'paramet':27 'particular':17 'program':30 'provid':48 'python':4,12,40 'python-first':3,11 'readabl':37 'reduc':45 'version':57","created_at":"2026-04-12T13:56:46.095271+00:00","updated_at":"2026-04-16T15:00:57.791657+00:00","problems":[{"fix":"Install the library using pip: `pip install fiddle`","cause":"The `fiddle` library is not installed in the current Python environment or the import statement has a typo.","error":"ModuleNotFoundError: No module named 'fiddle'"},{"fix":"Ensure that the configuration value, particularly when using `fdl_flags.DEFINE_fiddle_config` with string defaults, is properly resolved into an `fdl.Buildable` instance. This may involve explicitly building the configuration if it's still a list of command strings.","cause":"A Fiddle configuration, often sourced from `fdl_flags` or a default string, was expected to be an `fdl.Buildable` object (like `fdl.Config` or `fdl.Partial`) but instead resulted in a standard Python list, preventing further Fiddle operations.","error":"TypeError: Configuration did not resolve to an fdl.Buildable. Got: <class 'list'>"},{"fix":"Review how `default_module` is defined and how configurations are referenced. Ensure that Fiddle's parsing mechanisms correctly resolve names to `fdl.Buildable` objects or actual modules/callables, rather than leaving them as unresolved strings within a list that is then treated as a configuration object.","cause":"This error often occurs when Fiddle's name resolution logic or `fdl.build()` attempts to access an attribute on what it expects to be an `fdl.Buildable` (e.g., a configured module or recipe) but is instead a Python list. This can happen when `default_module` is a list and Fiddle tries to interpret a string as an attribute of an item within that list.","error":"AttributeError: 'list' object has no attribute '...'"},{"fix":"Ensure you are using the latest version of the `fiddle` library by running `pip install --upgrade fiddle`. If the issue persists, simplify the configuration that triggers the error, or consult the `fiddle` documentation/issue tracker for similar cases.","cause":"This is an internal `AttributeError` within the `fiddle` library, specifically related to the `__qualname__` attribute in `fiddle.config.py`. While a fix for this specific issue has been implemented, it might be encountered with older versions of the library or in specific, complex scenarios related to how Python objects are qualified within Fiddle's configuration system.","error":"AttributeError: module 'fiddle.config' has no attribute '__qualname__'"},{"fix":"Carefully check the `fdl.Config` definition against the signature of the target function or class (`<callable_name>`). Correct any misspelled parameter names, provide all required positional and keyword arguments, and ensure argument types are compatible if type hints are present.","cause":"When using `fdl.Config` to configure a function or class, `fiddle` passes the configured arguments directly to the underlying callable. If the arguments provided to `fdl.Config` do not match the expected parameters of the callable (e.g., misspelled keyword arguments, missing required arguments, or incorrect number of positional arguments), Python will raise a standard `TypeError`.","error":"TypeError: <callable_name>() got an unexpected keyword argument '...' OR TypeError: <callable_name>() missing 1 required positional argument: '...'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.3.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://google.github.io/fiddle/","github":"https://github.com/google/fiddle","docs":"https://github.com/google/fiddle/docs","changelog":null,"pypi":"https://pypi.org/project/fiddle/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-30","next_check":"2026-07-28","install_tag":null}}