arpakitlib 1.6.46__py3-none-any.whl → 1.7.89__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.
- arpakitlib/_arpakit_project_template/.gitignore +51 -0
- arpakitlib/_arpakit_project_template/.python-version +1 -0
- arpakitlib/_arpakit_project_template/ARPAKITLIB +1 -0
- arpakitlib/_arpakit_project_template/AUTHOR.md +4 -0
- arpakitlib/{LICENSE → _arpakit_project_template/LICENSE} +1 -1
- arpakitlib/_arpakit_project_template/NOTICE +16 -0
- arpakitlib/_arpakit_project_template/README.md +6 -0
- arpakitlib/_arpakit_project_template/example.env +22 -0
- arpakitlib/_arpakit_project_template/manage/__init__.py +0 -0
- arpakitlib/_arpakit_project_template/manage/docker_ps.sh +2 -0
- arpakitlib/_arpakit_project_template/manage/docker_ps_a.sh +2 -0
- arpakitlib/_arpakit_project_template/manage/docker_run_postgres_for_dev.sh +4 -0
- arpakitlib/_arpakit_project_template/manage/docker_start_postgres_for_dev.sh +2 -0
- arpakitlib/_arpakit_project_template/manage/docker_stop_postgres_for_dev.sh +2 -0
- arpakitlib/_arpakit_project_template/manage/example_nginx_proxy.nginx +14 -0
- arpakitlib/_arpakit_project_template/manage/example_poetry_arpakitlib.sh +1 -0
- arpakitlib/_arpakit_project_template/manage/example_pyproject.toml +18 -0
- arpakitlib/_arpakit_project_template/manage/example_systemd.service +12 -0
- arpakitlib/_arpakit_project_template/manage/git_branch.sh +2 -0
- arpakitlib/_arpakit_project_template/manage/git_commit.sh +3 -0
- arpakitlib/_arpakit_project_template/manage/git_push_arpakit_company_github_1.sh +4 -0
- arpakitlib/_arpakit_project_template/manage/git_push_arpakit_company_gitlab_1.sh +4 -0
- arpakitlib/_arpakit_project_template/manage/git_push_arpakit_github_1.sh +4 -0
- arpakitlib/_arpakit_project_template/manage/git_push_arpakit_gitlab_1.sh +4 -0
- arpakitlib/_arpakit_project_template/manage/git_remote_v.sh +2 -0
- arpakitlib/_arpakit_project_template/manage/git_set_arpakit_company_origin.sh +7 -0
- arpakitlib/_arpakit_project_template/manage/git_set_arpakit_origin.sh +7 -0
- arpakitlib/_arpakit_project_template/manage/git_status.sh +2 -0
- arpakitlib/_arpakit_project_template/manage/hello_world.py +6 -0
- arpakitlib/_arpakit_project_template/manage/json_beutify.py +10 -0
- arpakitlib/_arpakit_project_template/manage/logging_check.py +14 -0
- arpakitlib/_arpakit_project_template/manage/note/__init__.py +0 -0
- arpakitlib/_arpakit_project_template/manage/note/note_1.txt +0 -0
- arpakitlib/_arpakit_project_template/manage/note/note_2.txt +0 -0
- arpakitlib/_arpakit_project_template/manage/note/note_3.txt +0 -0
- arpakitlib/_arpakit_project_template/manage/note/note_4.txt +0 -0
- arpakitlib/_arpakit_project_template/manage/note/note_5.txt +0 -0
- arpakitlib/_arpakit_project_template/manage/poetry_add_plugin_export.sh +2 -0
- arpakitlib/_arpakit_project_template/manage/poetry_check.sh +2 -0
- arpakitlib/_arpakit_project_template/manage/poetry_clear_cache.sh +4 -0
- arpakitlib/_arpakit_project_template/manage/poetry_config_virtualenvs_in_project_true.sh +2 -0
- arpakitlib/_arpakit_project_template/manage/poetry_generate_requirements.txt.sh +1 -0
- arpakitlib/_arpakit_project_template/manage/poetry_install.sh +5 -0
- arpakitlib/_arpakit_project_template/manage/poetry_lock.sh +2 -0
- arpakitlib/_arpakit_project_template/manage/poetry_remove_and_add_arpakitlib.sh +7 -0
- arpakitlib/_arpakit_project_template/manage/poetry_show.sh +2 -0
- arpakitlib/_arpakit_project_template/manage/poetry_show_arpakitlib.sh +2 -0
- arpakitlib/_arpakit_project_template/manage/poetry_update.sh +6 -0
- arpakitlib/_arpakit_project_template/manage/poetry_update_arpakitlib.sh +5 -0
- arpakitlib/_arpakit_project_template/manage/requirements.txt +209 -0
- arpakitlib/_arpakit_project_template/manage/sandbox/__init__.py +0 -0
- arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_1.py +14 -0
- arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_2.py +14 -0
- arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_3.py +14 -0
- arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_4.py +14 -0
- arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_5.py +14 -0
- arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_6.py +14 -0
- arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_7.py +14 -0
- arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_8.sh +0 -0
- arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_9.sh +0 -0
- arpakitlib/_arpakit_project_template/manage/settings_check.py +10 -0
- arpakitlib/_arpakit_project_template/manage/settings_generate_env_example.py +13 -0
- arpakitlib/_arpakit_project_template/manage/sqlalchemy_db_check_conn.py +11 -0
- arpakitlib/_arpakit_project_template/manage/sqlalchemy_db_init.py +11 -0
- arpakitlib/_arpakit_project_template/manage/sqlalchemy_db_reinit.py +11 -0
- arpakitlib/_arpakit_project_template/resource/__init__.py +0 -0
- arpakitlib/_arpakit_project_template/resource/static/__init__.py +0 -0
- arpakitlib/_arpakit_project_template/resource/static/healthcheck +1 -0
- arpakitlib/_arpakit_project_template/resource/static/helloworld +1 -0
- arpakitlib/_arpakit_project_template/src/__init__.py +0 -0
- arpakitlib/_arpakit_project_template/src/additional_model/__init__.py +0 -0
- arpakitlib/_arpakit_project_template/src/additional_model/additional_model.py +6 -0
- arpakitlib/_arpakit_project_template/src/api/__init__.py +0 -0
- arpakitlib/_arpakit_project_template/src/api/asgi.py +3 -0
- arpakitlib/_arpakit_project_template/src/api/auth.py +1 -0
- arpakitlib/_arpakit_project_template/src/api/const.py +13 -0
- arpakitlib/_arpakit_project_template/src/api/create_api_app.py +117 -0
- arpakitlib/_arpakit_project_template/src/api/event.py +20 -0
- arpakitlib/_arpakit_project_template/src/api/router/__init__.py +0 -0
- arpakitlib/_arpakit_project_template/src/api/router/main_router.py +9 -0
- arpakitlib/_arpakit_project_template/src/api/router/v1/__init__.py +0 -0
- arpakitlib/_arpakit_project_template/src/api/router/v1/get_api_error_info.py +27 -0
- arpakitlib/_arpakit_project_template/src/api/router/v1/main_router.py +11 -0
- arpakitlib/_arpakit_project_template/src/api/schema/__init__.py +0 -0
- arpakitlib/_arpakit_project_template/src/api/schema/v1/__init__.py +0 -0
- arpakitlib/_arpakit_project_template/src/api/schema/v1/in_.py +0 -0
- arpakitlib/_arpakit_project_template/src/api/schema/v1/out.py +6 -0
- arpakitlib/_arpakit_project_template/src/api/start_api_for_dev.py +17 -0
- arpakitlib/_arpakit_project_template/src/api/start_api_for_dev_with_reload.py +9 -0
- arpakitlib/_arpakit_project_template/src/api/transmitted_api_data.py +9 -0
- arpakitlib/_arpakit_project_template/src/api/util.py +0 -0
- arpakitlib/_arpakit_project_template/src/business_service/__init__.py +0 -0
- arpakitlib/_arpakit_project_template/src/core/__init__.py +0 -0
- arpakitlib/_arpakit_project_template/src/core/const.py +48 -0
- arpakitlib/_arpakit_project_template/src/core/settings.py +86 -0
- arpakitlib/_arpakit_project_template/src/core/util.py +58 -0
- arpakitlib/_arpakit_project_template/src/db/__init__.py +0 -0
- arpakitlib/_arpakit_project_template/src/db/sqlalchemy_model.py +8 -0
- arpakitlib/_arpakit_project_template/src/db/util.py +21 -0
- arpakitlib/_arpakit_project_template/src/operation_execution/__init__.py +0 -0
- arpakitlib/_arpakit_project_template/src/operation_execution/const.py +9 -0
- arpakitlib/_arpakit_project_template/src/operation_execution/operation_executor.py +14 -0
- arpakitlib/_arpakit_project_template/src/operation_execution/scheduled_operations.py +25 -0
- arpakitlib/_arpakit_project_template/src/operation_execution/start_operation_executor_worker_for_dev.py +18 -0
- arpakitlib/_arpakit_project_template/src/operation_execution/start_scheduled_operation_creator_worker_for_dev.py +17 -0
- arpakitlib/_arpakit_project_template/src/operation_execution/util.py +21 -0
- arpakitlib/_arpakit_project_template/src/test_data/__init__.py +0 -0
- arpakitlib/_arpakit_project_template/src/test_data/make_test_data_1.py +6 -0
- arpakitlib/_arpakit_project_template/src/test_data/make_test_data_2.py +6 -0
- arpakitlib/_arpakit_project_template/src/test_data/make_test_data_3.py +6 -0
- arpakitlib/_arpakit_project_template/src/test_data/make_test_data_4.py +6 -0
- arpakitlib/_arpakit_project_template/src/test_data/make_test_data_5.py +6 -0
- arpakitlib/_arpakit_project_template/src/util/__init__.py +0 -0
- arpakitlib/api_key_util.py +21 -0
- arpakitlib/ar_additional_model_util.py +25 -2
- arpakitlib/ar_aiogram_util.py +10 -18
- arpakitlib/ar_arpakit_lib_module_util.py +6 -1
- arpakitlib/ar_arpakit_project_template_util.py +96 -0
- arpakitlib/ar_arpakit_schedule_uust_api_client_util.py +24 -3
- arpakitlib/ar_arpakitlib_cli_util.py +79 -0
- arpakitlib/ar_base_worker_util.py +95 -48
- arpakitlib/ar_dream_ai_api_client_util.py +26 -52
- arpakitlib/ar_enumeration_util.py +11 -0
- arpakitlib/ar_exception_util.py +18 -0
- arpakitlib/ar_fastapi_static/healthcheck +1 -0
- arpakitlib/ar_fastapi_util.py +270 -137
- arpakitlib/ar_file_util.py +22 -0
- arpakitlib/ar_func_util.py +55 -0
- arpakitlib/ar_http_request_util.py +35 -6
- arpakitlib/ar_json_util.py +13 -7
- arpakitlib/ar_logging_util.py +5 -2
- arpakitlib/ar_need_type_util.py +12 -2
- arpakitlib/{ar_openai_util.py → ar_openai_api_client_util.py} +16 -2
- arpakitlib/ar_operation_execution_util.py +250 -105
- arpakitlib/ar_parse_command.py +25 -7
- arpakitlib/ar_schedule_uust_api_client_util.py +37 -23
- arpakitlib/ar_settings_util.py +37 -11
- arpakitlib/ar_sleep_util.py +0 -13
- arpakitlib/ar_sqlalchemy_model_util.py +35 -10
- arpakitlib/ar_sqlalchemy_util.py +4 -3
- arpakitlib/{ar_ssh_util.py → ar_ssh_runner_util.py} +2 -2
- arpakitlib/ar_str_util.py +43 -2
- arpakitlib/ar_type_util.py +68 -4
- arpakitlib/ar_yookassa_api_client_util.py +26 -44
- {arpakitlib-1.6.46.dist-info → arpakitlib-1.7.89.dist-info}/LICENSE +1 -1
- {arpakitlib-1.6.46.dist-info → arpakitlib-1.7.89.dist-info}/METADATA +17 -8
- arpakitlib-1.7.89.dist-info/NOTICE +16 -0
- arpakitlib-1.7.89.dist-info/RECORD +186 -0
- arpakitlib-1.7.89.dist-info/entry_points.txt +3 -0
- arpakitlib/AUTHOR.md +0 -7
- arpakitlib/NOTICE +0 -2
- arpakitlib/README.md +0 -7
- arpakitlib/ar_arpakitlib_info.py +0 -13
- arpakitlib/ar_generate_env_example.py +0 -22
- arpakitlib-1.6.46.dist-info/NOTICE +0 -2
- arpakitlib-1.6.46.dist-info/RECORD +0 -71
- /arpakitlib/{ar_zabbix_util.py → ar_zabbix_api_client_util.py} +0 -0
- {arpakitlib-1.6.46.dist-info → arpakitlib-1.7.89.dist-info}/WHEEL +0 -0
File without changes
|
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
from arpakitlib.ar_json_util import safely_transfer_obj_to_json_str
|
2
|
+
from src.core.settings import get_cached_settings
|
3
|
+
|
4
|
+
|
5
|
+
def command():
|
6
|
+
print(safely_transfer_obj_to_json_str(get_cached_settings().model_dump(mode="json")))
|
7
|
+
|
8
|
+
|
9
|
+
if __name__ == '__main__':
|
10
|
+
command()
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import os.path
|
2
|
+
|
3
|
+
from src.core.const import BASE_DIRPATH
|
4
|
+
from src.core.settings import Settings
|
5
|
+
|
6
|
+
|
7
|
+
def command():
|
8
|
+
print(Settings.generate_env_example())
|
9
|
+
Settings.save_env_example_to_file(filepath=os.path.join(BASE_DIRPATH, "example.env"))
|
10
|
+
|
11
|
+
|
12
|
+
if __name__ == '__main__':
|
13
|
+
command()
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
Healthcheck
|
@@ -0,0 +1 @@
|
|
1
|
+
HELLO WORLD
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
# ...
|
@@ -0,0 +1,13 @@
|
|
1
|
+
from arpakitlib.ar_fastapi_util import BaseAPIErrorCodes, BaseAPIErrorSpecificationCodes
|
2
|
+
|
3
|
+
|
4
|
+
class APIErrorCodes(BaseAPIErrorCodes):
|
5
|
+
pass
|
6
|
+
|
7
|
+
|
8
|
+
class APIErrorSpecificationCodes(BaseAPIErrorSpecificationCodes):
|
9
|
+
pass
|
10
|
+
|
11
|
+
|
12
|
+
if __name__ == '__main__':
|
13
|
+
print(APIErrorCodes.str_for_print())
|
@@ -0,0 +1,117 @@
|
|
1
|
+
from fastapi import FastAPI
|
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
|
8
|
+
from arpakitlib.ar_sqlalchemy_util import SQLAlchemyDB
|
9
|
+
from arpakitlib.ar_type_util import raise_for_type
|
10
|
+
from src.api.event import StartupAPIEvent, ShutdownAPIEvent
|
11
|
+
from src.api.router.main_router import main_api_router
|
12
|
+
from src.api.transmitted_api_data import TransmittedAPIData
|
13
|
+
from src.core.const import STATIC_DIRPATH
|
14
|
+
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
|
17
|
+
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
|
+
|
21
|
+
|
22
|
+
def create_api_app() -> FastAPI:
|
23
|
+
setup_logging()
|
24
|
+
|
25
|
+
settings = get_cached_settings()
|
26
|
+
|
27
|
+
sqlalchemy_db = get_cached_sqlalchemy_db() if settings.sql_db_url is not None else None
|
28
|
+
|
29
|
+
transmitted_api_data = TransmittedAPIData(
|
30
|
+
settings=settings,
|
31
|
+
sqlalchemy_db=sqlalchemy_db
|
32
|
+
)
|
33
|
+
|
34
|
+
funcs_before_response = []
|
35
|
+
|
36
|
+
if settings.api_create_story_log_before_response_in_handle_exception:
|
37
|
+
raise_for_type(sqlalchemy_db, SQLAlchemyDB)
|
38
|
+
funcs_before_response.append(
|
39
|
+
create_story_log_before_response_in_handle_exception(
|
40
|
+
sqlalchemy_db=sqlalchemy_db,
|
41
|
+
ignore_api_error_code_not_found=True
|
42
|
+
)
|
43
|
+
)
|
44
|
+
|
45
|
+
handle_exception = create_handle_exception(
|
46
|
+
funcs_before_response=funcs_before_response,
|
47
|
+
async_funcs_after_response=[]
|
48
|
+
)
|
49
|
+
|
50
|
+
startup_api_events = []
|
51
|
+
|
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
|
+
startup_api_events.append(StartupAPIEvent(transmitted_api_data=transmitted_api_data))
|
65
|
+
|
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
|
+
shutdown_api_events = []
|
96
|
+
|
97
|
+
shutdown_api_events.append(ShutdownAPIEvent(transmitted_api_data=transmitted_api_data))
|
98
|
+
|
99
|
+
api_app = create_fastapi_app(
|
100
|
+
title=settings.api_title.strip(),
|
101
|
+
description=settings.api_description.strip(),
|
102
|
+
log_filepath=settings.log_filepath,
|
103
|
+
handle_exception_=handle_exception,
|
104
|
+
startup_api_events=startup_api_events,
|
105
|
+
shutdown_api_events=shutdown_api_events,
|
106
|
+
transmitted_api_data=transmitted_api_data,
|
107
|
+
main_api_router=main_api_router,
|
108
|
+
contact=DEFAULT_CONTACT,
|
109
|
+
media_dirpath=settings.media_dirpath,
|
110
|
+
static_dirpath=STATIC_DIRPATH
|
111
|
+
)
|
112
|
+
|
113
|
+
return api_app
|
114
|
+
|
115
|
+
|
116
|
+
if __name__ == '__main__':
|
117
|
+
create_api_app()
|
@@ -0,0 +1,20 @@
|
|
1
|
+
from arpakitlib.ar_fastapi_util import BaseStartupAPIEvent, BaseShutdownAPIEvent
|
2
|
+
from src.api.transmitted_api_data import TransmittedAPIData
|
3
|
+
|
4
|
+
|
5
|
+
class StartupAPIEvent(BaseStartupAPIEvent):
|
6
|
+
def __init__(self, transmitted_api_data: TransmittedAPIData):
|
7
|
+
super().__init__()
|
8
|
+
self.transmitted_api_data = transmitted_api_data
|
9
|
+
|
10
|
+
async def async_on_startup(self, *args, **kwargs):
|
11
|
+
self._logger.info(self.__class__.__name__)
|
12
|
+
|
13
|
+
|
14
|
+
class ShutdownAPIEvent(BaseShutdownAPIEvent):
|
15
|
+
def __init__(self, transmitted_api_data: TransmittedAPIData):
|
16
|
+
super().__init__()
|
17
|
+
self.transmitted_api_data = transmitted_api_data
|
18
|
+
|
19
|
+
async def async_on_shutdown(self, *args, **kwargs):
|
20
|
+
self._logger.info(self.__class__.__name__)
|
File without changes
|
File without changes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import fastapi.requests
|
2
|
+
from fastapi import APIRouter, Depends
|
3
|
+
from starlette import status
|
4
|
+
|
5
|
+
from arpakitlib.ar_fastapi_util import ErrorSO, get_transmitted_api_data
|
6
|
+
from src.api.const import APIErrorCodes, APIErrorSpecificationCodes
|
7
|
+
from src.api.schema.v1.out import APIErrorInfoSO
|
8
|
+
from src.api.transmitted_api_data import TransmittedAPIData
|
9
|
+
|
10
|
+
api_router = APIRouter()
|
11
|
+
|
12
|
+
|
13
|
+
@api_router.get(
|
14
|
+
"",
|
15
|
+
response_model=APIErrorInfoSO | ErrorSO,
|
16
|
+
status_code=status.HTTP_200_OK
|
17
|
+
)
|
18
|
+
async def _(
|
19
|
+
*,
|
20
|
+
request: fastapi.requests.Request,
|
21
|
+
response: fastapi.responses.Response,
|
22
|
+
transmitted_api_data: TransmittedAPIData = Depends(get_transmitted_api_data)
|
23
|
+
):
|
24
|
+
return APIErrorInfoSO(
|
25
|
+
api_error_codes=APIErrorCodes.values_list(),
|
26
|
+
api_error_specification_codes=APIErrorSpecificationCodes.values_list()
|
27
|
+
)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
from fastapi import APIRouter
|
2
|
+
|
3
|
+
from src.api.router.v1 import get_api_error_info
|
4
|
+
|
5
|
+
main_v1_api_router = APIRouter()
|
6
|
+
|
7
|
+
main_v1_api_router.include_router(
|
8
|
+
router=get_api_error_info.api_router,
|
9
|
+
prefix="/get_api_error_info",
|
10
|
+
tags=["API Error Info"]
|
11
|
+
)
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import uvicorn
|
2
|
+
|
3
|
+
from src.core.settings import get_cached_settings
|
4
|
+
|
5
|
+
|
6
|
+
def start_api_for_dev(*, reload: bool = False):
|
7
|
+
uvicorn.run(
|
8
|
+
"src.api.asgi:app",
|
9
|
+
port=get_cached_settings().api_port,
|
10
|
+
host="localhost",
|
11
|
+
workers=1,
|
12
|
+
reload=reload
|
13
|
+
)
|
14
|
+
|
15
|
+
|
16
|
+
if __name__ == '__main__':
|
17
|
+
start_api_for_dev(reload=False)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
from arpakitlib.ar_fastapi_util import BaseTransmittedAPIData
|
2
|
+
from arpakitlib.ar_sqlalchemy_util import SQLAlchemyDB
|
3
|
+
|
4
|
+
from src.core.settings import Settings
|
5
|
+
|
6
|
+
|
7
|
+
class TransmittedAPIData(BaseTransmittedAPIData):
|
8
|
+
settings: Settings
|
9
|
+
sqlalchemy_db: SQLAlchemyDB | None = None
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import asyncio
|
2
|
+
import os
|
3
|
+
import pathlib
|
4
|
+
|
5
|
+
BASE_DIRPATH: str = str(pathlib.Path(__file__).parent.parent.parent)
|
6
|
+
|
7
|
+
ENV_FILENAME: str = ".env"
|
8
|
+
|
9
|
+
ENV_FILEPATH: str = os.path.join(BASE_DIRPATH, ENV_FILENAME)
|
10
|
+
|
11
|
+
SRC_DIRNAME: str = "src"
|
12
|
+
|
13
|
+
SRC_DIRPATH: str = os.path.join(BASE_DIRPATH, SRC_DIRNAME)
|
14
|
+
|
15
|
+
MANAGE_DIRNAME: str = "manage"
|
16
|
+
|
17
|
+
MANAGE_DIRPATH: str = os.path.join(BASE_DIRPATH, MANAGE_DIRNAME)
|
18
|
+
|
19
|
+
RESOURCE_DIRNAME: str = "resource"
|
20
|
+
|
21
|
+
RESOURCE_DIRPATH: str = os.path.join(BASE_DIRPATH, RESOURCE_DIRNAME)
|
22
|
+
|
23
|
+
STATIC_DIRNAME: str = "static"
|
24
|
+
|
25
|
+
STATIC_DIRPATH: str = os.path.join(RESOURCE_DIRPATH, STATIC_DIRNAME)
|
26
|
+
|
27
|
+
|
28
|
+
def __example():
|
29
|
+
print(f"BASE_DIRPATH: {BASE_DIRPATH}")
|
30
|
+
print(f"ENV_FILENAME: {ENV_FILENAME}")
|
31
|
+
print(f"ENV_FILEPATH: {ENV_FILEPATH}")
|
32
|
+
print(f"SRC_DIRNAME: {SRC_DIRNAME}")
|
33
|
+
print(f"SRC_DIRPATH: {SRC_DIRPATH}")
|
34
|
+
print(f"MANAGE_DIRNAME: {MANAGE_DIRNAME}")
|
35
|
+
print(f"MANAGE_DIRPATH: {MANAGE_DIRPATH}")
|
36
|
+
print(f"RESOURCE_DIRNAME: {RESOURCE_DIRNAME}")
|
37
|
+
print(f"RESOURCE_DIRPATH: {RESOURCE_DIRPATH}")
|
38
|
+
print(f"STATIC_DIRNAME: {STATIC_DIRNAME}")
|
39
|
+
print(f"STATIC_DIRPATH: {STATIC_DIRPATH}")
|
40
|
+
|
41
|
+
|
42
|
+
async def __async_example():
|
43
|
+
pass
|
44
|
+
|
45
|
+
|
46
|
+
if __name__ == '__main__':
|
47
|
+
__example()
|
48
|
+
asyncio.run(__async_example())
|
@@ -0,0 +1,86 @@
|
|
1
|
+
import asyncio
|
2
|
+
import os
|
3
|
+
from functools import lru_cache
|
4
|
+
from typing import Any
|
5
|
+
|
6
|
+
import pytz
|
7
|
+
|
8
|
+
from arpakitlib.ar_json_util import safely_transfer_obj_to_json_str
|
9
|
+
from arpakitlib.ar_settings_util import SimpleSettings
|
10
|
+
from src.core.const import BASE_DIRPATH, ENV_FILEPATH
|
11
|
+
|
12
|
+
|
13
|
+
class Settings(SimpleSettings):
|
14
|
+
project_name: str = "{PROJECT_NAME}"
|
15
|
+
|
16
|
+
sql_db_url: str | None = (
|
17
|
+
"postgresql://{PROJECT_NAME}:{PROJECT_NAME}@127.0.0.1:{SQL_DB_PORT}/{PROJECT_NAME}"
|
18
|
+
) if (str("{PROJECT_NAME}") and str("{SQL_DB_PORT}").strip().isdigit()) else None
|
19
|
+
|
20
|
+
sql_db_echo: bool = False
|
21
|
+
|
22
|
+
api_init_sql_db_at_start: bool = True
|
23
|
+
|
24
|
+
api_title: str = "{PROJECT_NAME}"
|
25
|
+
|
26
|
+
api_description: str = "{PROJECT_NAME} (arpakitlib)"
|
27
|
+
|
28
|
+
api_create_story_log_before_response_in_handle_exception: bool = True
|
29
|
+
|
30
|
+
api_start_operation_executor_worker: bool = False
|
31
|
+
|
32
|
+
api_start_scheduled_operation_creator_worker: bool = False
|
33
|
+
|
34
|
+
api_port: int | None = int("{API_PORT}") if "{API_PORT}".strip().isdigit() else None
|
35
|
+
|
36
|
+
api_correct_api_key: str | None = "1"
|
37
|
+
|
38
|
+
api_correct_token: str | None = "1"
|
39
|
+
|
40
|
+
var_dirname: str | None = "var"
|
41
|
+
|
42
|
+
var_dirpath: str | None = os.path.join(BASE_DIRPATH, var_dirname)
|
43
|
+
|
44
|
+
log_filename: str | None = "story.log"
|
45
|
+
|
46
|
+
log_filepath: str | None = os.path.join(var_dirpath, log_filename)
|
47
|
+
|
48
|
+
cache_dirname: str | None = "cache"
|
49
|
+
|
50
|
+
cache_dirpath: str | None = os.path.join(var_dirpath, cache_dirname)
|
51
|
+
|
52
|
+
media_dirname: str | None = "media"
|
53
|
+
|
54
|
+
media_dirpath: str | None = os.path.join(var_dirpath, media_dirname)
|
55
|
+
|
56
|
+
dump_dirname: str | None = "dump"
|
57
|
+
|
58
|
+
dump_dirpath: str | None = os.path.join(var_dirpath, dump_dirname)
|
59
|
+
|
60
|
+
local_timezone: str | None = None
|
61
|
+
|
62
|
+
@property
|
63
|
+
def local_timezone_as_pytz(self) -> Any:
|
64
|
+
return pytz.timezone(self.local_timezone)
|
65
|
+
|
66
|
+
# ...
|
67
|
+
|
68
|
+
|
69
|
+
@lru_cache()
|
70
|
+
def get_cached_settings() -> Settings:
|
71
|
+
if os.path.exists(ENV_FILEPATH):
|
72
|
+
return Settings(_env_file=ENV_FILEPATH, _env_file_encoding="utf-8")
|
73
|
+
return Settings()
|
74
|
+
|
75
|
+
|
76
|
+
def __example():
|
77
|
+
print(safely_transfer_obj_to_json_str(get_cached_settings().model_dump(mode="json")))
|
78
|
+
|
79
|
+
|
80
|
+
async def __async_example():
|
81
|
+
pass
|
82
|
+
|
83
|
+
|
84
|
+
if __name__ == '__main__':
|
85
|
+
__example()
|
86
|
+
asyncio.run(__async_example())
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import asyncio
|
2
|
+
from datetime import datetime
|
3
|
+
from functools import lru_cache
|
4
|
+
|
5
|
+
from arpakitlib.ar_datetime_util import now_dt
|
6
|
+
from arpakitlib.ar_file_storage_in_dir_util import FileStorageInDir
|
7
|
+
from arpakitlib.ar_logging_util import setup_normal_logging
|
8
|
+
from arpakitlib.ar_type_util import raise_if_none
|
9
|
+
from src.core.settings import get_cached_settings
|
10
|
+
|
11
|
+
|
12
|
+
def setup_logging():
|
13
|
+
setup_normal_logging(log_filepath=get_cached_settings().log_filepath)
|
14
|
+
|
15
|
+
|
16
|
+
def create_cache_file_storage_in_dir() -> FileStorageInDir:
|
17
|
+
return FileStorageInDir(dirpath=get_cached_settings().cache_dirpath)
|
18
|
+
|
19
|
+
|
20
|
+
@lru_cache()
|
21
|
+
def get_cached_cache_file_storage_in_dir() -> FileStorageInDir:
|
22
|
+
return create_cache_file_storage_in_dir()
|
23
|
+
|
24
|
+
|
25
|
+
def create_media_file_storage_in_dir() -> FileStorageInDir:
|
26
|
+
return FileStorageInDir(dirpath=get_cached_settings().media_dirpath)
|
27
|
+
|
28
|
+
|
29
|
+
@lru_cache()
|
30
|
+
def get_cached_media_file_storage_in_dir() -> FileStorageInDir:
|
31
|
+
return create_media_file_storage_in_dir()
|
32
|
+
|
33
|
+
|
34
|
+
def create_dump_file_storage_in_dir() -> FileStorageInDir:
|
35
|
+
return FileStorageInDir(dirpath=get_cached_settings().dump_dirpath)
|
36
|
+
|
37
|
+
|
38
|
+
@lru_cache()
|
39
|
+
def get_cached_dump_file_storage_in_dir() -> FileStorageInDir:
|
40
|
+
return create_dump_file_storage_in_dir()
|
41
|
+
|
42
|
+
|
43
|
+
def now_local_dt() -> datetime:
|
44
|
+
raise_if_none(get_cached_settings().local_timezone_as_pytz)
|
45
|
+
return now_dt(tz=get_cached_settings().local_timezone_as_pytz)
|
46
|
+
|
47
|
+
|
48
|
+
def __example():
|
49
|
+
pass
|
50
|
+
|
51
|
+
|
52
|
+
async def __async_example():
|
53
|
+
pass
|
54
|
+
|
55
|
+
|
56
|
+
if __name__ == '__main__':
|
57
|
+
__example()
|
58
|
+
asyncio.run(__async_example())
|
File without changes
|