Skip to content

Commit d50294b

Browse files
authored
Merge pull request #4305 from akash5100/whisper-backend
Adds whisper backend
2 parents 109ca3c + 33060af commit d50294b

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

contentcuration/automation/tests/appnexus/test_base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import pytest
2+
13
from automation.utils.appnexus.base import Adapter
24
from automation.utils.appnexus.base import Backend
35

@@ -19,6 +21,11 @@ def mockoperation(self):
1921
pass
2022

2123

24+
def test_backend_error():
25+
with pytest.raises(NotImplementedError) as error:
26+
Backend.get_instance()
27+
assert "Subclasses should implement the creation of instance" in str(error.value)
28+
2229
def test_backend_singleton():
2330
b1, b2 = MockBackend.get_instance(), MockBackend.get_instance()
2431
assert id(b1) == id(b2)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from automation.utils.appnexus.base import Adapter
2+
from automation.utils.appnexus.base import Backend
3+
from automation.utils.appnexus.base import BackendFactory
4+
from automation.utils.appnexus.base import BackendRequest
5+
from automation.utils.appnexus.base import BackendResponse
6+
7+
8+
class WhisperRequest(BackendRequest):
9+
def __init__(self) -> None:
10+
super().__init__()
11+
12+
class WhisperResponse(BackendResponse):
13+
def __init__(self) -> None:
14+
super().__init__()
15+
16+
17+
class Whisper(Backend):
18+
def connect(self) -> None:
19+
raise NotImplementedError("The 'connect' method is not implemented for the 'Whisper' backend.")
20+
21+
def make_request(self, request: WhisperRequest) -> WhisperResponse:
22+
# Implement production backend here.
23+
pass
24+
25+
@classmethod
26+
def _create_instance(cls) -> 'Whisper':
27+
return cls()
28+
29+
class LocalWhisper(Backend):
30+
def make_request(self, request: WhisperRequest) -> WhisperResponse:
31+
# Implement your local backend here.
32+
pass
33+
34+
35+
class WhisperBackendFactory(BackendFactory):
36+
def create_backend(self) -> Backend:
37+
# Return backend based on some setting.
38+
return super().create_backend()
39+
40+
41+
class WhisperAdapter(Adapter):
42+
def transcribe(self, caption_file_id: str) -> WhisperResponse:
43+
request = WhisperRequest()
44+
return self.backend.make_request(request)

0 commit comments

Comments
 (0)