destiny_sdk 0.1.3__tar.gz → 0.1.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: destiny_sdk
3
- Version: 0.1.3
3
+ Version: 0.1.5
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
@@ -75,20 +75,9 @@ poetry build
75
75
  poetry add ./PATH/TO/WHEEL.whl
76
76
  ```
77
77
 
78
- ### Publishing to test pypi
78
+ ### Publishing
79
79
 
80
- ```sh
81
- poetry config repositories.testpypi https://test.pypi.org/legacy/
82
- poetry config pypi-token.testpypi [YOUR_TESTPYPI_TOKEN]
83
- poetry publish --repository testpypi
84
- ```
85
-
86
- ## Publishing
87
-
88
- ```sh
89
- poetry config pypi-token.pypi [YOUR_PYPI_TOKEN]
90
- poetry publish
91
- ```
80
+ Once the package change is merged to main with an iterated `libs/sdk/pyproject.toml` version number, you can run the [github action](https://github.com/destiny-evidence/destiny-repository/actions/workflows/release-sdk-to-pypi.yml) to publish to the test pypi and then production pypi registries.
92
81
 
93
82
  ### Versioning
94
83
 
@@ -53,20 +53,9 @@ poetry build
53
53
  poetry add ./PATH/TO/WHEEL.whl
54
54
  ```
55
55
 
56
- ### Publishing to test pypi
56
+ ### Publishing
57
57
 
58
- ```sh
59
- poetry config repositories.testpypi https://test.pypi.org/legacy/
60
- poetry config pypi-token.testpypi [YOUR_TESTPYPI_TOKEN]
61
- poetry publish --repository testpypi
62
- ```
63
-
64
- ## Publishing
65
-
66
- ```sh
67
- poetry config pypi-token.pypi [YOUR_PYPI_TOKEN]
68
- poetry publish
69
- ```
58
+ Once the package change is merged to main with an iterated `libs/sdk/pyproject.toml` version number, you can run the [github action](https://github.com/destiny-evidence/destiny-repository/actions/workflows/release-sdk-to-pypi.yml) to publish to the test pypi and then production pypi registries.
70
59
 
71
60
  ### Versioning
72
61
 
@@ -13,7 +13,7 @@ description = "A software development kit (sdk) to support interaction with the
13
13
  license = "Apache 2.0"
14
14
  name = "destiny_sdk"
15
15
  readme = "README.md"
16
- version = "0.1.3"
16
+ version = "0.1.5"
17
17
 
18
18
  [tool.poetry.dependencies]
19
19
  cachetools = "^5.5.2"
@@ -219,7 +219,7 @@ class AnnotationEnhancement(BaseModel):
219
219
  """An enhancement which is composed of a list of Annotations."""
220
220
 
221
221
  enhancement_type: Literal[EnhancementType.ANNOTATION] = EnhancementType.ANNOTATION
222
- annotations: list[Annotation]
222
+ annotations: list[Annotation] = Field(min_length=1)
223
223
 
224
224
 
225
225
  class DriverVersion(StrEnum):
@@ -299,7 +299,8 @@ class LocationEnhancement(BaseModel):
299
299
 
300
300
  enhancement_type: Literal[EnhancementType.LOCATION] = EnhancementType.LOCATION
301
301
  locations: list[Location] = Field(
302
- description="A list of locations where this reference can be found."
302
+ min_length=1,
303
+ description="A list of locations where this reference can be found.",
303
304
  )
304
305
 
305
306
 
@@ -1,12 +1,16 @@
1
1
  """Reference classes for the Destiny SDK."""
2
2
 
3
- from pydantic import UUID4, BaseModel, Field
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."""
File without changes