-
I have trouble using fl_ctx in the Swarm Learning controller (nvflare/app_common/ccwf/swarm_client_ctl.py). I wanted to use fl_ctx to pass aggr info from SwarmClientController._scatter (swarm_client_ctl.py:376) to Gatherer.aggregate (swarm_client_ctl.py:161). At swarm_client_ctl.py:376, if I assign aggr to new prop of fl_ctx, like: But If I use existing prop name, like: Can anyone advise on how to do this right? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
When setting a new prop of fl_ctx, there should be no issues with this, is Retrieving the public prop from the Gatherer requires an additional step given that setting the prop and getting the prop can occur across different sites (since the scattering client can be different from the gathering client). The FL Context contains a peer context that contains public props when processing a message from another party (https://nvflare.readthedocs.io/en/main/programming_guide/fl_context.html#peer-context-fl-ctx-get-peer-context). However a peer context is only available in certain situations for cross-component data sharing (eg. certain callback functions, execute(), and handle_event() etc). In swarm_client_ctl.py:161, the fl_ctx of the Gatherer does contain a peer context (if you trace the fl_ctx all the way back, it comes from client_ctl.py:375 which is in execute()). Thus we can use Lastly, for this specific example, the |
Beta Was this translation helpful? Give feedback.
-
Add to @SYangster 's point, So:
Or: |
Beta Was this translation helpful? Give feedback.
-
Thanks @SYangster and @YuanTingHsieh . My issue was solved by both of your suggestions combined. |
Beta Was this translation helpful? Give feedback.
When setting a new prop of fl_ctx, there should be no issues with this, is
CURRENT_AGGR
a str?Retrieving the public prop from the Gatherer requires an additional step given that setting the prop and getting the prop can occur across different sites (since the scattering client can be different from the gathering client).
The FL Context contains a peer context that contains public props when processing a message from another party (https://nvflare.readthedocs.io/en/main/programming_guide/fl_context.html#peer-context-fl-ctx-get-peer-context). However a peer context is only available in certain situations for cross-component data sharing (eg. certain callback functions, execute(), and handl…