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
18 changes: 1 addition & 17 deletions README-SDK.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,15 +434,6 @@ build_ctx_obj = runloop.storage_object.upload_from_bytes(
content_type="tgz",
)

shared_root = Path("./shared-lib")
shared_tar = build_docker_context_tar(shared_root)

shared_ctx_obj = runloop.storage_object.upload_from_bytes(
data=shared_tar,
name="shared-lib-context.tar.gz",
content_type="tgz",
)

blueprint_with_context = runloop.blueprint.create(
name="my-blueprint-with-context",
dockerfile="""\
Expand All @@ -453,18 +444,11 @@ WORKDIR /usr/src/app
COPY package.json package.json
COPY src src

# copy from named context
COPY --from=shared / ./libs

RUN npm install --only=production
CMD ["node", "src/app.js"]
""",
# Primary build context
# Build context
build_context=build_ctx_obj.as_build_context(),
# Additional named build contexts (for Docker buildx-style usage)
named_build_contexts={
"shared": shared_ctx_obj.as_build_context(),
},
)

# Or get an existing one
Expand Down
4 changes: 0 additions & 4 deletions src/runloop_api_client/resources/blueprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ def create_and_await_build_complete(
file_mounts: Optional[Dict[str, str]] | Omit = omit,
launch_parameters: Optional[LaunchParameters] | Omit = omit,
metadata: Optional[Dict[str, str]] | Omit = omit,
named_build_contexts: Optional[Dict[str, blueprint_create_params.NamedBuildContexts]] | Omit = omit,
secrets: Optional[Dict[str, str]] | Omit = omit,
services: Optional[Iterable[blueprint_create_params.Service]] | Omit = omit,
system_setup_commands: Optional[SequenceNotStr[str]] | Omit = omit,
Expand Down Expand Up @@ -365,7 +364,6 @@ def create_and_await_build_complete(
file_mounts=file_mounts,
launch_parameters=launch_parameters,
metadata=metadata,
named_build_contexts=named_build_contexts,
secrets=secrets,
services=services,
system_setup_commands=system_setup_commands,
Expand Down Expand Up @@ -966,7 +964,6 @@ async def create_and_await_build_complete(
file_mounts: Optional[Dict[str, str]] | Omit = omit,
launch_parameters: Optional[LaunchParameters] | Omit = omit,
metadata: Optional[Dict[str, str]] | Omit = omit,
named_build_contexts: Optional[Dict[str, blueprint_create_params.NamedBuildContexts]] | Omit = omit,
secrets: Optional[Dict[str, str]] | Omit = omit,
services: Optional[Iterable[blueprint_create_params.Service]] | Omit = omit,
system_setup_commands: Optional[SequenceNotStr[str]] | Omit = omit,
Expand Down Expand Up @@ -1006,7 +1003,6 @@ async def create_and_await_build_complete(
file_mounts=file_mounts,
launch_parameters=launch_parameters,
metadata=metadata,
named_build_contexts=named_build_contexts,
secrets=secrets,
services=services,
system_setup_commands=system_setup_commands,
Expand Down
33 changes: 13 additions & 20 deletions src/runloop_api_client/sdk/async_.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from ..lib.context_loader import TarFilter, build_directory_tar
from .async_storage_object import AsyncStorageObject
from ..types.object_create_params import ContentType
from ..types.shared_params.agent_source import Git, Npm, Pip, Object


class AsyncDevboxOps:
Expand Down Expand Up @@ -622,18 +623,16 @@ async def create_from_npm(
"Cannot specify 'source' when using create_from_npm(); source is automatically set to npm configuration"
)

npm_config: dict = {"package_name": package_name}
npm_config: Npm = {"package_name": package_name}
if npm_version is not None:
npm_config["npm_version"] = npm_version
if registry_url is not None:
npm_config["registry_url"] = registry_url
if agent_setup is not None:
npm_config["agent_setup"] = agent_setup

return await self.create(
source={"type": "npm", "npm": npm_config},
**params,
)
params["source"] = {"type": "npm", "npm": npm_config}
return await self.create(**params)

async def create_from_pip(
self,
Expand Down Expand Up @@ -664,18 +663,16 @@ async def create_from_pip(
"Cannot specify 'source' when using create_from_pip(); source is automatically set to pip configuration"
)

pip_config: dict = {"package_name": package_name}
pip_config: Pip = {"package_name": package_name}
if pip_version is not None:
pip_config["pip_version"] = pip_version
if registry_url is not None:
pip_config["registry_url"] = registry_url
if agent_setup is not None:
pip_config["agent_setup"] = agent_setup

return await self.create(
source={"type": "pip", "pip": pip_config},
**params,
)
params["source"] = {"type": "pip", "pip": pip_config}
return await self.create(**params)

async def create_from_git(
self,
Expand Down Expand Up @@ -703,16 +700,14 @@ async def create_from_git(
"Cannot specify 'source' when using create_from_git(); source is automatically set to git configuration"
)

git_config: dict = {"repository": repository}
git_config: Git = {"repository": repository}
if ref is not None:
git_config["ref"] = ref
if agent_setup is not None:
git_config["agent_setup"] = agent_setup

return await self.create(
source={"type": "git", "git": git_config},
**params,
)
params["source"] = {"type": "git", "git": git_config}
return await self.create(**params)

async def create_from_object(
self,
Expand All @@ -737,14 +732,12 @@ async def create_from_object(
"Cannot specify 'source' when using create_from_object(); source is automatically set to object configuration"
)

object_config: dict = {"object_id": object_id}
object_config: Object = {"object_id": object_id}
if agent_setup is not None:
object_config["agent_setup"] = agent_setup

return await self.create(
source={"type": "object", "object": object_config},
**params,
)
params["source"] = {"type": "object", "object": object_config}
return await self.create(**params)

def from_id(self, agent_id: str) -> AsyncAgent:
"""Attach to an existing agent by ID.
Expand Down
4 changes: 2 additions & 2 deletions src/runloop_api_client/sdk/async_storage_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ async def upload_content(self, content: str | bytes | Iterable[bytes]) -> None:
def as_build_context(self) -> BuildContext:
"""Return this object in the shape expected for a Blueprint build context.

The returned mapping can be passed directly to ``build_context`` or
``named_build_contexts`` when creating a blueprint.
The returned mapping can be passed directly to ``build_context``
when creating a blueprint.

:return: Mapping suitable for use as a blueprint build context
:rtype: BuildContext
Expand Down
4 changes: 2 additions & 2 deletions src/runloop_api_client/sdk/storage_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ def upload_content(self, content: str | bytes | Iterable[bytes]) -> None:
def as_build_context(self) -> BuildContext:
"""Return this object in the shape expected for a Blueprint build context.

The returned mapping can be passed directly to ``build_context`` or
``named_build_contexts`` when creating a blueprint.
The returned mapping can be passed directly to ``build_context``
when creating a blueprint.

:return: Mapping suitable for use as a blueprint build context
:rtype: BuildContext
Expand Down
33 changes: 13 additions & 20 deletions src/runloop_api_client/sdk/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from .storage_object import StorageObject
from ..lib.context_loader import TarFilter, build_directory_tar
from ..types.object_create_params import ContentType
from ..types.shared_params.agent_source import Git, Npm, Pip, Object


class DevboxOps:
Expand Down Expand Up @@ -622,18 +623,16 @@ def create_from_npm(
"Cannot specify 'source' when using create_from_npm(); source is automatically set to npm configuration"
)

npm_config: dict = {"package_name": package_name}
npm_config: Npm = {"package_name": package_name}
if npm_version is not None:
npm_config["npm_version"] = npm_version
if registry_url is not None:
npm_config["registry_url"] = registry_url
if agent_setup is not None:
npm_config["agent_setup"] = agent_setup

return self.create(
source={"type": "npm", "npm": npm_config},
**params,
)
params["source"] = {"type": "npm", "npm": npm_config}
return self.create(**params)

def create_from_pip(
self,
Expand Down Expand Up @@ -669,18 +668,16 @@ def create_from_pip(
"Cannot specify 'source' when using create_from_pip(); source is automatically set to pip configuration"
)

pip_config: dict = {"package_name": package_name}
pip_config: Pip = {"package_name": package_name}
if pip_version is not None:
pip_config["pip_version"] = pip_version
if registry_url is not None:
pip_config["registry_url"] = registry_url
if agent_setup is not None:
pip_config["agent_setup"] = agent_setup

return self.create(
source={"type": "pip", "pip": pip_config},
**params,
)
params["source"] = {"type": "pip", "pip": pip_config}
return self.create(**params)

def create_from_git(
self,
Expand Down Expand Up @@ -716,16 +713,14 @@ def create_from_git(
"Cannot specify 'source' when using create_from_git(); source is automatically set to git configuration"
)

git_config: dict = {"repository": repository}
git_config: Git = {"repository": repository}
if ref is not None:
git_config["ref"] = ref
if agent_setup is not None:
git_config["agent_setup"] = agent_setup

return self.create(
source={"type": "git", "git": git_config},
**params,
)
params["source"] = {"type": "git", "git": git_config}
return self.create(**params)

def create_from_object(
self,
Expand Down Expand Up @@ -758,14 +753,12 @@ def create_from_object(
"Cannot specify 'source' when using create_from_object(); source is automatically set to object configuration"
)

object_config: dict = {"object_id": object_id}
object_config: Object = {"object_id": object_id}
if agent_setup is not None:
object_config["agent_setup"] = agent_setup

return self.create(
source={"type": "object", "object": object_config},
**params,
)
params["source"] = {"type": "object", "object": object_config}
return self.create(**params)

def from_id(self, agent_id: str) -> Agent:
"""Attach to an existing agent by ID.
Expand Down
3 changes: 1 addition & 2 deletions tests/sdk/test_async_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,6 @@ async def test_create(self, mock_async_client: AsyncMock, agent_view: MockAgentV
client = AsyncAgentOps(mock_async_client)
agent = await client.create(
name="test-agent",
metadata={"key": "value"},
)

assert isinstance(agent, AsyncAgent)
Expand Down Expand Up @@ -838,7 +837,7 @@ async def test_list(self, mock_async_client: AsyncMock) -> None:
mock_async_client.agents.list = AsyncMock(return_value=page)

# Mock retrieve to return the corresponding agent_view when called
async def mock_retrieve(agent_id, **_unused_kwargs):
async def mock_retrieve(agent_id: str):
if agent_id == "agent_001":
return agent_view_1
elif agent_id == "agent_002":
Expand Down
1 change: 0 additions & 1 deletion tests/sdk/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,6 @@ def test_create(self, mock_client: Mock, agent_view: MockAgentView) -> None:
client = AgentOps(mock_client)
agent = client.create(
name="test-agent",
metadata={"key": "value"},
)

assert isinstance(agent, Agent)
Expand Down
Loading