Skip to content

Commit 1c9a59e

Browse files
authored
Several minor issues (#127)
Fixes #125 Fixes #124 Fixes #122 Fixes #119 Fixes #118 Fixes #117 Fixes #115 Fixes #114 Fixes #110 Fixes #103 Fixes #92 Fixes #40
1 parent 07da1b9 commit 1c9a59e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2412
-655
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,8 @@ jobs:
5959
run: poe gen-docs
6060
- name: Deploy prod API docs
6161
if: ${{ github.ref == 'refs/heads/main' && matrix.docsTarget }}
62-
uses: netlify/actions/cli@master
63-
with:
64-
args: deploy --dir=build/apidocs --prod
65-
env:
66-
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
67-
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
68-
- name: Deploy draft API docs
69-
if: ${{ github.ref != 'refs/heads/main' && matrix.docsTarget }}
70-
uses: netlify/actions/cli@master
71-
with:
72-
args: deploy --dir=build/apidocs
62+
# Using NPX instead of action due to https://github.com/netlify/actions/issues/60
63+
run: npx netlify-cli deploy --build --dir=build/apidocs --prod
7364
env:
7465
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
7566
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ add_ignore = [
141141
add-package = ["temporalio"]
142142
docformat = "google"
143143
html-output = "build/apidocs"
144+
html-viewsource-base = "https://github.com/temporalio/sdk-python/tree/main"
144145
intersphinx = [
145146
"https://docs.python.org/3/objects.inv",
146147
"https://googleapis.dev/python/protobuf/latest/objects.inv",
@@ -158,7 +159,7 @@ privacy = [
158159
"HIDDEN:temporalio.worker.workflow_instance",
159160
"HIDDEN:**.*_pb2*",
160161
]
161-
project-name = "Temporal"
162+
project-name = "Temporal Python"
162163
sidebar-expand-depth = 2
163164

164165
[build-system]

scripts/gen_protos.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
proto_dir = base_dir / "temporalio" / "bridge" / "sdk-core" / "protos"
1313
api_proto_dir = proto_dir / "api_upstream"
1414
core_proto_dir = proto_dir / "local"
15+
health_proto_dir = proto_dir / "grpc"
1516
testsrv_proto_dir = proto_dir / "testsrv_upstream"
1617

17-
# Exclude testsrv dependencies
18+
# Exclude testsrv dependencies protos
1819
proto_paths = (
1920
v
2021
for v in proto_dir.glob("**/*.proto")
@@ -77,7 +78,7 @@ def fix_generated_output(base_path: Path):
7778
with (base_path / "__init__.py").open("w") as f:
7879
# Add docstring to API's init
7980
if str(base_path.as_posix()).endswith("/temporal/api"):
80-
f.write('"""gRPC API."""\n')
81+
f.write('"""Temporal API protobuf models."""\n')
8182
# Non-gRPC imports
8283
message_names = []
8384
for stem, messages in imports.items():
@@ -124,13 +125,17 @@ def fix_generated_output(base_path: Path):
124125
f"--proto_path={api_proto_dir}",
125126
f"--proto_path={core_proto_dir}",
126127
f"--proto_path={testsrv_proto_dir}",
128+
f"--proto_path={health_proto_dir}",
127129
f"--python_out={temp_dir}",
128130
f"--grpc_python_out={temp_dir}",
129131
f"--mypy_out={temp_dir}",
130132
f"--mypy_grpc_out={temp_dir}",
131133
*map(str, proto_paths),
132134
]
133135
)
136+
# Remove health gRPC parts
137+
(temp_dir / "health" / "v1" / "health_pb2_grpc.py").unlink()
138+
(temp_dir / "health" / "v1" / "health_pb2_grpc.pyi").unlink()
134139
# Apply fixes before moving code
135140
fix_generated_output(temp_dir)
136141
# Move protos
@@ -142,4 +147,6 @@ def fix_generated_output(base_path: Path):
142147
for p in (temp_dir / "temporal" / "sdk" / "core").iterdir():
143148
shutil.rmtree(sdk_out_dir / p.name, ignore_errors=True)
144149
p.replace(sdk_out_dir / p.name)
150+
shutil.rmtree(sdk_out_dir / "health", ignore_errors=True)
151+
(temp_dir / "health").replace(sdk_out_dir / "health")
145152
print("Done", file=sys.stderr)

temporalio/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
"""Python SDK for Temporal."""
1+
"""Python SDK for Temporal.
2+
3+
See the
4+
`Temporal Application Development Guide <https://docs.temporal.io/application-development/?lang=python>`_
5+
and the `GitHub project <https://github.com/temporalio/sdk-python>`_.
6+
7+
Most users will use :py:mod:`client` for creating a client to Temporal and
8+
:py:mod:`worker` to run workflows and activities.
9+
"""
210

311
from .service import __version__ as __sdk_version
412

temporalio/activity.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@
2121
from typing import (
2222
Any,
2323
Callable,
24-
Iterable,
2524
Mapping,
2625
MutableMapping,
2726
NoReturn,
2827
Optional,
28+
Sequence,
2929
Tuple,
30+
Union,
3031
overload,
3132
)
3233

@@ -81,7 +82,7 @@ class Info:
8182
activity_type: str
8283
attempt: int
8384
current_attempt_scheduled_time: datetime
84-
heartbeat_details: Iterable[Any]
85+
heartbeat_details: Sequence[Any]
8586
heartbeat_timeout: Optional[timedelta]
8687
is_local: bool
8788
schedule_to_close_timeout: Optional[timedelta]
@@ -227,7 +228,7 @@ async def wait_for_cancelled() -> None:
227228
await _Context.current().cancelled_event.wait()
228229

229230

230-
def wait_for_cancelled_sync(timeout: Optional[float] = None) -> None:
231+
def wait_for_cancelled_sync(timeout: Optional[Union[timedelta, float]] = None) -> None:
231232
"""Synchronously block while waiting for a cancellation request on this
232233
activity.
233234
@@ -239,7 +240,9 @@ def wait_for_cancelled_sync(timeout: Optional[float] = None) -> None:
239240
Raises:
240241
RuntimeError: When not in an activity.
241242
"""
242-
_Context.current().cancelled_event.wait_sync(timeout)
243+
_Context.current().cancelled_event.wait_sync(
244+
timeout.total_seconds() if isinstance(timeout, timedelta) else timeout
245+
)
243246

244247

245248
def is_worker_shutdown() -> bool:
@@ -263,7 +266,9 @@ async def wait_for_worker_shutdown() -> None:
263266
await _Context.current().worker_shutdown_event.wait()
264267

265268

266-
def wait_for_worker_shutdown_sync(timeout: Optional[float] = None) -> None:
269+
def wait_for_worker_shutdown_sync(
270+
timeout: Optional[Union[timedelta, float]] = None
271+
) -> None:
267272
"""Synchronously block while waiting for shutdown to be called on the
268273
worker.
269274
@@ -276,7 +281,9 @@ def wait_for_worker_shutdown_sync(timeout: Optional[float] = None) -> None:
276281
Raises:
277282
RuntimeError: When not in an activity.
278283
"""
279-
_Context.current().worker_shutdown_event.wait_sync(timeout)
284+
_Context.current().worker_shutdown_event.wait_sync(
285+
timeout.total_seconds() if isinstance(timeout, timedelta) else timeout
286+
)
280287

281288

282289
def raise_complete_async() -> NoReturn:

temporalio/api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"""gRPC API."""
1+
"""Temporal API protobuf models."""

temporalio/api/batch/__init__.py

Whitespace-only changes.

temporalio/api/batch/v1/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from .message_pb2 import (
2+
BatchOperationCancellation,
3+
BatchOperationInfo,
4+
BatchOperationSignal,
5+
BatchOperationTermination,
6+
)
7+
8+
__all__ = [
9+
"BatchOperationCancellation",
10+
"BatchOperationInfo",
11+
"BatchOperationSignal",
12+
"BatchOperationTermination",
13+
]

temporalio/api/batch/v1/message_pb2.py

Lines changed: 105 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)