arpakitlib 1.7.103__py3-none-any.whl → 1.7.132__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 (64) hide show
  1. arpakitlib/_arpakit_project_template/README.md +1 -3
  2. arpakitlib/_arpakit_project_template/example.env +5 -0
  3. arpakitlib/_arpakit_project_template/manage/docker_run_postgres_for_dev.sh +3 -3
  4. arpakitlib/_arpakit_project_template/manage/docker_start_postgres_for_dev.sh +1 -1
  5. arpakitlib/_arpakit_project_template/manage/docker_stop_postgres_for_dev.sh +1 -1
  6. arpakitlib/_arpakit_project_template/manage/git_set_arpakit_company_origin.sh +2 -2
  7. arpakitlib/_arpakit_project_template/manage/git_set_arpakit_origin.sh +2 -2
  8. arpakitlib/_arpakit_project_template/manage/hello_world.py +2 -2
  9. arpakitlib/_arpakit_project_template/manage/{json_beutify.py → json_beautify.py} +2 -2
  10. arpakitlib/_arpakit_project_template/manage/poetry_config.sh +2 -0
  11. arpakitlib/_arpakit_project_template/manage/poetry_self_add_plugin_export.sh +2 -0
  12. arpakitlib/_arpakit_project_template/manage/poetry_show_arpakitlib.sh +1 -1
  13. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_1.py +4 -4
  14. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_2.py +4 -4
  15. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_3.py +4 -4
  16. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_4.py +4 -4
  17. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_5.py +4 -4
  18. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_6.py +4 -4
  19. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_7.py +4 -4
  20. arpakitlib/_arpakit_project_template/src/admin1/__init__.py +0 -0
  21. arpakitlib/_arpakit_project_template/src/admin1/add_admin_in_app.py +26 -0
  22. arpakitlib/_arpakit_project_template/src/admin1/admin_auth.py +29 -0
  23. arpakitlib/_arpakit_project_template/src/admin1/model_view.py +19 -0
  24. arpakitlib/_arpakit_project_template/src/api/create_api_app.py +14 -54
  25. arpakitlib/_arpakit_project_template/src/api/event.py +51 -2
  26. arpakitlib/_arpakit_project_template/src/api/start_api_for_dev_with_reload.py +12 -4
  27. arpakitlib/_arpakit_project_template/src/api/{start_api_for_dev.py → start_api_for_dev_without_reload.py} +3 -3
  28. arpakitlib/_arpakit_project_template/src/api/transmitted_api_data.py +4 -0
  29. arpakitlib/_arpakit_project_template/src/business_service/hello_world.py +12 -0
  30. arpakitlib/_arpakit_project_template/{manage/logging_check.py → src/core/check_logging.py} +3 -3
  31. arpakitlib/_arpakit_project_template/{manage/settings_check.py → src/core/check_settings.py} +2 -0
  32. arpakitlib/_arpakit_project_template/src/core/const.py +24 -25
  33. arpakitlib/_arpakit_project_template/src/core/generate_settings_env_example.py +16 -0
  34. arpakitlib/_arpakit_project_template/src/core/settings.py +16 -10
  35. arpakitlib/_arpakit_project_template/{manage/sqlalchemy_db_init.py → src/db/init_sqlalchemy_db.py} +2 -2
  36. arpakitlib/_arpakit_project_template/{manage/sqlalchemy_db_reinit.py → src/db/reinit_sqlalchemy_db.py} +4 -2
  37. arpakitlib/_arpakit_project_template/src/operation_execution/operation_executor.py +6 -4
  38. arpakitlib/_arpakit_project_template/src/operation_execution/scheduled_operations.py +3 -3
  39. arpakitlib/_arpakit_project_template/src/operation_execution/{start_operation_executor_worker_for_dev.py → start_operation_executor_worker.py} +5 -4
  40. arpakitlib/_arpakit_project_template/src/operation_execution/{start_scheduled_operation_creator_worker_for_dev.py → start_scheduled_operation_creator_worker.py} +6 -4
  41. arpakitlib/_arpakit_project_template/src/operation_execution/util.py +0 -21
  42. arpakitlib/_arpakit_project_template/src/tg_bot/__init__.py +0 -0
  43. arpakitlib/_arpakit_project_template/src/tg_bot/router/__init__.py +0 -0
  44. arpakitlib/_arpakit_project_template/src/tg_bot/start_tg_bot.py +0 -0
  45. arpakitlib/ar_arpakit_lib_module_util.py +7 -0
  46. arpakitlib/ar_arpakit_project_template_util.py +3 -3
  47. arpakitlib/ar_fastapi_util.py +0 -42
  48. arpakitlib/ar_settings_util.py +14 -5
  49. arpakitlib/ar_str_util.py +15 -15
  50. arpakitlib/ar_type_util.py +1 -1
  51. {arpakitlib-1.7.103.dist-info → arpakitlib-1.7.132.dist-info}/METADATA +27 -20
  52. {arpakitlib-1.7.103.dist-info → arpakitlib-1.7.132.dist-info}/RECORD +57 -53
  53. {arpakitlib-1.7.103.dist-info → arpakitlib-1.7.132.dist-info}/WHEEL +1 -1
  54. arpakitlib/_arpakit_project_template/AUTHOR.md +0 -4
  55. arpakitlib/_arpakit_project_template/manage/example_nginx_proxy.nginx +0 -14
  56. arpakitlib/_arpakit_project_template/manage/example_poetry_arpakitlib.sh +0 -1
  57. arpakitlib/_arpakit_project_template/manage/example_pyproject.toml +0 -18
  58. arpakitlib/_arpakit_project_template/manage/example_systemd.service +0 -12
  59. arpakitlib/_arpakit_project_template/manage/requirements.txt +0 -209
  60. arpakitlib/_arpakit_project_template/manage/settings_generate_env_example.py +0 -13
  61. /arpakitlib/_arpakit_project_template/{manage/sqlalchemy_db_check_conn.py → src/db/check_conn_sqlalchemy_db.py} +0 -0
  62. {arpakitlib-1.7.103.dist-info → arpakitlib-1.7.132.dist-info}/LICENSE +0 -0
  63. {arpakitlib-1.7.103.dist-info → arpakitlib-1.7.132.dist-info}/NOTICE +0 -0
  64. {arpakitlib-1.7.103.dist-info → arpakitlib-1.7.132.dist-info}/entry_points.txt +0 -0
@@ -1,6 +1,4 @@
1
- # {PROJECT_NAME}
2
-
3
- ...
1
+ # {{PROJECT_NAME}}
4
2
 
5
3
  ## ❤️ Made by ARPAKIT Company ❤️
6
4
 
@@ -1,4 +1,6 @@
1
1
  # mode_type=
2
+ # project_name=
3
+ # sql_db_port=
2
4
  # sql_db_url=
3
5
  # sql_db_echo=
4
6
  # api_init_sql_db_at_start=
@@ -9,6 +11,8 @@
9
11
  # api_start_scheduled_operation_creator_worker=
10
12
  # api_port=
11
13
  # api_correct_api_key=
14
+ # api_correct_token=
15
+ # api_enable_admin1=
12
16
  # var_dirname=
13
17
  # var_dirpath=
14
18
  # log_filename=
@@ -20,3 +24,4 @@
20
24
  # dump_dirname=
21
25
  # dump_dirpath=
22
26
  # local_timezone=
27
+ # admin1_secret_key=
@@ -1,4 +1,4 @@
1
1
  cd ..
2
- docker rm {PROJECT_NAME}_postgres
3
- docker run --name {PROJECT_NAME}_postgres -d -p {SQL_DB_PORT}:5432 -e POSTGRES_USER={PROJECT_NAME} -e POSTGRES_PASSWORD={PROJECT_NAME} -e POSTGRES_DB={PROJECT_NAME} postgres:16 -c max_connections=100
4
- docker start {PROJECT_NAME}_postgres
2
+ docker rm {{PROJECT_NAME}}_postgres
3
+ docker run --name {{PROJECT_NAME}}_postgres -d -p {{SQL_DB_PORT}}:5432 -e POSTGRES_USER={{PROJECT_NAME}} -e POSTGRES_PASSWORD={{PROJECT_NAME}} -e POSTGRES_DB={{PROJECT_NAME}} postgres:16 -c max_connections=100
4
+ docker start {{PROJECT_NAME}}_postgres
@@ -1,2 +1,2 @@
1
1
  cd ..
2
- docker start {PROJECT_NAME}_postgres
2
+ docker start {{PROJECT_NAME}}_postgres
@@ -1,2 +1,2 @@
1
1
  cd ..
2
- docker stop {PROJECT_NAME}_postgres
2
+ docker stop {{PROJECT_NAME}}_postgres
@@ -1,7 +1,7 @@
1
1
  cd ..
2
2
 
3
3
  git remote remove arpakit_company_github_1
4
- git remote add arpakit_company_github_1 git@github.com:ARPAKIT-Company/{PROJECT_NAME}.git
4
+ git remote add arpakit_company_github_1 git@github.com:ARPAKIT-Company/{{PROJECT_NAME}}.git
5
5
 
6
6
  git remote remove arpakit_company_gitlab_1
7
- git remote add arpakit_company_gitlab_1 git@gitlab.com:ARPAKIT-Company/{PROJECT_NAME}.git
7
+ git remote add arpakit_company_gitlab_1 git@gitlab.com:ARPAKIT-Company/{{PROJECT_NAME}}.git
@@ -1,7 +1,7 @@
1
1
  cd ..
2
2
 
3
3
  git remote remove arpakit_github_1
4
- git remote add arpakit_github_1 git@github.com:arpakit/{PROJECT_NAME}.git
4
+ git remote add arpakit_github_1 git@github.com:arpakit/{{PROJECT_NAME}}.git
5
5
 
6
6
  git remote remove arpakit_gitlab_1
7
- git remote add arpakit_gitlab_1 git@gitlab.com:arpakit/{PROJECT_NAME}.git
7
+ git remote add arpakit_gitlab_1 git@gitlab.com:arpakit/{{PROJECT_NAME}}.git
@@ -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 __json_beautify():
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
+ __json_beautify()
@@ -0,0 +1,2 @@
1
+ cd ..
2
+ poetry config --list
@@ -0,0 +1,2 @@
1
+ cd ..
2
+ poetry self add poetry-plugin-export
@@ -1,2 +1,2 @@
1
1
  cd ..
2
- poetry show arpakitlib --no-dev
2
+ poetry show arpakitlib --latest
@@ -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())
@@ -0,0 +1,26 @@
1
+ from fastapi import FastAPI
2
+ from sqladmin import Admin
3
+
4
+ from src.admin1.admin_auth import AdminAuth
5
+ from src.admin1.model_view import MODEL_VIEWS
6
+ from src.api.transmitted_api_data import TransmittedAPIData
7
+ from src.core.settings import get_cached_settings
8
+
9
+
10
+ def add_admin1_in_app(*, app: FastAPI) -> FastAPI:
11
+ transmitted_api_data: TransmittedAPIData = app.state.transmitted_api_data
12
+
13
+ authentication_backend = AdminAuth()
14
+
15
+ admin = Admin(
16
+ app=app,
17
+ engine=transmitted_api_data.sqlalchemy_db.engine,
18
+ base_url="/admin1",
19
+ authentication_backend=authentication_backend,
20
+ title=get_cached_settings().project_name
21
+ )
22
+
23
+ for model_view in MODEL_VIEWS:
24
+ admin.add_model_view(model_view)
25
+
26
+ return app
@@ -0,0 +1,29 @@
1
+ import logging
2
+
3
+ from sqladmin.authentication import AuthenticationBackend
4
+ from starlette.requests import Request
5
+
6
+ from src.core.settings import get_cached_settings
7
+
8
+
9
+ class AdminAuth(AuthenticationBackend):
10
+ def __init__(self):
11
+ self._logger = logging.getLogger(self.__class__.__name__)
12
+ super().__init__(secret_key=get_cached_settings().admin1_secret_key)
13
+
14
+ async def login(self, request: Request) -> bool:
15
+ # ...
16
+ # form = await request.form()
17
+ # request.session.update(...)
18
+ # ...
19
+ return True
20
+
21
+ async def logout(self, request: Request) -> bool:
22
+ request.session.clear()
23
+ return True
24
+
25
+ async def authenticate(self, request: Request) -> bool:
26
+ # ...
27
+ # request.session.get("...")
28
+ # ...
29
+ return True
@@ -0,0 +1,19 @@
1
+ from sqladmin import ModelView
2
+
3
+
4
+ class BaseModelView(ModelView):
5
+ can_create = True
6
+ can_edit = True
7
+ can_delete = True
8
+ can_view_details = True
9
+ can_export = True
10
+ page_size = 50
11
+ page_size_options = [25, 50, 100, 200]
12
+ save_as = True
13
+ save_as_continue = True
14
+ export_types = ["xlsx", "csv", "json"]
15
+
16
+
17
+ MODEL_VIEWS = []
18
+
19
+ # ...
@@ -1,22 +1,17 @@
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, DEFAULT_CONTACT, \
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
11
8
  from src.api.router.main_router import main_api_router
12
9
  from src.api.transmitted_api_data import TransmittedAPIData
13
- from src.core.const import STATIC_DIRPATH
10
+ from src.core.const import ProjectPaths
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))
@@ -105,11 +62,14 @@ def create_api_app() -> FastAPI:
105
62
  shutdown_api_events=shutdown_api_events,
106
63
  transmitted_api_data=transmitted_api_data,
107
64
  main_api_router=main_api_router,
108
- contact=DEFAULT_CONTACT,
109
65
  media_dirpath=settings.media_dirpath,
110
- static_dirpath=STATIC_DIRPATH
66
+ static_dirpath=ProjectPaths.static_dirpath
111
67
  )
112
68
 
69
+ if settings.api_enable_admin1:
70
+ from src.admin1.add_admin_in_app import add_admin1_in_app
71
+ add_admin1_in_app(app=api_app)
72
+
113
73
  return api_app
114
74
 
115
75
 
@@ -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