destiny_sdk 0.2.3__py3-none-any.whl → 0.3.0__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.
destiny_sdk/client.py CHANGED
@@ -7,8 +7,6 @@ import httpx
7
7
  from pydantic import UUID4, HttpUrl
8
8
 
9
9
  from destiny_sdk.robots import (
10
- BatchEnhancementRequestRead,
11
- BatchRobotResult,
12
10
  EnhancementRequestRead,
13
11
  RobotResult,
14
12
  )
@@ -80,34 +78,14 @@ class Client:
80
78
 
81
79
  Signs the request with the client's secret key.
82
80
 
83
- :param robot_result: The Robot Result to send
81
+ :param robot_result: The RobotResult to send
84
82
  :type robot_result: RobotResult
85
83
  :return: The EnhancementRequestRead object from the response.
86
84
  :rtype: EnhancementRequestRead
87
85
  """
88
86
  response = self.session.post(
89
- f"/enhancement-requests/single-requests/{robot_result.request_id}/results/",
87
+ f"/enhancement-requests/{robot_result.request_id}/results/",
90
88
  json=robot_result.model_dump(mode="json"),
91
89
  )
92
90
  response.raise_for_status()
93
91
  return EnhancementRequestRead.model_validate(response.json())
94
-
95
- def send_batch_robot_result(
96
- self, batch_robot_result: BatchRobotResult
97
- ) -> BatchEnhancementRequestRead:
98
- """
99
- Send a BatchRobotResult to destiny repository.
100
-
101
- Signs the request with the client's secret key.
102
-
103
- :param batch_robot_result: The Batch Robot Result to send
104
- :type batch_robot_result: BatchRobotResult
105
- :return: The BatchEnhancementRequestRead object from the response.
106
- :rtype: BatchEnhancementRequestRead
107
- """
108
- response = self.session.post(
109
- f"/enhancement-requests/batch-requests/{batch_robot_result.request_id}/results/",
110
- json=batch_robot_result.model_dump(mode="json"),
111
- )
112
- response.raise_for_status()
113
- return BatchEnhancementRequestRead.model_validate(response.json())
destiny_sdk/robots.py CHANGED
@@ -1,13 +1,12 @@
1
1
  """Schemas that define inputs/outputs for robots."""
2
2
 
3
3
  from enum import StrEnum, auto
4
- from typing import Annotated, Any, Self
4
+ from typing import Annotated, Any
5
5
 
6
- from pydantic import UUID4, BaseModel, ConfigDict, Field, HttpUrl, model_validator
6
+ from pydantic import UUID4, BaseModel, ConfigDict, Field, HttpUrl
7
7
 
8
8
  from destiny_sdk.core import _JsonlFileInputMixIn
9
9
  from destiny_sdk.enhancements import Enhancement
10
- from destiny_sdk.references import Reference
11
10
 
12
11
 
13
12
  class RobotError(BaseModel):
@@ -37,29 +36,6 @@ class LinkedRobotError(_JsonlFileInputMixIn, RobotError):
37
36
 
38
37
 
39
38
  class RobotResult(BaseModel):
40
- """The result of a robot request which is returned to the repo."""
41
-
42
- request_id: UUID4
43
- error: RobotError | None = Field(
44
- default=None,
45
- description="Error the robot encountered while creating enhancement.",
46
- )
47
- enhancement: Enhancement | None = Field(
48
- default=None, description="An enhancement to create"
49
- )
50
-
51
- @model_validator(mode="after")
52
- def validate_error_or_enhancement_set(self) -> Self:
53
- """Validate that a robot result has either an error or an enhancement set."""
54
- if (self.error is None) == (self.enhancement is None):
55
- msg = """
56
- exactly one of 'error' or 'enhancement' must be provided
57
- """
58
- raise ValueError(msg)
59
- return self
60
-
61
-
62
- class BatchRobotResult(BaseModel):
63
39
  """Used to indicate to the repository that the robot has finished processing."""
64
40
 
65
41
  request_id: UUID4
@@ -67,7 +43,8 @@ class BatchRobotResult(BaseModel):
67
43
  default=None,
68
44
  description="""
69
45
  Error the robot encountered while creating enhancements. If this field is populated,
70
- we assume the entire batch or request failed, rather than an individual reference.
46
+ we assume the entire enhancement request or http request request failed,
47
+ rather than an individual reference.
71
48
  If there was an error with processing an individual reference, it should be passed in
72
49
  the result file and this field should be left as None. Vice-versa, if this field is
73
50
  None, the repository will assume that the result file is ready for processing.
@@ -75,14 +52,14 @@ None, the repository will assume that the result file is ready for processing.
75
52
  )
76
53
 
77
54
 
78
- class BatchRobotResultValidationEntry(_JsonlFileInputMixIn, BaseModel):
55
+ class RobotResultValidationEntry(_JsonlFileInputMixIn, BaseModel):
79
56
  """A single entry in the validation result file for a batch enhancement request."""
80
57
 
81
58
  reference_id: UUID4 | None = Field(
82
59
  default=None,
83
60
  description=(
84
61
  "The ID of the reference which was enhanced. "
85
- "If this is empty, the BatchEnhancementResultEntry could not be parsed."
62
+ "If this is empty, the EnhancementResultEntry could not be parsed."
86
63
  ),
87
64
  )
88
65
  error: str | None = Field(
@@ -94,30 +71,15 @@ class BatchRobotResultValidationEntry(_JsonlFileInputMixIn, BaseModel):
94
71
  )
95
72
 
96
73
 
97
- class RobotRequest(BaseModel):
98
- """An enhancement request from the repo to a robot."""
99
-
100
- id: UUID4
101
- reference: Reference = Field(
102
- description=(
103
- "Reference to be enhanced, includes identifiers and existing enhancments."
104
- )
105
- )
106
- extra_fields: dict | None = Field(
107
- default=None,
108
- description="Extra fields to pass to the robot. TBC.",
109
- )
110
-
111
-
112
- #: The result for a single reference when processed by a batch enhancement request.
74
+ #: The result for a single reference when processed by an enhancement request.
113
75
  #: This is a single entry in the result file.
114
- BatchEnhancementResultEntry = Annotated[
76
+ EnhancementResultEntry = Annotated[
115
77
  Enhancement | LinkedRobotError,
116
78
  Field(),
117
79
  ]
118
80
 
119
81
 
120
- class BatchRobotRequest(BaseModel):
82
+ class RobotRequest(BaseModel):
121
83
  """A batch enhancement request from the repo to a robot."""
122
84
 
123
85
  id: UUID4
@@ -130,16 +92,16 @@ reference per line.
130
92
  Each reference may have identifiers or enhancements attached, as
131
93
  required by the robot.
132
94
  If the URL expires, a new one can be generated using
133
- ``GET /references/enhancement/batch/<batch_request_id>``.
95
+ ``GET /enhancement-requests/{request_id}/``.
134
96
  """
135
97
  )
136
98
  result_storage_url: HttpUrl = Field(
137
99
  description="""
138
100
  The URL at which the set of enhancements are to be stored. The file is to be a jsonl
139
101
  with each line formatted according to
140
- :class:`BatchEnhancementResultEntry <libs.sdk.src.destiny_sdk.robots.BatchEnhancementResultEntry>`.
102
+ :class:`EnhancementResultEntry <libs.sdk.src.destiny_sdk.robots.EnhancementResultEntry>`.
141
103
  If the URL expires, a new one can be generated using
142
- ``GET /references/enhancement/batch/<batch_request_id>``.
104
+ ``GET /enhancement-requests/{request_id}/``.
143
105
  """ # noqa: E501
144
106
  )
145
107
  extra_fields: dict | None = Field(
@@ -152,64 +114,6 @@ class EnhancementRequestStatus(StrEnum):
152
114
  """
153
115
  The status of an enhancement request.
154
116
 
155
- **Allowed values**:
156
- - `received`: Enhancement request has been received.
157
- - `accepted`: Enhancement request has been accepted.
158
- - `rejected`: Enhancement request has been rejected.
159
- - `failed`: Enhancement failed to create.
160
- - `completed`: Enhancement has been created.
161
- """
162
-
163
- RECEIVED = auto()
164
- ACCEPTED = auto()
165
- REJECTED = auto()
166
- FAILED = auto()
167
- COMPLETED = auto()
168
-
169
-
170
- class _EnhancementRequestBase(BaseModel):
171
- """
172
- Base enhancement request class.
173
-
174
- An enhancement request is a request to create an enhancement on a reference.
175
- It contains the reference and the robot to be used to create the enhancement.
176
- """
177
-
178
- reference_id: UUID4 = Field(description="The ID of the reference to be enhanced.")
179
- robot_id: UUID4 = Field(
180
- description="The robot to be used to create the enhancement."
181
- )
182
- source: str | None = Field(
183
- default=None,
184
- description="The source of the batch enhancement request.",
185
- )
186
-
187
- enhancement_parameters: dict | None = Field(
188
- default=None, description="Information needed to create the enhancement. TBC."
189
- )
190
-
191
-
192
- class EnhancementRequestIn(_EnhancementRequestBase):
193
- """The model for requesting an enhancement on specific reference."""
194
-
195
-
196
- class EnhancementRequestRead(_EnhancementRequestBase):
197
- """Core enhancement request class."""
198
-
199
- id: UUID4
200
- request_status: EnhancementRequestStatus = Field(
201
- description="The status of the request to create an enhancement",
202
- )
203
- error: str | None = Field(
204
- default=None,
205
- description="Error encountered during the enhancement process",
206
- )
207
-
208
-
209
- class BatchEnhancementRequestStatus(StrEnum):
210
- """
211
- The status of an enhancement request.
212
-
213
117
  **Allowed values**:
214
118
  - `received`: Enhancement request has been received by the repo.
215
119
  - `accepted`: Enhancement request has been accepted by the robot.
@@ -233,11 +137,11 @@ class BatchEnhancementRequestStatus(StrEnum):
233
137
  COMPLETED = auto()
234
138
 
235
139
 
236
- class _BatchEnhancementRequestBase(BaseModel):
140
+ class _EnhancementRequestBase(BaseModel):
237
141
  """
238
- Base batch enhancement request class.
142
+ Base enhancement request class.
239
143
 
240
- A batch enhancement request is a request to create multiple enhancements.
144
+ A enhancement request is a request to create one or more enhancements.
241
145
  """
242
146
 
243
147
  robot_id: UUID4 = Field(
@@ -252,15 +156,15 @@ class _BatchEnhancementRequestBase(BaseModel):
252
156
  )
253
157
 
254
158
 
255
- class BatchEnhancementRequestIn(_BatchEnhancementRequestBase):
159
+ class EnhancementRequestIn(_EnhancementRequestBase):
256
160
  """The model for requesting multiple enhancements on specific references."""
257
161
 
258
162
 
259
- class BatchEnhancementRequestRead(_BatchEnhancementRequestBase):
163
+ class EnhancementRequestRead(_EnhancementRequestBase):
260
164
  """Core batch enhancement request class."""
261
165
 
262
166
  id: UUID4
263
- request_status: BatchEnhancementRequestStatus = Field(
167
+ request_status: EnhancementRequestStatus = Field(
264
168
  description="The status of the request to create enhancements",
265
169
  )
266
170
  reference_data_url: HttpUrl | None = Field(
@@ -273,7 +177,7 @@ formatted according to
273
177
  Each reference may have identifiers or enhancements attached, as
274
178
  required by the robot.
275
179
  If the URL expires, a new one can be generated using
276
- ``GET /references/enhancement/batch/<batch_request_id>``.
180
+ ``GET /enhancement-requests/{request_id}/``.
277
181
  """,
278
182
  )
279
183
  result_storage_url: HttpUrl | None = Field(
@@ -281,26 +185,26 @@ If the URL expires, a new one can be generated using
281
185
  description="""
282
186
  The URL at which the set of enhancements are stored. The file is to be a jsonl
283
187
  with each line formatted according to
284
- :class:`BatchEnhancementResultEntry <libs.sdk.src.destiny_sdk.robots.BatchEnhancementResultEntry>`.
188
+ :class:`EnhancementResultEntry <libs.sdk.src.destiny_sdk.robots.EnhancementResultEntry>`.
285
189
  This field is only relevant to robots.
286
190
  If the URL expires, a new one can be generated using
287
- ``GET /references/enhancement/batch/<batch_request_id>``.
191
+ ``GET /enhancement-requests/{request_id}/``.
288
192
  """, # noqa: E501
289
193
  )
290
194
  validation_result_url: HttpUrl | None = Field(
291
195
  default=None,
292
196
  description="""
293
- The URL at which the result of the batch enhancement request is stored.
197
+ The URL at which the result of the enhancement request is stored.
294
198
  This file is a txt file, one line per reference, with either an error
295
199
  or a success message.
296
200
  If the URL expires, a new one can be generated using
297
- ``GET /references/enhancement/batch/<batch_request_id>``.
201
+ ``GET /enhancement-requests/{request_id}/``.
298
202
  """,
299
203
  )
300
204
  error: str | None = Field(
301
205
  default=None,
302
206
  description="Error encountered during the enhancement process. This "
303
- "is only used if the entire batch enhancement request failed, rather than an "
207
+ "is only used if the entire enhancement request failed, rather than an "
304
208
  "individual reference. If there was an error with processing an individual "
305
209
  "reference, it is passed in the validation result file.",
306
210
  )
@@ -317,8 +221,7 @@ class _RobotBase(BaseModel):
317
221
 
318
222
  name: str = Field(description="The name of the robot, must be unique.")
319
223
  base_url: HttpUrl = Field(
320
- description="The base url of the robot. The robot must implement endpoints "
321
- "base_url/single for the enhancement of single references and "
224
+ description="The base url of the robot. The robot must implement endpoint"
322
225
  "base_url/batch for batch enhancements of references.",
323
226
  )
324
227
  description: str = Field(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: destiny_sdk
3
- Version: 0.2.3
3
+ Version: 0.3.0
4
4
  Summary: A software development kit (sdk) to support interaction with the DESTINY repository
5
5
  Author-email: Adam Hamilton <adam@futureevidence.org>, Andrew Harvey <andrew@futureevidence.org>, Daniel Breves <daniel@futureevidence.org>, Jack Walmisley <jack@futureevidence.org>
6
6
  License-Expression: Apache-2.0
@@ -1,17 +1,17 @@
1
1
  destiny_sdk/__init__.py,sha256=gmmrceJX84T4msk_GSm_OjTQvCpHFZRjnlUK5_7IODE,356
2
2
  destiny_sdk/auth.py,sha256=bY72ywZEcG_67YBd9PrwgWTXkCf58rhLvVEXrtXbWtA,6247
3
- destiny_sdk/client.py,sha256=ADPJhVA0vGR-wSI7tRxyUKwgd7xSEVFLIY2pLB7d9sc,3788
3
+ destiny_sdk/client.py,sha256=2X_z0Z0T5xPD2vRzDBXs2D-Xk-mkVGz9CRhIeJLuaaU,2906
4
4
  destiny_sdk/core.py,sha256=_FwDaczKTSaUSV_qfcnLhkBbZagh4ayFpN0qUwJ03-o,1448
5
5
  destiny_sdk/enhancements.py,sha256=_S_anq194qdaEGklgycSG1qLEJeWzKe1u3oyXNxAg54,11800
6
6
  destiny_sdk/identifiers.py,sha256=9CFEaPhZr2IHfL4RSAzOvidXhhzKLDPXiSKddBMWzwM,3606
7
7
  destiny_sdk/imports.py,sha256=mfC1QXbAU27iD3hO9OFTRQes352F6DS1U4fSMw26-8w,8243
8
8
  destiny_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  destiny_sdk/references.py,sha256=Dx-WKcv9gNJkKU9n52AYoEey7siTHR5_wBVBKSHND6Q,2321
10
- destiny_sdk/robots.py,sha256=CL8hRTyHhTp4PShLmCuX2Ck4UBScPkOF44ivT1XRbMs,12806
10
+ destiny_sdk/robots.py,sha256=aFOcAAmyWOixW2MnRfyKJORSYKf1tr0PWkyO9i3oJ4M,9605
11
11
  destiny_sdk/visibility.py,sha256=nDLqnWuSZSk0vG3ynzDpHAvaALsbk8cuEZujTsqf6no,684
12
12
  destiny_sdk/parsers/__init__.py,sha256=d5gS--bXla_0I7e_9wTBnGWMXt2U8b-_ndeprTPe1hk,149
13
13
  destiny_sdk/parsers/eppi_parser.py,sha256=aSTqmm8N2WK1gnkj38XvfWaEXsaf0y6je6h9qN0xvFA,5584
14
- destiny_sdk-0.2.3.dist-info/METADATA,sha256=UV-AOwRoOoCJsHyL6kQgHb0qLQEepDFt0PYvKNfPVHo,2440
15
- destiny_sdk-0.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- destiny_sdk-0.2.3.dist-info/licenses/LICENSE,sha256=6QURU4gvvTjVZ5rfp5amZ6FtFvcpPhAGUjxF5WSZAHI,9138
17
- destiny_sdk-0.2.3.dist-info/RECORD,,
14
+ destiny_sdk-0.3.0.dist-info/METADATA,sha256=Dki-h1DBuii3ToRUlotDtY_hVVxRvGerkqgeRYlGHkQ,2440
15
+ destiny_sdk-0.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ destiny_sdk-0.3.0.dist-info/licenses/LICENSE,sha256=6QURU4gvvTjVZ5rfp5amZ6FtFvcpPhAGUjxF5WSZAHI,9138
17
+ destiny_sdk-0.3.0.dist-info/RECORD,,