most-client 1.0.20__py3-none-any.whl → 1.0.22__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.
most/api.py CHANGED
@@ -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, )
most/async_api.py CHANGED
@@ -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, )
most/score_calculation.py CHANGED
@@ -1,23 +1,27 @@
1
- import dataclasses
2
1
  from typing import Dict, Tuple, List, Optional
3
-
2
+ from dataclasses_json import dataclass_json, DataClassJsonMixin
3
+ from dataclasses import dataclass, replace
4
4
  from .types import Result, ScriptScoreMapping
5
5
 
6
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
- }
7
+ @dataclass_json
8
+ @dataclass
9
+ class ScoreCalculation(DataClassJsonMixin):
10
+ score_mapping: List[ScriptScoreMapping]
14
11
 
15
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
+ }
16
17
  if result is None:
17
18
  return None
18
- result = dataclasses.replace(result)
19
+ result = replace(result)
19
20
  for column_result in result.results:
20
21
  for subcolumn_result in column_result.subcolumns:
21
- subcolumn_result.score = self.score_mapping[(column_result.name, subcolumn_result.name, subcolumn_result.score)]
22
+ subcolumn_result.score = score_mapping.get((column_result.name,
23
+ subcolumn_result.name,
24
+ subcolumn_result.score),
25
+ subcolumn_result.score)
22
26
 
23
27
  return result
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: most-client
3
- Version: 1.0.20
3
+ Version: 1.0.22
4
4
  Summary: Most AI API for https://the-most.ai
5
5
  Home-page: https://github.com/the-most-ai/most-client
6
6
  Author: George Kasparyants
@@ -0,0 +1,10 @@
1
+ most/__init__.py,sha256=62uFFeM_1VVR83K3bTYWK3PEoqnmFCy9aWYerQ6U4Ds,67
2
+ most/api.py,sha256=ffgsS-i9pxNOgjMBd7-G-PqA69-VFCVn47vHSJW8XeM,15980
3
+ most/async_api.py,sha256=UF7DXTmIGfPl93noMR742FkMiRtSO5zLV-c4qZVDMNs,16949
4
+ most/score_calculation.py,sha256=1XU1LfIH5LSCwAbAaKkr-EjH5qOTXrJKOUvhCCawka4,1054
5
+ most/types.py,sha256=Qgyv261J8b1cfbmeITz1C9QgkoCMGQQd_L4t4M3dd6M,3603
6
+ most_client-1.0.22.dist-info/METADATA,sha256=ske3Ee2ObuBu-q6omKkTPdwBgwfAKqVDTmf-jn0vlDs,1027
7
+ most_client-1.0.22.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
8
+ most_client-1.0.22.dist-info/top_level.txt,sha256=2g5fk02LKkM1hV3pVVti_LQ60TToLBcR2zQ3JEKGVk8,5
9
+ most_client-1.0.22.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
10
+ most_client-1.0.22.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.2)
2
+ Generator: setuptools (76.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,10 +0,0 @@
1
- most/__init__.py,sha256=62uFFeM_1VVR83K3bTYWK3PEoqnmFCy9aWYerQ6U4Ds,67
2
- most/api.py,sha256=8OzUI_Af0Ct1hx0fopTf3bDGPU8gxWuuMP1VvxpAFiU,14227
3
- most/async_api.py,sha256=40orcOYLvFJTTlfYGIyyUXvvsfKYchDblRXzHNNGNPs,15124
4
- most/score_calculation.py,sha256=oGBEIzefKiqCS77BOX7-jHTvpLRkH0Vhnqu1IVDmsdM,800
5
- most/types.py,sha256=Qgyv261J8b1cfbmeITz1C9QgkoCMGQQd_L4t4M3dd6M,3603
6
- most_client-1.0.20.dist-info/METADATA,sha256=XTRaD7okJvsBLOJWUKlRTPaRhM423CFOkQ6wuT2_1XI,1027
7
- most_client-1.0.20.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
8
- most_client-1.0.20.dist-info/top_level.txt,sha256=2g5fk02LKkM1hV3pVVti_LQ60TToLBcR2zQ3JEKGVk8,5
9
- most_client-1.0.20.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
10
- most_client-1.0.20.dist-info/RECORD,,