datashare-python 0.11.1__py3-none-any.whl → 0.11.2__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.
@@ -309,8 +309,9 @@ class Document(DatashareModel):
309
309
  resource_name = self.path.name
310
310
  else:
311
311
  msg = (
312
- f"doc {self} can't turn ES document into a {ProcessedFile.__name__} "
313
- f"without tika metadata resources name in metadata: {self.metadata}"
312
+ f"doc {self} can't turn ES document into a"
313
+ f" {ProcessedFile.__name__} without tika metadata resources name"
314
+ f" in metadata: {self.metadata}"
314
315
  )
315
316
  raise ValueError(msg)
316
317
  resource_name = cast(str, resource_name)
@@ -365,7 +366,17 @@ class ManifestEntryStatus(StrEnum):
365
366
  PARTIAL = "partial"
366
367
 
367
368
 
369
+ class User(DatashareModel):
370
+ id: str
371
+ name: str | None = None
372
+ email: str | None = None
373
+ provider: str | None = None
374
+ details: dict[str, Any] = Field(default_factory=dict)
375
+
376
+
368
377
  class TaskArgs(DatashareModel, ABC):
378
+ user: User | None = None
379
+
369
380
  def as_manifest_task_input(self) -> dict[str, Any]:
370
381
  # This is a base implementation, if the input is too large to be dumped,
371
382
  # override this and pop large keys
datashare_python/utils.py CHANGED
@@ -512,13 +512,21 @@ def _write_artifact_bytes(path: Path, artifact: bytes | BytesIO | Path) -> None:
512
512
  with path.open("wb") as f:
513
513
  f.write(artifact.read())
514
514
  case Path():
515
- path.unlink(missing_ok=True)
515
+ _remove_previous_artifacts(path)
516
516
  shutil.move(artifact, path)
517
517
  case _:
518
518
  msg = f"unsupported artifact type: {artifact.__class__.__name__}"
519
519
  raise ValueError(msg)
520
520
 
521
521
 
522
+ def _remove_previous_artifacts(path: Path) -> None:
523
+ if isinstance(path, Path) and path.exists():
524
+ with contextlib.suppress(FileNotFoundError):
525
+ path.rmdir()
526
+ else:
527
+ path.unlink(missing_ok=True)
528
+
529
+
522
530
  def debuggable_name(
523
531
  path: str, component_size_limit: int = 10, *, deterministic: bool = False
524
532
  ) -> str:
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: datashare-python
3
- Version: 0.11.1
3
+ Version: 0.11.2
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/
@@ -10,19 +10,19 @@ datashare_python/exceptions.py,sha256=bVHEAXxDPKfxeeMC0hJXEsrJkgsKO2ESAhxWU96GA4
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=mjQgaqnSFZEcl3LoLDGBaBBjTTzwYfSNZND9Fmkk2zs,49682
13
- datashare_python/objects.py,sha256=YdySfsOgpbbTuo-PUxI8Szw1zIrjrcSoXfvTRpKoxwc,18545
13
+ datashare_python/objects.py,sha256=RuDEC4dZPndMYwFKhmMlToY8jjwjupG7mGGCG5tzc6g,18788
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=8OzlY9Y1QfXhhzERck4-Iizdmqt87SHNT0r19C0U7BA,28371
18
- datashare_python/worker-template.tar.gz,sha256=I1FubYndt8K1Up0oIs6fvLTgCkonUZEKheL2cklx854,236564
17
+ datashare_python/utils.py,sha256=k85QP34hSHBRFo8YwGA7rYPO5cqCt33i3ntl2oSfHkE,28603
18
+ datashare_python/worker-template.tar.gz,sha256=3Lu6zLEXlndprxXPGMN9L19XrplmxUki3v15HymMmls,236583
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.11.1.dist-info/METADATA,sha256=4uO75jtf88X_ECkG0GVDpa5SrHEhYoI-VTVmCdj8tUY,1012
26
- datashare_python-0.11.1.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
27
- datashare_python-0.11.1.dist-info/entry_points.txt,sha256=ILE7auxabHWiu3GC-AunWnzjhOI_SbZp7D4GqZHlLw4,68
28
- datashare_python-0.11.1.dist-info/RECORD,,
25
+ datashare_python-0.11.2.dist-info/METADATA,sha256=STmFFjil2tcX6BgZOyEBdlraEtIs69qEWV6FGHGhGnY,1012
26
+ datashare_python-0.11.2.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
27
+ datashare_python-0.11.2.dist-info/entry_points.txt,sha256=ILE7auxabHWiu3GC-AunWnzjhOI_SbZp7D4GqZHlLw4,68
28
+ datashare_python-0.11.2.dist-info/RECORD,,