datashare-python 0.12.10__py3-none-any.whl → 0.12.12__py3-none-any.whl
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.
- datashare_python/conftest.py +1 -0
- datashare_python/exceptions.py +8 -0
- datashare_python/utils.py +32 -0
- datashare_python/worker-template.tar.gz +0 -0
- {datashare_python-0.12.10.dist-info → datashare_python-0.12.12.dist-info}/METADATA +2 -2
- {datashare_python-0.12.10.dist-info → datashare_python-0.12.12.dist-info}/RECORD +8 -8
- {datashare_python-0.12.10.dist-info → datashare_python-0.12.12.dist-info}/WHEEL +0 -0
- {datashare_python-0.12.10.dist-info → datashare_python-0.12.12.dist-info}/entry_points.txt +0 -0
datashare_python/conftest.py
CHANGED
datashare_python/exceptions.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from abc import ABC
|
|
2
2
|
|
|
3
|
+
from .objects import DocArtifact
|
|
4
|
+
|
|
3
5
|
|
|
4
6
|
class DatashareError(Exception, ABC): ...
|
|
5
7
|
|
|
@@ -16,3 +18,9 @@ class DependencyInjectionError(DatashareError, RuntimeError):
|
|
|
16
18
|
def __init__(self, name: str):
|
|
17
19
|
msg = f"{name} was not injected"
|
|
18
20
|
super().__init__(msg)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ArtifactNotFound(DatashareError):
|
|
24
|
+
def __init__(self, doc_id: str, artifact_type: type[DocArtifact]):
|
|
25
|
+
msg = f"could not find {artifact_type.__name__} for {doc_id}"
|
|
26
|
+
super().__init__(msg)
|
datashare_python/utils.py
CHANGED
|
@@ -54,6 +54,7 @@ from datashare_python.types_ import (
|
|
|
54
54
|
)
|
|
55
55
|
|
|
56
56
|
from .constants import MANIFEST_JSON, METADATA_JSON
|
|
57
|
+
from .exceptions import ArtifactNotFound
|
|
57
58
|
from .mimetypes_ import types_map
|
|
58
59
|
from .objects import (
|
|
59
60
|
BaseModel,
|
|
@@ -401,6 +402,37 @@ def artifacts_dir(doc_id: str, *, project: str) -> Path:
|
|
|
401
402
|
return Path(project, safe_dir(doc_id), doc_id)
|
|
402
403
|
|
|
403
404
|
|
|
405
|
+
async def async_read_artifact(
|
|
406
|
+
paths: WorkerPaths, doc_id: str, artifact_type: type[DocArtifact], *, project: str
|
|
407
|
+
) -> bytes:
|
|
408
|
+
# Reading the manifest can be long, we load it only if the artifact exists then
|
|
409
|
+
# we check that the entry is in the manifest
|
|
410
|
+
artifact_path = (
|
|
411
|
+
paths.artifacts
|
|
412
|
+
/ artifacts_dir(doc_id, project=project)
|
|
413
|
+
/ artifact_type.filename
|
|
414
|
+
)
|
|
415
|
+
if not artifact_path.exists():
|
|
416
|
+
raise ArtifactNotFound(doc_id, artifact_type)
|
|
417
|
+
m_path = paths.artifacts / _manifest_path(doc_id, project=project)
|
|
418
|
+
|
|
419
|
+
try:
|
|
420
|
+
async with async_open(m_path, "r") as f:
|
|
421
|
+
manifest_json = await f.read()
|
|
422
|
+
except OSError as e:
|
|
423
|
+
raise ArtifactNotFound(doc_id, artifact_type) from e
|
|
424
|
+
|
|
425
|
+
manifest = json.loads(manifest_json)
|
|
426
|
+
if artifact_type.type.value not in manifest:
|
|
427
|
+
raise ArtifactNotFound(doc_id, artifact_type)
|
|
428
|
+
|
|
429
|
+
try:
|
|
430
|
+
async with async_open(artifact_path, "rb") as f:
|
|
431
|
+
return await f.read()
|
|
432
|
+
except OSError as e:
|
|
433
|
+
raise ArtifactNotFound(doc_id, artifact_type) from e
|
|
434
|
+
|
|
435
|
+
|
|
404
436
|
def _metadata_path(doc_id: str, *, project: str) -> Path:
|
|
405
437
|
metadata_path = artifacts_dir(doc_id, project=project) / METADATA_JSON
|
|
406
438
|
return metadata_path
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: datashare-python
|
|
3
|
-
Version: 0.12.
|
|
3
|
+
Version: 0.12.12
|
|
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/
|
|
@@ -18,6 +18,6 @@ Requires-Dist: lru-dict~=1.4
|
|
|
18
18
|
Requires-Dist: pydantic-extra-types[pycountry]>=2.11.1
|
|
19
19
|
Requires-Dist: python-json-logger~=4.0
|
|
20
20
|
Requires-Dist: pyyaml~=6.0
|
|
21
|
-
Requires-Dist: temporalio~=1.
|
|
21
|
+
Requires-Dist: temporalio~=1.34
|
|
22
22
|
Requires-Dist: tomlkit~=0.14.0
|
|
23
23
|
Requires-Dist: typer<0.25.1,>=0.15.4
|
|
@@ -2,11 +2,11 @@ datashare_python/.gitignore,sha256=e-SRgnvGGdsjRrqgKsTzALz6Obx8IYiOjr0yaAxT6v8,2
|
|
|
2
2
|
datashare_python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
datashare_python/__main__.py,sha256=g-fvS46zl9umKmGrSpl-OG-8PSuZgjqvTCqjpsZtSps,101
|
|
4
4
|
datashare_python/config.py,sha256=sQ-M4_T4iojWXFsR_auQn5GMrGHj9E5Nwt6DgJe1kC0,5203
|
|
5
|
-
datashare_python/conftest.py,sha256=
|
|
5
|
+
datashare_python/conftest.py,sha256=EuRICBdocWVc30yNzEJq-71uHYnHW-BpoYjAnN-ko78,13860
|
|
6
6
|
datashare_python/constants.py,sha256=ELS71jupoHAYTPrCvjWizCJUdzNbOiwza58CG2WP4lU,6136
|
|
7
7
|
datashare_python/dependencies.py,sha256=Q-BIhCwWu-GGp9omYNhENZ88cF0QJ8spfaMZX40mmNU,4386
|
|
8
8
|
datashare_python/discovery.py,sha256=3mUck2GUSKu2DSP9-MM1OdVM4FqFKqfBeSQDQZxgh2g,7177
|
|
9
|
-
datashare_python/exceptions.py,sha256=
|
|
9
|
+
datashare_python/exceptions.py,sha256=lYtbana4ubreOBeSMa70exQA1YIYPQCx9Ar_d-JBb8M,743
|
|
10
10
|
datashare_python/interceptors.py,sha256=-XC-y_MvGyHlZQ6jItfMRPAmKwQkQzzncpAGxceKlwM,16485
|
|
11
11
|
datashare_python/logging_.py,sha256=96KNXhP-JR5ybu9dld4VLtF7v7PfiphOCR1Nio-mmUs,4483
|
|
12
12
|
datashare_python/mimetypes_.py,sha256=omd2g8JyN-tfZL-lmxbWsjgc987iUe5w87ZpEtbyUK0,49930
|
|
@@ -14,15 +14,15 @@ datashare_python/objects.py,sha256=2v83v4A0KcEJxiqQjv1PDDN6XRbEyTKJuGPuMpG4-jU,2
|
|
|
14
14
|
datashare_python/task_client.py,sha256=oTmP8bvZW0UyhLNMi1AV3XIAx7hrdbxNRss2Mw2azEc,8435
|
|
15
15
|
datashare_python/template.py,sha256=N1uM8TRXh5tQPV7BC1oJj-Pdm2Gs_SkjaXv50RnNYso,4682
|
|
16
16
|
datashare_python/types_.py,sha256=cPcCkIk6ecILrKetPnAsrb0njHYuWJU3eZicUXy2lF8,1278
|
|
17
|
-
datashare_python/utils.py,sha256=
|
|
18
|
-
datashare_python/worker-template.tar.gz,sha256=
|
|
17
|
+
datashare_python/utils.py,sha256=0B2Cl-G4FbudTKTm2CWYRg2pNTIvHHu1i9ZS02zr0Lk,35858
|
|
18
|
+
datashare_python/worker-template.tar.gz,sha256=tp0Flt3wvlDeoxWlVSYH8cRlk4yQgAB2nEx6WmJA6b4,281023
|
|
19
19
|
datashare_python/worker.py,sha256=ad36_yJOgwtj8KBheWndGkqaP_2aXTPSrYaHrbCXTvg,8389
|
|
20
20
|
datashare_python/cli/__init__.py,sha256=9BPWtssDgsVfWMsZ1TtZCla0EC_kai4RHttr8oNLYOE,1401
|
|
21
21
|
datashare_python/cli/project.py,sha256=w32Gy9AOL5B00uDT4in7YUCt2g68FnNbvwg2M3a8G6o,946
|
|
22
22
|
datashare_python/cli/task.py,sha256=GsyR5o0fN4Pd8tJKAUgivAvCBKT3L4Ay5j_BCW1XBHk,5828
|
|
23
23
|
datashare_python/cli/utils.py,sha256=p69CQb0zfixuyBkiZprhdMCc_NuYwXyAn6vC9H1UzAw,911
|
|
24
24
|
datashare_python/cli/worker.py,sha256=x0p3a1_NsZPbmV7-WSVMRyW3_iadYcgyZKbDvWgymQc,5790
|
|
25
|
-
datashare_python-0.12.
|
|
26
|
-
datashare_python-0.12.
|
|
27
|
-
datashare_python-0.12.
|
|
28
|
-
datashare_python-0.12.
|
|
25
|
+
datashare_python-0.12.12.dist-info/METADATA,sha256=HMp32lYZoL_c7U1qC63SxgX6Gcs3fofv8eeL0sChq_c,1013
|
|
26
|
+
datashare_python-0.12.12.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
27
|
+
datashare_python-0.12.12.dist-info/entry_points.txt,sha256=ILE7auxabHWiu3GC-AunWnzjhOI_SbZp7D4GqZHlLw4,68
|
|
28
|
+
datashare_python-0.12.12.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|