Skip to content

Commit

Permalink
[DOP-13290] Refact code
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-pedchenko committed Mar 18, 2024
1 parent 762b949 commit 580873b
Show file tree
Hide file tree
Showing 126 changed files with 454 additions and 620 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
run: poetry run flake8 syncmaster/

- name: Run mypy
run: poetry run mypy --config-file ./pyproject.toml ./syncmaster/backend
run: poetry run mypy --config-file ./pyproject.toml ./backend

codeql:
name: CodeQL
Expand Down
242 changes: 0 additions & 242 deletions .gitlab-ci.yml

This file was deleted.

6 changes: 4 additions & 2 deletions docker/backend.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ RUN poetry install --no-root --extras "backend"

COPY ./syncmaster/ /syncmaster/

ENV PYTHONPATH=/syncmaster
COPY ./tests/ /tests/

CMD [ "python", "app/main.py" ]
ENV PYTHONPATH=/

CMD [ "python", "backend/main.py" ]
4 changes: 2 additions & 2 deletions docker/worker.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ COPY ./syncmaster/ /syncmaster/

# https://docs.celeryq.dev/en/stable/userguide/workers.html#max-tasks-per-child-setting
# Required to start each Celery task in separated process, avoiding issues with global Spark session object
CMD ["celery", "-A" ,"backend.worker.config.celery", "worker", "--loglevel=info", "--max-tasks-per-child=1"]
CMD ["celery", "-A" ,"syncmaster.worker.config.celery", "worker", "--loglevel=info", "--max-tasks-per-child=1"]

FROM prod as test

Expand All @@ -43,4 +43,4 @@ RUN poetry install --no-root --extras "worker backend" --with test

ENV CREATE_SPARK_SESSION_FUNCTION="tests.spark.get_worker_spark_session.get_worker_spark_session"
# Queue for tests
CMD ["coverage", "run", "-m", "celery", "-A" ,"backend.worker.config.celery", "worker", "--loglevel=info", "--max-tasks-per-child=1", "-Q", "test_queue"]
CMD ["coverage", "run", "-m", "celery", "-A" ,"syncmaster.worker.config.celery", "worker", "--loglevel=info", "--max-tasks-per-child=1", "-Q", "test_queue"]
16 changes: 1 addition & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,7 @@ classifiers = [
keywords = ["Syncmaster", "REST", "API", "Worker", "Replication"]

packages = [
{ include = "syncmaster/backend" },
]

include = [
{path = "syncmaster/db/*"},
{path = "syncmaster/db/migrations/*"},
{path = "syncmaster/db/migrations/versions/*"},
{path = "syncmaster/db/repositories/*"},
{path = "syncmaster/dto/*.py"},
{path = "syncmaster/exceptions/*.py"},
{path = "syncmaster/schemas/v1/connections/*.py"},
{path = "syncmaster/schemas/v1/transfers/*.py"},
{path = "syncmaster/schemas/v1/transfers/file/*.py"},
{path = "syncmaster/schemas/v1/*.py"},
{path = "syncmaster/schemas/*.py"},
{ include = "syncmaster" },
]

exclude = [
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions syncmaster/backend/api/router.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# SPDX-FileCopyrightText: 2023-2024 MTS (Mobile Telesystems)
# SPDX-License-Identifier: Apache-2.0
from backend.api import monitoring
from backend.api.v1.router import router as v1_router
from fastapi import APIRouter

from syncmaster.backend.api import monitoring
from syncmaster.backend.api.v1.router import router as v1_router

api_router = APIRouter()
api_router.include_router(monitoring.router)
api_router.include_router(v1_router)
13 changes: 7 additions & 6 deletions syncmaster/backend/api/v1/auth/router.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# SPDX-FileCopyrightText: 2023-2024 MTS (Mobile Telesystems)
# SPDX-License-Identifier: Apache-2.0
from backend.api.deps import SettingsMarker, UnitOfWorkMarker
from backend.api.v1.auth.utils import sign_jwt
from backend.config import Settings
from backend.services import UnitOfWork
from exceptions import EntityNotFoundError
from fastapi import APIRouter, Depends
from fastapi.security import OAuth2PasswordRequestForm
from schemas.v1.auth import AuthTokenSchema

from syncmaster.backend.api.deps import SettingsMarker, UnitOfWorkMarker
from syncmaster.backend.api.v1.auth.utils import sign_jwt
from syncmaster.backend.config import Settings
from syncmaster.backend.services import UnitOfWork
from syncmaster.exceptions import EntityNotFoundError
from syncmaster.schemas.v1.auth import AuthTokenSchema

router = APIRouter(prefix="/auth", tags=["Auth"])

Expand Down
5 changes: 3 additions & 2 deletions syncmaster/backend/api/v1/auth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# SPDX-License-Identifier: Apache-2.0
import time

from backend.config import Settings
from jose import JWTError, jwt
from pydantic import ValidationError
from schemas.v1.auth import TokenPayloadSchema

from syncmaster.backend.config import Settings
from syncmaster.schemas.v1.auth import TokenPayloadSchema


def sign_jwt(user_id: int, settings: Settings) -> str:
Expand Down
22 changes: 15 additions & 7 deletions syncmaster/backend/api/v1/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,29 @@
import asyncio
from typing import get_args

from backend.api.deps import UnitOfWorkMarker
from backend.services import UnitOfWork, get_user
from db import Permission, User
from exceptions import ActionNotAllowedError, AuthDataNotFoundError, GroupNotFoundError
from exceptions.connection import ConnectionDeleteError, ConnectionNotFoundError
from fastapi import APIRouter, Depends, Query, status
from pydantic import SecretStr
from schemas.v1.connections.connection import (

from syncmaster.backend.api.deps import UnitOfWorkMarker
from syncmaster.backend.services import UnitOfWork, get_user
from syncmaster.db import Permission, User
from syncmaster.exceptions import (
ActionNotAllowedError,
AuthDataNotFoundError,
GroupNotFoundError,
)
from syncmaster.exceptions.connection import (
ConnectionDeleteError,
ConnectionNotFoundError,
)
from syncmaster.schemas.v1.connections.connection import (
ConnectionCopySchema,
ConnectionPageSchema,
CreateConnectionSchema,
ReadConnectionSchema,
UpdateConnectionSchema,
)
from schemas.v1.schemas import (
from syncmaster.schemas.v1.schemas import (
ORACLE_TYPE,
POSTGRES_TYPE,
MetaPageSchema,
Expand Down
Loading

0 comments on commit 580873b

Please sign in to comment.