Added the simulation_id as parameter to the Redis channel name, in or…#234
Added the simulation_id as parameter to the Redis channel name, in or…#234
Conversation
…der to be able to connect to a simulation using a specific id even when running via Redis. Ignored messages from areas that are not registered to this sdk execution.
…ll simulations but only to the one defined by simulation_id (which is empty string for the case of tests).
mrsaemir
left a comment
There was a problem hiding this comment.
LGTM with 1 suggestion. Thanks a lot.
| @@ -145,9 +145,9 @@ def test_constructor_connect_and_subscribe_side_effects_3(): | |||
| -> Side effects of _subscribe_to_response_channels private method | |||
| """ | |||
| aggregator = RedisAggregator(aggregator_name=TEST_AGGREGATOR_NAME) | |||
There was a problem hiding this comment.
I would suggest to set the simulation_id on the aggregatator to also test the part where the init function is reading simulation_id from env variables. That can potentially make your test even more robust. Thanks a lot.
| channel_dict_2 = {f"external-aggregator/*/{aggregator.aggregator_uuid}/events" | ||
| channel_dict_2 = {f"external-aggregator//{aggregator.aggregator_uuid}/events" | ||
| f"/all": aggregator._events_callback_dict, | ||
| f"external-aggregator/*/{aggregator.aggregator_uuid}/response" |
There was a problem hiding this comment.
So this * is not needed any more in the subscribe pattern?
There was a problem hiding this comment.
It was never needed actually. This * represents that the aggregator subsribes to all responses from all simulations. Up until now it was fine because we were only running one simulation, however it could not work correctly if we run more than one simulation at the same time. To be more detailed, this pattern will match both following channels:
external-aggregator/sim1/aggregator1/response
external-aggregator/sim2/aggregator1/response
Of course, we never fell upon this case because we are protected by the uuid of the aggregator (which is unique, therefore the channel name is also unique - in other words, there is never the case that the uuid e.g. aggregator1 will be generated for both simulations). Nevertheless, does not hurt to make it more detailed only listen to channels that are destined for one specific simulation. Hence I removed this.
There was a problem hiding this comment.
Thank you for the verbose answer! I still wonder though: What does the absence of the * mean?
Doesn't it also mean:
the aggregator subsribes to all responses from all simulations
?
There was a problem hiding this comment.
Sorry took a long time to check it out. Actually the * is not absent, it is just replaced with the actual simulation id, therefore each SDK instance will connect only to one simulation with this specified ID. What you describe here :
the aggregator subsribes to all responses from all simulations
was the former behavior, because the * in the channel name subscribed to all responses from all simulations. Now that * is replaced with the actual simulation id , the aggregator subscribes to all responses from one specific simulation.
Ah, and if your question was actually asking what would this mean external-aggregator//aggregator1/response , this would match all responses sent in that exact channel, since no wildcard is part of the channel.
hannesdiedrich
left a comment
There was a problem hiding this comment.
Once Amirhosseins' comment is dealt with, LGTM
…of unit tests, in order to test that the simulation id set by the variable is correctly passed to the channel name. Modified test that does not explicitly test the simulation_id assignment to use the aggregator._simulation_id variable in order to be future-proof.
…der to be able to connect to a simulation using a specific id even when running via Redis. Ignored messages from areas that are not registered to this sdk execution.
Reason for the proposed changes
Please describe what we want to achieve and why.
Proposed changes
INTEGRATION_TESTS_BRANCH=master
GSY_E_TARGET_BRANCH=fix_external_load_forecast_strategy
GSY_FRAMEWORK_BRANCH=master