Skip to content

Commit e0de14d

Browse files
committed
WIP: Improve support for proxy objects
* Do not require (and subsequently ignore) an api Protocol type. * Make the dir function list the actually available members.
1 parent 9e9550f commit e0de14d

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

src/appose/service.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,10 @@ def call(self, function: str, *args: Any) -> Any:
262262
task = self.task(script, inputs).wait_for()
263263
return task.outputs.get("result")
264264

265-
def proxy(self, var: str, api: type, queue: str | None = None) -> Any:
265+
def proxy(self, var: str, queue: str | None = None) -> Any:
266266
"""
267-
Create a proxy object providing strongly typed access to a remote
268-
object in this service's worker process.
267+
Create a proxy object providing access to a remote object in this
268+
service's worker process.
269269
270270
Method calls on the proxy are transparently forwarded to the remote
271271
object via Tasks.
@@ -277,7 +277,6 @@ def proxy(self, var: str, api: type, queue: str | None = None) -> Any:
277277
Args:
278278
var: The name of the exported variable in the worker process
279279
referencing the remote object.
280-
api: The interface/protocol class that the proxy should implement.
281280
queue: Optional queue identifier for task execution. Pass "main" to
282281
ensure execution on the worker's main thread.
283282

tests/test_syntax.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,6 @@ def test_call_nonexistent_function():
119119
assert "failed" in str(exc_info.value).lower()
120120

121121

122-
class Creature(Protocol):
123-
"""Test protocol for proxy testing."""
124-
125-
def walk(self, speed: int) -> str: ...
126-
def fly(self, speed: int, height: int) -> bool: ...
127-
def dive(self, depth: float) -> str: ...
128-
129-
130122
def test_proxy():
131123
"""Test Service.proxy functionality."""
132124
env = appose.system()
@@ -163,7 +155,7 @@ def walk(self, rate):
163155
assert_complete(setup)
164156

165157
# Validate bird behavior
166-
bird = service.proxy("bird", Creature)
158+
bird = service.proxy("bird")
167159
assert bird.walk(1) == "Hopped at rate: 1"
168160
assert bird.walk(2) == "Too fast for birds!"
169161
assert bird.fly(5, 100) is True
@@ -173,7 +165,7 @@ def walk(self, rate):
173165
assert bird.dive(3) == "Too deep for birds!"
174166

175167
# Validate fish behavior
176-
fish = service.proxy("fish", Creature)
168+
fish = service.proxy("fish")
177169
assert fish.walk(1) == "Nope! Only the Darwin fish can do that."
178170
assert fish.fly(2, 4) is True
179171
assert fish.fly(2, 10) is False

0 commit comments

Comments
 (0)