-
-
Notifications
You must be signed in to change notification settings - Fork 238
[Feature] Supporting dstack-inside-dstack for dev environments and tasks #4023
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
Open
peterschmidt85
wants to merge
10
commits into
master
Choose a base branch
from
codex/task-server-access
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,090
−8
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
979de8e
Add server access to tasks and dev environments
ebe8aa3
Update run response expectations
eec8991
Preserve compatibility with older servers
8d0dfd4
Fix server access retry timeout for starting jobs
065c6ab
Allow DSTACK_TOKEN to override the configured token
2c29b3a
Rename `server` to `dstack` in run configurations
c958855
Rename docs section to `dstack` inside `dstack`
93d455d
Follow the server bind address for job server access
e45abbf
Drop redundant pool lock in JobServerConnectionsPool
e428da5
Reject dstack access combined with inactivity_duration
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,16 @@ | ||
| from urllib.parse import quote | ||
|
|
||
| # shim (runs on the host) HTTP API port | ||
| DSTACK_SHIM_HTTP_PORT = 10998 | ||
| # runner (runs inside a container) HTTP API port | ||
| DSTACK_RUNNER_HTTP_PORT = 10999 | ||
| # ssh server (runs alongside the runner inside a container) listen port | ||
| DSTACK_RUNNER_SSH_PORT = 10022 | ||
| # Private socket created inside jobs that request access to the dstack server. | ||
| DSTACK_RUN_SERVER_SOCKET_PATH = "/run/dstack/server.sock" | ||
| DSTACK_RUN_SERVER_URL = f"http+unix://{quote(DSTACK_RUN_SERVER_SOCKET_PATH, safe='')}" | ||
| DSTACK_PROJECT_ENV = "DSTACK_PROJECT" | ||
| DSTACK_SERVER_URL_ENV = "DSTACK_SERVER_URL" | ||
| DSTACK_TOKEN_ENV = "DSTACK_TOKEN" | ||
| # legacy AWS, Azure, GCP, and OCI image for older GPUs | ||
| DSTACK_OS_IMAGE_WITH_PROPRIETARY_NVIDIA_KERNEL_MODULES = "0.10" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,40 @@ | ||
| import os | ||
| from typing import Optional, Tuple | ||
|
|
||
| import dstack._internal.core.services.configs as configs | ||
| from dstack._internal.core.consts import ( | ||
| DSTACK_PROJECT_ENV, | ||
| DSTACK_SERVER_URL_ENV, | ||
| DSTACK_TOKEN_ENV, | ||
| ) | ||
| from dstack._internal.core.errors import ConfigurationError | ||
| from dstack.api.server import APIClient | ||
|
|
||
|
|
||
| def get_api_client(project_name: Optional[str] = None) -> Tuple[APIClient, str]: | ||
| env_project_name = project_name or os.getenv(DSTACK_PROJECT_ENV) | ||
| server_url = os.getenv(DSTACK_SERVER_URL_ENV) | ||
| token = os.getenv(DSTACK_TOKEN_ENV) | ||
| if server_url is not None and token is not None: | ||
| if env_project_name is None: | ||
| raise ConfigurationError( | ||
| f"{DSTACK_SERVER_URL_ENV} and {DSTACK_TOKEN_ENV} are set," | ||
| f" but the project is not specified." | ||
| f" Set {DSTACK_PROJECT_ENV} or use --project" | ||
| ) | ||
| return APIClient(server_url, token), env_project_name | ||
|
|
||
| config = configs.ConfigManager() | ||
| project = config.get_project_config(project_name) | ||
| if project is None: | ||
| if server_url is not None: | ||
| raise ConfigurationError( | ||
| f"{DSTACK_SERVER_URL_ENV} is set, but {DSTACK_TOKEN_ENV} is not set" | ||
| ) | ||
| if project_name is not None: | ||
| raise ConfigurationError(f"Project {project_name} is not configured") | ||
| raise ConfigurationError("No default project, specify project name") | ||
| if token is not None: | ||
| # DSTACK_TOKEN overrides the configured token | ||
| return APIClient(project.url, token), project.name | ||
| return APIClient(project.url, project.token), project.name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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 reason not to support this new property for services? For example, it could be useful for agentic services that use
dstackto start sandboxes, or for monitoring / visualization services that usedstackas a data source