datashare-python 0.8.17__tar.gz → 0.8.19__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 (28) hide show
  1. {datashare_python-0.8.17 → datashare_python-0.8.19}/PKG-INFO +1 -1
  2. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/config.py +10 -0
  3. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/utils.py +40 -2
  4. datashare_python-0.8.19/datashare_python/worker-template.tar.gz +0 -0
  5. {datashare_python-0.8.17 → datashare_python-0.8.19}/pyproject.toml +1 -1
  6. datashare_python-0.8.17/datashare_python/worker-template.tar.gz +0 -0
  7. {datashare_python-0.8.17 → datashare_python-0.8.19}/.gitignore +0 -0
  8. {datashare_python-0.8.17 → datashare_python-0.8.19}/README.md +0 -0
  9. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/.gitignore +0 -0
  10. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/__init__.py +0 -0
  11. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/__main__.py +0 -0
  12. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/cli/__init__.py +0 -0
  13. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/cli/project.py +0 -0
  14. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/cli/task.py +0 -0
  15. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/cli/utils.py +0 -0
  16. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/cli/worker.py +0 -0
  17. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/conftest.py +0 -0
  18. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/constants.py +0 -0
  19. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/dependencies.py +0 -0
  20. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/discovery.py +0 -0
  21. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/exceptions.py +0 -0
  22. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/interceptors.py +0 -0
  23. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/logging_.py +0 -0
  24. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/objects.py +0 -0
  25. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/task_client.py +0 -0
  26. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/template.py +0 -0
  27. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/types_.py +0 -0
  28. {datashare_python-0.8.17 → datashare_python-0.8.19}/datashare_python/worker.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datashare-python
3
- Version: 0.8.17
3
+ Version: 0.8.19
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/
@@ -13,6 +13,7 @@ from temporalio.converter import (
13
13
  DefaultPayloadConverter,
14
14
  JSONPlainPayloadConverter,
15
15
  )
16
+ from temporalio.runtime import PrometheusConfig, Runtime, TelemetryConfig
16
17
 
17
18
  import datashare_python
18
19
 
@@ -64,13 +65,22 @@ class DatashareClientConfig(BaseModel):
64
65
  class TemporalClientConfig(BaseModel):
65
66
  host: str = "temporal:7233"
66
67
  namespace: str = "datashare-default"
68
+ prometheus_host: str | None = None
69
+
67
70
  _client: TemporalClient | None = PrivateAttr(default=None)
68
71
 
69
72
  async def to_client(self) -> TemporalClient:
70
73
  if self._client is None:
74
+ runtime = None
75
+ if self.prometheus_host is not None:
76
+ telemetry_config = TelemetryConfig(
77
+ metrics=PrometheusConfig(bind_address="0.0.0.0:9000")
78
+ )
79
+ runtime = Runtime(telemetry=telemetry_config)
71
80
  self._client = await TemporalClient.connect(
72
81
  target_host=self.host,
73
82
  namespace=self.namespace,
83
+ runtime=runtime,
74
84
  data_converter=PYDANTIC_DATA_CONVERTER,
75
85
  )
76
86
  return self._client
@@ -470,7 +470,7 @@ def _metadata_path(doc_id: str, *, project: str) -> Path:
470
470
 
471
471
 
472
472
  def _read_artifact_metadata(root: Path, artifact: DocArtifact) -> dict:
473
- m_path = root / _metadata_path(artifact.filename, project=artifact.project)
473
+ m_path = root / _metadata_path(artifact.doc_id, project=artifact.project)
474
474
  return json.loads(m_path.read_text())
475
475
 
476
476
 
@@ -502,7 +502,7 @@ def debuggable_name(
502
502
  return f"{uuid}-{'--'.join(displayable_file_name)}"
503
503
 
504
504
 
505
- def activity_contextual_id(
505
+ def contextual_id(
506
506
  *, wf_context: bool = True, act_context: bool = False, run_context: bool = False
507
507
  ) -> str:
508
508
  contextual_id = []
@@ -519,3 +519,41 @@ def activity_contextual_id(
519
519
  if run_context:
520
520
  contextual_id.append(act_info.activity_run_id)
521
521
  return "-".join(contextual_id)
522
+
523
+
524
+ # TODO: deprecated, remove me at the next breaking
525
+ activity_contextual_id = contextual_id
526
+
527
+
528
+ def _contextual_path(
529
+ *, wf_context: bool = True, act_context: bool = True, run_context: bool = False
530
+ ) -> Path:
531
+ act_info = activity.info()
532
+ path = []
533
+ if not wf_context and not act_context:
534
+ raise ValueError("at least one of wf_context and act_context must be True")
535
+ if wf_context:
536
+ path = [act_info.workflow_type]
537
+ path.append(act_info.workflow_id)
538
+ if run_context:
539
+ path.append(act_info.workflow_run_id)
540
+ if act_context:
541
+ path.append(act_info.activity_type)
542
+ path.append(act_info.activity_id)
543
+ if run_context:
544
+ path.append(act_info.activity_run_id)
545
+ return Path(*path)
546
+
547
+
548
+ def activity_workdir(
549
+ workdir: Path,
550
+ project: str,
551
+ *,
552
+ wf_context: bool = True,
553
+ act_context: bool = True,
554
+ run_context: bool = False,
555
+ ) -> Path:
556
+ ctx_path = _contextual_path(
557
+ wf_context=wf_context, act_context=act_context, run_context=run_context
558
+ )
559
+ return workdir.joinpath(project, ctx_path)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "datashare-python"
3
- version = "0.8.17"
3
+ version = "0.8.19"
4
4
  description = "Manage Python tasks and local resources in Datashare"
5
5
  authors = [
6
6
  { name = "Clément Doumouro", email = "cdoumouro@icij.org" },