datashare-python 0.10.10__tar.gz → 0.11.0__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.
- {datashare_python-0.10.10 → datashare_python-0.11.0}/PKG-INFO +1 -1
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/conftest.py +12 -2
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/objects.py +36 -1
- datashare_python-0.11.0/datashare_python/worker-template.tar.gz +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/pyproject.toml +1 -1
- datashare_python-0.10.10/datashare_python/worker-template.tar.gz +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/.gitignore +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/README.md +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/.gitignore +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/__init__.py +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/__main__.py +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/cli/__init__.py +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/cli/project.py +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/cli/task.py +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/cli/utils.py +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/cli/worker.py +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/config.py +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/constants.py +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/dependencies.py +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/discovery.py +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/exceptions.py +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/interceptors.py +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/logging_.py +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/mimetypes_.py +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/task_client.py +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/template.py +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/types_.py +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/utils.py +0 -0
- {datashare_python-0.10.10 → datashare_python-0.11.0}/datashare_python/worker.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: datashare-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11.0
|
|
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/
|
|
@@ -233,14 +233,22 @@ def text_1() -> str:
|
|
|
233
233
|
@pytest.fixture(scope="session")
|
|
234
234
|
def doc_0(text_0: str) -> Document:
|
|
235
235
|
return Document(
|
|
236
|
-
id="doc-0",
|
|
236
|
+
id="doc-0",
|
|
237
|
+
root_document="root-0",
|
|
238
|
+
extraction_level=1,
|
|
239
|
+
language="ENGLISH",
|
|
240
|
+
content=text_0,
|
|
237
241
|
)
|
|
238
242
|
|
|
239
243
|
|
|
240
244
|
@pytest.fixture(scope="session")
|
|
241
245
|
def doc_1(text_1: str) -> Document:
|
|
242
246
|
return Document(
|
|
243
|
-
id="doc-1",
|
|
247
|
+
id="doc-1",
|
|
248
|
+
root_document="root-1",
|
|
249
|
+
extraction_level=1,
|
|
250
|
+
language="ENGLISH",
|
|
251
|
+
content=text_1,
|
|
244
252
|
)
|
|
245
253
|
|
|
246
254
|
|
|
@@ -249,6 +257,7 @@ def doc_2() -> Document:
|
|
|
249
257
|
return Document(
|
|
250
258
|
id="doc-2",
|
|
251
259
|
root_document="root-2",
|
|
260
|
+
extraction_level=1,
|
|
252
261
|
language="FRENCH",
|
|
253
262
|
content="traduis ce texte en anglais",
|
|
254
263
|
)
|
|
@@ -260,6 +269,7 @@ def doc_3() -> Document:
|
|
|
260
269
|
id="doc-3",
|
|
261
270
|
index=TEST_PROJECT,
|
|
262
271
|
root_document="root-3",
|
|
272
|
+
extraction_level=1,
|
|
263
273
|
language="SPANISH",
|
|
264
274
|
content="traduce este texto al inglés",
|
|
265
275
|
)
|
|
@@ -24,6 +24,7 @@ with workflow.unsafe.imports_passed_through():
|
|
|
24
24
|
from icij_common.es import (
|
|
25
25
|
DOC_CONTENT,
|
|
26
26
|
DOC_CONTENT_TRANSLATED,
|
|
27
|
+
DOC_EXTRACTION_LEVEL,
|
|
27
28
|
DOC_LANGUAGE,
|
|
28
29
|
DOC_METADATA,
|
|
29
30
|
DOC_PATH,
|
|
@@ -222,6 +223,8 @@ class Document(DatashareModel):
|
|
|
222
223
|
language: DatashareLanguage
|
|
223
224
|
index: str | None = None
|
|
224
225
|
root_document: str | None = None
|
|
226
|
+
content: Annotated[str, BeforeValidator(_from_sentences)]
|
|
227
|
+
extraction_level: int = 0
|
|
225
228
|
content: str | None = None
|
|
226
229
|
content_text_length: int | None = None
|
|
227
230
|
content_type: str | None = None
|
|
@@ -244,6 +247,37 @@ class Document(DatashareModel):
|
|
|
244
247
|
data["content_text_length"] = len(content)
|
|
245
248
|
return data
|
|
246
249
|
|
|
250
|
+
@model_validator(mode="before")
|
|
251
|
+
@classmethod
|
|
252
|
+
def _set_root_document_to_self_when_not_provided(cls, data: Any) -> Any:
|
|
253
|
+
if isinstance(data, dict):
|
|
254
|
+
root = data.get("root_document")
|
|
255
|
+
if root is None:
|
|
256
|
+
data["root_document"] = data.get("id")
|
|
257
|
+
return data
|
|
258
|
+
|
|
259
|
+
@model_validator(mode="after")
|
|
260
|
+
def _validate_root_document(self) -> Any:
|
|
261
|
+
if self.root_document is None:
|
|
262
|
+
msg = (
|
|
263
|
+
"inconsistent state, root_document cannot be after validation, "
|
|
264
|
+
"there's a bug in this object's implementation."
|
|
265
|
+
" Please report to a developer."
|
|
266
|
+
)
|
|
267
|
+
raise ValueError(msg)
|
|
268
|
+
if self.is_root_document:
|
|
269
|
+
if self.extraction_level > 0:
|
|
270
|
+
msg = "extraction_level should be <= 0 for root documents"
|
|
271
|
+
raise ValueError(msg)
|
|
272
|
+
elif self.extraction_level <= 0:
|
|
273
|
+
msg = "extraction_level should be > 0 for embedded documents"
|
|
274
|
+
raise ValueError(msg)
|
|
275
|
+
return self
|
|
276
|
+
|
|
277
|
+
@property
|
|
278
|
+
def is_root_document(self) -> bool:
|
|
279
|
+
return self.root_document == self.id and self.extraction_level <= 0
|
|
280
|
+
|
|
247
281
|
@classmethod
|
|
248
282
|
def from_es(cls, es_doc: dict) -> Self:
|
|
249
283
|
sources = es_doc[SOURCE]
|
|
@@ -255,6 +289,7 @@ class Document(DatashareModel):
|
|
|
255
289
|
content_text_length=sources.get("content_text_length"),
|
|
256
290
|
language=DatashareLanguage(sources[DOC_LANGUAGE]),
|
|
257
291
|
root_document=sources.get(DOC_ROOT_ID),
|
|
292
|
+
extraction_level=sources.get(DOC_EXTRACTION_LEVEL),
|
|
258
293
|
tags=sources.get("tags", []),
|
|
259
294
|
path=sources.get(DOC_PATH),
|
|
260
295
|
metadata=sources.get(DOC_METADATA),
|
|
@@ -275,7 +310,7 @@ class Document(DatashareModel):
|
|
|
275
310
|
)
|
|
276
311
|
raise ValueError(msg)
|
|
277
312
|
resource_name = cast(str, resource_name)
|
|
278
|
-
if self.
|
|
313
|
+
if self.is_root_document:
|
|
279
314
|
path = self.path
|
|
280
315
|
location = DocumentLocation.FILESYSTEM
|
|
281
316
|
else:
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|