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: 17 additions & 0 deletions src/runloop_api_client/sdk/async_.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,23 @@ class AsyncBlueprintOps:
... dockerfile="FROM ubuntu:22.04\\nRUN apt-get update",
... )
>>> blueprints = await runloop.blueprint.list()

To use a local directory as a build context, use an object.

Example:
>>> from datetime import timedelta
>>> from runloop_api_client.types.blueprint_build_parameters import BuildContext
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From an ergonomics standpoint, this is pretty ugly. I don't think we should try to fix this now, but it would be nice to avoid needing to pollute the imports with a bunch of specific types.

For this specific case, what if the storage Object had a to_build_context()? Then we skip the import and just do

blueprint = await runloop.blueprint.create(
... name="my-blueprint",
... dockerfile="FROM ubuntu:22.04\nCOPY . .\n",
... build_context=obj.to_build_context(),
... )

>>>
>>> runloop = AsyncRunloopSDK()
>>> obj = await runloop.object_storage.upload_from_dir(
... "./",
... ttl=timedelta(hours=1),
... )
>>> blueprint = await runloop.blueprint.create(
... name="my-blueprint",
... dockerfile="FROM ubuntu:22.04\\nCOPY . .\\n",
... build_context=BuildContext(type="object", object_id=obj.id),
... )
"""

def __init__(self, client: AsyncRunloop) -> None:
Expand Down
17 changes: 17 additions & 0 deletions src/runloop_api_client/sdk/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,23 @@ class BlueprintOps:
... name="my-blueprint", dockerfile="FROM ubuntu:22.04\\nRUN apt-get update"
... )
>>> blueprints = runloop.blueprint.list()

To use a local directory as a build context, use an object.

Example:
>>> from datetime import timedelta
>>> from runloop_api_client.types.blueprint_build_parameters import BuildContext
>>>
>>> runloop = RunloopSDK()
>>> obj = runloop.object_storage.upload_from_dir(
... "./",
... ttl=timedelta(hours=1),
... )
>>> blueprint = runloop.blueprint.create(
... name="my-blueprint",
... dockerfile="FROM ubuntu:22.04\\nCOPY . .\\n",
... build_context=BuildContext(type="object", object_id=obj.id),
... )
"""

def __init__(self, client: Runloop) -> None:
Expand Down