playmak3r commited on
Commit
3c83381
·
1 Parent(s): 1c9a4c3

feat: add option to run the worker from translation_queue module

Browse files
opus_api/__init__.py CHANGED
@@ -1,2 +1,5 @@
1
- from opus_api.app_uvi import *
 
 
 
2
 
 
1
+ # __init__.py importei o pacote
2
+ # __main__.py → executei o pacote
3
+ from .app_uvi import main
4
+
5
 
opus_api/app_uvi.py CHANGED
@@ -81,4 +81,6 @@ def main():
81
  uvicorn.run("opus_api.app_uvi:app", host="0.0.0.0", port=7860, reload=False)
82
 
83
  if __name__ == "__main__":
84
- main()
 
 
 
81
  uvicorn.run("opus_api.app_uvi:app", host="0.0.0.0", port=7860, reload=False)
82
 
83
  if __name__ == "__main__":
84
+ main()
85
+
86
+
opus_api/translation_queue.py CHANGED
@@ -1,6 +1,7 @@
1
  import time, os
2
  import asyncio
3
  from huey import SqliteHuey
 
4
  from opus_api.model import run, run_batch
5
  from typing import List
6
 
@@ -39,4 +40,10 @@ async def status(task_id: str):
39
  "status": "pending",
40
  }]
41
 
 
 
 
42
 
 
 
 
 
1
  import time, os
2
  import asyncio
3
  from huey import SqliteHuey
4
+ from huey.consumer import Consumer
5
  from opus_api.model import run, run_batch
6
  from typing import List
7
 
 
40
  "status": "pending",
41
  }]
42
 
43
+ def run_worker():
44
+ consumer = Consumer(huey, workers=4)
45
+ consumer.run()
46
 
47
+
48
+ if __name__ == "__main__":
49
+ run_worker()
setup.py CHANGED
@@ -1,13 +1,17 @@
1
  from setuptools import setup, find_packages
2
 
 
 
 
 
3
  setup(
4
  name="opus_api",
5
  version="1.0",
6
  packages=["opus_api"],
7
- #install_requires=[],
8
  entry_points={
9
  "console_scripts": [
10
- "app_uvi=opus_api.app_uvi.__main__:main", # Substitua pelo ponto de entrada correto
11
  ],
12
  },
13
  )
 
1
  from setuptools import setup, find_packages
2
 
3
+
4
+ with open('requirements.txt', 'r', encoding='utf-8') as fh:
5
+ install_requires = fh.read().splitlines()
6
+
7
  setup(
8
  name="opus_api",
9
  version="1.0",
10
  packages=["opus_api"],
11
+ install_requires=install_requires,
12
  entry_points={
13
  "console_scripts": [
14
+ "opus_api=opus_api.app_uvi.__main__:main", # Substitua pelo ponto de entrada correto
15
  ],
16
  },
17
  )