SIGN IN SIGN UP
langflow-ai / langflow UNCLAIMED

Langflow is a powerful tool for building and deploying AI-powered agents and workflows.

0 0 0 Python

feat(lfx): add adapter registries (#11990)

* checkout subservice implementation

* improve tests (added one, removed dead code) and handling of conflicting namespace registries

* introduce subservice types to scope and validate subservice registries by

* remove strict issubclass checks

* rename the feature to "adapter registry"

* refactor to /adapter directory

* major refactor to use shared config helpers

* refactor: align adapter registry with service manager patterns

- Use asyncio.iscoroutine for teardown (matches ServiceManager)
- Two-tier entry point error handling (warning vs debug)
- Add config load logging after adapter discovery
- Remove _get_nested_section wrapper, call shared helper directly
- Remove deployment/registry.py thin wrapper
- Export DeploymentServiceProtocol from services/__init__
- Extract test stubs into shared adapter_test_helpers module
- Revert incorrect ValueError->TypeError in schema validators

* refactor: remove adapter registry staging dict, derive config by convention

Align adapter registry with the service manager's @register_service
pattern: decorators now write directly to the AdapterRegistry singleton
instead of buffering in a module-level staging dict.

- register_adapter calls get_adapter_registry() + register_class()
  directly, removing _decorator_adapter_registry and _decorator_lock
- get_adapter_registry derives entry_point_group and
  config_section_path from AdapterType by convention, making them
  optional parameters
- Remove _discover_from_decorators() since decorators are already
  registered before discover() runs
- Fix discover_plugins docstring that incorrectly claimed decorators
  had highest priority (config files do)
- Simplify _reset_registries, deps.py, test helpers, and docs

* move AdapterType enum to dedicated schema file in /adapters

* move config dir resolution to shared helper

* move import logic to a shared helper

* [autofix.ci] apply automated fixes

* Fix encapsulation, error handling, thread safety, and test gaps in adapter registry

  - Encapsulate AdapterRegistry internal state behind private attrs and
    read-only properties (adapter_type, entry_point_group, config_section_path,
    is_discovered, has_cached_instances)
  - Re-raise unexpected exceptions in register_adapter decorator instead of
    silently swallowing them
  - Promote entry-point discovery catch-all from debug to warning with traceback
  - Wrap register_class in RLock for thread safety
  - Add try/except with context logging around factory calls in get_instance
  - Improve teardown_instances: preserve keys for error messages, add exc_info
  - Evict stale cached instances when register_class changes the class for a key
  - Narrow load_toml_config exception to ValueError (parent of TOMLDecodeError)
  - Split load_object_from_import_path error handling: expected import failures
    vs unexpected errors with traceback
  - Guard redundant discover() calls in get_deployment_adapter via is_discovered
  - Add tests for teardown exception isolation, sync teardown, and no-teardown
    adapters

* [autofix.ci] apply automated fixes

* tighten up documentation

* add locking mechanisms around more functions

* [autofix.ci] apply automated fixes

* test config discovery

* Add lock around discovery

* improve teardown concurrency, add more concurrency tests, and improve protocol parity

* use kwarg lambda

* release lock before iterating with awaits

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jordan Frazier <[email protected]>
H
Hamza Rashid committed
a9d913ae3fac325782521283fdbf8a5f790c3954
Parent: 902252e
Committed by GitHub <[email protected]> on 3/5/2026, 7:23:37 PM