Skip to content
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

Bm/on-build-descriptors #27

Merged
merged 3 commits into from
Dec 5, 2023
Merged

Conversation

BenjaminMidtvedt
Copy link
Collaborator

@BenjaminMidtvedt BenjaminMidtvedt commented Dec 1, 2023

Add some descriptors for methods that specify that those methods should be run on the build cycle.

This is intended for developers.

The main utility is that methods that live on the build life cycle are now guaranteed to operate on the final object. So these configurations are ensured to survive .new(). By default, only the operations done in __init__ and configure survive new.

In the future, it may be worth it to make configure such a hook as well.

Example:

class MyModule(DeeplayModule)
    @after_build
    def set(self, name, value):
        setattr(self, name, value 

module = MyModule()
module.set("foo", 10)

module.foo # AttributeError

module.build()

module.foo # 10

@BenjaminMidtvedt BenjaminMidtvedt merged commit a869744 into develop Dec 5, 2023
12 checks passed
@BenjaminMidtvedt BenjaminMidtvedt deleted the bm/on-build-descriptors branch December 5, 2023 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants