Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions baseten/sandbox/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,22 +362,17 @@ def create(
info = sandbox_info_from_api(sandbox)
return SandboxCreateResult(self._sandbox_context(info.name, info.url), info)

def get_info(self, *, name: str, show_secrets: bool | None = None) -> SandboxInfo:
def get_info(self, *, name: str) -> SandboxInfo:
"""Get a sandbox's current record.

Args:
name: Name of the sandbox.
show_secrets: Reveal environment variable values for workspace
administrators. Defaults to false. Callers without the admin
role receive masked values even when true.
"""
with self._control_api() as api:
sandbox = api.get_sandbox(
sandbox_name=name,
params=baseten.client.managementapi.GetSandboxParams(
**set_fields(
team_id=self._options.team_id, show_secrets=show_secrets
)
**set_fields(team_id=self._options.team_id)
),
)
return sandbox_info_from_api(sandbox)
Expand Down Expand Up @@ -742,17 +737,13 @@ async def create(
self._sandbox_context(info.name, info.url), info
)

async def get_info(
self, *, name: str, show_secrets: bool | None = None
) -> SandboxInfo:
async def get_info(self, *, name: str) -> SandboxInfo:
"""Get a sandbox's current record. As :meth:`SandboxClient.get_info`."""
with self._control_api() as api:
sandbox = await api.get_sandbox(
sandbox_name=name,
params=baseten.client.managementapi.GetSandboxParams(
**set_fields(
team_id=self._options.team_id, show_secrets=show_secrets
)
**set_fields(team_id=self._options.team_id)
),
)
return sandbox_info_from_api(sandbox)
Expand Down
3 changes: 1 addition & 2 deletions baseten/sandbox/_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ class SandboxEnvValue:
secret: bool | None = None
"""Whether the value is a secret. Defaults to true.

Secret values come back masked as ``"****"``, unless read with
``show_secrets``.
Secret values come back masked as ``"****"``.
"""


Expand Down
11 changes: 0 additions & 11 deletions tests/sandbox/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,6 @@ def test_omits_team_id_when_unset(self) -> None:
api.client().get_info(name="sbx")
assert "team_id" not in api.requests[0].url.params

def test_gets_info_with_show_secrets_only_when_set(self) -> None:
api = _Api()
api.route("GET", "/v1/sandboxes/instances/sbx", _record())
client = api.client()
client.get_info(name="sbx")
client.get_info(name="sbx", show_secrets=True)
assert [r.url.params.get("show_secrets") for r in api.requests] == [
None,
"true",
]

def test_gets_sandbox_by_name_with_call_and_from_record_without(self) -> None:
api = _Api()
api.route("GET", "/v1/sandboxes/instances/sbx", _record())
Expand Down
18 changes: 0 additions & 18 deletions tests/sandbox/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,24 +176,6 @@ async def test_gets_record(
}


@pytest.mark.asyncio
async def test_gets_record_with_secrets_revealed(
client: SandboxClient | AsyncSandboxClient, shared: _Shared
) -> None:
# The e2e key is a workspace admin, so secrets are revealed.
if isinstance(client, SandboxClient):
info = await asyncio.to_thread(
client.get_info, name=shared.name, show_secrets=True
)
else:
info = await client.get_info(name=shared.name, show_secrets=True)
assert info.envs == {
"E2E_PLAIN": SandboxEnvValue(value="plain-value", secret=False),
"E2E_SECRET": SandboxEnvValue(value="secret-value", secret=True),
"E2E_DEFAULT": SandboxEnvValue(value="default-value", secret=True),
}


@pytest.mark.asyncio
async def test_gets_sandbox_by_name_record_and_url(
client: SandboxClient | AsyncSandboxClient, shared: _Shared
Expand Down
Loading