tiqi-group / pydase

A flexible and robust Python library for creating, managing, and interacting with data services, with built-in support for web and RPC servers, and customizable features for diverse use cases.
MIT License
0 stars 1 forks source link

Skip coroutines with arguments instead of raising an exception #127

Closed mastadle closed 1 month ago

mastadle commented 1 month ago

Currently, a DataService can not contain a coroutine that takes arguments even if it is private. As far as I remember, the decision was to not support functions that take arguments in the frontend. But private functions are never exposed in the frontend, so it shouldn't be an issue.

mosmuell commented 1 month ago

Fair point. As public async functions will always be displayed as tasks in the frontend, I had to make sure that they cannot take arguments. I am not really happy with my solution. Async functions really should be able to take any arguments. I will think about this a bit more, probably converting "tasks" into a decorator or so. Async functions are then not regarded as tasks any more.

What do you think?

mastadle commented 1 month ago

Yes, that would make a lot of sense considering that there already is a frontend decorator for synchronous functions. It is not that important though.

This PR could be a reasonable stopgap solution until you get around to implement this. If you want to hide a coroutine, just add a dummy argument. If you need arguments in your coroutine, you can always add them directly to the class as attributes. Or even create a nested class for this purpose. A bit cumbersome and it could be automated but should be fine for now.