infra PR1: deployment provider registry + plugin discovery#16
Conversation
📚 Documentation Status✅ Code changes detected
This comment is automatically generated by the documentation workflow. |
| if not callable(loaded_factory): | ||
| raise TypeError("entry point did not resolve to a callable provider factory") | ||
| register_provider(provider_name, loaded_factory) | ||
| except Exception as exc: # pragma: no cover - exercised via tests with monkeypatch |
There was a problem hiding this comment.
Inaccurate pragma comment
The # pragma: no cover comment says "exercised via tests with monkeypatch", which contradicts the purpose of a no cover annotation. The monkeypatch test test_discover_providers_loads_entry_points_and_tracks_broken_plugins does exercise the _bad_loader path through this except block. If the test is already covering this branch, the pragma: no cover should be removed so coverage accurately reflects the tested paths.
Prompt To Fix With AI
This is a comment left during a code review.
Path: neural/deployment/registry.py
Line: 82
Comment:
**Inaccurate pragma comment**
The `# pragma: no cover` comment says "exercised via tests with monkeypatch", which contradicts the purpose of a `no cover` annotation. The monkeypatch test `test_discover_providers_loads_entry_points_and_tracks_broken_plugins` does exercise the `_bad_loader` path through this `except` block. If the test is already covering this branch, the `pragma: no cover` should be removed so coverage accurately reflects the tested paths.
How can I resolve this? If you propose a fix, please make it concise.| _DOCKER_AVAILABLE = False | ||
| _DOCKER_IMPORT_ERROR = exc | ||
|
|
||
| class DockerDeploymentProvider: # type: ignore[override] |
There was a problem hiding this comment.
Incorrect mypy suppression directive
The # type: ignore[override] comment is not the correct mypy error code for this situation. Redefining a name in the same module scope is flagged by mypy as no-redef, not override (which is for method override mismatches in subclasses). This should be # type: ignore[no-redef] to suppress the correct diagnostic.
| class DockerDeploymentProvider: # type: ignore[override] | |
| class DockerDeploymentProvider: # type: ignore[no-redef] |
Prompt To Fix With AI
This is a comment left during a code review.
Path: neural/deployment/__init__.py
Line: 81
Comment:
**Incorrect mypy suppression directive**
The `# type: ignore[override]` comment is not the correct mypy error code for this situation. Redefining a name in the same module scope is flagged by mypy as `no-redef`, not `override` (which is for method override mismatches in subclasses). This should be `# type: ignore[no-redef]` to suppress the correct diagnostic.
```suggestion
class DockerDeploymentProvider: # type: ignore[no-redef]
```
How can I resolve this? If you propose a fix, please make it concise.
Summary
neural.deploymentprovider registry APIs:register_provider,create_provider,list_providersneural.deployment.providersValidation
ruff check neural/deployment/__init__.py neural/deployment/registry.py tests/deployment/test_registry.pypytest -q tests/deployment/test_registry.pypytest -q tests/test_public_api.pyGreptile Summary
This PR implements a deployment provider registry and plugin discovery system that enables external packages to contribute deployment backends without modifying SDK source code.
Core Infrastructure Changes:
neural.deployment.registrymodule withregister_provider,create_provider, andlist_providersAPIsneural.deployment.providersgroupProviderNotFoundErrorwhen Docker dependencies are unavailableError Handling:
DeploymentProviderinstances are returnedTesting & Documentation:
Unrelated Changes:
neural.auth.polymarket_us_envhelper functionsneural.auth.signers.polymarket_usandtests.exchanges.test_polymarket_streamingThe architecture follows established Python packaging patterns (entry points) and maintains backward compatibility by preserving direct
DockerDeploymentProviderimports while adding the registry layer.Confidence Score: 5/5
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[User calls create_provider name] --> B[discover_providers] B --> C{Plugins discovered?} C -->|No| D[Load entry points from neural.deployment.providers] C -->|Yes| E[Check normalized name] D --> F{Entry point loads?} F -->|Success| G[register_provider] F -->|Failure| H[Store in _provider_load_errors] G --> E H --> E E --> I{Name in _provider_load_errors?} I -->|Yes| J[Raise ProviderNotFoundError with load error] I -->|No| K{Name in _provider_factories?} K -->|No| L[Raise ProviderNotFoundError with available list] K -->|Yes| M[Call factory with kwargs] M --> N{Returns DeploymentProvider?} N -->|No| O[Raise ConfigurationError] N -->|Yes| P[Return provider instance]Last reviewed commit: acafb9f