datashare-python 0.10.4__tar.gz → 0.10.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {datashare_python-0.10.4 → datashare_python-0.10.5}/PKG-INFO +1 -1
  2. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/interceptors.py +33 -13
  3. datashare_python-0.10.5/datashare_python/worker-template.tar.gz +0 -0
  4. {datashare_python-0.10.4 → datashare_python-0.10.5}/pyproject.toml +1 -1
  5. datashare_python-0.10.4/datashare_python/worker-template.tar.gz +0 -0
  6. {datashare_python-0.10.4 → datashare_python-0.10.5}/.gitignore +0 -0
  7. {datashare_python-0.10.4 → datashare_python-0.10.5}/README.md +0 -0
  8. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/.gitignore +0 -0
  9. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/__init__.py +0 -0
  10. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/__main__.py +0 -0
  11. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/cli/__init__.py +0 -0
  12. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/cli/project.py +0 -0
  13. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/cli/task.py +0 -0
  14. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/cli/utils.py +0 -0
  15. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/cli/worker.py +0 -0
  16. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/config.py +0 -0
  17. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/conftest.py +0 -0
  18. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/constants.py +0 -0
  19. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/dependencies.py +0 -0
  20. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/discovery.py +0 -0
  21. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/exceptions.py +0 -0
  22. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/logging_.py +0 -0
  23. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/mimetypes_.py +0 -0
  24. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/objects.py +0 -0
  25. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/task_client.py +0 -0
  26. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/template.py +0 -0
  27. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/types_.py +0 -0
  28. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/utils.py +0 -0
  29. {datashare_python-0.10.4 → datashare_python-0.10.5}/datashare_python/worker.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: datashare-python
3
- Version: 0.10.4
3
+ Version: 0.10.5
4
4
  Summary: Manage Python tasks and local resources in Datashare
5
5
  Project-URL: Homepage, https://icij.github.io/datashare-python/
6
6
  Project-URL: Documentation, https://icij.github.io/datashare-python/
@@ -8,12 +8,13 @@ from contextlib import contextmanager
8
8
  from contextvars import ContextVar
9
9
  from copy import deepcopy
10
10
  from functools import wraps
11
- from inspect import signature
11
+ from inspect import iscoroutinefunction, signature
12
12
  from types import UnionType
13
13
  from typing import (
14
14
  Annotated,
15
15
  Any,
16
16
  NoReturn,
17
+ ParamSpec,
17
18
  Self,
18
19
  TypeVar,
19
20
  get_args,
@@ -28,6 +29,7 @@ from temporalio.activity import _Definition
28
29
  from temporalio.api.common.v1 import Payload
29
30
  from temporalio.client import WorkflowHandle
30
31
  from temporalio.converter import DataConverter
32
+ from temporalio.service import RPCError
31
33
  from temporalio.worker import (
32
34
  ActivityInboundInterceptor,
33
35
  ActivityOutboundInterceptor,
@@ -332,7 +334,8 @@ def _get_progress_handler(
332
334
  weight=weight,
333
335
  min_progress_interval_s=min_progress_interval_s,
334
336
  )
335
- return handler.progress
337
+ handler = _fail_safe(handler.progress, "emit progress", excs=(RPCError,))
338
+ return handler
336
339
 
337
340
 
338
341
  def _is_progress(t: type) -> bool:
@@ -438,7 +441,7 @@ class _HeartbeatInboundInterceptor(ActivityInboundInterceptor):
438
441
  period = heartbeat_timeout.total_seconds() / self._n_missed_before_timeout
439
442
  # We don't want a failing hearbeat to fail the worker task so we just
440
443
  # ignore any exception
441
- heartbeat_fn = _fail_safe(self._outbound.heartbeat)
444
+ heartbeat_fn = _fail_safe(self._outbound.heartbeat, "heartbeat")
442
445
  heartbeat_task = asyncio.create_task(_heartbeat_every(heartbeat_fn, period))
443
446
  try:
444
447
  activity.heartbeat()
@@ -449,19 +452,36 @@ class _HeartbeatInboundInterceptor(ActivityInboundInterceptor):
449
452
  await asyncio.wait([heartbeat_task])
450
453
 
451
454
 
452
- def _fail_safe(
453
- fn: Callable[[Any], None], excs: tuple[type[Exception]] | None = None
454
- ) -> Callable[[Any], None]:
455
+ P = ParamSpec("P")
456
+ T = TypeVar("T")
457
+
458
+
459
+ def _fail_safe[P, T](
460
+ fn: Callable[P, T],
461
+ action: str,
462
+ excs: tuple[type[Exception]] | None = None,
463
+ ) -> Callable[P, T]:
455
464
  if excs is None:
456
465
  excs = (Exception,)
466
+ if iscoroutinefunction(fn):
457
467
 
458
- @wraps(fn)
459
- def wrapper(*args, **kwargs) -> None:
460
- try:
461
- fn(*args, **kwargs)
462
- except excs as exc:
463
- msg = f"failed to heartbeat due to {exc}"
464
- logger.exception(msg)
468
+ @wraps(fn)
469
+ async def wrapper(*args, **kwargs) -> None:
470
+ try:
471
+ await fn(*args, **kwargs)
472
+ except excs as exc:
473
+ msg = f"failed to {action} due to {exc}"
474
+ logger.exception(msg)
475
+
476
+ else:
477
+
478
+ @wraps(fn)
479
+ def wrapper(*args, **kwargs) -> None:
480
+ try:
481
+ fn(*args, **kwargs)
482
+ except excs as exc:
483
+ msg = f"failed to {action} due to {exc}"
484
+ logger.exception(msg)
465
485
 
466
486
  return wrapper
467
487
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "datashare-python"
3
- version = "0.10.4"
3
+ version = "0.10.5"
4
4
  description = "Manage Python tasks and local resources in Datashare"
5
5
  authors = [
6
6
  { name = "Clément Doumouro", email = "cdoumouro@icij.org" },