pycraftcore 5.0.1__tar.gz → 5.2.0__tar.gz
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.
- {pycraftcore-5.0.1/src/pycraftcore.egg-info → pycraftcore-5.2.0}/PKG-INFO +86 -9
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/Readme.md +84 -8
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/pyproject.toml +2 -2
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/model/connector.py +16 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/circuit_breaker/adapter/aiobreaker_circuit_breaker_policy.py +1 -4
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/adapter/__init__.py +14 -1
- pycraftcore-5.2.0/src/pycraftcore/repository/adapter/sql/sqlalchemy/__init__.py +17 -0
- pycraftcore-5.2.0/src/pycraftcore/repository/adapter/sql/sqlalchemy/adapter.py +21 -0
- pycraftcore-5.2.0/src/pycraftcore/repository/adapter/sql/sqlalchemy/engine_builder.py +8 -0
- pycraftcore-5.2.0/src/pycraftcore/repository/adapter/sql/sqlalchemy/factory.py +33 -0
- pycraftcore-5.2.0/src/pycraftcore/repository/adapter/sql/sqlalchemy/postgresql_engine_builder.py +29 -0
- pycraftcore-5.2.0/src/pycraftcore/repository/adapter/sql/sqlalchemy/sqlite_engine_builder.py +34 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/adapter/sql/sqlite/__init__.py +2 -0
- pycraftcore-5.2.0/src/pycraftcore/repository/adapter/sql/sqlite/database_file.py +18 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/adapter/sql/sqlite/factory.py +5 -22
- pycraftcore-5.2.0/src/pycraftcore/repository/adapter/sql/sqlite/pragmas.py +5 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/port/repository.py +0 -2
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/runtime/adapter/python/python_runner_template.py +0 -15
- {pycraftcore-5.0.1 → pycraftcore-5.2.0/src/pycraftcore.egg-info}/PKG-INFO +86 -9
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore.egg-info/SOURCES.txt +8 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore.egg-info/requires.txt +1 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/LICENSE +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/setup.cfg +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/adapter/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/adapter/load_application_configuration.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/adapter/omega_configuration_reader.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/adapter/schema.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/enum/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/enum/connector_type.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/enum/file_operation_action.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/enum/operation_type.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/enum/run_type_application.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/enum/run_type_environment.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/enum/server_type.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/model/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/model/configuration.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/model/operation.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/model/server.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/port/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/port/configuration.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/port/configuration_reader.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/authentication/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/authentication/model/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/authentication/model/auth_type.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/authentication/model/basic_auth.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/authentication/model/no_auth.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/authentication/model/token_auth.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/circuit_breaker/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/circuit_breaker/adapter/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/circuit_breaker/configuration/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/circuit_breaker/configuration/circuit_breaker_configuration.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/circuit_breaker/enum/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/circuit_breaker/enum/circuit_breaker_status.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/circuit_breaker/exception/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/circuit_breaker/exception/circuit_breaker_open_exception.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/circuit_breaker/port/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/circuit_breaker/port/async_circuit_breaker.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/computation_engine/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/computation_engine/adapter/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/computation_engine/adapter/compute_engine.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/computation_engine/adapter/numpy_arithmetic_operation.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/computation_engine/adapter/scipy_calculus_operation.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/computation_engine/const_typing.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/computation_engine/port/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/computation_engine/port/arithmetic_operation.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/computation_engine/port/calculus_operation.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/computation_engine/port/engine.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/context/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/context/request_id_context.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/extension/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/extension/csv/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/extension/csv/csv_reader.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/extension/csv/csv_writer.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/extension/json/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/extension/json/json_reader.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/extension/json/json_writer.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/extension/markdown/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/extension/markdown/markdown_reader.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/extension/markdown/markdown_writer.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/extension/svg/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/extension/svg/svg_reader.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/extension/svg/svg_writer.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/extension/txt/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/extension/txt/txt_reader.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/extension/txt/txt_writer.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/extension/yml/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/extension/yml/yml_reader.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/extension/yml/yml_writer.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/factory.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/handler.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/provider.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/adapter/strategy.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/enum/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/enum/read_chunk_mode.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/port/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/port/file_handler_factory.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/port/file_handler_provider.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/port/reader.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/port/writer.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/schema/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/file_handler/schema/file_manifest.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/http/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/http/adapter/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/http/adapter/aiohttp_client.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/http/adapter/httpx_client.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/http/configuration/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/http/configuration/client_configuration.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/http/configuration/http_client_configuration.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/http/configuration/limits_configuration.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/http/configuration/security_configuration.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/http/enum/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/http/enum/http_method.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/http/policy/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/http/policy/http_error_policy.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/http/port/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/http/port/async_http_client.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/logger/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/logger/adapter/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/logger/adapter/standard_logger.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/logger/configuration.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/logger/enum/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/logger/enum/log_level.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/logger/port/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/logger/port/logger.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/profiler/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/profiler/profiled.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/py.typed +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/query_language/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/query_language/adapter/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/query_language/adapter/sql/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/query_language/adapter/sql/adapter.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/query_language/adapter/sql/factory.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/query_language/constants/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/query_language/constants/sql/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/query_language/constants/sql/allowed_sql_root_statements.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/query_language/constants/sql/forbidden_sql_statements.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/query_language/port/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/query_language/port/query_handler.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/adapter/no_sql/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/adapter/no_sql/mongodb/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/adapter/no_sql/mongodb/adapter.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/adapter/no_sql/mongodb/factory.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/adapter/no_sql/mongodb/mapper.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/adapter/no_sql/mongodb/schema.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/adapter/sql/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/adapter/sql/postgresql/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/adapter/sql/postgresql/adapter.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/adapter/sql/postgresql/factory.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/adapter/sql/postgresql/mapper.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/adapter/sql/postgresql/schema.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/adapter/sql/sqlite/adapter.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/adapter/sql/sqlite/mapper.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/adapter/sql/sqlite/schema.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/port/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/resilient_http/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/resilient_http/adapter/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/resilient_http/adapter/resilient_client.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/resilient_http/adapter/resilient_http_client_factory.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/resilient_http/adapter/resilient_transport.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/resilient_http/adapter/resilient_transport_factory.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/resilient_http/configuration/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/resilient_http/configuration/resilient_http_configuration.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/resilient_http/port/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/resilient_http/port/async_resilient_http_client.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/retry/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/retry/adapter/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/retry/adapter/tenacity_retry_policy.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/retry/configuration/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/retry/configuration/retry_configuration.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/retry/port/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/retry/port/retry.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/runtime/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/runtime/adapter/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/runtime/adapter/python/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/runtime/adapter/python/adapter.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/runtime/adapter/python/factory.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/runtime/adapter/python/host_bridge_server.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/runtime/port/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/runtime/port/code.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/runtime/schema/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/runtime/schema/code_result.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/runtime/schema/code_stdout.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/runtime/schema/host_bridge.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/runtime/schema/safe_code_settings.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/serializer/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/serializer/adapter/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/serializer/adapter/binary_serializer.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/serializer/adapter/dictionary_serializer.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/serializer/adapter/json_serializer.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/serializer/port/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/serializer/port/serializer.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/telemetry/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/telemetry/adapter/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/telemetry/adapter/null_telemetry.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/telemetry/adapter/open_telemetry.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/telemetry/adapter/open_telemetry_logger_provider.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/telemetry/adapter/open_telemetry_meter_provider.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/telemetry/adapter/open_telemetry_provider.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/telemetry/adapter/open_telemetry_tracer.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/telemetry/port/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/telemetry/port/logger_provider.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/telemetry/port/meter_provider.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/telemetry/port/telemetry.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/telemetry/port/trace_provider.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/telemetry/port/tracer.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web/actuator/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web/actuator/actuator.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web/actuator/enum/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web/actuator/enum/health_status.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web/actuator/schema/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web/actuator/schema/actuator_response.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web/asgi.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web/middleware/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web/middleware/request_id_middleware.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web/schema/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web/schema/api_settings.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web/sse.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web/streaming.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web_blacksheep/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web_blacksheep/actuator_router.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web_blacksheep/app_factory.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web_blacksheep/detail_handler.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web_blacksheep/event_stream.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web_fastapi/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web_fastapi/actuator_router.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web_fastapi/app_factory.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web_fastapi/detail_handler.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web_fastapi/event_stream.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web_litestar/__init__.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web_litestar/actuator_router.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web_litestar/app_factory.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web_litestar/detail_handler.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/web_litestar/event_stream.py +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore.egg-info/dependency_links.txt +0 -0
- {pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pycraftcore
|
|
3
|
-
Version: 5.0
|
|
3
|
+
Version: 5.2.0
|
|
4
4
|
Summary: Provides reusable technical infrastructure and adapter implementations for Python applications
|
|
5
5
|
Author-email: Toufik Saouchi <toufik.saouchi@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -82,6 +82,7 @@ Requires-Dist: aiosqlite; extra == "repository"
|
|
|
82
82
|
Requires-Dist: pymongo; extra == "repository"
|
|
83
83
|
Requires-Dist: psycopg[binary]; extra == "repository"
|
|
84
84
|
Requires-Dist: psycopg-pool; extra == "repository"
|
|
85
|
+
Requires-Dist: sqlalchemy[asyncio]>=2; extra == "repository"
|
|
85
86
|
Requires-Dist: orjson; extra == "repository"
|
|
86
87
|
Requires-Dist: pydantic>=2; extra == "repository"
|
|
87
88
|
Requires-Dist: pycraftcore[application_configuration,authentication]; extra == "repository"
|
|
@@ -131,7 +132,7 @@ A shared technical foundation for Python services: configuration, logging, telem
|
|
|
131
132
|
│ set up application_configuration · logger · telemetry · context │
|
|
132
133
|
│ talk out http · resilient_http (retry + circuit_breaker) │
|
|
133
134
|
│ serve web: ASGI APIs on Litestar, FastAPI or BlackSheep │
|
|
134
|
-
│ store repository: SQLite · PostgreSQL · MongoDB
|
|
135
|
+
│ store repository: SQLite · PostgreSQL · MongoDB · SQLAlchemy │
|
|
135
136
|
│ run safely query_language (read-only SQL) · runtime (Python sandbox) │
|
|
136
137
|
│ utilities file_handler · serializer · computation_engine · profiler │
|
|
137
138
|
│ … new modules, same port + adapter shape │
|
|
@@ -172,14 +173,14 @@ A bare `pycraftcore` installs no third-party packages: only `authentication`, `c
|
|
|
172
173
|
| `application_configuration` | omegaconf, pydantic, python-dotenv | `http`, `logger`, `authentication` |
|
|
173
174
|
| `telemetry` | opentelemetry (api, sdk, otlp exporter, logging instrumentation) | `application_configuration`, `context` |
|
|
174
175
|
| `resilient_http` | aiohttp, httpx | `circuit_breaker`, `http`, `retry`, `telemetry` |
|
|
175
|
-
| `repository` | aiosqlite, pymongo, psycopg, psycopg-pool, orjson, pydantic | `application_configuration`, `authentication` |
|
|
176
|
+
| `repository` | aiosqlite, pymongo, psycopg, psycopg-pool, sqlalchemy, orjson, pydantic | `application_configuration`, `authentication` |
|
|
176
177
|
|
|
177
178
|
List every module your code imports, even when one extra already brings in another. That way your service stays correct if these links change. For the Python sandbox, use `runtime-sandbox` rather than `runtime`: the sandboxed code runs on your service's interpreter, so the libraries it may import (pandas, numpy, matplotlib, dateutil) must be installed there.
|
|
178
179
|
|
|
179
|
-
Development builds are published to TestPyPI; use them for testing only. Their dependencies come from PyPI, so add it as an extra index:
|
|
180
|
+
Development builds (tags on `develop`, such as `v5.1.0-rc.1`, published as `5.1.0rc1`) are published to TestPyPI; use them for testing only. Their dependencies come from PyPI, so add it as an extra index, and name the version, since pip skips pre-releases otherwise:
|
|
180
181
|
|
|
181
182
|
```bash
|
|
182
|
-
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ "pycraftcore[http]"
|
|
183
|
+
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ "pycraftcore[http]==5.1.0rc1"
|
|
183
184
|
```
|
|
184
185
|
|
|
185
186
|
### What's inside
|
|
@@ -198,7 +199,7 @@ Each module stands on its own: use the ones you need. The modules today (new one
|
|
|
198
199
|
| `web_litestar`, `web_fastapi`, `web_blacksheep` | One toolkit per framework: build the app with pycraftcore's conventions and write your routes with the framework's own features |
|
|
199
200
|
| `resilient_http` | An HTTP transport with retries and a circuit breaker built in |
|
|
200
201
|
| `retry`, `circuit_breaker` | The two policies on their own, for any async call |
|
|
201
|
-
| `repository` | Async repositories built from a database connector — today SQLite (pooled), PostgreSQL and
|
|
202
|
+
| `repository` | Async repositories built from a database connector — today SQLite (pooled), PostgreSQL, MongoDB, and SQLAlchemy (PostgreSQL or SQLite, for libraries that need an engine) |
|
|
202
203
|
| `query_language` | Checks that a SQL statement is read-only, and translates between dialects, before it reaches a database |
|
|
203
204
|
| `runtime` | Runs untrusted Python in a separate process with memory, time and module limits; optionally lets it call your functions |
|
|
204
205
|
| `file_handler` | Read and write files by extension (today csv, json, yml, md, txt, svg); a new format is a new reader/writer pair |
|
|
@@ -296,6 +297,7 @@ server = config.server.asgi("weather-api") # AsgiServer
|
|
|
296
297
|
|
|
297
298
|
- `log` is a `LogLevel` (`DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`, upper case): pass it to `configure_logging(config.log)`.
|
|
298
299
|
- A server holds `base_path`, `docs` and `cors_origins`: turn them into the web toolkit's `ApiSettings` (see [Serving an HTTP API](#serving-an-http-api)). Which framework serves the API is a choice made in code, not in the configuration.
|
|
300
|
+
- An MCP connector can hold a `refresh` block for clients that re-read the server's tools in the background: `interval` (seconds between reads while it answers, default 60), `retry_delay` (the first wait after a failure, default 5, doubled each time) and `max_retry_delay` (the longest wait, default 60). Leave it out to keep the defaults.
|
|
299
301
|
- `parameters` is yours: pycraftcore passes it through untouched. `oc.env` always gives strings, so convert the values where you read them.
|
|
300
302
|
- `log` and `server` are required, like `connector` and `operation`. A service that serves no HTTP API writes `server: {}`.
|
|
301
303
|
|
|
@@ -446,6 +448,40 @@ await factory.disconnect()
|
|
|
446
448
|
|
|
447
449
|
`PostgresRepositoryFactory` / `PostgresSettingsMapper` and `MongoRepositoryFactory` / `MongoSettingsMapper` work the same way, and so will any database added later: a factory, a settings mapper and a repository behind the same `AsyncRepository` port.
|
|
448
450
|
|
|
451
|
+
Every factory has three methods: `connect()` gives the `AsyncRepository`, `connection()` gives the driver's own client, and `disconnect()` closes both. Use `connection()` to hand the database to a library that brings its own code, such as LangGraph's checkpointers (`MongoClient`, an aiosqlite connection).
|
|
452
|
+
|
|
453
|
+
#### SQLAlchemy
|
|
454
|
+
|
|
455
|
+
For a library that asks for a SQLAlchemy engine, `SqlAlchemyRepositoryFactory` manages one: it builds it once, checks it answers, and disposes of it. How the engine is built is injected, as an engine builder made from the existing PostgreSQL or SQLite settings, so the factory never knows which database it's on:
|
|
456
|
+
|
|
457
|
+
```python
|
|
458
|
+
from pycraftcore.repository.adapter import (
|
|
459
|
+
PostgresEngineBuilder,
|
|
460
|
+
PostgresSettingsMapper,
|
|
461
|
+
SqlAlchemyRepositoryFactory,
|
|
462
|
+
SqliteEngineBuilder,
|
|
463
|
+
SqliteSettingsMapper,
|
|
464
|
+
)
|
|
465
|
+
|
|
466
|
+
postgres = PostgresEngineBuilder(PostgresSettingsMapper(config.connector.database("tasks"))())
|
|
467
|
+
sqlite = SqliteEngineBuilder(SqliteSettingsMapper(config.connector.database("tasks_fallback"))())
|
|
468
|
+
|
|
469
|
+
factory = SqlAlchemyRepositoryFactory(postgres) # or sqlite: same factory
|
|
470
|
+
await factory.ping() # raises when the database can't be reached
|
|
471
|
+
engine = await factory.connection() # an AsyncEngine, for the library
|
|
472
|
+
await factory.disconnect() # disposes the engine
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
| Builder | Settings | Engine |
|
|
476
|
+
|---|---|---|
|
|
477
|
+
| `PostgresEngineBuilder` | `PostgresConnector` | `postgresql+psycopg`, a pool of `pool.max` connections checked before use (`pool_pre_ping`), so a database restart doesn't leave dead connections |
|
|
478
|
+
| `SqliteEngineBuilder` | `SqliteConnector` | `sqlite+aiosqlite` on the file `SqliteDatabaseFile` prepares (`<host>/<default_name>.db`, folder created); every connection it opens gets the same PRAGMAs as `SqliteRepositoryFactory` (WAL, a 5-second busy timeout, `synchronous=NORMAL`) |
|
|
479
|
+
|
|
480
|
+
- Both builders use the drivers the other adapters use, so there's no other driver to install.
|
|
481
|
+
- Another database is another class with a `build() -> AsyncEngine` method (the `SqlAlchemyEngineBuilder` protocol); the factory doesn't change.
|
|
482
|
+
- `connect()` also gives an `AsyncRepository`. Its `execute(query, parameters)` takes the driver's own placeholders, as the other SQL adapters do: `%s` for PostgreSQL, `?` for SQLite. Each call runs in its own transaction.
|
|
483
|
+
- The factory builds the engine and nothing else: tables belong to the code that owns them, through its own models or migrations.
|
|
484
|
+
|
|
449
485
|
### Read-only SQL
|
|
450
486
|
|
|
451
487
|
```python
|
|
@@ -538,9 +574,50 @@ uv run pre-commit install --hook-type pre-commit --hook-type pre-push
|
|
|
538
574
|
|
|
539
575
|
### Releasing
|
|
540
576
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
577
|
+
Every push and pull request runs the checks; only a tag publishes, and the branch it is on decides where:
|
|
578
|
+
|
|
579
|
+
```text
|
|
580
|
+
feature/… ──PR──► develop ──PR──► main
|
|
581
|
+
│ │
|
|
582
|
+
tag vX.Y.Z-rc.N tag vX.Y.Z
|
|
583
|
+
▼ ▼
|
|
584
|
+
TestPyPI PyPI
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
| Event | CI ([`.github/workflows/cicd.yml`](.github/workflows/cicd.yml)) | Publishes |
|
|
588
|
+
|---|---|---|
|
|
589
|
+
| Pull request to `develop` or `main` | LINT, TYPECHECK, TEST, EXTRAS, BUILD | nothing |
|
|
590
|
+
| Push to `develop` or `main` | the same | nothing |
|
|
591
|
+
| Tag `vX.Y.Z-rc.N` on a commit only on `develop` | the same + RELEASE TARGET + PUBLISH | TestPyPI |
|
|
592
|
+
| Tag `vX.Y.Z` on a commit of `main` | the same + RELEASE TARGET + PUBLISH | PyPI |
|
|
593
|
+
| Tag on neither branch, a pre-release on `main`, a final version only on `develop` | RELEASE TARGET fails | nothing |
|
|
594
|
+
|
|
595
|
+
- The tag is the version: `v5.1.0` builds `5.1.0` and `v5.1.0-rc.1` builds `5.1.0rc1` (the Python spelling), whatever `pyproject.toml` says (the run notes it when they differ). Keep `pyproject.toml` on the next version anyway, for local builds.
|
|
596
|
+
- A tag name is used once, so tags on `develop` are pre-releases (`vX.Y.Z-rc.N`) and the final `vX.Y.Z` goes on `main`. PyPI and TestPyPI both refuse a version they already have.
|
|
597
|
+
- RELEASE TARGET is the same job in every repository with this pipeline (agent-runtime, agent-toolbox, homelab-ui, pricelab): only what a channel publishes differs.
|
|
598
|
+
- A commit on both branches (after `main` is merged back into `develop`) counts as `main`.
|
|
599
|
+
- PUBLISH runs in the `production` environment, with `TEST_PYPI_TOKEN`, `RELEASE_PYPI_TOKEN` and the `TEST_PYPI_URL` variable.
|
|
600
|
+
|
|
601
|
+
Try a version on TestPyPI:
|
|
602
|
+
|
|
603
|
+
```bash
|
|
604
|
+
git switch develop && git pull
|
|
605
|
+
git tag v5.1.0-rc.1
|
|
606
|
+
git push origin v5.1.0-rc.1
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
Release it:
|
|
610
|
+
|
|
611
|
+
1. Bump `version` in `pyproject.toml` on `develop`, then merge `develop` into `main` (pull request); CI is green.
|
|
612
|
+
2. Tag `main`:
|
|
613
|
+
```bash
|
|
614
|
+
git switch main && git pull
|
|
615
|
+
git tag v5.1.0
|
|
616
|
+
git push origin v5.1.0
|
|
617
|
+
```
|
|
618
|
+
3. **Actions**: RELEASE TARGET says `pypi`, PUBLISH is green.
|
|
544
619
|
4. Raise the minimum version in the services that need the change (`pycraftcore[<extras>]>=…` in their `pyproject.toml`), then `uv lock --upgrade-package pycraftcore`.
|
|
545
620
|
|
|
621
|
+
`make publish_dev` and `make publish` still publish a local `make build` by hand, with the same tokens.
|
|
622
|
+
|
|
546
623
|
To work on pycraftcore and a service at the same time, point the service at your checkout with an editable path dependency in its `pyproject.toml`: `pycraftcore = { path = "../pycraftcore", editable = true }` under `[tool.uv.sources]`.
|
|
@@ -14,7 +14,7 @@ A shared technical foundation for Python services: configuration, logging, telem
|
|
|
14
14
|
│ set up application_configuration · logger · telemetry · context │
|
|
15
15
|
│ talk out http · resilient_http (retry + circuit_breaker) │
|
|
16
16
|
│ serve web: ASGI APIs on Litestar, FastAPI or BlackSheep │
|
|
17
|
-
│ store repository: SQLite · PostgreSQL · MongoDB
|
|
17
|
+
│ store repository: SQLite · PostgreSQL · MongoDB · SQLAlchemy │
|
|
18
18
|
│ run safely query_language (read-only SQL) · runtime (Python sandbox) │
|
|
19
19
|
│ utilities file_handler · serializer · computation_engine · profiler │
|
|
20
20
|
│ … new modules, same port + adapter shape │
|
|
@@ -55,14 +55,14 @@ A bare `pycraftcore` installs no third-party packages: only `authentication`, `c
|
|
|
55
55
|
| `application_configuration` | omegaconf, pydantic, python-dotenv | `http`, `logger`, `authentication` |
|
|
56
56
|
| `telemetry` | opentelemetry (api, sdk, otlp exporter, logging instrumentation) | `application_configuration`, `context` |
|
|
57
57
|
| `resilient_http` | aiohttp, httpx | `circuit_breaker`, `http`, `retry`, `telemetry` |
|
|
58
|
-
| `repository` | aiosqlite, pymongo, psycopg, psycopg-pool, orjson, pydantic | `application_configuration`, `authentication` |
|
|
58
|
+
| `repository` | aiosqlite, pymongo, psycopg, psycopg-pool, sqlalchemy, orjson, pydantic | `application_configuration`, `authentication` |
|
|
59
59
|
|
|
60
60
|
List every module your code imports, even when one extra already brings in another. That way your service stays correct if these links change. For the Python sandbox, use `runtime-sandbox` rather than `runtime`: the sandboxed code runs on your service's interpreter, so the libraries it may import (pandas, numpy, matplotlib, dateutil) must be installed there.
|
|
61
61
|
|
|
62
|
-
Development builds are published to TestPyPI; use them for testing only. Their dependencies come from PyPI, so add it as an extra index:
|
|
62
|
+
Development builds (tags on `develop`, such as `v5.1.0-rc.1`, published as `5.1.0rc1`) are published to TestPyPI; use them for testing only. Their dependencies come from PyPI, so add it as an extra index, and name the version, since pip skips pre-releases otherwise:
|
|
63
63
|
|
|
64
64
|
```bash
|
|
65
|
-
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ "pycraftcore[http]"
|
|
65
|
+
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ "pycraftcore[http]==5.1.0rc1"
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
### What's inside
|
|
@@ -81,7 +81,7 @@ Each module stands on its own: use the ones you need. The modules today (new one
|
|
|
81
81
|
| `web_litestar`, `web_fastapi`, `web_blacksheep` | One toolkit per framework: build the app with pycraftcore's conventions and write your routes with the framework's own features |
|
|
82
82
|
| `resilient_http` | An HTTP transport with retries and a circuit breaker built in |
|
|
83
83
|
| `retry`, `circuit_breaker` | The two policies on their own, for any async call |
|
|
84
|
-
| `repository` | Async repositories built from a database connector — today SQLite (pooled), PostgreSQL and
|
|
84
|
+
| `repository` | Async repositories built from a database connector — today SQLite (pooled), PostgreSQL, MongoDB, and SQLAlchemy (PostgreSQL or SQLite, for libraries that need an engine) |
|
|
85
85
|
| `query_language` | Checks that a SQL statement is read-only, and translates between dialects, before it reaches a database |
|
|
86
86
|
| `runtime` | Runs untrusted Python in a separate process with memory, time and module limits; optionally lets it call your functions |
|
|
87
87
|
| `file_handler` | Read and write files by extension (today csv, json, yml, md, txt, svg); a new format is a new reader/writer pair |
|
|
@@ -179,6 +179,7 @@ server = config.server.asgi("weather-api") # AsgiServer
|
|
|
179
179
|
|
|
180
180
|
- `log` is a `LogLevel` (`DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`, upper case): pass it to `configure_logging(config.log)`.
|
|
181
181
|
- A server holds `base_path`, `docs` and `cors_origins`: turn them into the web toolkit's `ApiSettings` (see [Serving an HTTP API](#serving-an-http-api)). Which framework serves the API is a choice made in code, not in the configuration.
|
|
182
|
+
- An MCP connector can hold a `refresh` block for clients that re-read the server's tools in the background: `interval` (seconds between reads while it answers, default 60), `retry_delay` (the first wait after a failure, default 5, doubled each time) and `max_retry_delay` (the longest wait, default 60). Leave it out to keep the defaults.
|
|
182
183
|
- `parameters` is yours: pycraftcore passes it through untouched. `oc.env` always gives strings, so convert the values where you read them.
|
|
183
184
|
- `log` and `server` are required, like `connector` and `operation`. A service that serves no HTTP API writes `server: {}`.
|
|
184
185
|
|
|
@@ -329,6 +330,40 @@ await factory.disconnect()
|
|
|
329
330
|
|
|
330
331
|
`PostgresRepositoryFactory` / `PostgresSettingsMapper` and `MongoRepositoryFactory` / `MongoSettingsMapper` work the same way, and so will any database added later: a factory, a settings mapper and a repository behind the same `AsyncRepository` port.
|
|
331
332
|
|
|
333
|
+
Every factory has three methods: `connect()` gives the `AsyncRepository`, `connection()` gives the driver's own client, and `disconnect()` closes both. Use `connection()` to hand the database to a library that brings its own code, such as LangGraph's checkpointers (`MongoClient`, an aiosqlite connection).
|
|
334
|
+
|
|
335
|
+
#### SQLAlchemy
|
|
336
|
+
|
|
337
|
+
For a library that asks for a SQLAlchemy engine, `SqlAlchemyRepositoryFactory` manages one: it builds it once, checks it answers, and disposes of it. How the engine is built is injected, as an engine builder made from the existing PostgreSQL or SQLite settings, so the factory never knows which database it's on:
|
|
338
|
+
|
|
339
|
+
```python
|
|
340
|
+
from pycraftcore.repository.adapter import (
|
|
341
|
+
PostgresEngineBuilder,
|
|
342
|
+
PostgresSettingsMapper,
|
|
343
|
+
SqlAlchemyRepositoryFactory,
|
|
344
|
+
SqliteEngineBuilder,
|
|
345
|
+
SqliteSettingsMapper,
|
|
346
|
+
)
|
|
347
|
+
|
|
348
|
+
postgres = PostgresEngineBuilder(PostgresSettingsMapper(config.connector.database("tasks"))())
|
|
349
|
+
sqlite = SqliteEngineBuilder(SqliteSettingsMapper(config.connector.database("tasks_fallback"))())
|
|
350
|
+
|
|
351
|
+
factory = SqlAlchemyRepositoryFactory(postgres) # or sqlite: same factory
|
|
352
|
+
await factory.ping() # raises when the database can't be reached
|
|
353
|
+
engine = await factory.connection() # an AsyncEngine, for the library
|
|
354
|
+
await factory.disconnect() # disposes the engine
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
| Builder | Settings | Engine |
|
|
358
|
+
|---|---|---|
|
|
359
|
+
| `PostgresEngineBuilder` | `PostgresConnector` | `postgresql+psycopg`, a pool of `pool.max` connections checked before use (`pool_pre_ping`), so a database restart doesn't leave dead connections |
|
|
360
|
+
| `SqliteEngineBuilder` | `SqliteConnector` | `sqlite+aiosqlite` on the file `SqliteDatabaseFile` prepares (`<host>/<default_name>.db`, folder created); every connection it opens gets the same PRAGMAs as `SqliteRepositoryFactory` (WAL, a 5-second busy timeout, `synchronous=NORMAL`) |
|
|
361
|
+
|
|
362
|
+
- Both builders use the drivers the other adapters use, so there's no other driver to install.
|
|
363
|
+
- Another database is another class with a `build() -> AsyncEngine` method (the `SqlAlchemyEngineBuilder` protocol); the factory doesn't change.
|
|
364
|
+
- `connect()` also gives an `AsyncRepository`. Its `execute(query, parameters)` takes the driver's own placeholders, as the other SQL adapters do: `%s` for PostgreSQL, `?` for SQLite. Each call runs in its own transaction.
|
|
365
|
+
- The factory builds the engine and nothing else: tables belong to the code that owns them, through its own models or migrations.
|
|
366
|
+
|
|
332
367
|
### Read-only SQL
|
|
333
368
|
|
|
334
369
|
```python
|
|
@@ -421,9 +456,50 @@ uv run pre-commit install --hook-type pre-commit --hook-type pre-push
|
|
|
421
456
|
|
|
422
457
|
### Releasing
|
|
423
458
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
459
|
+
Every push and pull request runs the checks; only a tag publishes, and the branch it is on decides where:
|
|
460
|
+
|
|
461
|
+
```text
|
|
462
|
+
feature/… ──PR──► develop ──PR──► main
|
|
463
|
+
│ │
|
|
464
|
+
tag vX.Y.Z-rc.N tag vX.Y.Z
|
|
465
|
+
▼ ▼
|
|
466
|
+
TestPyPI PyPI
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
| Event | CI ([`.github/workflows/cicd.yml`](.github/workflows/cicd.yml)) | Publishes |
|
|
470
|
+
|---|---|---|
|
|
471
|
+
| Pull request to `develop` or `main` | LINT, TYPECHECK, TEST, EXTRAS, BUILD | nothing |
|
|
472
|
+
| Push to `develop` or `main` | the same | nothing |
|
|
473
|
+
| Tag `vX.Y.Z-rc.N` on a commit only on `develop` | the same + RELEASE TARGET + PUBLISH | TestPyPI |
|
|
474
|
+
| Tag `vX.Y.Z` on a commit of `main` | the same + RELEASE TARGET + PUBLISH | PyPI |
|
|
475
|
+
| Tag on neither branch, a pre-release on `main`, a final version only on `develop` | RELEASE TARGET fails | nothing |
|
|
476
|
+
|
|
477
|
+
- The tag is the version: `v5.1.0` builds `5.1.0` and `v5.1.0-rc.1` builds `5.1.0rc1` (the Python spelling), whatever `pyproject.toml` says (the run notes it when they differ). Keep `pyproject.toml` on the next version anyway, for local builds.
|
|
478
|
+
- A tag name is used once, so tags on `develop` are pre-releases (`vX.Y.Z-rc.N`) and the final `vX.Y.Z` goes on `main`. PyPI and TestPyPI both refuse a version they already have.
|
|
479
|
+
- RELEASE TARGET is the same job in every repository with this pipeline (agent-runtime, agent-toolbox, homelab-ui, pricelab): only what a channel publishes differs.
|
|
480
|
+
- A commit on both branches (after `main` is merged back into `develop`) counts as `main`.
|
|
481
|
+
- PUBLISH runs in the `production` environment, with `TEST_PYPI_TOKEN`, `RELEASE_PYPI_TOKEN` and the `TEST_PYPI_URL` variable.
|
|
482
|
+
|
|
483
|
+
Try a version on TestPyPI:
|
|
484
|
+
|
|
485
|
+
```bash
|
|
486
|
+
git switch develop && git pull
|
|
487
|
+
git tag v5.1.0-rc.1
|
|
488
|
+
git push origin v5.1.0-rc.1
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
Release it:
|
|
492
|
+
|
|
493
|
+
1. Bump `version` in `pyproject.toml` on `develop`, then merge `develop` into `main` (pull request); CI is green.
|
|
494
|
+
2. Tag `main`:
|
|
495
|
+
```bash
|
|
496
|
+
git switch main && git pull
|
|
497
|
+
git tag v5.1.0
|
|
498
|
+
git push origin v5.1.0
|
|
499
|
+
```
|
|
500
|
+
3. **Actions**: RELEASE TARGET says `pypi`, PUBLISH is green.
|
|
427
501
|
4. Raise the minimum version in the services that need the change (`pycraftcore[<extras>]>=…` in their `pyproject.toml`), then `uv lock --upgrade-package pycraftcore`.
|
|
428
502
|
|
|
503
|
+
`make publish_dev` and `make publish` still publish a local `make build` by hand, with the same tokens.
|
|
504
|
+
|
|
429
505
|
To work on pycraftcore and a service at the same time, point the service at your checkout with an editable path dependency in its `pyproject.toml`: `pycraftcore = { path = "../pycraftcore", editable = true }` under `[tool.uv.sources]`.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pycraftcore"
|
|
7
|
-
version = "5.0
|
|
7
|
+
version = "5.2.0"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name = "Toufik Saouchi", email = "toufik.saouchi@gmail.com" },
|
|
10
10
|
]
|
|
@@ -49,7 +49,7 @@ web_blacksheep = ["blacksheep", "pycraftcore[web]"]
|
|
|
49
49
|
resilient_http = ["aiohttp", "httpx", "pycraftcore[circuit_breaker, http, logger, retry, telemetry]"]
|
|
50
50
|
application_configuration = ["omegaconf", "pydantic>=2", "python-dotenv", "pycraftcore[logger, http, authentication]"]
|
|
51
51
|
telemetry = ["opentelemetry-api", "opentelemetry-sdk", "opentelemetry-exporter-otlp", "opentelemetry-instrumentation-logging", "pycraftcore[application_configuration, context]"]
|
|
52
|
-
repository = ["aiosqlite", "pymongo", "psycopg[binary]", "psycopg-pool", "orjson", "pydantic>=2", "pycraftcore[application_configuration, authentication]"]
|
|
52
|
+
repository = ["aiosqlite", "pymongo", "psycopg[binary]", "psycopg-pool", "sqlalchemy[asyncio]>=2", "orjson", "pydantic>=2", "pycraftcore[application_configuration, authentication]"]
|
|
53
53
|
runtime-sandbox = ["pandas", "numpy", "matplotlib", "python-dateutil", "pycraftcore[runtime]"]
|
|
54
54
|
|
|
55
55
|
all = [
|
{pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/application_configuration/model/connector.py
RENAMED
|
@@ -41,12 +41,28 @@ class TelemetryConnector(BaseConnector):
|
|
|
41
41
|
port: int | None
|
|
42
42
|
|
|
43
43
|
|
|
44
|
+
@dataclass(frozen=True, slots=True)
|
|
45
|
+
class McpRefresh:
|
|
46
|
+
interval: float = 60.0
|
|
47
|
+
retry_delay: float = 5.0
|
|
48
|
+
max_retry_delay: float = 60.0
|
|
49
|
+
|
|
50
|
+
def __post_init__(self) -> None:
|
|
51
|
+
if self.interval <= 0:
|
|
52
|
+
raise ValueError("refresh interval must be greater than 0")
|
|
53
|
+
if self.retry_delay <= 0:
|
|
54
|
+
raise ValueError("refresh retry_delay must be greater than 0")
|
|
55
|
+
if self.max_retry_delay < self.retry_delay:
|
|
56
|
+
raise ValueError("refresh max_retry_delay must be greater than or equal to retry_delay")
|
|
57
|
+
|
|
58
|
+
|
|
44
59
|
@dataclass(slots=True)
|
|
45
60
|
class McpConnector(BaseConnector):
|
|
46
61
|
base_url: str
|
|
47
62
|
timeout: int
|
|
48
63
|
transport: Literal["sse", "streamable_http"] = "streamable_http"
|
|
49
64
|
certificate: str | None = field(default=None)
|
|
65
|
+
refresh: McpRefresh = field(default_factory=McpRefresh)
|
|
50
66
|
|
|
51
67
|
|
|
52
68
|
ConnectorTyping = (
|
|
@@ -30,8 +30,6 @@ STATE_MAPPING: dict[CircuitBreakerState, CircuitState] = {
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
class CircuitBreakerLogger(CircuitBreakerListener):
|
|
33
|
-
"""Bridges aiobreaker state changes onto the `Logger` port."""
|
|
34
|
-
|
|
35
33
|
def __init__(self, settings: CircuitBreakerSettings, logger: Logger | None = None) -> None:
|
|
36
34
|
self._settings: CircuitBreakerSettings = settings
|
|
37
35
|
self._logger: Logger | None = logger
|
|
@@ -47,8 +45,7 @@ class CircuitBreakerLogger(CircuitBreakerListener):
|
|
|
47
45
|
return None
|
|
48
46
|
|
|
49
47
|
def state_change(self, breaker: CircuitBreaker, old: object, new: object) -> None:
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
# aiobreaker hands over state *objects*, not enum members.
|
|
52
49
|
if not self._logger:
|
|
53
50
|
return
|
|
54
51
|
|
|
@@ -6,7 +6,14 @@ from pycraftcore.repository.adapter.sql.postgresql.adapter import PostgresReposi
|
|
|
6
6
|
from pycraftcore.repository.adapter.sql.postgresql.factory import PostgresRepositoryFactory
|
|
7
7
|
from pycraftcore.repository.adapter.sql.postgresql.mapper import PostgresSettingsMapper
|
|
8
8
|
from pycraftcore.repository.adapter.sql.postgresql.schema import PostgresConnector
|
|
9
|
-
from pycraftcore.repository.adapter.sql.
|
|
9
|
+
from pycraftcore.repository.adapter.sql.sqlalchemy import (
|
|
10
|
+
PostgresEngineBuilder,
|
|
11
|
+
SqlAlchemyEngineBuilder,
|
|
12
|
+
SqlAlchemyRepository,
|
|
13
|
+
SqlAlchemyRepositoryFactory,
|
|
14
|
+
SqliteEngineBuilder,
|
|
15
|
+
)
|
|
16
|
+
from pycraftcore.repository.adapter.sql.sqlite import SqliteConnector, SqliteDatabaseFile
|
|
10
17
|
from pycraftcore.repository.adapter.sql.sqlite.factory import SqliteRepositoryFactory
|
|
11
18
|
from pycraftcore.repository.adapter.sql.sqlite.adapter import SqliteRepository
|
|
12
19
|
from pycraftcore.repository.adapter.sql.sqlite.mapper import SqliteSettingsMapper
|
|
@@ -15,6 +22,7 @@ from pycraftcore.repository.adapter.sql.sqlite.mapper import SqliteSettingsMappe
|
|
|
15
22
|
__all__ = [
|
|
16
23
|
"SqliteRepositoryFactory",
|
|
17
24
|
"SqliteConnector",
|
|
25
|
+
"SqliteDatabaseFile",
|
|
18
26
|
"SqliteRepository",
|
|
19
27
|
"SqliteSettingsMapper",
|
|
20
28
|
"MongoRepositoryFactory",
|
|
@@ -25,4 +33,9 @@ __all__ = [
|
|
|
25
33
|
"PostgresConnector",
|
|
26
34
|
"PostgresRepository",
|
|
27
35
|
"PostgresSettingsMapper",
|
|
36
|
+
"SqlAlchemyRepositoryFactory",
|
|
37
|
+
"SqlAlchemyEngineBuilder",
|
|
38
|
+
"SqlAlchemyRepository",
|
|
39
|
+
"PostgresEngineBuilder",
|
|
40
|
+
"SqliteEngineBuilder",
|
|
28
41
|
]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from pycraftcore.repository.adapter.sql.sqlalchemy.adapter import SqlAlchemyRepository
|
|
2
|
+
from pycraftcore.repository.adapter.sql.sqlalchemy.engine_builder import SqlAlchemyEngineBuilder
|
|
3
|
+
from pycraftcore.repository.adapter.sql.sqlalchemy.factory import SqlAlchemyRepositoryFactory
|
|
4
|
+
from pycraftcore.repository.adapter.sql.sqlalchemy.postgresql_engine_builder import (
|
|
5
|
+
PostgresEngineBuilder,
|
|
6
|
+
)
|
|
7
|
+
from pycraftcore.repository.adapter.sql.sqlalchemy.sqlite_engine_builder import (
|
|
8
|
+
SqliteEngineBuilder,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"PostgresEngineBuilder",
|
|
13
|
+
"SqliteEngineBuilder",
|
|
14
|
+
"SqlAlchemyEngineBuilder",
|
|
15
|
+
"SqlAlchemyRepository",
|
|
16
|
+
"SqlAlchemyRepositoryFactory",
|
|
17
|
+
]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from sqlalchemy.ext.asyncio import AsyncEngine
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class SqlAlchemyRepository:
|
|
7
|
+
def __init__(self, engine: AsyncEngine) -> None:
|
|
8
|
+
self._engine = engine
|
|
9
|
+
|
|
10
|
+
async def execute(
|
|
11
|
+
self,
|
|
12
|
+
query: str,
|
|
13
|
+
parameters: tuple[Any, ...] = (),
|
|
14
|
+
) -> list[dict[str, Any]]:
|
|
15
|
+
async with self._engine.begin() as connection:
|
|
16
|
+
result = await connection.exec_driver_sql(query, parameters)
|
|
17
|
+
|
|
18
|
+
if not result.returns_rows:
|
|
19
|
+
return []
|
|
20
|
+
|
|
21
|
+
return [dict(row) for row in result.mappings().all()]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from sqlalchemy.ext.asyncio import AsyncEngine
|
|
2
|
+
|
|
3
|
+
from pycraftcore.repository.adapter.sql.sqlalchemy.adapter import SqlAlchemyRepository
|
|
4
|
+
from pycraftcore.repository.adapter.sql.sqlalchemy.engine_builder import SqlAlchemyEngineBuilder
|
|
5
|
+
from pycraftcore.repository.port.repository import AsyncRepository
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SqlAlchemyRepositoryFactory:
|
|
9
|
+
def __init__(self, builder: SqlAlchemyEngineBuilder) -> None:
|
|
10
|
+
self._builder = builder
|
|
11
|
+
self._engine: AsyncEngine | None = None
|
|
12
|
+
self._repository: AsyncRepository | None = None
|
|
13
|
+
|
|
14
|
+
async def connection(self) -> AsyncEngine:
|
|
15
|
+
if self._engine is None:
|
|
16
|
+
self._engine = self._builder.build()
|
|
17
|
+
return self._engine
|
|
18
|
+
|
|
19
|
+
async def connect(self) -> AsyncRepository:
|
|
20
|
+
if self._repository is None:
|
|
21
|
+
self._repository = SqlAlchemyRepository(await self.connection())
|
|
22
|
+
return self._repository
|
|
23
|
+
|
|
24
|
+
async def disconnect(self) -> None:
|
|
25
|
+
if self._engine is not None:
|
|
26
|
+
await self._engine.dispose()
|
|
27
|
+
self._engine = None
|
|
28
|
+
self._repository = None
|
|
29
|
+
|
|
30
|
+
async def ping(self) -> None:
|
|
31
|
+
engine = await self.connection()
|
|
32
|
+
async with engine.connect() as connection:
|
|
33
|
+
await connection.exec_driver_sql("SELECT 1")
|
pycraftcore-5.2.0/src/pycraftcore/repository/adapter/sql/sqlalchemy/postgresql_engine_builder.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from sqlalchemy import URL
|
|
2
|
+
from sqlalchemy.ext.asyncio import AsyncEngine, create_async_engine
|
|
3
|
+
|
|
4
|
+
from pycraftcore.repository.adapter.sql.postgresql.schema import PostgresConnector
|
|
5
|
+
|
|
6
|
+
DRIVER: str = "postgresql+psycopg"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PostgresEngineBuilder:
|
|
10
|
+
def __init__(self, settings: PostgresConnector) -> None:
|
|
11
|
+
self._settings = settings
|
|
12
|
+
|
|
13
|
+
def build(self) -> AsyncEngine:
|
|
14
|
+
return create_async_engine(
|
|
15
|
+
self._url(),
|
|
16
|
+
pool_size=self._settings.max_pool_size,
|
|
17
|
+
max_overflow=0,
|
|
18
|
+
pool_pre_ping=True,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
def _url(self) -> URL:
|
|
22
|
+
return URL.create(
|
|
23
|
+
DRIVER,
|
|
24
|
+
username=self._settings.user,
|
|
25
|
+
password=self._settings.password,
|
|
26
|
+
host=self._settings.host,
|
|
27
|
+
port=self._settings.port,
|
|
28
|
+
database=self._settings.default_name,
|
|
29
|
+
)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from sqlalchemy import URL, event
|
|
4
|
+
from sqlalchemy.ext.asyncio import AsyncEngine, create_async_engine
|
|
5
|
+
|
|
6
|
+
from pycraftcore.repository.adapter.sql.sqlite.database_file import SqliteDatabaseFile
|
|
7
|
+
from pycraftcore.repository.adapter.sql.sqlite.pragmas import SQLITE_PRAGMAS
|
|
8
|
+
from pycraftcore.repository.adapter.sql.sqlite.schema import SqliteConnector
|
|
9
|
+
|
|
10
|
+
DRIVER: str = "sqlite+aiosqlite"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class SqliteEngineBuilder:
|
|
14
|
+
def __init__(self, settings: SqliteConnector) -> None:
|
|
15
|
+
self._settings = settings
|
|
16
|
+
self._file = SqliteDatabaseFile(settings.path, settings.default_name)
|
|
17
|
+
|
|
18
|
+
def build(self) -> AsyncEngine:
|
|
19
|
+
engine = create_async_engine(
|
|
20
|
+
URL.create(DRIVER, database=str(self._file.prepare())),
|
|
21
|
+
pool_size=self._settings.max_pool_size,
|
|
22
|
+
max_overflow=0,
|
|
23
|
+
)
|
|
24
|
+
event.listen(engine.sync_engine, "connect", _apply_pragmas)
|
|
25
|
+
return engine
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _apply_pragmas(dbapi_connection: Any, _record: Any) -> None:
|
|
29
|
+
cursor = dbapi_connection.cursor()
|
|
30
|
+
try:
|
|
31
|
+
for pragma in SQLITE_PRAGMAS:
|
|
32
|
+
cursor.execute(pragma)
|
|
33
|
+
finally:
|
|
34
|
+
cursor.close()
|
{pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/adapter/sql/sqlite/__init__.py
RENAMED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
from pycraftcore.repository.adapter.sql.sqlite.adapter import SqliteRepository
|
|
2
|
+
from pycraftcore.repository.adapter.sql.sqlite.database_file import SqliteDatabaseFile
|
|
2
3
|
from pycraftcore.repository.adapter.sql.sqlite.factory import SqliteRepositoryFactory
|
|
3
4
|
from pycraftcore.repository.adapter.sql.sqlite.mapper import SqliteSettingsMapper
|
|
4
5
|
from pycraftcore.repository.adapter.sql.sqlite.schema import SqliteConnector
|
|
5
6
|
|
|
6
7
|
__all__ = [
|
|
7
8
|
"SqliteRepositoryFactory",
|
|
9
|
+
"SqliteDatabaseFile",
|
|
8
10
|
"SqliteConnector",
|
|
9
11
|
"SqliteRepository",
|
|
10
12
|
"SqliteSettingsMapper",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
DATABASE_SUFFIX: str = ".db"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass(frozen=True, slots=True)
|
|
8
|
+
class SqliteDatabaseFile:
|
|
9
|
+
directory: str
|
|
10
|
+
name: str
|
|
11
|
+
|
|
12
|
+
@property
|
|
13
|
+
def path(self) -> Path:
|
|
14
|
+
return Path(self.directory) / f"{self.name}{DATABASE_SUFFIX}"
|
|
15
|
+
|
|
16
|
+
def prepare(self) -> Path:
|
|
17
|
+
self.path.parent.mkdir(parents=True, exist_ok=True)
|
|
18
|
+
return self.path
|
{pycraftcore-5.0.1 → pycraftcore-5.2.0}/src/pycraftcore/repository/adapter/sql/sqlite/factory.py
RENAMED
|
@@ -1,29 +1,24 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
1
|
from sqlite3 import Row
|
|
3
2
|
|
|
4
3
|
from aiosqlite import Connection, connect
|
|
5
4
|
|
|
6
5
|
from pycraftcore.repository.port.repository import AsyncRepository
|
|
7
6
|
from pycraftcore.repository.adapter.sql.sqlite import SqliteRepository
|
|
7
|
+
from pycraftcore.repository.adapter.sql.sqlite.database_file import SqliteDatabaseFile
|
|
8
|
+
from pycraftcore.repository.adapter.sql.sqlite.pragmas import SQLITE_PRAGMAS
|
|
8
9
|
from pycraftcore.repository.adapter.sql.sqlite.schema import SqliteConnector
|
|
9
10
|
|
|
10
|
-
_PRAGMAS: tuple[str, ...] = (
|
|
11
|
-
"PRAGMA journal_mode=WAL",
|
|
12
|
-
"PRAGMA busy_timeout=5000",
|
|
13
|
-
"PRAGMA synchronous=NORMAL",
|
|
14
|
-
)
|
|
15
|
-
|
|
16
11
|
|
|
17
12
|
class SqliteRepositoryFactory:
|
|
18
13
|
def __init__(self, settings: SqliteConnector):
|
|
19
14
|
self._settings = settings
|
|
15
|
+
self._file = SqliteDatabaseFile(settings.path, settings.default_name)
|
|
20
16
|
self._client: Connection | None = None
|
|
21
17
|
self._pool: list[Connection] | None = None
|
|
22
18
|
self._repository: AsyncRepository | None = None
|
|
23
19
|
|
|
24
20
|
async def connection(self) -> Connection:
|
|
25
21
|
if self._client is None:
|
|
26
|
-
self._create_repository_directory(self._settings.path)
|
|
27
22
|
self._client = await self._open_connection()
|
|
28
23
|
|
|
29
24
|
return self._client
|
|
@@ -33,7 +28,6 @@ class SqliteRepositoryFactory:
|
|
|
33
28
|
if self._repository is not None:
|
|
34
29
|
return self._repository
|
|
35
30
|
|
|
36
|
-
self._create_repository_directory(self._settings.path)
|
|
37
31
|
self._pool = [await self._open_connection() for _ in range(self._settings.max_pool_size)]
|
|
38
32
|
self._repository = SqliteRepository(self._pool)
|
|
39
33
|
return self._repository
|
|
@@ -50,21 +44,10 @@ class SqliteRepositoryFactory:
|
|
|
50
44
|
self._repository = None
|
|
51
45
|
|
|
52
46
|
async def _open_connection(self) -> Connection:
|
|
53
|
-
client = await connect(
|
|
54
|
-
self._set_repository_file(self._settings.path, self._settings.default_name)
|
|
55
|
-
)
|
|
47
|
+
client = await connect(str(self._file.prepare()))
|
|
56
48
|
client.row_factory = Row
|
|
57
49
|
|
|
58
|
-
for pragma in
|
|
50
|
+
for pragma in SQLITE_PRAGMAS:
|
|
59
51
|
await client.execute(pragma)
|
|
60
52
|
|
|
61
53
|
return client
|
|
62
|
-
|
|
63
|
-
@staticmethod
|
|
64
|
-
def _create_repository_directory(path: str) -> None:
|
|
65
|
-
directory: Path = Path(path)
|
|
66
|
-
directory.mkdir(parents=True, exist_ok=True)
|
|
67
|
-
|
|
68
|
-
@staticmethod
|
|
69
|
-
def _set_repository_file(path: str, repository_name: str = "sqlite") -> str:
|
|
70
|
-
return str(Path(path) / f"{repository_name}.db")
|