-
Notifications
You must be signed in to change notification settings - Fork 65
add wait_until_running() function [ART-5] #3549
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
base: main
Are you sure you want to change the base?
Conversation
…en scheduled to a worker
This is a little confusing to me. The name implies that the function will block until the Sandbox has been scheduled. So under what circumstances does it raise? |
Did you consider making this a parameter of |
Oh my bad, I initially thought I've added support for a |
modal/sandbox.py
Outdated
@@ -320,6 +320,7 @@ async def create( | |||
] = None, # Experimental controls over fine-grained scheduling (alpha). | |||
client: Optional[_Client] = None, | |||
environment_name: Optional[str] = None, # *DEPRECATED* Optionally override the default environment | |||
wait_for_scheduled: bool = False, # Enables waiting for the sandbox to be assigned to worker before returning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would wait_until_running
be a better name? I'm having trouble parsing wait_for_scheduled
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah wait_for_scheduled
could be confusing. I will change it to wait_until_running
.
modal/sandbox.py
Outdated
@@ -320,7 +320,7 @@ async def create( | |||
] = None, # Experimental controls over fine-grained scheduling (alpha). | |||
client: Optional[_Client] = None, | |||
environment_name: Optional[str] = None, # *DEPRECATED* Optionally override the default environment | |||
wait_for_scheduled: bool = False, # Enables waiting for the sandbox to be assigned to worker before returning | |||
wait_until_running: bool = False, # Enable waiting for the sandbox to be assigned to a worker before returning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait_until_running: bool = False, # Enable waiting for the sandbox to be assigned to a worker before returning | |
wait_until_running: bool = False, # Wait for the sandbox to start running before returning |
The "worker" concept is part of our internal ontology but not something we really expose to users. And it's redundant to say "Enable ..." when you have a boolean parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I can get rid of the references to a worker in the comments and the use of enable.
modal/sandbox.py
Outdated
@@ -706,8 +706,8 @@ async def _get_task_id(self) -> str: | |||
await asyncio.sleep(0.5) | |||
return self._task_id | |||
|
|||
async def wait_for_scheduled(self) -> None: | |||
"""Allows user to wait for the sandbox to be scheduled onto a worker.""" | |||
async def wait_until_running(self) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a usecase for a public method here if we're going to have a boolean for it in the constructor? Could the constructor call self._get_task_id()
directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, that makes sense. I can get rid of the extra method and just directly call get_task_id()
in the _create()
function.
…tionality just with constructor parameter
We discussed this on the Agent Runtime team and are in favor of this being a separate method rather than a sandbox parameter for these reasons:
My vote is to remove the constructor arg and support only the method. |
OK — FWIW I actually think that I would have expected Not sure if it's weird to have |
to let user check if sandbox has been scheduled to a worker
UPDATED: replacing
wait_for_scheduled
name withwait_until_running
Describe your changes
This PR provides a user facing API to check if their sandbox has been assigned onto a worker (Linear Issue ART-5 in agent runtime).
It exposes a
wait_until_running()
function that can be utilized to check if the sandbox has been assigned to a worker, raising an error if no worker is assigned and returning None if a worker gets assigned.Checklists
Compatibility checklist
Check these boxes or delete any item (or this section) if not relevant for this PR.
Note on protobuf: protobuf message changes in one place may have impact to
multiple entities (client, server, worker, database). See points above.
Changelog
wait_until_running()
function to Sandbox class that wraps the_get_task_id()
function for a discoverable method to check if your sandbox has been assigned to a worker.