Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add delayed container start #131

Merged
merged 10 commits into from
Nov 4, 2024
Merged

add delayed container start #131

merged 10 commits into from
Nov 4, 2024

Conversation

maurerle
Copy link
Collaborator

@maurerle maurerle commented Oct 30, 2024

This solves having sync creation of as_agent_process.

fixes #129

This is based on top of the described wanted behavior in: maurerle@eaccade

Dill has to be dumped on the creation of the mirror agent function and not later.
Otherwise this leads to very unexpected behavior (storing the state of the variables at the time of dumping, which is then the same for all delayed agent_creators, leading to duplicate agent ids)

Furthermore, it was missing to call on_ready in mirror containers, which is fixed as well through this PR

This is the case for containers created by a MirrorContainerProcessManager
This was a weird bug which saved the state at the time of the delayed start.
Instead we need to serializer the  agent_creator function at the creation of the agent process in create_agent_process
@maurerle maurerle marked this pull request as ready for review October 31, 2024 08:10
@maurerle maurerle force-pushed the add_mp_tests branch 2 times, most recently from ac4f8bb to 2925aa0 Compare October 31, 2024 08:15
Copy link

codecov bot commented Oct 31, 2024

Codecov Report

Attention: Patch coverage is 92.68293% with 3 lines in your changes missing coverage. Please review.

Project coverage is 88.92%. Comparing base (b0c1850) to head (a080e76).
Report is 13 commits behind head on development.

Files with missing lines Patch % Lines
mango/container/mp.py 95.65% 1 Missing ⚠️
mango/container/mqtt.py 50.00% 1 Missing ⚠️
mango/container/tcp.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           development     #131      +/-   ##
===============================================
+ Coverage        88.65%   88.92%   +0.27%     
===============================================
  Files               22       22              
  Lines             2407     2448      +41     
===============================================
+ Hits              2134     2177      +43     
+ Misses             273      271       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@rcschrg rcschrg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One further comment: as this feature is really relevant for users, documenting using docstrings might not be enough, a short hint in the documentation would make sense too.

mango/container/mp.py Outdated Show resolved Hide resolved
@@ -444,6 +449,21 @@ def _find_sp_queue(self, aid):
raise ValueError(f"The aid '{aid}' does not exist in any subprocess.")

def create_agent_process(self, agent_creator, container, mirror_container_creator):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the design, it makes sense that delayed starting agent processes is an additional feature. I do not feel the prior approach was bad. Being able to start the process at will before starting the container makes sense as it is closer to the normal agent lifecycle. So I would suggest to introduce a new method for delayed agent process start (or a flag?). This also would prevent breaking the API.

) in self._agent_process_init_list:
await self.create_internal_agent_process(
agent_creator, container, mirror_container_creator
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be using asyncio.gather instead to decrease runtime

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gather did not work somehow, as the ProcessHandle is unhashable..
Using a poor men's version of gather now instead

@maurerle
Copy link
Collaborator Author

maurerle commented Nov 1, 2024

It probably helps to only review the changes since yesterday's review:

9cf064a...add_mp_tests

@rcschrg rcschrg merged commit 155e5cd into development Nov 4, 2024
11 checks passed
@maurerle maurerle deleted the add_mp_tests branch November 4, 2024 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

as_agent_process requires to serialize whole self scope
2 participants