Skip to content

Commit

Permalink
[DOP-16662] Prepare repo structure for adding consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
dolfinus committed Jul 1, 2024
1 parent 2be0269 commit aaa8d88
Show file tree
Hide file tree
Showing 135 changed files with 519 additions and 526 deletions.
2 changes: 1 addition & 1 deletion .env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ POSTGRES_PASSWORD=changeme

# See Backend -> Configuration documentation
ARRAKIS__DATABASE__URL=postgresql+asyncpg://arrakis:changeme@db:5432/arrakis
ARRAKIS__SERVER__LOGGING__PRESET=colored
ARRAKIS__LOGGING__PRESET=colored
ARRAKIS__SERVER__DEBUG=false
2 changes: 1 addition & 1 deletion .env.local
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export ARRAKIS__DATABASE__URL=postgresql+asyncpg://arrakis:changeme@127.0.0.1:5432/arrakis
export ARRAKIS__LOGGING__PRESET=colored
export ARRAKIS__SERVER__DEBUG=true
export ARRAKIS__SERVER__LOGGING__PRESET=colored
export ARRAKIS_TEST_SERVER_URL=http://localhost:8000
5 changes: 3 additions & 2 deletions .github/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
description: Add this label to skip changelog file check
color: 04990f

- name: component:backend
description: Backend-related changes
- name: component:server
description: Server-related changes
color: '5319e7'
from_name: component:backend

- name: component:client
description: Client-related changes
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ repos:
- id: chmod
args: ['644']
exclude_types: [shell]
exclude: ^(.*__main__\.py|arrakis/backend/export_openapi_schema\.py|arrakis/backend/db/scripts/create_partitions\.py)$
exclude: ^(.*__main__\.py|arrakis/server/scripts/export_openapi_schema\.py|arrakis/db/scripts/create_partitions\.py)$
- id: chmod
args: ['755']
types: [shell]
- id: chmod
args: ['755']
files: ^(.*__main__\.py|arrakis/backend/export_openapi_schema\.py|arrakis/backend/db/scripts/create_partitions\.py)$
files: ^(.*__main__\.py|arrakis/server/scripts/export_openapi_schema\.py|arrakis/db/scripts/create_partitions\.py)$
- id: insert-license
files: .*\.py$
exclude: ^(arrakis/backend/dependencies/stub.py|docs/.*\.py|tests/.*\.py)$
exclude: ^(arrakis/server/dependencies/stub.py|docs/.*\.py|tests/.*\.py)$
args:
- --license-filepath
- .spdx-license-header.txt
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ build:
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH python -m poetry install --no-root --all-extras --with docs --without dev,test
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH python -m poetry show -v
- python -m pip list -v
- ARRAKIS__DATABASE__URL=postgresql+asyncpg://fake:fake@127.0.0.1:5432/fake python -m arrakis.backend.export_openapi_schema docs/_static/openapi.json
- ARRAKIS__DATABASE__URL=postgresql+asyncpg://fake:fake@127.0.0.1:5432/fake python -m arrakis.server.export_openapi_schema docs/_static/openapi.json

sphinx:
configuration: docs/conf.py
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ db-start: ##@DB Start database
docker compose -f docker-compose.test.yml up -d --wait db $(DOCKER_COMPOSE_ARGS)

db-revision: ##@DB Generate migration file
${POETRY} run python -m arrakis.backend.db.migrations revision --autogenerate $(ARGS)
${POETRY} run python -m arrakis.db.migrations revision --autogenerate $(ARGS)

db-upgrade: ##@DB Run migrations to head
${POETRY} run python -m arrakis.backend.db.migrations upgrade head $(ARGS)
${POETRY} run python -m arrakis.db.migrations upgrade head $(ARGS)

db-downgrade: ##@DB Downgrade head migration
${POETRY} run python -m arrakis.backend.db.migrations downgrade head-1 $(ARGS)
${POETRY} run python -m arrakis.db.migrations downgrade head-1 $(ARGS)

db-partitions: ##@DB Create partitions
${POETRY} run python -m arrakis.backend.db.scripts.create_partitions $(ARGS)
${POETRY} run python -m arrakis.db.scripts.create_partitions $(ARGS)


test: db-start ##@Test Run tests
Expand All @@ -70,10 +70,10 @@ cleanup: ##@Test Cleanup tests dependencies


dev: db-start ##@Application Run development server (without docker)
${POETRY} run python -m arrakis.backend $(ARGS)
${POETRY} run python -m arrakis.server $(ARGS)

prod-build: ##@Application Build docker image
docker build --progress=plain --network=host -t mtsrus/arrakis-backend:develop -f ./docker/Dockerfile.backend $(ARGS) .
docker build --progress=plain --network=host -t mtsrus/arrakis-server:develop -f ./docker/Dockerfile.server $(ARGS) .

prod: ##@Application Run production server (with docker)
docker compose up -d
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Arrakis
:target: https://github.com/MobileTeleSystems/arrakis/blob/develop/LICENSE.txt
.. |PyPI Python Version| image:: https://img.shields.io/pypi/pyversions/data-arrakis.svg
:target: https://badge.fury.io/py/data-arrakis
.. |Docker image| image:: https://img.shields.io/docker/v/mtsrus/arrakis-backend?sort=semver&label=docker
:target: https://hub.docker.com/r/mtsrus/arrakis-backend
.. |Docker image| image:: https://img.shields.io/docker/v/mtsrus/arrakis-server?sort=semver&label=docker
:target: https://hub.docker.com/r/mtsrus/arrakis-server
.. |Documentation| image:: https://readthedocs.org/projects/data-arrakis/badge/?version=stable
:target: https://data-arrakis.readthedocs.io/
.. |Build Status| image:: https://github.com/MobileTeleSystems/arrakis/workflows/Tests/badge.svg
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Security

Supported Python versions
-------------------------
* Backend: 3.10 or above
* Server: 3.10 or above

Product development security recommendations
--------------------------------------------
Expand Down
61 changes: 0 additions & 61 deletions arrakis/backend/__init__.py

This file was deleted.

24 changes: 0 additions & 24 deletions arrakis/backend/db/factory.py

This file was deleted.

33 changes: 0 additions & 33 deletions arrakis/backend/db/models/__init__.py

This file was deleted.

34 changes: 0 additions & 34 deletions arrakis/backend/middlewares/__init__.py

This file was deleted.

73 changes: 0 additions & 73 deletions arrakis/backend/settings/server/__init__.py

This file was deleted.

File renamed without changes.
19 changes: 19 additions & 0 deletions arrakis/db/factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: 2024 MTS PJSC
# SPDX-License-Identifier: Apache-2.0

from sqlalchemy.ext.asyncio import (
AsyncSession,
async_engine_from_config,
async_sessionmaker,
)

from arrakis.db.settings import DatabaseSettings


def create_session_factory(settings: DatabaseSettings) -> async_sessionmaker[AsyncSession]:
engine = async_engine_from_config(settings.model_dump(), prefix="")
return async_sessionmaker(
bind=engine,
class_=AsyncSession,
expire_on_commit=False,
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from sqlalchemy.engine import Connection
from sqlalchemy.ext.asyncio import async_engine_from_config

from arrakis.backend.db.models import Base
from arrakis.backend.settings import Settings
from arrakis.db.models import Base
from arrakis.db.settings import DatabaseSettings

config = context.config

Expand All @@ -19,7 +19,7 @@

if not config.get_main_option("sqlalchemy.url"):
# read application settings only if sqlalchemy.url is not being passed via cli arguments
config.set_main_option("sqlalchemy.url", Settings().database.url)
config.set_main_option("sqlalchemy.url", DatabaseSettings().url)

target_metadata = (Base.metadata,)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit aaa8d88

Please sign in to comment.