Skip to content
Merged
4 changes: 2 additions & 2 deletions .dagger/modules/e2e/fixtures/collections/caller.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""A module that calls the shelf collection through its generated client.

keys, get, list, subset and batch exist only in the engine's projection of the
keys, get, list and subset exist only in the engine's projection of the
collection, so the client has them only if it was generated from that.
"""

Expand All @@ -16,5 +16,5 @@ async def report(self) -> str:
keys = await items.keys()
listed = [await item.name() for item in await items.list_()]
got = await items.get("a").name()
removed = await items.subset(["c"]).batch().removed()
removed = await items.subset(["c"]).removed()
return f"keys={keys} list={listed} get={got} removed={removed}"
14 changes: 4 additions & 10 deletions .dagger/modules/e2e/fixtures/collections/kinds.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Collections of every key type, copied into a module a check generates.

The keys are Int, Float, Boolean, an enum and a core scalar. Shelves returns
an item that is a collection itself. Items has a batch generator that
replaces its item's generator of the same name.
an item that is a collection itself. Item has a generator that writes a file
named after its item.
"""

import enum
Expand Down Expand Up @@ -119,8 +119,8 @@ class Item:
@function
@generate
def write(self) -> Changeset:
msg = "replaced item generator ran: " + self.name
raise ValueError(msg)
empty = core().directory()
return empty.with_new_file("selected-" + self.name, self.name).changes(empty)


@object_type
Expand All @@ -133,12 +133,6 @@ class Items:
def item(self, name: str) -> Item:
return Item(name=name)

@function
@generate
def write(self) -> Changeset:
empty = core().directory()
return empty.with_new_file("selected", ",".join(self.names)).changes(empty)

@function
def selected(self) -> list[str]:
return self.names
Expand Down
22 changes: 16 additions & 6 deletions .dagger/modules/e2e/fixtures/reach/reach.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def src_ctx(s: Context) -> Context:
# Mutations that clone and may reload the context.
for label, field, arg in (
("withName", "withName", Arg("name", "reach")),
("withSDK", "withSDK", Arg("source", "")),
("withSDK", "withSdk", Arg("source", "")),
("withEngineVersion", "withEngineVersion", Arg("version", "v1.0.0-0")),
):
add(
Expand Down Expand Up @@ -249,13 +249,20 @@ async def _probe(ctx: Context) -> tuple[str, str]:


async def reach(secret: str) -> str:
held = [*_held_ids(), await _own_workspace_id()]
sdk_held = _held_ids()
own_id = await _own_workspace_id()
held = [*sdk_held, own_id]
# The held IDs, plus one level of sub-sources reached from each.
sources = list(held)
for i in held:
sources += await _sub_source_ids(Context().select_id("ModuleSource", i))

reads: list[str] = []
# What the engine serves as the module's own current workspace, kept apart
# from what the SDK holds: dagger/dagger serves the caller's workspace there.
# The SDK holding that same ID makes its reads the SDK's.
engine_only = own_id not in sdk_held
engine: list[str] = []
counts = {"read": 0, "refused": 0, "absent": 0, "errored": 0}
absent_routes: list[str] = []
total = 0
Expand All @@ -268,7 +275,9 @@ async def reach(secret: str) -> str:
# module's loaded files, so any successful read of it is a leak,
# whatever its contents.
if status == "read":
reads.append(f"{label}: {detail}")
(engine if i == own_id and engine_only else reads).append(
f"{label}: {detail}"
)
elif status == "absent":
absent_routes.append(label)

Expand All @@ -281,11 +290,12 @@ async def reach(secret: str) -> str:
total += 1
counts[status] += 1
if status == "read":
reads.append(f"currentWorkspace.directory: {detail}")
engine.append(f"currentWorkspace.directory: {detail}")

absent = ",".join(sorted(set(absent_routes)))
return (
f"held={len(held)} sources={len(sources)} routes={total} "
f"reads={reads} refused={counts['refused']} absent={counts['absent']} "
f"errored={counts['errored']} absentRoutes=[{absent}]"
f"reads={reads} engine={engine} refused={counts['refused']} "
f"absent={counts['absent']} errored={counts['errored']} "
f"absentRoutes=[{absent}]"
)
Loading