destiny_sdk 0.1.3__py3-none-any.whl → 0.1.5__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.
@@ -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
 
destiny_sdk/references.py CHANGED
@@ -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."""
@@ -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
 
@@ -2,14 +2,14 @@ destiny_sdk/__init__.py,sha256=gmmrceJX84T4msk_GSm_OjTQvCpHFZRjnlUK5_7IODE,356
2
2
  destiny_sdk/auth.py,sha256=bY72ywZEcG_67YBd9PrwgWTXkCf58rhLvVEXrtXbWtA,6247
3
3
  destiny_sdk/client.py,sha256=gUZJ8Mnmm1mUH7zd8fJbTksgPzBQQoYOFcuzJGiO2Dk,3642
4
4
  destiny_sdk/core.py,sha256=GgNc7EncHKyZ5ppIG2CATWN2JFPjtA7IYhF0FutqwGE,945
5
- destiny_sdk/enhancements.py,sha256=2bAFVMVWc-9-82sDnzd0Wujz8CeNm1C5ZtveuSX0JKU,11735
5
+ destiny_sdk/enhancements.py,sha256=Sciu5YCyYbOXCdlmqVdL6Z-J9nDjByj_H_QW4sfveU4,11780
6
6
  destiny_sdk/identifiers.py,sha256=JHxu-wM3T8kKtAYuk5dMec35Ay73KxYP7gthbSvOhuI,3480
7
7
  destiny_sdk/imports.py,sha256=mfC1QXbAU27iD3hO9OFTRQes352F6DS1U4fSMw26-8w,8243
8
8
  destiny_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- destiny_sdk/references.py,sha256=Tt9sVgw6WIXIhXGrlgGdRgIrIgQL0yr3Aqb0nr0WfK0,1493
9
+ destiny_sdk/references.py,sha256=Dx-WKcv9gNJkKU9n52AYoEey7siTHR5_wBVBKSHND6Q,2321
10
10
  destiny_sdk/robots.py,sha256=wBXDqD7WGG7fEGUsfQN9T9ZRDCE9jmGPfBwQHH0zO3g,12806
11
11
  destiny_sdk/visibility.py,sha256=nDLqnWuSZSk0vG3ynzDpHAvaALsbk8cuEZujTsqf6no,684
12
- destiny_sdk-0.1.3.dist-info/LICENSE,sha256=6QURU4gvvTjVZ5rfp5amZ6FtFvcpPhAGUjxF5WSZAHI,9138
13
- destiny_sdk-0.1.3.dist-info/METADATA,sha256=fPQsKE7jBjy1vo6-kOvbpxMszEqx-m5OlaaQhMxINsc,2543
14
- destiny_sdk-0.1.3.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
15
- destiny_sdk-0.1.3.dist-info/RECORD,,
12
+ destiny_sdk-0.1.5.dist-info/LICENSE,sha256=6QURU4gvvTjVZ5rfp5amZ6FtFvcpPhAGUjxF5WSZAHI,9138
13
+ destiny_sdk-0.1.5.dist-info/METADATA,sha256=5ck3Xf6TqtJbmUqap2ozSR67Y9H3gRZozXODBRqtVaw,2568
14
+ destiny_sdk-0.1.5.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
15
+ destiny_sdk-0.1.5.dist-info/RECORD,,