most-client 1.0.20__tar.gz → 1.0.21__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.2
2
2
  Name: most-client
3
- Version: 1.0.20
3
+ Version: 1.0.21
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
@@ -301,9 +301,11 @@ class MostClient(object):
301
301
  resp = self.get(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/info")
302
302
  return self.retort.load(resp.json(), StoredAudioData)
303
303
 
304
- def __call__(self, audio_path: Path):
304
+ def __call__(self, audio_path: Path,
305
+ modify_scores: bool = False) -> Result:
305
306
  audio = self.upload_audio(audio_path)
306
- return self.apply(audio.id)
307
+ return self.apply(audio.id,
308
+ modify_scores=modify_scores)
307
309
 
308
310
  def __repr__(self):
309
311
  return "<MostClient(model_id='%s')>" % (self.model_id, )
@@ -306,9 +306,11 @@ class AsyncMostClient(object):
306
306
  resp = await self.get(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/info")
307
307
  return self.retort.load(resp.json(), StoredAudioData)
308
308
 
309
- async def __call__(self, audio_path: Path):
309
+ async def __call__(self, audio_path: Path,
310
+ modify_scores: bool = False) -> Result:
310
311
  audio = await self.upload_audio(audio_path)
311
- return await self.apply(audio.id)
312
+ return await self.apply(audio.id,
313
+ modify_scores=modify_scores)
312
314
 
313
315
  def __repr__(self):
314
316
  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,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: most-client
3
- Version: 1.0.20
3
+ Version: 1.0.21
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
@@ -8,7 +8,7 @@ with open('requirements.txt', 'r') as f:
8
8
 
9
9
  setup(
10
10
  name='most-client',
11
- version='1.0.20',
11
+ version='1.0.21',
12
12
  python_requires=f'>=3.6',
13
13
  description='Most AI API for https://the-most.ai',
14
14
  url='https://github.com/the-most-ai/most-client',
@@ -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