arpakitlib 1.7.118__py3-none-any.whl → 1.7.123__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.
Files changed (47) hide show
  1. arpakitlib/_arpakit_project_template/example.env +4 -0
  2. arpakitlib/_arpakit_project_template/manage/hello_world.py +2 -2
  3. arpakitlib/_arpakit_project_template/manage/json_beutify.py +2 -2
  4. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_1.py +4 -4
  5. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_2.py +4 -4
  6. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_3.py +4 -4
  7. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_4.py +4 -4
  8. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_5.py +4 -4
  9. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_6.py +4 -4
  10. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_7.py +4 -4
  11. arpakitlib/_arpakit_project_template/src/admin1/add_admin_in_app.py +3 -1
  12. arpakitlib/_arpakit_project_template/src/admin1/admin_auth.py +4 -7
  13. arpakitlib/_arpakit_project_template/src/admin1/model_view.py +5 -0
  14. arpakitlib/_arpakit_project_template/src/api/create_api_app.py +8 -51
  15. arpakitlib/_arpakit_project_template/src/api/event.py +51 -2
  16. arpakitlib/_arpakit_project_template/src/api/start_api_for_dev_with_reload.py +12 -4
  17. arpakitlib/_arpakit_project_template/src/api/{start_api_for_dev.py → start_api_for_dev_without_reload.py} +3 -3
  18. arpakitlib/_arpakit_project_template/src/api/transmitted_api_data.py +4 -0
  19. arpakitlib/_arpakit_project_template/src/business_service/hello_world.py +12 -0
  20. arpakitlib/_arpakit_project_template/{manage/logging_check.py → src/core/check_logging.py} +3 -3
  21. arpakitlib/_arpakit_project_template/{manage/settings_check.py → src/core/check_settings.py} +2 -0
  22. arpakitlib/_arpakit_project_template/src/core/generate_settings_env_example.py +16 -0
  23. arpakitlib/_arpakit_project_template/{manage/sqlalchemy_db_init.py → src/db/init_sqlalchemy_db.py} +2 -2
  24. arpakitlib/_arpakit_project_template/{manage/sqlalchemy_db_reinit.py → src/db/reinit_sqlalchemy_db.py} +4 -2
  25. arpakitlib/_arpakit_project_template/src/operation_execution/scheduled_operations.py +3 -3
  26. arpakitlib/_arpakit_project_template/src/operation_execution/{start_operation_executor_worker_for_dev.py → start_operation_executor_worker.py} +5 -4
  27. arpakitlib/_arpakit_project_template/src/operation_execution/{start_scheduled_operation_creator_worker_for_dev.py → start_scheduled_operation_creator_worker.py} +6 -4
  28. arpakitlib/_arpakit_project_template/src/operation_execution/util.py +0 -19
  29. arpakitlib/_arpakit_project_template/src/tg_bot/__init__.py +0 -0
  30. arpakitlib/_arpakit_project_template/src/tg_bot/router/__init__.py +0 -0
  31. arpakitlib/_arpakit_project_template/src/tg_bot/start_tg_bot.py +0 -0
  32. arpakitlib/ar_fastapi_util.py +0 -33
  33. arpakitlib/ar_settings_util.py +14 -5
  34. {arpakitlib-1.7.118.dist-info → arpakitlib-1.7.123.dist-info}/METADATA +1 -1
  35. {arpakitlib-1.7.118.dist-info → arpakitlib-1.7.123.dist-info}/RECORD +40 -42
  36. arpakitlib/_arpakit_project_template/AUTHOR.md +0 -4
  37. arpakitlib/_arpakit_project_template/manage/example_nginx_proxy.nginx +0 -14
  38. arpakitlib/_arpakit_project_template/manage/example_poetry_arpakitlib.sh +0 -1
  39. arpakitlib/_arpakit_project_template/manage/example_pyproject.toml +0 -23
  40. arpakitlib/_arpakit_project_template/manage/example_systemd.service +0 -12
  41. arpakitlib/_arpakit_project_template/manage/requirements.txt +0 -208
  42. arpakitlib/_arpakit_project_template/manage/settings_generate_env_example.py +0 -13
  43. /arpakitlib/_arpakit_project_template/{manage/sqlalchemy_db_check_conn.py → src/db/check_conn_sqlalchemy_db.py} +0 -0
  44. {arpakitlib-1.7.118.dist-info → arpakitlib-1.7.123.dist-info}/LICENSE +0 -0
  45. {arpakitlib-1.7.118.dist-info → arpakitlib-1.7.123.dist-info}/NOTICE +0 -0
  46. {arpakitlib-1.7.118.dist-info → arpakitlib-1.7.123.dist-info}/WHEEL +0 -0
  47. {arpakitlib-1.7.118.dist-info → arpakitlib-1.7.123.dist-info}/entry_points.txt +0 -0
@@ -1,4 +1,5 @@
1
1
  # mode_type=
2
+ # project_name=
2
3
  # sql_db_url=
3
4
  # sql_db_echo=
4
5
  # api_init_sql_db_at_start=
@@ -9,6 +10,8 @@
9
10
  # api_start_scheduled_operation_creator_worker=
10
11
  # api_port=
11
12
  # api_correct_api_key=
13
+ # api_correct_token=
14
+ # api_enable_admin1=
12
15
  # var_dirname=
13
16
  # var_dirpath=
14
17
  # log_filename=
@@ -20,3 +23,4 @@
20
23
  # dump_dirname=
21
24
  # dump_dirpath=
22
25
  # local_timezone=
26
+ # admin1_secret_key=
@@ -1,6 +1,6 @@
1
- def command():
1
+ def __hello_world():
2
2
  print("Hello world")
3
3
 
4
4
 
5
5
  if __name__ == '__main__':
6
- command()
6
+ __hello_world()
@@ -1,10 +1,10 @@
1
1
  from arpakitlib.ar_json_util import safely_transfer_str_to_json_obj_to_json_str
2
2
 
3
3
 
4
- def command():
4
+ def __command():
5
5
  s = input("JSON:\n")
6
6
  print(safely_transfer_str_to_json_obj_to_json_str(s))
7
7
 
8
8
 
9
9
  if __name__ == '__main__':
10
- command()
10
+ __command()
@@ -1,14 +1,14 @@
1
1
  import asyncio
2
2
 
3
3
 
4
- def command():
4
+ def __sandbox():
5
5
  pass
6
6
 
7
7
 
8
- async def async_command():
8
+ async def __async_sandbox():
9
9
  pass
10
10
 
11
11
 
12
12
  if __name__ == '__main__':
13
- command()
14
- asyncio.run(async_command())
13
+ __sandbox()
14
+ asyncio.run(__async_sandbox())
@@ -1,14 +1,14 @@
1
1
  import asyncio
2
2
 
3
3
 
4
- def command():
4
+ def __sandbox():
5
5
  pass
6
6
 
7
7
 
8
- async def async_command():
8
+ async def __async_sandbox():
9
9
  pass
10
10
 
11
11
 
12
12
  if __name__ == '__main__':
13
- command()
14
- asyncio.run(async_command())
13
+ __sandbox()
14
+ asyncio.run(__async_sandbox())
@@ -1,14 +1,14 @@
1
1
  import asyncio
2
2
 
3
3
 
4
- def command():
4
+ def __sandbox():
5
5
  pass
6
6
 
7
7
 
8
- async def async_command():
8
+ async def __async_sandbox():
9
9
  pass
10
10
 
11
11
 
12
12
  if __name__ == '__main__':
13
- command()
14
- asyncio.run(async_command())
13
+ __sandbox()
14
+ asyncio.run(__async_sandbox())
@@ -1,14 +1,14 @@
1
1
  import asyncio
2
2
 
3
3
 
4
- def command():
4
+ def __sandbox():
5
5
  pass
6
6
 
7
7
 
8
- async def async_command():
8
+ async def __async_sandbox():
9
9
  pass
10
10
 
11
11
 
12
12
  if __name__ == '__main__':
13
- command()
14
- asyncio.run(async_command())
13
+ __sandbox()
14
+ asyncio.run(__async_sandbox())
@@ -1,14 +1,14 @@
1
1
  import asyncio
2
2
 
3
3
 
4
- def command():
4
+ def __sandbox():
5
5
  pass
6
6
 
7
7
 
8
- async def async_command():
8
+ async def __async_sandbox():
9
9
  pass
10
10
 
11
11
 
12
12
  if __name__ == '__main__':
13
- command()
14
- asyncio.run(async_command())
13
+ __sandbox()
14
+ asyncio.run(__async_sandbox())
@@ -1,14 +1,14 @@
1
1
  import asyncio
2
2
 
3
3
 
4
- def command():
4
+ def __sandbox():
5
5
  pass
6
6
 
7
7
 
8
- async def async_command():
8
+ async def __async_sandbox():
9
9
  pass
10
10
 
11
11
 
12
12
  if __name__ == '__main__':
13
- command()
14
- asyncio.run(async_command())
13
+ __sandbox()
14
+ asyncio.run(__async_sandbox())
@@ -1,14 +1,14 @@
1
1
  import asyncio
2
2
 
3
3
 
4
- def command():
4
+ def __sandbox():
5
5
  pass
6
6
 
7
7
 
8
- async def async_command():
8
+ async def __async_sandbox():
9
9
  pass
10
10
 
11
11
 
12
12
  if __name__ == '__main__':
13
- command()
14
- asyncio.run(async_command())
13
+ __sandbox()
14
+ asyncio.run(__async_sandbox())
@@ -2,6 +2,7 @@ from fastapi import FastAPI
2
2
  from sqladmin import Admin
3
3
 
4
4
  from src.admin1.admin_auth import AdminAuth
5
+ from src.admin1.model_view import MODEL_VIEWS
5
6
  from src.api.transmitted_api_data import TransmittedAPIData
6
7
 
7
8
 
@@ -18,6 +19,7 @@ def add_admin1_in_app(*, app: FastAPI) -> FastAPI:
18
19
  title="{PROJECT_NAME}"
19
20
  )
20
21
 
21
- # admin.add_model_view(CurrentSemesterMV)
22
+ for model_view in MODEL_VIEWS:
23
+ admin.add_model_view(model_view)
22
24
 
23
25
  return app
@@ -9,15 +9,13 @@ from src.core.settings import get_cached_settings
9
9
  class AdminAuth(AuthenticationBackend):
10
10
  def __init__(self):
11
11
  self._logger = logging.getLogger(self.__class__.__name__)
12
- super().__init__(secret_key=get_cached_settings().sec)
12
+ super().__init__(secret_key=get_cached_settings().admin1_secret_key)
13
13
 
14
14
  async def login(self, request: Request) -> bool:
15
- form = await request.form()
16
-
17
15
  # ...
18
-
16
+ # form = await request.form()
19
17
  # request.session.update(...)
20
-
18
+ # ...
21
19
  return True
22
20
 
23
21
  async def logout(self, request: Request) -> bool:
@@ -25,8 +23,7 @@ class AdminAuth(AuthenticationBackend):
25
23
  return True
26
24
 
27
25
  async def authenticate(self, request: Request) -> bool:
26
+ # ...
28
27
  # request.session.get("...")
29
-
30
28
  # ...
31
-
32
29
  return True
@@ -12,3 +12,8 @@ class BaseModelView(ModelView):
12
12
  save_as = True
13
13
  save_as_continue = True
14
14
  export_types = ["xlsx", "csv", "json"]
15
+
16
+
17
+ MODEL_VIEWS = []
18
+
19
+ # ...
@@ -1,10 +1,7 @@
1
1
  from fastapi import FastAPI
2
2
 
3
- from arpakitlib.ar_base_worker_util import SafeRunInBackgroundModes
4
- from arpakitlib.ar_fastapi_util import create_fastapi_app, InitSqlalchemyDBStartupAPIEvent, InitFileStoragesInDir, \
5
- create_handle_exception, create_story_log_before_response_in_handle_exception, \
6
- SafeRunWorkerStartupAPIEvent
7
- from arpakitlib.ar_operation_execution_util import OperationExecutorWorker, ScheduledOperationCreatorWorker
3
+ from arpakitlib.ar_fastapi_util import create_fastapi_app, \
4
+ create_handle_exception, create_story_log_before_response_in_handle_exception
8
5
  from arpakitlib.ar_sqlalchemy_util import SQLAlchemyDB
9
6
  from arpakitlib.ar_type_util import raise_for_type
10
7
  from src.api.event import StartupAPIEvent, ShutdownAPIEvent
@@ -12,11 +9,9 @@ from src.api.router.main_router import main_api_router
12
9
  from src.api.transmitted_api_data import TransmittedAPIData
13
10
  from src.core.const import STATIC_DIRPATH
14
11
  from src.core.settings import get_cached_settings
15
- from src.core.util import get_cached_media_file_storage_in_dir, \
16
- get_cached_cache_file_storage_in_dir, get_cached_dump_file_storage_in_dir, setup_logging
12
+ from src.core.util import setup_logging, get_cached_media_file_storage_in_dir, get_cached_cache_file_storage_in_dir, \
13
+ get_cached_dump_file_storage_in_dir
17
14
  from src.db.util import get_cached_sqlalchemy_db
18
- from src.operation_execution.operation_executor import OperationExecutor
19
- from src.operation_execution.scheduled_operations import ALL_SCHEDULED_OPERATIONS
20
15
 
21
16
 
22
17
  def create_api_app() -> FastAPI:
@@ -28,7 +23,10 @@ def create_api_app() -> FastAPI:
28
23
 
29
24
  transmitted_api_data = TransmittedAPIData(
30
25
  settings=settings,
31
- sqlalchemy_db=sqlalchemy_db
26
+ sqlalchemy_db=sqlalchemy_db,
27
+ media_file_storage_in_dir=get_cached_media_file_storage_in_dir(),
28
+ cache_file_storage_in_dir=get_cached_cache_file_storage_in_dir(),
29
+ dump_file_storage_in_dir=get_cached_dump_file_storage_in_dir()
32
30
  )
33
31
 
34
32
  funcs_before_response = []
@@ -49,49 +47,8 @@ def create_api_app() -> FastAPI:
49
47
 
50
48
  startup_api_events = []
51
49
 
52
- startup_api_events.append(InitFileStoragesInDir(
53
- file_storages_in_dir=[
54
- get_cached_media_file_storage_in_dir() if settings.media_dirpath is not None else None,
55
- get_cached_cache_file_storage_in_dir() if settings.cache_dirpath is not None else None,
56
- get_cached_dump_file_storage_in_dir() if settings.dump_dirpath is not None else None
57
- ]
58
- ))
59
-
60
- if settings.api_init_sql_db_at_start:
61
- raise_for_type(sqlalchemy_db, SQLAlchemyDB)
62
- startup_api_events.append(InitSqlalchemyDBStartupAPIEvent(sqlalchemy_db=sqlalchemy_db))
63
-
64
50
  startup_api_events.append(StartupAPIEvent(transmitted_api_data=transmitted_api_data))
65
51
 
66
- if settings.api_start_operation_executor_worker:
67
- raise_for_type(sqlalchemy_db, SQLAlchemyDB)
68
- startup_api_events.append(
69
- SafeRunWorkerStartupAPIEvent(
70
- workers=[
71
- OperationExecutorWorker(
72
- sqlalchemy_db=sqlalchemy_db,
73
- operation_executor=OperationExecutor(sqlalchemy_db=sqlalchemy_db),
74
- filter_operation_types=None
75
- )
76
- ],
77
- safe_run_in_background_mode=SafeRunInBackgroundModes.async_task
78
- )
79
- )
80
-
81
- if settings.api_start_scheduled_operation_creator_worker:
82
- raise_for_type(sqlalchemy_db, SQLAlchemyDB)
83
- startup_api_events.append(
84
- SafeRunWorkerStartupAPIEvent(
85
- workers=[
86
- ScheduledOperationCreatorWorker(
87
- sqlalchemy_db=sqlalchemy_db,
88
- scheduled_operations=ALL_SCHEDULED_OPERATIONS
89
- )
90
- ],
91
- safe_run_in_background_mode=SafeRunInBackgroundModes.async_task
92
- )
93
- )
94
-
95
52
  shutdown_api_events = []
96
53
 
97
54
  shutdown_api_events.append(ShutdownAPIEvent(transmitted_api_data=transmitted_api_data))
@@ -1,5 +1,11 @@
1
+ from arpakitlib.ar_base_worker_util import safe_run_worker_in_background, SafeRunInBackgroundModes
1
2
  from arpakitlib.ar_fastapi_util import BaseStartupAPIEvent, BaseShutdownAPIEvent
3
+ from arpakitlib.ar_operation_execution_util import OperationExecutorWorker, ScheduledOperationCreatorWorker
4
+ from arpakitlib.ar_sqlalchemy_util import SQLAlchemyDB
5
+ from arpakitlib.ar_type_util import raise_for_type
2
6
  from src.api.transmitted_api_data import TransmittedAPIData
7
+ from src.operation_execution.operation_executor import OperationExecutor
8
+ from src.operation_execution.scheduled_operations import SCHEDULED_OPERATIONS
3
9
 
4
10
 
5
11
  class StartupAPIEvent(BaseStartupAPIEvent):
@@ -8,7 +14,49 @@ class StartupAPIEvent(BaseStartupAPIEvent):
8
14
  self.transmitted_api_data = transmitted_api_data
9
15
 
10
16
  async def async_on_startup(self, *args, **kwargs):
11
- self._logger.info(self.__class__.__name__)
17
+ self._logger.info("start")
18
+
19
+ if self.transmitted_api_data.media_file_storage_in_dir is not None:
20
+ self.transmitted_api_data.media_file_storage_in_dir.init()
21
+
22
+ if self.transmitted_api_data.cache_file_storage_in_dir is not None:
23
+ self.transmitted_api_data.cache_file_storage_in_dir.init()
24
+
25
+ if self.transmitted_api_data.dump_file_storage_in_dir is not None:
26
+ self.transmitted_api_data.dump_file_storage_in_dir.init()
27
+
28
+ if self.transmitted_api_data.settings.api_init_sql_db_at_start:
29
+ raise_for_type(self.transmitted_api_data.sqlalchemy_db, SQLAlchemyDB)
30
+ self.transmitted_api_data.sqlalchemy_db.init()
31
+
32
+ if self.transmitted_api_data.settings.api_start_operation_executor_worker:
33
+ raise_for_type(self.transmitted_api_data.sqlalchemy_db, SQLAlchemyDB)
34
+ _ = safe_run_worker_in_background(
35
+ worker=OperationExecutorWorker(
36
+ sqlalchemy_db=self.transmitted_api_data.sqlalchemy_db,
37
+ operation_executor=OperationExecutor(sqlalchemy_db=self.transmitted_api_data.sqlalchemy_db),
38
+ filter_operation_types=None,
39
+ startup_funcs=[
40
+ self.transmitted_api_data.sqlalchemy_db.init
41
+ ]
42
+ ),
43
+ mode=SafeRunInBackgroundModes.thread
44
+ )
45
+
46
+ if self.transmitted_api_data.settings.api_start_scheduled_operation_creator_worker:
47
+ raise_for_type(self.transmitted_api_data.sqlalchemy_db, SQLAlchemyDB)
48
+ _ = safe_run_worker_in_background(
49
+ worker=ScheduledOperationCreatorWorker(
50
+ sqlalchemy_db=self.transmitted_api_data.sqlalchemy_db,
51
+ scheduled_operations=SCHEDULED_OPERATIONS,
52
+ startup_funcs=[
53
+ self.transmitted_api_data.sqlalchemy_db.init
54
+ ]
55
+ ),
56
+ mode=SafeRunInBackgroundModes.async_task
57
+ )
58
+
59
+ self._logger.info("finish")
12
60
 
13
61
 
14
62
  class ShutdownAPIEvent(BaseShutdownAPIEvent):
@@ -17,4 +65,5 @@ class ShutdownAPIEvent(BaseShutdownAPIEvent):
17
65
  self.transmitted_api_data = transmitted_api_data
18
66
 
19
67
  async def async_on_shutdown(self, *args, **kwargs):
20
- self._logger.info(self.__class__.__name__)
68
+ self._logger.info("start")
69
+ self._logger.info("finish")
@@ -1,9 +1,17 @@
1
- from src.api.start_api_for_dev import start_api_for_dev
1
+ import uvicorn
2
2
 
3
+ from src.core.settings import get_cached_settings
3
4
 
4
- def command():
5
- start_api_for_dev(reload=True)
5
+
6
+ def __command():
7
+ uvicorn.run(
8
+ "src.api.asgi:app",
9
+ port=get_cached_settings().api_port,
10
+ host="localhost",
11
+ workers=1,
12
+ reload=True
13
+ )
6
14
 
7
15
 
8
16
  if __name__ == '__main__':
9
- command()
17
+ __command()
@@ -3,15 +3,15 @@ import uvicorn
3
3
  from src.core.settings import get_cached_settings
4
4
 
5
5
 
6
- def start_api_for_dev(*, reload: bool = False):
6
+ def __command():
7
7
  uvicorn.run(
8
8
  "src.api.asgi:app",
9
9
  port=get_cached_settings().api_port,
10
10
  host="localhost",
11
11
  workers=1,
12
- reload=reload
12
+ reload=False
13
13
  )
14
14
 
15
15
 
16
16
  if __name__ == '__main__':
17
- start_api_for_dev(reload=False)
17
+ __command()
@@ -1,4 +1,5 @@
1
1
  from arpakitlib.ar_fastapi_util import BaseTransmittedAPIData
2
+ from arpakitlib.ar_file_storage_in_dir_util import FileStorageInDir
2
3
  from arpakitlib.ar_sqlalchemy_util import SQLAlchemyDB
3
4
 
4
5
  from src.core.settings import Settings
@@ -7,3 +8,6 @@ from src.core.settings import Settings
7
8
  class TransmittedAPIData(BaseTransmittedAPIData):
8
9
  settings: Settings
9
10
  sqlalchemy_db: SQLAlchemyDB | None = None
11
+ media_file_storage_in_dir: FileStorageInDir | None = None
12
+ cache_file_storage_in_dir: FileStorageInDir | None = None
13
+ dump_file_storage_in_dir: FileStorageInDir | None = None
@@ -0,0 +1,12 @@
1
+ import logging
2
+
3
+ _logger = logging.getLogger(__name__)
4
+
5
+
6
+ def hello_world() -> str:
7
+ _logger.info("hello world")
8
+ return "Hello world"
9
+
10
+
11
+ if __name__ == '__main__':
12
+ print(hello_world())
@@ -5,10 +5,10 @@ from src.core.util import setup_logging
5
5
  _logger = logging.getLogger(__name__)
6
6
 
7
7
 
8
- def command():
8
+ def __check_logging():
9
9
  setup_logging()
10
- _logger.info("checking logging")
10
+ _logger.info("logging is good")
11
11
 
12
12
 
13
13
  if __name__ == '__main__':
14
- command()
14
+ __check_logging()
@@ -1,8 +1,10 @@
1
1
  from arpakitlib.ar_json_util import safely_transfer_obj_to_json_str
2
2
  from src.core.settings import get_cached_settings
3
+ from src.core.util import setup_logging
3
4
 
4
5
 
5
6
  def command():
7
+ setup_logging()
6
8
  print(safely_transfer_obj_to_json_str(get_cached_settings().model_dump(mode="json")))
7
9
 
8
10
 
@@ -0,0 +1,16 @@
1
+ import os.path
2
+
3
+ from arpakitlib.ar_json_util import safely_transfer_obj_to_json_str
4
+ from src.core.const import BASE_DIRPATH
5
+ from src.core.settings import Settings, get_cached_settings
6
+ from src.core.util import setup_logging
7
+
8
+
9
+ def command():
10
+ setup_logging()
11
+ print(safely_transfer_obj_to_json_str(get_cached_settings().model_dump(mode="json")))
12
+ Settings.save_env_example_to_file(filepath=os.path.join(BASE_DIRPATH, "example.env"))
13
+
14
+
15
+ if __name__ == '__main__':
16
+ command()
@@ -2,10 +2,10 @@ from src.core.util import setup_logging
2
2
  from src.db.util import get_cached_sqlalchemy_db
3
3
 
4
4
 
5
- def command():
5
+ def __init_sqlalchemy_db():
6
6
  setup_logging()
7
7
  get_cached_sqlalchemy_db().init()
8
8
 
9
9
 
10
10
  if __name__ == '__main__':
11
- command()
11
+ __init_sqlalchemy_db()
@@ -1,11 +1,13 @@
1
+ from src.core.settings import get_cached_settings
1
2
  from src.core.util import setup_logging
2
3
  from src.db.util import get_cached_sqlalchemy_db
3
4
 
4
5
 
5
- def command():
6
+ def __reinit_sqlalchemy_db():
6
7
  setup_logging()
8
+ get_cached_settings().raise_if_mode_type_not_prod()
7
9
  get_cached_sqlalchemy_db().reinit()
8
10
 
9
11
 
10
12
  if __name__ == '__main__':
11
- command()
13
+ __reinit_sqlalchemy_db()
@@ -4,14 +4,14 @@ from arpakitlib.ar_operation_execution_util import ScheduledOperation, every_tim
4
4
  between_different_times_is_time_func
5
5
  from arpakitlib.ar_sqlalchemy_model_util import BaseOperationTypes
6
6
 
7
- ALL_SCHEDULED_OPERATIONS = []
7
+ SCHEDULED_OPERATIONS = []
8
8
 
9
9
  healthcheck_1_scheduled_operation = ScheduledOperation(
10
10
  type=BaseOperationTypes.healthcheck_,
11
11
  input_data={"healthcheck_1": "healthcheck_1"},
12
12
  is_time_func=every_timedelta_is_time_func(td=timedelta(seconds=15))
13
13
  )
14
- ALL_SCHEDULED_OPERATIONS.append(healthcheck_1_scheduled_operation)
14
+ SCHEDULED_OPERATIONS.append(healthcheck_1_scheduled_operation)
15
15
 
16
16
  healthcheck_2_scheduled_operation = ScheduledOperation(
17
17
  type=BaseOperationTypes.healthcheck_,
@@ -22,4 +22,4 @@ healthcheck_2_scheduled_operation = ScheduledOperation(
22
22
  ),
23
23
  timeout_after_creation=timedelta(seconds=60)
24
24
  )
25
- ALL_SCHEDULED_OPERATIONS.append(healthcheck_2_scheduled_operation)
25
+ SCHEDULED_OPERATIONS.append(healthcheck_2_scheduled_operation)
@@ -1,18 +1,19 @@
1
1
  from arpakitlib.ar_operation_execution_util import OperationExecutorWorker
2
+ from src.core.settings import get_cached_settings
2
3
  from src.core.util import setup_logging
3
4
  from src.db.util import get_cached_sqlalchemy_db
4
5
  from src.operation_execution.operation_executor import OperationExecutor
5
6
 
6
7
 
7
- def start_operation_executor_worker_for_dev():
8
+ def start_operation_executor_worker():
8
9
  setup_logging()
10
+ get_cached_settings().raise_if_mode_type_prod()
9
11
  worker = OperationExecutorWorker(
10
12
  sqlalchemy_db=get_cached_sqlalchemy_db(),
11
- operation_executor=OperationExecutor(sqlalchemy_db=get_cached_sqlalchemy_db()),
12
- filter_operation_types=None
13
+ operation_executor=OperationExecutor(sqlalchemy_db=get_cached_sqlalchemy_db())
13
14
  )
14
15
  worker.sync_safe_run()
15
16
 
16
17
 
17
18
  if __name__ == '__main__':
18
- start_operation_executor_worker_for_dev()
19
+ start_operation_executor_worker()
@@ -1,17 +1,19 @@
1
1
  from arpakitlib.ar_operation_execution_util import ScheduledOperationCreatorWorker
2
+ from src.core.settings import get_cached_settings
2
3
  from src.core.util import setup_logging
3
4
  from src.db.util import get_cached_sqlalchemy_db
4
- from src.operation_execution.scheduled_operations import ALL_SCHEDULED_OPERATIONS
5
+ from src.operation_execution.scheduled_operations import SCHEDULED_OPERATIONS
5
6
 
6
7
 
7
- def start_create_scheduled_operation_worker_for_dev():
8
+ def start_scheduled_operation_creator_worker():
8
9
  setup_logging()
10
+ get_cached_settings().raise_if_mode_type_prod()
9
11
  worker = ScheduledOperationCreatorWorker(
10
12
  sqlalchemy_db=get_cached_sqlalchemy_db(),
11
- scheduled_operations=ALL_SCHEDULED_OPERATIONS
13
+ scheduled_operations=SCHEDULED_OPERATIONS
12
14
  )
13
15
  worker.sync_safe_run()
14
16
 
15
17
 
16
18
  if __name__ == '__main__':
17
- start_create_scheduled_operation_worker_for_dev()
19
+ start_scheduled_operation_creator_worker()
@@ -1,19 +0,0 @@
1
- from datetime import timedelta
2
- from functools import lru_cache
3
-
4
- from arpakitlib.ar_operation_execution_util import ScheduledOperationCreatorWorker
5
- from src.db.util import get_cached_sqlalchemy_db
6
-
7
-
8
- def create_scheduled_operation_creator_worker() -> ScheduledOperationCreatorWorker:
9
- from src.operation_execution.scheduled_operations import ALL_SCHEDULED_OPERATIONS
10
- scheduled_operation_creator_worker = ScheduledOperationCreatorWorker(
11
- sqlalchemy_db=get_cached_sqlalchemy_db(),
12
- scheduled_operations=ALL_SCHEDULED_OPERATIONS
13
- )
14
- return scheduled_operation_creator_worker
15
-
16
-
17
- @lru_cache()
18
- def get_scheduled_operation_creator_worker() -> ScheduledOperationCreatorWorker:
19
- return create_scheduled_operation_creator_worker()