-
Notifications
You must be signed in to change notification settings - Fork 15
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
feat: Make backend discoverable TCTC-3456 #1441
base: master
Are you sure you want to change the base?
Conversation
Your Render PR Server URL is https://weaverbird-playground-pr-1441.onrender.com. Follow its progress at https://dashboard.render.com/web/srv-cbhvl8arrk09qi6c49lg. |
Signed-off-by: Luka Peschke <luka.peschke@toucantoco.com>
TCTC-3456 Signed-off-by: Luka Peschke <luka.peschke@toucantoco.com>
2461ee4
to
9735663
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this, it's a very interesting for the architecture of the weaverbird's python module!
Your approach is nice and pragamatic, additive-only. The added features such as the minimum version are useful touches 👍
Yet I feel we kinda already have the same sort of information in the files where we import all steps in each backend that the one you put in the registry. Maybe we can think of something that would use it?
This would be to avoid an unfortunate state when we forget either the decorator or the import in the backend main method.
But this would probably mean reconsidering also how we write backends, maybe with an abstract base for all of them? Happy to discuss alternatives if you feel like it. Otherwise, it could also be a nice first version (if so, we need to update the documentation about how to add a step)
signature = inspect.signature(fn) | ||
if 'step' in signature.parameters: | ||
return cls._get_step_model(signature.parameters['step'].annotation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow nice use of the inspect
module 👍
|
||
def register(*args, **kwargs) -> Callable: | ||
called_with_kwargs = bool(kwargs) | ||
step_name = kwargs.pop('step_name', None) or args[0].__name__.replace('translate_', '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to add an enum and use everytime an explicit @register(step_name=...)
instead of the magic translate_...
.
We spend way more time reading and refactoring than writing new code
TCTC-3456
Signed-off-by: Luka Peschke luka.peschke@toucantoco.com