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

Validation for lightweight components #793

Merged
merged 9 commits into from
Jan 22, 2024

Conversation

mrchtr
Copy link
Contributor

@mrchtr mrchtr commented Jan 18, 2024

Adding validation to the PythonComponent.

  • change BaseComponents methods to abstractmethods
  • validate that all abstractmethods were implemented in the PythonComponent
  • validate that the function interface is the same as in the BaseComponents

Fix #783

@mrchtr mrchtr marked this pull request as ready for review January 18, 2024 10:10
@GeorgesLorre
Copy link
Collaborator

One thing I noticed while writing tests:

@lightweight_component()
    class Foo(DaskLoadComponent):
        def load(self) -> str:
            return ["bar"]works

but

@lightweight_component
    class Foo(DaskLoadComponent):
        def load(self) -> str:
            return ["bar"]

does not

Notice the () on the decorator. It might be nice to support both or at least throw a clear error.

@mrchtr
Copy link
Contributor Author

mrchtr commented Jan 22, 2024

One thing I noticed while writing tests:

@lightweight_component()
    class Foo(DaskLoadComponent):
        def load(self) -> str:
            return ["bar"]works

but

@lightweight_component
    class Foo(DaskLoadComponent):
        def load(self) -> str:
            return ["bar"]

does not

Notice the () on the decorator. It might be nice to support both or at least throw a clear error.

Added the support for both variants. When we call the decorator without parentheses the default values of the Image will be used.

Copy link
Collaborator

@GeorgesLorre GeorgesLorre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice ! We can still expand once we discover more cases.

@mrchtr mrchtr merged commit f07ea5b into main Jan 22, 2024
11 checks passed
@mrchtr mrchtr deleted the feature/validation-for-lightweight-components branch January 22, 2024 13:09
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.

Add validation to lightweight python component decorator
4 participants