Skip to content

Commit 6928652

Browse files
authored
cleanup(blueprints): remove references to named_build_contexts (#703)
* uv lock upgrade * remove references to named_build_context * add type annotations for agent create sources * remove metadata, _unused_kwargs parameters in agent unit tests
1 parent ea91ef6 commit 6928652

9 files changed

Lines changed: 279 additions & 287 deletions

File tree

README-SDK.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -434,15 +434,6 @@ build_ctx_obj = runloop.storage_object.upload_from_bytes(
434434
content_type="tgz",
435435
)
436436

437-
shared_root = Path("./shared-lib")
438-
shared_tar = build_docker_context_tar(shared_root)
439-
440-
shared_ctx_obj = runloop.storage_object.upload_from_bytes(
441-
data=shared_tar,
442-
name="shared-lib-context.tar.gz",
443-
content_type="tgz",
444-
)
445-
446437
blueprint_with_context = runloop.blueprint.create(
447438
name="my-blueprint-with-context",
448439
dockerfile="""\
@@ -453,18 +444,11 @@ WORKDIR /usr/src/app
453444
COPY package.json package.json
454445
COPY src src
455446
456-
# copy from named context
457-
COPY --from=shared / ./libs
458-
459447
RUN npm install --only=production
460448
CMD ["node", "src/app.js"]
461449
""",
462-
# Primary build context
450+
# Build context
463451
build_context=build_ctx_obj.as_build_context(),
464-
# Additional named build contexts (for Docker buildx-style usage)
465-
named_build_contexts={
466-
"shared": shared_ctx_obj.as_build_context(),
467-
},
468452
)
469453

470454
# Or get an existing one

src/runloop_api_client/resources/blueprints.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ def create_and_await_build_complete(
325325
file_mounts: Optional[Dict[str, str]] | Omit = omit,
326326
launch_parameters: Optional[LaunchParameters] | Omit = omit,
327327
metadata: Optional[Dict[str, str]] | Omit = omit,
328-
named_build_contexts: Optional[Dict[str, blueprint_create_params.NamedBuildContexts]] | Omit = omit,
329328
secrets: Optional[Dict[str, str]] | Omit = omit,
330329
services: Optional[Iterable[blueprint_create_params.Service]] | Omit = omit,
331330
system_setup_commands: Optional[SequenceNotStr[str]] | Omit = omit,
@@ -365,7 +364,6 @@ def create_and_await_build_complete(
365364
file_mounts=file_mounts,
366365
launch_parameters=launch_parameters,
367366
metadata=metadata,
368-
named_build_contexts=named_build_contexts,
369367
secrets=secrets,
370368
services=services,
371369
system_setup_commands=system_setup_commands,
@@ -966,7 +964,6 @@ async def create_and_await_build_complete(
966964
file_mounts: Optional[Dict[str, str]] | Omit = omit,
967965
launch_parameters: Optional[LaunchParameters] | Omit = omit,
968966
metadata: Optional[Dict[str, str]] | Omit = omit,
969-
named_build_contexts: Optional[Dict[str, blueprint_create_params.NamedBuildContexts]] | Omit = omit,
970967
secrets: Optional[Dict[str, str]] | Omit = omit,
971968
services: Optional[Iterable[blueprint_create_params.Service]] | Omit = omit,
972969
system_setup_commands: Optional[SequenceNotStr[str]] | Omit = omit,
@@ -1006,7 +1003,6 @@ async def create_and_await_build_complete(
10061003
file_mounts=file_mounts,
10071004
launch_parameters=launch_parameters,
10081005
metadata=metadata,
1009-
named_build_contexts=named_build_contexts,
10101006
secrets=secrets,
10111007
services=services,
10121008
system_setup_commands=system_setup_commands,

src/runloop_api_client/sdk/async_.py

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from ..lib.context_loader import TarFilter, build_directory_tar
3939
from .async_storage_object import AsyncStorageObject
4040
from ..types.object_create_params import ContentType
41+
from ..types.shared_params.agent_source import Git, Npm, Pip, Object
4142

4243

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

625-
npm_config: dict = {"package_name": package_name}
626+
npm_config: Npm = {"package_name": package_name}
626627
if npm_version is not None:
627628
npm_config["npm_version"] = npm_version
628629
if registry_url is not None:
629630
npm_config["registry_url"] = registry_url
630631
if agent_setup is not None:
631632
npm_config["agent_setup"] = agent_setup
632633

633-
return await self.create(
634-
source={"type": "npm", "npm": npm_config},
635-
**params,
636-
)
634+
params["source"] = {"type": "npm", "npm": npm_config}
635+
return await self.create(**params)
637636

638637
async def create_from_pip(
639638
self,
@@ -664,18 +663,16 @@ async def create_from_pip(
664663
"Cannot specify 'source' when using create_from_pip(); source is automatically set to pip configuration"
665664
)
666665

667-
pip_config: dict = {"package_name": package_name}
666+
pip_config: Pip = {"package_name": package_name}
668667
if pip_version is not None:
669668
pip_config["pip_version"] = pip_version
670669
if registry_url is not None:
671670
pip_config["registry_url"] = registry_url
672671
if agent_setup is not None:
673672
pip_config["agent_setup"] = agent_setup
674673

675-
return await self.create(
676-
source={"type": "pip", "pip": pip_config},
677-
**params,
678-
)
674+
params["source"] = {"type": "pip", "pip": pip_config}
675+
return await self.create(**params)
679676

680677
async def create_from_git(
681678
self,
@@ -703,16 +700,14 @@ async def create_from_git(
703700
"Cannot specify 'source' when using create_from_git(); source is automatically set to git configuration"
704701
)
705702

706-
git_config: dict = {"repository": repository}
703+
git_config: Git = {"repository": repository}
707704
if ref is not None:
708705
git_config["ref"] = ref
709706
if agent_setup is not None:
710707
git_config["agent_setup"] = agent_setup
711708

712-
return await self.create(
713-
source={"type": "git", "git": git_config},
714-
**params,
715-
)
709+
params["source"] = {"type": "git", "git": git_config}
710+
return await self.create(**params)
716711

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

740-
object_config: dict = {"object_id": object_id}
735+
object_config: Object = {"object_id": object_id}
741736
if agent_setup is not None:
742737
object_config["agent_setup"] = agent_setup
743738

744-
return await self.create(
745-
source={"type": "object", "object": object_config},
746-
**params,
747-
)
739+
params["source"] = {"type": "object", "object": object_config}
740+
return await self.create(**params)
748741

749742
def from_id(self, agent_id: str) -> AsyncAgent:
750743
"""Attach to an existing agent by ID.

src/runloop_api_client/sdk/async_storage_object.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ async def upload_content(self, content: str | bytes | Iterable[bytes]) -> None:
165165
def as_build_context(self) -> BuildContext:
166166
"""Return this object in the shape expected for a Blueprint build context.
167167
168-
The returned mapping can be passed directly to ``build_context`` or
169-
``named_build_contexts`` when creating a blueprint.
168+
The returned mapping can be passed directly to ``build_context``
169+
when creating a blueprint.
170170
171171
:return: Mapping suitable for use as a blueprint build context
172172
:rtype: BuildContext

src/runloop_api_client/sdk/storage_object.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ def upload_content(self, content: str | bytes | Iterable[bytes]) -> None:
165165
def as_build_context(self) -> BuildContext:
166166
"""Return this object in the shape expected for a Blueprint build context.
167167
168-
The returned mapping can be passed directly to ``build_context`` or
169-
``named_build_contexts`` when creating a blueprint.
168+
The returned mapping can be passed directly to ``build_context``
169+
when creating a blueprint.
170170
171171
:return: Mapping suitable for use as a blueprint build context
172172
:rtype: BuildContext

src/runloop_api_client/sdk/sync.py

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from .storage_object import StorageObject
3838
from ..lib.context_loader import TarFilter, build_directory_tar
3939
from ..types.object_create_params import ContentType
40+
from ..types.shared_params.agent_source import Git, Npm, Pip, Object
4041

4142

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

625-
npm_config: dict = {"package_name": package_name}
626+
npm_config: Npm = {"package_name": package_name}
626627
if npm_version is not None:
627628
npm_config["npm_version"] = npm_version
628629
if registry_url is not None:
629630
npm_config["registry_url"] = registry_url
630631
if agent_setup is not None:
631632
npm_config["agent_setup"] = agent_setup
632633

633-
return self.create(
634-
source={"type": "npm", "npm": npm_config},
635-
**params,
636-
)
634+
params["source"] = {"type": "npm", "npm": npm_config}
635+
return self.create(**params)
637636

638637
def create_from_pip(
639638
self,
@@ -669,18 +668,16 @@ def create_from_pip(
669668
"Cannot specify 'source' when using create_from_pip(); source is automatically set to pip configuration"
670669
)
671670

672-
pip_config: dict = {"package_name": package_name}
671+
pip_config: Pip = {"package_name": package_name}
673672
if pip_version is not None:
674673
pip_config["pip_version"] = pip_version
675674
if registry_url is not None:
676675
pip_config["registry_url"] = registry_url
677676
if agent_setup is not None:
678677
pip_config["agent_setup"] = agent_setup
679678

680-
return self.create(
681-
source={"type": "pip", "pip": pip_config},
682-
**params,
683-
)
679+
params["source"] = {"type": "pip", "pip": pip_config}
680+
return self.create(**params)
684681

685682
def create_from_git(
686683
self,
@@ -716,16 +713,14 @@ def create_from_git(
716713
"Cannot specify 'source' when using create_from_git(); source is automatically set to git configuration"
717714
)
718715

719-
git_config: dict = {"repository": repository}
716+
git_config: Git = {"repository": repository}
720717
if ref is not None:
721718
git_config["ref"] = ref
722719
if agent_setup is not None:
723720
git_config["agent_setup"] = agent_setup
724721

725-
return self.create(
726-
source={"type": "git", "git": git_config},
727-
**params,
728-
)
722+
params["source"] = {"type": "git", "git": git_config}
723+
return self.create(**params)
729724

730725
def create_from_object(
731726
self,
@@ -758,14 +753,12 @@ def create_from_object(
758753
"Cannot specify 'source' when using create_from_object(); source is automatically set to object configuration"
759754
)
760755

761-
object_config: dict = {"object_id": object_id}
756+
object_config: Object = {"object_id": object_id}
762757
if agent_setup is not None:
763758
object_config["agent_setup"] = agent_setup
764759

765-
return self.create(
766-
source={"type": "object", "object": object_config},
767-
**params,
768-
)
760+
params["source"] = {"type": "object", "object": object_config}
761+
return self.create(**params)
769762

770763
def from_id(self, agent_id: str) -> Agent:
771764
"""Attach to an existing agent by ID.

tests/sdk/test_async_ops.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,6 @@ async def test_create(self, mock_async_client: AsyncMock, agent_view: MockAgentV
793793
client = AsyncAgentOps(mock_async_client)
794794
agent = await client.create(
795795
name="test-agent",
796-
metadata={"key": "value"},
797796
)
798797

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

840839
# Mock retrieve to return the corresponding agent_view when called
841-
async def mock_retrieve(agent_id, **_unused_kwargs):
840+
async def mock_retrieve(agent_id: str):
842841
if agent_id == "agent_001":
843842
return agent_view_1
844843
elif agent_id == "agent_002":

tests/sdk/test_ops.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,6 @@ def test_create(self, mock_client: Mock, agent_view: MockAgentView) -> None:
716716
client = AgentOps(mock_client)
717717
agent = client.create(
718718
name="test-agent",
719-
metadata={"key": "value"},
720719
)
721720

722721
assert isinstance(agent, Agent)

0 commit comments

Comments
 (0)