datashare-python 0.12.2__tar.gz → 0.12.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.12.2 → datashare_python-0.12.5}/PKG-INFO +1 -1
  2. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/config.py +19 -6
  3. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/conftest.py +1 -1
  4. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/objects.py +1 -1
  5. datashare_python-0.12.5/datashare_python/worker-template.tar.gz +0 -0
  6. {datashare_python-0.12.2 → datashare_python-0.12.5}/pyproject.toml +1 -1
  7. datashare_python-0.12.2/datashare_python/worker-template.tar.gz +0 -0
  8. {datashare_python-0.12.2 → datashare_python-0.12.5}/.gitignore +0 -0
  9. {datashare_python-0.12.2 → datashare_python-0.12.5}/README.md +0 -0
  10. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/.gitignore +0 -0
  11. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/__init__.py +0 -0
  12. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/__main__.py +0 -0
  13. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/cli/__init__.py +0 -0
  14. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/cli/project.py +0 -0
  15. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/cli/task.py +0 -0
  16. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/cli/utils.py +0 -0
  17. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/cli/worker.py +0 -0
  18. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/constants.py +0 -0
  19. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/dependencies.py +0 -0
  20. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/discovery.py +0 -0
  21. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/exceptions.py +0 -0
  22. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/interceptors.py +0 -0
  23. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/logging_.py +0 -0
  24. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/mimetypes_.py +0 -0
  25. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/task_client.py +0 -0
  26. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/template.py +0 -0
  27. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/types_.py +0 -0
  28. {datashare_python-0.12.2 → datashare_python-0.12.5}/datashare_python/utils.py +0 -0
  29. {datashare_python-0.12.2 → datashare_python-0.12.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.12.2
3
+ Version: 0.12.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/
@@ -1,10 +1,10 @@
1
1
  from datetime import timedelta
2
2
  from enum import StrEnum
3
- from typing import TYPE_CHECKING, Literal
3
+ from typing import TYPE_CHECKING, Any, Literal
4
4
 
5
5
  from icij_common.es import ESClient
6
6
  from icij_common.pydantic_utils import ICIJSettings
7
- from pydantic import PrivateAttr
7
+ from pydantic import PrivateAttr, model_validator
8
8
  from pydantic_settings import SettingsConfigDict
9
9
  from temporalio.runtime import PrometheusConfig, Runtime, TelemetryConfig
10
10
 
@@ -61,18 +61,31 @@ class DatashareClientConfig(BaseModel):
61
61
  class TemporalClientConfig(BaseModel):
62
62
  host: str = "temporal:7233"
63
63
  namespace: str = "datashare-default"
64
- prometheus_host: str | None = None
64
+ prometheus_address: str | None = None
65
65
 
66
66
  _client: TemporalClient | None = PrivateAttr(default=None)
67
67
 
68
+ @model_validator(mode="before")
69
+ @classmethod
70
+ def _prometheus_host_backward_compatibility(cls, v: Any) -> Any:
71
+ # the combination of nested_model_default_partial_update=True in the
72
+ # WorkerConfig with extra="forbid" makes alias fail when loading from envvars.
73
+ # We can't use field aliases...
74
+ if not isinstance(v, dict):
75
+ return v
76
+ prometheus_address = v.pop("prometheus_host", v.pop("PROMETHEUS_HOST", None))
77
+ if prometheus_address is not None:
78
+ v["prometheus_address"] = prometheus_address
79
+ return v
80
+
68
81
  async def to_client(self) -> TemporalClient:
69
82
  from .utils import PYDANTIC_DATA_CONVERTER # noqa: PLC0415
70
83
 
71
84
  if self._client is None:
72
85
  runtime = None
73
- if self.prometheus_host is not None:
86
+ if self.prometheus_address is not None:
74
87
  telemetry_config = TelemetryConfig(
75
- metrics=PrometheusConfig(bind_address="0.0.0.0:9000")
88
+ metrics=PrometheusConfig(bind_address=self.prometheus_address)
76
89
  )
77
90
  runtime = Runtime(telemetry=telemetry_config)
78
91
 
@@ -145,5 +158,5 @@ class WorkerConfig(ICIJSettings, BaseModel):
145
158
 
146
159
 
147
160
  class ActivityTimeouts(BaseModel):
148
- start_to_close: timedelta | None = None
161
+ start_to_close: timedelta = timedelta(minutes=10)
149
162
  heartbeat: timedelta = timedelta(minutes=1)
@@ -430,7 +430,7 @@ def _run_worker_process(
430
430
  runtime = Runtime(telemetry=TelemetryConfig())
431
431
  # We don't use config.to_temporal_client since we get a problem with the
432
432
  # temporal runtime not being properly recreated, we create it explicitely
433
- if temporal_config.prometheus_host is not None:
433
+ if temporal_config.prometheus_address is not None:
434
434
  telemetry_config = TelemetryConfig(
435
435
  metrics=PrometheusConfig(bind_address="0.0.0.0:9000")
436
436
  )
@@ -718,7 +718,7 @@ class ErrorReportWithPages(ProcessingReportWithPages, ABC):
718
718
  return ErrorReportWithPages(
719
719
  n_docs=other.n_docs + self.n_docs,
720
720
  n_pages=other.n_pages + self.n_pages,
721
- errors=self.errors + other.errors,
721
+ errors=other.errors + self.errors,
722
722
  )
723
723
 
724
724
  @classmethod
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "datashare-python"
3
- version = "0.12.2"
3
+ version = "0.12.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" },