destiny_sdk 0.1.0__tar.gz → 0.1.2__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.
- {destiny_sdk-0.1.0 → destiny_sdk-0.1.2}/PKG-INFO +11 -1
- {destiny_sdk-0.1.0 → destiny_sdk-0.1.2}/README.md +10 -0
- {destiny_sdk-0.1.0 → destiny_sdk-0.1.2}/pyproject.toml +1 -1
- {destiny_sdk-0.1.0 → destiny_sdk-0.1.2}/src/destiny_sdk/enhancements.py +7 -4
- {destiny_sdk-0.1.0 → destiny_sdk-0.1.2}/src/destiny_sdk/imports.py +7 -0
- {destiny_sdk-0.1.0 → destiny_sdk-0.1.2}/src/destiny_sdk/references.py +23 -1
- {destiny_sdk-0.1.0 → destiny_sdk-0.1.2}/src/destiny_sdk/robots.py +49 -1
- {destiny_sdk-0.1.0 → destiny_sdk-0.1.2}/LICENSE +0 -0
- {destiny_sdk-0.1.0 → destiny_sdk-0.1.2}/src/destiny_sdk/__init__.py +0 -0
- {destiny_sdk-0.1.0 → destiny_sdk-0.1.2}/src/destiny_sdk/auth.py +0 -0
- {destiny_sdk-0.1.0 → destiny_sdk-0.1.2}/src/destiny_sdk/client.py +0 -0
- {destiny_sdk-0.1.0 → destiny_sdk-0.1.2}/src/destiny_sdk/core.py +0 -0
- {destiny_sdk-0.1.0 → destiny_sdk-0.1.2}/src/destiny_sdk/identifiers.py +0 -0
- {destiny_sdk-0.1.0 → destiny_sdk-0.1.2}/src/destiny_sdk/py.typed +0 -0
- {destiny_sdk-0.1.0 → destiny_sdk-0.1.2}/src/destiny_sdk/visibility.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: destiny_sdk
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: A software development kit (sdk) to support interaction with the DESTINY repository
|
|
5
5
|
License: Apache 2.0
|
|
6
6
|
Author: Adam Hamilton
|
|
@@ -90,3 +90,13 @@ poetry config pypi-token.pypi [YOUR_PYPI_TOKEN]
|
|
|
90
90
|
poetry publish
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
+
### Versioning
|
|
94
|
+
|
|
95
|
+
Follow the [semver](https://semver.org/) guidelines for versioning, tldr;
|
|
96
|
+
|
|
97
|
+
Given a version number `MAJOR.MINOR.PATCH`, increment the:
|
|
98
|
+
|
|
99
|
+
- `MAJOR` version when you make incompatible API change
|
|
100
|
+
- `MINOR` version when you add functionality in a backward compatible manner
|
|
101
|
+
- `PATCH` version when you make backward compatible bug fixes
|
|
102
|
+
|
|
@@ -67,3 +67,13 @@ poetry publish --repository testpypi
|
|
|
67
67
|
poetry config pypi-token.pypi [YOUR_PYPI_TOKEN]
|
|
68
68
|
poetry publish
|
|
69
69
|
```
|
|
70
|
+
|
|
71
|
+
### Versioning
|
|
72
|
+
|
|
73
|
+
Follow the [semver](https://semver.org/) guidelines for versioning, tldr;
|
|
74
|
+
|
|
75
|
+
Given a version number `MAJOR.MINOR.PATCH`, increment the:
|
|
76
|
+
|
|
77
|
+
- `MAJOR` version when you make incompatible API change
|
|
78
|
+
- `MINOR` version when you add functionality in a backward compatible manner
|
|
79
|
+
- `PATCH` version when you make backward compatible bug fixes
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"""Enhancement classes for the Destiny Repository."""
|
|
2
2
|
|
|
3
|
+
import datetime
|
|
3
4
|
import uuid
|
|
4
5
|
from enum import StrEnum, auto
|
|
5
6
|
from typing import Annotated, Literal
|
|
6
7
|
|
|
7
|
-
from pydantic import BaseModel, Field, HttpUrl
|
|
8
|
+
from pydantic import BaseModel, Field, HttpUrl
|
|
8
9
|
|
|
9
10
|
from destiny_sdk.core import _JsonlFileInputMixIn
|
|
10
11
|
from destiny_sdk.visibility import Visibility
|
|
@@ -86,10 +87,10 @@ class BibliographicMetadataEnhancement(BaseModel):
|
|
|
86
87
|
other works have cited this work
|
|
87
88
|
""",
|
|
88
89
|
)
|
|
89
|
-
created_date:
|
|
90
|
+
created_date: datetime.date | None = Field(
|
|
90
91
|
default=None, description="The ISO8601 date this metadata record was created"
|
|
91
92
|
)
|
|
92
|
-
publication_date:
|
|
93
|
+
publication_date: datetime.date | None = Field(
|
|
93
94
|
default=None, description="The date which the version of record was published."
|
|
94
95
|
)
|
|
95
96
|
publication_year: int | None = Field(
|
|
@@ -172,10 +173,11 @@ class ScoreAnnotation(BaseModel):
|
|
|
172
173
|
)
|
|
173
174
|
score: float = Field(description="""Score for this annotation""")
|
|
174
175
|
data: dict = Field(
|
|
176
|
+
default_factory=dict,
|
|
175
177
|
description=(
|
|
176
178
|
"An object representation of the annotation including any confidence scores"
|
|
177
179
|
" or descriptions."
|
|
178
|
-
)
|
|
180
|
+
),
|
|
179
181
|
)
|
|
180
182
|
|
|
181
183
|
|
|
@@ -200,6 +202,7 @@ class BooleanAnnotation(BaseModel):
|
|
|
200
202
|
None, description="A confidence score for this annotation"
|
|
201
203
|
)
|
|
202
204
|
data: dict = Field(
|
|
205
|
+
default_factory=dict,
|
|
203
206
|
description="""
|
|
204
207
|
An object representation of the annotation including any confidence scores or
|
|
205
208
|
descriptions.
|
|
@@ -34,13 +34,20 @@ class ImportBatchStatus(StrEnum):
|
|
|
34
34
|
|
|
35
35
|
- `created`: Created, but no processing has started.
|
|
36
36
|
- `started`: Processing has started on the batch.
|
|
37
|
+
- `failed`: Processing has failed.
|
|
38
|
+
- `retrying`: Processing has failed, but is being retried.
|
|
39
|
+
- `indexing`: The imports have been saved and are being indexed.
|
|
40
|
+
- `indexing_failed`: The imports have been saved but were not indexed.
|
|
37
41
|
- `completed`: Processing has been completed.
|
|
38
42
|
- `cancelled`: Processing was cancelled by calling the API.
|
|
39
43
|
"""
|
|
40
44
|
|
|
41
45
|
CREATED = auto()
|
|
42
46
|
STARTED = auto()
|
|
47
|
+
RETRYING = auto()
|
|
43
48
|
FAILED = auto()
|
|
49
|
+
INDEXING = auto()
|
|
50
|
+
INDEXING_FAILED = auto()
|
|
44
51
|
COMPLETED = auto()
|
|
45
52
|
CANCELLED = auto()
|
|
46
53
|
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"""Reference classes for the Destiny SDK."""
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from typing import Self
|
|
4
|
+
|
|
5
|
+
from pydantic import UUID4, BaseModel, Field, TypeAdapter
|
|
4
6
|
|
|
5
7
|
from destiny_sdk.core import _JsonlFileInputMixIn
|
|
6
8
|
from destiny_sdk.enhancements import Enhancement, EnhancementFileInput
|
|
7
9
|
from destiny_sdk.identifiers import ExternalIdentifier
|
|
8
10
|
from destiny_sdk.visibility import Visibility
|
|
9
11
|
|
|
12
|
+
external_identifier_adapter = TypeAdapter(ExternalIdentifier)
|
|
13
|
+
|
|
10
14
|
|
|
11
15
|
class Reference(_JsonlFileInputMixIn, BaseModel):
|
|
12
16
|
"""Core reference class."""
|
|
@@ -27,6 +31,24 @@ class Reference(_JsonlFileInputMixIn, BaseModel):
|
|
|
27
31
|
description="A list of enhancements for the reference",
|
|
28
32
|
)
|
|
29
33
|
|
|
34
|
+
@classmethod
|
|
35
|
+
def from_es(cls, es_reference: dict) -> Self:
|
|
36
|
+
"""Create a Reference from an Elasticsearch document."""
|
|
37
|
+
return cls(
|
|
38
|
+
id=es_reference["_id"],
|
|
39
|
+
visibility=Visibility(es_reference["_source"]["visibility"]),
|
|
40
|
+
identifiers=[
|
|
41
|
+
external_identifier_adapter.validate_python(identifier)
|
|
42
|
+
for identifier in es_reference["_source"].get("identifiers", [])
|
|
43
|
+
],
|
|
44
|
+
enhancements=[
|
|
45
|
+
Enhancement.model_validate(
|
|
46
|
+
enhancement | {"reference_id": es_reference["_id"]},
|
|
47
|
+
)
|
|
48
|
+
for enhancement in es_reference["_source"].get("enhancements", [])
|
|
49
|
+
],
|
|
50
|
+
)
|
|
51
|
+
|
|
30
52
|
|
|
31
53
|
class ReferenceFileInput(_JsonlFileInputMixIn, BaseModel):
|
|
32
54
|
"""Enhancement model used to marshall a file input."""
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Schemas that define inputs/outputs for robots."""
|
|
2
2
|
|
|
3
3
|
from enum import StrEnum, auto
|
|
4
|
-
from typing import Annotated, Self
|
|
4
|
+
from typing import Annotated, Any, Self
|
|
5
5
|
|
|
6
6
|
from pydantic import UUID4, BaseModel, ConfigDict, Field, HttpUrl, model_validator
|
|
7
7
|
|
|
@@ -174,6 +174,10 @@ class _EnhancementRequestBase(BaseModel):
|
|
|
174
174
|
robot_id: UUID4 = Field(
|
|
175
175
|
description="The robot to be used to create the enhancement."
|
|
176
176
|
)
|
|
177
|
+
source: str | None = Field(
|
|
178
|
+
default=None,
|
|
179
|
+
description="The source of the batch enhancement request.",
|
|
180
|
+
)
|
|
177
181
|
|
|
178
182
|
enhancement_parameters: dict | None = Field(
|
|
179
183
|
default=None, description="Information needed to create the enhancement. TBC."
|
|
@@ -208,6 +212,8 @@ class BatchEnhancementRequestStatus(StrEnum):
|
|
|
208
212
|
- `partial_failed`: Some enhancements failed to create.
|
|
209
213
|
- `failed`: All enhancements failed to create.
|
|
210
214
|
- `importing`: Enhancements have been received by the repo and are being imported.
|
|
215
|
+
- `indexing`: Enhancements have been imported and are being indexed.
|
|
216
|
+
- `indexing_failed`: Enhancements have been imported but indexing failed.
|
|
211
217
|
- `completed`: All enhancements have been created.
|
|
212
218
|
"""
|
|
213
219
|
|
|
@@ -217,6 +223,8 @@ class BatchEnhancementRequestStatus(StrEnum):
|
|
|
217
223
|
PARTIAL_FAILED = auto()
|
|
218
224
|
FAILED = auto()
|
|
219
225
|
IMPORTING = auto()
|
|
226
|
+
INDEXING = auto()
|
|
227
|
+
INDEXING_FAILED = auto()
|
|
220
228
|
COMPLETED = auto()
|
|
221
229
|
|
|
222
230
|
|
|
@@ -233,6 +241,10 @@ class _BatchEnhancementRequestBase(BaseModel):
|
|
|
233
241
|
reference_ids: list[UUID4] = Field(
|
|
234
242
|
description="The IDs of the references to be enhanced."
|
|
235
243
|
)
|
|
244
|
+
source: str | None = Field(
|
|
245
|
+
default=None,
|
|
246
|
+
description="The source of the batch enhancement request.",
|
|
247
|
+
)
|
|
236
248
|
|
|
237
249
|
|
|
238
250
|
class BatchEnhancementRequestIn(_BatchEnhancementRequestBase):
|
|
@@ -335,3 +347,39 @@ class ProvisionedRobot(Robot):
|
|
|
335
347
|
description="The client secret of the robot, used as the secret key "
|
|
336
348
|
"when sending HMAC authenticated requests."
|
|
337
349
|
)
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
class _RobotAutomationBase(BaseModel):
|
|
353
|
+
"""Base Robot Automation class."""
|
|
354
|
+
|
|
355
|
+
query: dict[str, Any] = Field(
|
|
356
|
+
description="The percolator query that will be used to match references "
|
|
357
|
+
" or enhancements against."
|
|
358
|
+
)
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
class RobotAutomationIn(_RobotAutomationBase):
|
|
362
|
+
"""
|
|
363
|
+
Automation model for a robot.
|
|
364
|
+
|
|
365
|
+
This is used as a source of truth for an Elasticsearch index that percolates
|
|
366
|
+
references or enhancements against the queries. If a query matches, a request
|
|
367
|
+
is sent to the specified robot to perform the enhancement.
|
|
368
|
+
"""
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
class RobotAutomation(_RobotAutomationBase):
|
|
372
|
+
"""
|
|
373
|
+
Core Robot Automation class.
|
|
374
|
+
|
|
375
|
+
This is used as a source of truth for an Elasticsearch index that percolates
|
|
376
|
+
references or enhancements against the queries. If a query matches, a request
|
|
377
|
+
is sent to the specified robot to perform the enhancement.
|
|
378
|
+
"""
|
|
379
|
+
|
|
380
|
+
id: UUID4 = Field(
|
|
381
|
+
description="The ID of the robot automation.",
|
|
382
|
+
)
|
|
383
|
+
robot_id: UUID4 = Field(
|
|
384
|
+
description="The ID of the robot that will be used to enhance the reference."
|
|
385
|
+
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|