Skip to content

Commit ed7be01

Browse files
andystaplesCopilot
andcommitted
Preserve orchestration context compatibility
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 42bcd2ff-9f6f-4235-81b5-629d07ecaa30
1 parent b1f431a commit ed7be01

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

.github/copilot-instructions.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ Examples:
4848
- Follow PEP 8 conventions.
4949
- Use `autopep8` for Python formatting.
5050

51+
## Public API Compatibility
52+
53+
- Treat adding an abstract method or property to a public ABC as a breaking
54+
change because existing third-party subclasses will fail at instantiation.
55+
- Do not add new abstract members outside a major release. For additive APIs in
56+
non-major releases, provide a concrete default implementation that preserves
57+
existing subclass instantiation and raises `NotImplementedError` only when
58+
the new API is invoked.
59+
- Add a regression test that confirms a new concrete API is absent from the
60+
public ABC's `__abstractmethods__`.
61+
5162
## Copyright Headers
5263

5364
Every new Python (`.py`) source file MUST begin with the following copyright

durabletask/task.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,6 @@ def wait_for_external_event(self, name: str, *,
362362
"""
363363
pass
364364

365-
@abstractmethod
366365
def send_event(self, instance_id: str, event_name: str, *,
367366
data: Any | None = None) -> None:
368367
"""Send an event to another orchestration instance.
@@ -381,7 +380,10 @@ def send_event(self, instance_id: str, event_name: str, *,
381380
data : Any | None
382381
The optional serializable event payload.
383382
"""
384-
pass
383+
raise NotImplementedError(
384+
"This OrchestrationContext implementation does not support "
385+
"send_event()."
386+
)
385387

386388
@abstractmethod
387389
def continue_as_new(self, new_input: Any, *, save_events: bool = False) -> None:

tests/durabletask/test_orchestration_executor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,8 @@ def orchestrator(ctx: task.OrchestrationContext, _):
14261426

14271427
def test_send_event_action():
14281428
"""An orchestration can emit a one-way event action."""
1429+
assert "send_event" not in task.OrchestrationContext.__abstractmethods__
1430+
14291431
payload = {"approved": True, "approver": "Ada"}
14301432

14311433
def orchestrator(ctx: task.OrchestrationContext, _):

0 commit comments

Comments
 (0)