kalgory-com / kalgory-py

Python client library for kalgory
Mozilla Public License 2.0
0 stars 0 forks source link

Bridging between WebAssembly component and library consumer #5

Closed ZhaoTzuHsien closed 1 month ago

ZhaoTzuHsien commented 1 month ago

In this pull request, user can define Block class with arbitrary handle() logic and parameters, as well as enforcing static WIT definition at the same time. Besides, pytest, ruff, code climate, and related GitHub Actions workflow has been integrated to improve code quality. After the parsing logic in BaseBlock.execute() has been implemented, we can release the first version of this library.

ChuWeiChang commented 1 month ago

why is the output component/block.baseblock the class name? Follow up, where did you wrap users' handle() method

ZhaoTzuHsien commented 1 month ago

why is the output component/block.baseblock the class name? Follow up, where did you wrap users' handle() method

@ChuWeiChang I cannot understand your first question. Please clarify it.

The user-defined handle() function has been illustrated at the test block, which is located at tests/guest.py.

ChuWeiChang commented 1 month ago

I was saying, isn't execute function supposed to run user's "handle" function? You may change the function name in guest.py from "handle" to any other name and the program still compiles, which is a bit odd. I expect there some codes like user_handle_funtion = getattr(cls, "handle") return user_handle_function(payload)

ZhaoTzuHsien commented 1 month ago

That is the code you need to write, which stated at #5. I just provided a method called _find_block_class() to let you get the __class__ object of the user-defined Block class. https://github.com/kalgory-com/kalgory-py/blob/059648b28e42b125aa6322c3a9747ee2b5bf0e3f/kalgory/component/block.py#L10-L20

ChuWeiChang commented 1 month ago

OK i see. I will take on the task from now

ZhaoTzuHsien commented 1 month ago

Before you start implementing #5, accept the review if you don't find any other problems.