Replies: 5 comments 4 replies
-
@yanchengnv @YuanTingHsieh @yanchengnv, moved this topic to discussion. |
Beta Was this translation helpful? Give feedback.
-
This is a good/big topic. In any system development, there are intentional design decisions, and there are accidental decisions (side effects?) that just happened as part of the implementation detail. Intentional design decisions usually don't change easily (or major break would happen), whereas accidental decisions are subject to change. NVFLARE Core (the whole NVFLARE codebase minus app_common) itself tries to make as few major decisions as possible (so it can give maximum freedom to the applications). The examples you gave actually belong to app area (that's why they are in app_common). Regardless, they need to make design decisions, and apps built on top of them must live with their decisions. If you only look at the code without knowing the reasons of the coding, it won't be easy to know what is intentional (so you can depend on) and what is not. That's why we provided Best Practice for programming with NVFLARE. Still there are considerations that are not covered. As to async programming construct, NVFLARE provides the Responder API. During run time, NVFLARE is essentially (async) message-driven in that the server responds to messages from clients. But Responder is hard for researchers for workflow development, since it is not the programming paradigm they are used to (procedural). Hence we built the Controller API on top of Responder, which gives the users the feel of procedural programming. But if you look into the detail of Controller API implementation, everything is async. You can write a workflow as a Responder (instead of Controller). In fact, this is how we implemented the SAG behavior in old days. |
Beta Was this translation helpful? Give feedback.
-
Thanks this helped to clarify some thoughts. I think it is still not possible to write a clean workflow even with the Responder API. You still need to write the Perhaps my true issue is that the control flow is inverted. Really you want the server calling the shots. In such a situation writing a workflow is very simple for example.
In order to invert the control flow like this I think it would be necessary to rewrite the Some very rough pseudocode, there is probably a much cleaner way to do this without using
then rewrite your
Hope this make sense! |
Beta Was this translation helpful? Give feedback.
-
https://discuss.python.org/t/what-are-the-advantages-of-asyncio-over-threads/2112 Some discussion on the subject. You see how at the minimum you can clean up all the check abort calls with this kind of design. And some info from 0mq guide
The key line here is |
Beta Was this translation helpful? Give feedback.
-
@Nintorac very thoughtful and interesting discussion. although this discussion happens before I join the project. It still interesting to read through the thread. you seem to promoting the function program style ( no state, no site effect). I need to read few more time to capture all the details of the thoughts. thank you |
Beta Was this translation helpful? Give feedback.
-
Just trying to start a discussion here and get some inputs.
Working with the codebase I have come across several instances where state is being introduced to classes that isn't scoped by the calling functions. Done correctly this is probably fine but as the codebase grows more complex there is more opportunity to be bitten by some of the side effects
This does a few things
From what I see in a lot of the examples there is a lot of uses of side effects in this codebase.
Some examples:
In terms of solutions I am not overly confident in my own ideas here but it seems to me that some sort of async programming constructs would be invaluable for this project.
Beta Was this translation helpful? Give feedback.
All reactions