most-client 1.0.20__tar.gz → 1.0.22__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.
- {most_client-1.0.20/most_client.egg-info → most_client-1.0.22}/PKG-INFO +1 -1
- {most_client-1.0.20 → most_client-1.0.22}/most/api.py +39 -2
- {most_client-1.0.20 → most_client-1.0.22}/most/async_api.py +39 -2
- most_client-1.0.22/most/score_calculation.py +27 -0
- {most_client-1.0.20 → most_client-1.0.22/most_client.egg-info}/PKG-INFO +1 -1
- {most_client-1.0.20 → most_client-1.0.22}/setup.py +1 -1
- most_client-1.0.20/most/score_calculation.py +0 -23
- {most_client-1.0.20 → most_client-1.0.22}/MANIFEST.in +0 -0
- {most_client-1.0.20 → most_client-1.0.22}/README.md +0 -0
- {most_client-1.0.20 → most_client-1.0.22}/most/__init__.py +0 -0
- {most_client-1.0.20 → most_client-1.0.22}/most/types.py +0 -0
- {most_client-1.0.20 → most_client-1.0.22}/most_client.egg-info/SOURCES.txt +0 -0
- {most_client-1.0.20 → most_client-1.0.22}/most_client.egg-info/dependency_links.txt +0 -0
- {most_client-1.0.20 → most_client-1.0.22}/most_client.egg-info/requires.txt +0 -0
- {most_client-1.0.20 → most_client-1.0.22}/most_client.egg-info/top_level.txt +0 -0
- {most_client-1.0.20 → most_client-1.0.22}/most_client.egg-info/zip-safe +0 -0
- {most_client-1.0.20 → most_client-1.0.22}/requirements.txt +0 -0
- {most_client-1.0.20 → most_client-1.0.22}/setup.cfg +0 -0
@@ -173,6 +173,13 @@ class MostClient(object):
|
|
173
173
|
audio_list = resp.json()
|
174
174
|
return self.retort.load(audio_list, List[Audio])
|
175
175
|
|
176
|
+
def list_texts(self,
|
177
|
+
offset: int = 0,
|
178
|
+
limit: int = 10) -> List[Text]:
|
179
|
+
resp = self.get(f"https://api.the-most.ai/api/external/{self.client_id}/list_texts?offset={offset}&limit={limit}")
|
180
|
+
texts_list = resp.json()
|
181
|
+
return self.retort.load(texts_list, List[Text])
|
182
|
+
|
176
183
|
def get_model_script(self) -> Script:
|
177
184
|
if not is_valid_id(self.model_id):
|
178
185
|
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
@@ -209,6 +216,20 @@ class MostClient(object):
|
|
209
216
|
result = self.score_modifier.modify(result)
|
210
217
|
return result
|
211
218
|
|
219
|
+
def apply_on_text(self, text_id,
|
220
|
+
modify_scores: bool = False) -> Result:
|
221
|
+
if not is_valid_id(self.model_id):
|
222
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
223
|
+
|
224
|
+
if not is_valid_id(text_id):
|
225
|
+
raise RuntimeError("Please use valid text_id. [try text.id from list_texts()]")
|
226
|
+
|
227
|
+
resp = self.post(f"https://api.the-most.ai/api/external/{self.client_id}/text/{text_id}/model/{self.model_id}/apply")
|
228
|
+
result = self.retort.load(resp.json(), Result)
|
229
|
+
if modify_scores:
|
230
|
+
result = self.score_modifier.modify(result)
|
231
|
+
return result
|
232
|
+
|
212
233
|
def apply_later(self, audio_id,
|
213
234
|
modify_scores: bool = False) -> Result:
|
214
235
|
if not is_valid_id(self.model_id):
|
@@ -223,6 +244,20 @@ class MostClient(object):
|
|
223
244
|
result = self.score_modifier.modify(result)
|
224
245
|
return result
|
225
246
|
|
247
|
+
def apply_on_text_later(self, text_id,
|
248
|
+
modify_scores: bool = False) -> Result:
|
249
|
+
if not is_valid_id(self.model_id):
|
250
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
251
|
+
|
252
|
+
if not is_valid_id(text_id):
|
253
|
+
raise RuntimeError("Please use valid text_id. [try audio.id from list_texts()]")
|
254
|
+
|
255
|
+
resp = self.post(f"https://api.the-most.ai/api/external/{self.client_id}/text/{text_id}/model/{self.model_id}/apply_async")
|
256
|
+
result = self.retort.load(resp.json(), Result)
|
257
|
+
if modify_scores:
|
258
|
+
result = self.score_modifier.modify(result)
|
259
|
+
return result
|
260
|
+
|
226
261
|
def get_job_status(self, audio_id) -> JobStatus:
|
227
262
|
if not is_valid_id(self.model_id):
|
228
263
|
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
@@ -301,9 +336,11 @@ class MostClient(object):
|
|
301
336
|
resp = self.get(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/info")
|
302
337
|
return self.retort.load(resp.json(), StoredAudioData)
|
303
338
|
|
304
|
-
def __call__(self, audio_path: Path
|
339
|
+
def __call__(self, audio_path: Path,
|
340
|
+
modify_scores: bool = False) -> Result:
|
305
341
|
audio = self.upload_audio(audio_path)
|
306
|
-
return self.apply(audio.id
|
342
|
+
return self.apply(audio.id,
|
343
|
+
modify_scores=modify_scores)
|
307
344
|
|
308
345
|
def __repr__(self):
|
309
346
|
return "<MostClient(model_id='%s')>" % (self.model_id, )
|
@@ -182,6 +182,13 @@ class AsyncMostClient(object):
|
|
182
182
|
audio_list = resp.json()
|
183
183
|
return self.retort.load(audio_list, List[Audio])
|
184
184
|
|
185
|
+
async def list_texts(self,
|
186
|
+
offset: int = 0,
|
187
|
+
limit: int = 10) -> List[Text]:
|
188
|
+
resp = await self.get(f"https://api.the-most.ai/api/external/{self.client_id}/list_texts?offset={offset}&limit={limit}")
|
189
|
+
texts_list = resp.json()
|
190
|
+
return self.retort.load(texts_list, List[Text])
|
191
|
+
|
185
192
|
async def get_model_script(self) -> Script:
|
186
193
|
if not is_valid_id(self.model_id):
|
187
194
|
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
@@ -218,6 +225,20 @@ class AsyncMostClient(object):
|
|
218
225
|
result = self.score_modifier.modify(result)
|
219
226
|
return result
|
220
227
|
|
228
|
+
async def apply_on_text(self, text_id,
|
229
|
+
modify_scores: bool = False) -> Result:
|
230
|
+
if not is_valid_id(self.model_id):
|
231
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
232
|
+
|
233
|
+
if not is_valid_id(text_id):
|
234
|
+
raise RuntimeError("Please use valid text_id. [try text.id from list_texts()]")
|
235
|
+
|
236
|
+
resp = await self.post(f"https://api.the-most.ai/api/external/{self.client_id}/text/{text_id}/model/{self.model_id}/apply")
|
237
|
+
result = self.retort.load(resp.json(), Result)
|
238
|
+
if modify_scores:
|
239
|
+
result = self.score_modifier.modify(result)
|
240
|
+
return result
|
241
|
+
|
221
242
|
async def apply_later(self, audio_id,
|
222
243
|
modify_scores: bool = False) -> Result:
|
223
244
|
if not is_valid_id(self.model_id):
|
@@ -232,6 +253,20 @@ class AsyncMostClient(object):
|
|
232
253
|
result = self.score_modifier.modify(result)
|
233
254
|
return result
|
234
255
|
|
256
|
+
async def apply_on_text_later(self, text_id,
|
257
|
+
modify_scores: bool = False) -> Result:
|
258
|
+
if not is_valid_id(self.model_id):
|
259
|
+
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
260
|
+
|
261
|
+
if not is_valid_id(text_id):
|
262
|
+
raise RuntimeError("Please use valid text_id. [try audio.id from list_texts()]")
|
263
|
+
|
264
|
+
resp = await self.post(f"https://api.the-most.ai/api/external/{self.client_id}/text/{text_id}/model/{self.model_id}/apply_async")
|
265
|
+
result = self.retort.load(resp.json(), Result)
|
266
|
+
if modify_scores:
|
267
|
+
result = self.score_modifier.modify(result)
|
268
|
+
return result
|
269
|
+
|
235
270
|
async def get_job_status(self, audio_id) -> JobStatus:
|
236
271
|
if not is_valid_id(self.model_id):
|
237
272
|
raise RuntimeError("Please choose valid model to apply. [try list_models()]")
|
@@ -306,9 +341,11 @@ class AsyncMostClient(object):
|
|
306
341
|
resp = await self.get(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/info")
|
307
342
|
return self.retort.load(resp.json(), StoredAudioData)
|
308
343
|
|
309
|
-
async def __call__(self, audio_path: Path
|
344
|
+
async def __call__(self, audio_path: Path,
|
345
|
+
modify_scores: bool = False) -> Result:
|
310
346
|
audio = await self.upload_audio(audio_path)
|
311
|
-
return await self.apply(audio.id
|
347
|
+
return await self.apply(audio.id,
|
348
|
+
modify_scores=modify_scores)
|
312
349
|
|
313
350
|
def __repr__(self):
|
314
351
|
return "<AsyncMostClient(model_id='%s')>" % (self.model_id, )
|
@@ -0,0 +1,27 @@
|
|
1
|
+
from typing import Dict, Tuple, List, Optional
|
2
|
+
from dataclasses_json import dataclass_json, DataClassJsonMixin
|
3
|
+
from dataclasses import dataclass, replace
|
4
|
+
from .types import Result, ScriptScoreMapping
|
5
|
+
|
6
|
+
|
7
|
+
@dataclass_json
|
8
|
+
@dataclass
|
9
|
+
class ScoreCalculation(DataClassJsonMixin):
|
10
|
+
score_mapping: List[ScriptScoreMapping]
|
11
|
+
|
12
|
+
def modify(self, result: Optional[Result]):
|
13
|
+
score_mapping = {
|
14
|
+
(sm.column, sm.subcolumn, sm.from_score): sm.to_score
|
15
|
+
for sm in self.score_mapping
|
16
|
+
}
|
17
|
+
if result is None:
|
18
|
+
return None
|
19
|
+
result = replace(result)
|
20
|
+
for column_result in result.results:
|
21
|
+
for subcolumn_result in column_result.subcolumns:
|
22
|
+
subcolumn_result.score = score_mapping.get((column_result.name,
|
23
|
+
subcolumn_result.name,
|
24
|
+
subcolumn_result.score),
|
25
|
+
subcolumn_result.score)
|
26
|
+
|
27
|
+
return result
|
@@ -1,23 +0,0 @@
|
|
1
|
-
import dataclasses
|
2
|
-
from typing import Dict, Tuple, List, Optional
|
3
|
-
|
4
|
-
from .types import Result, ScriptScoreMapping
|
5
|
-
|
6
|
-
|
7
|
-
class ScoreCalculation:
|
8
|
-
def __init__(self, score_mapping: List[ScriptScoreMapping]):
|
9
|
-
super(ScoreCalculation, self).__init__()
|
10
|
-
self.score_mapping = {
|
11
|
-
(sm.column, sm.subcolumn, sm.from_score): sm.to_score
|
12
|
-
for sm in score_mapping
|
13
|
-
}
|
14
|
-
|
15
|
-
def modify(self, result: Optional[Result]):
|
16
|
-
if result is None:
|
17
|
-
return None
|
18
|
-
result = dataclasses.replace(result)
|
19
|
-
for column_result in result.results:
|
20
|
-
for subcolumn_result in column_result.subcolumns:
|
21
|
-
subcolumn_result.score = self.score_mapping[(column_result.name, subcolumn_result.name, subcolumn_result.score)]
|
22
|
-
|
23
|
-
return result
|
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
|