-
Notifications
You must be signed in to change notification settings - Fork 0
Migrate converters to metaclass-registry for auto-registration #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…sed converters Co-authored-by: trissim <56880052+trissim@users.noreply.github.com>
Co-authored-by: trissim <56880052+trissim@users.noreply.github.com>
…urity documentation Co-authored-by: trissim <56880052+trissim@users.noreply.github.com>
Co-authored-by: trissim <56880052+trissim@users.noreply.github.com>
Co-authored-by: trissim <56880052+trissim@users.noreply.github.com>
Co-authored-by: trissim <56880052+trissim@users.noreply.github.com>
|
@copilot why is he minmum version of metaclass-regitry 0.4.0? doesn't even exist. don't specify a minimum version unecessarily |
Co-authored-by: trissim <56880052+trissim@users.noreply.github.com>
|
@copilot I see mention of backwards compatibility layers. Get rid of them and make eveyrhting usgin the metaclass-regsitry pattern properly. no bloat |
…entation Co-authored-by: trissim <56880052+trissim@users.noreply.github.com>
Done in cbf3253. Removed all backward compatibility layers:
Now using pure metaclass-registry pattern with no bloat. All converters auto-register directly via |
Migrate converters to metaclass-registry system ✅ COMPLETE
Summary:
Successfully migrated arraybridge converters to use metaclass-registry for automatic registration and discovery. All converters now auto-register via the
AutoRegisterMetametaclass with a clean implementation - no backward compatibility bloat.Key Achievements:
Recent Updates:
Files Changed:
pyproject.toml: Added metaclass-registry dependency (no version constraint)src/arraybridge/converters_registry.py: New registry infrastructure (168 lines)src/arraybridge/conversion_helpers.py: DELETED (was backward compatibility layer)src/arraybridge/types.py: Updated converter property (1 line change)src/arraybridge/converters.py: Updated to use registry (-2 lines)tests/test_converters_registry.py: Registry tests (109 lines)tests/test_registry_integration.py: Integration tests (130 lines, removed backward compat test)ADDING_NEW_FRAMEWORKS.md: Developer guide (updated to reflect clean implementation)MIGRATION_SUMMARY.md: Complete migration summary (updated to reflect clean implementation)Clean Implementation Benefits:
Original prompt
GitHub Copilot Chat Assistant
Short answer
Why it fits (based on the repos)
Recommended integration pattern
Create a Converter base class that uses the metaclass:
registry_key = "memory_type"
memory_type: str = None
def to_numpy(...): ...
optional: factory/instance method
Implement each framework converter as a subclass that sets memory_type to the same string used in MemoryType (e.g., "numpy", "torch"). Those classes will auto-register into ConverterBase.registry.
Replace _CONVERTERS lookups with registry lookups:
Ensure discovery/imports:
Concrete example (conceptual)
class ConverterBase(metaclass=AutoRegisterMeta):
registry_key = "memory_type"
memory_type: str = None
def to_numpy(self, data, gpu_id): raise NotImplementedError
# optional factory
class NumpyConverter(ConverterBase):
memory_type = "numpy"
def to_numpy(self, data, gpu_id): return data # no-op
def get_converter(mem_type_str):
cls = ConverterBase.registry.get(mem_type_str)
if cls is None: raise ValueError(...)
return cls() # or return cls if you prefer singleton classes
@Property
def converter(self):
return get_converter(self.value)
Migration steps (practical)
Benefits you’ll get
Pitfalls and how to avoid them
Extras to consider (from metaclass-registry features)
Tests to add
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.