Skip to content

Commit

Permalink
♻️Use correct import (#6597)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg authored Oct 24, 2024
1 parent 6199ed6 commit cd6f545
Show file tree
Hide file tree
Showing 20 changed files with 25 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging

import pytest
from models_library.error_codes import create_error_code, parse_error_code
from common_library.error_codes import create_error_code, parse_error_code

logger = logging.getLogger(__name__)

Expand Down
32 changes: 0 additions & 32 deletions packages/models-library/src/models_library/error_codes.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from aiohttp import web
from aiohttp.web_request import Request
from aiohttp.web_response import StreamResponse
from models_library.error_codes import create_error_code
from common_library.error_codes import create_error_code
from models_library.utils.json_serialization import json_dumps

from ..logging_errors import create_troubleshotting_log_kwargs
Expand Down
4 changes: 2 additions & 2 deletions packages/service-library/src/servicelib/logging_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from pprint import pformat
from typing import Any, TypedDict

from models_library.error_codes import ErrorCodeStr
from models_library.errors_classes import OsparcErrorMixin
from common_library.error_codes import ErrorCodeStr
from common_library.errors_classes import OsparcErrorMixin

from .logging_utils import LogExtra, get_log_record_extra

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import pytest
from aiohttp import web
from aiohttp.test_utils import TestClient
from models_library.error_codes import parse_error_code
from common_library.error_codes import parse_error_code
from models_library.utils.json_serialization import json_dumps
from servicelib.aiohttp import status
from servicelib.aiohttp.rest_middlewares import (
Expand Down Expand Up @@ -99,7 +99,7 @@ async def raise_exception(cls, request: web.Request):
case NotImplementedError.__name__:
raise NotImplementedError
case asyncio.TimeoutError.__name__:
raise asyncio.TimeoutError
raise TimeoutError
case web.HTTPOk.__name__:
raise web.HTTPOk # 2XX
case web.HTTPUnauthorized.__name__:
Expand Down
4 changes: 2 additions & 2 deletions packages/service-library/tests/test_logging_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import logging

import pytest
from models_library.error_codes import create_error_code
from models_library.errors_classes import OsparcErrorMixin
from common_library.error_codes import create_error_code
from common_library.errors_classes import OsparcErrorMixin
from servicelib.logging_errors import (
create_troubleshotting_log_kwargs,
create_troubleshotting_log_message,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any

from models_library.errors_classes import OsparcErrorMixin
from common_library.errors_classes import OsparcErrorMixin


class ApiServerBaseError(OsparcErrorMixin, Exception):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging

from common_library.error_codes import create_error_code
from fastapi.requests import Request
from fastapi.responses import JSONResponse
from models_library.error_codes import create_error_code
from servicelib.logging_errors import create_troubleshotting_log_kwargs

from ._utils import ExceptionHandler, create_error_json_response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from collections.abc import AsyncIterable
from typing import Final

from models_library.error_codes import create_error_code
from common_library.error_codes import create_error_code
from models_library.rabbitmq_messages import LoggerRabbitMessage
from models_library.users import UserID
from pydantic import NonNegativeInt
Expand Down Expand Up @@ -123,7 +123,7 @@ async def log_generator(self) -> AsyncIterable[str]:
self._queue.get(), timeout=self._log_check_timeout
)
yield log.json() + _NEW_LINE
except asyncio.TimeoutError:
except TimeoutError:
done = await self._project_done()

except BaseBackEndError as exc:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any

from models_library.errors_classes import OsparcErrorMixin
from common_library.errors_classes import OsparcErrorMixin


class CatalogBaseError(OsparcErrorMixin, Exception):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
from uuid import UUID

import arrow
from common_library.error_codes import ErrorCodeStr
from models_library.api_schemas_directorv2.dynamic_services import DynamicServiceCreate
from models_library.api_schemas_directorv2.dynamic_services_service import (
CommonServiceDetails,
)
from models_library.basic_types import PortInt
from models_library.callbacks_mapping import CallbacksMapping
from models_library.error_codes import ErrorCodeStr
from models_library.generated_models.docker_rest_api import ContainerState, Status2
from models_library.projects_nodes_io import NodeID
from models_library.resource_tracker import HardwareInfo, PricingInfo
Expand Down Expand Up @@ -116,7 +116,7 @@ def __eq__(self, other: object) -> bool:
@classmethod
def create_as_initially_ok(cls) -> "Status":
# the service is initially ok when started
initial_state: "Status" = cls(current=DynamicSidecarStatus.OK, info="")
initial_state: Status = cls(current=DynamicSidecarStatus.OK, info="")
return initial_state


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from copy import deepcopy
from math import floor

from common_library.error_codes import create_error_code
from fastapi import FastAPI
from models_library.error_codes import create_error_code
from servicelib.logging_errors import create_troubleshotting_log_kwargs

from .....core.dynamic_services_settings.scheduler import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any

from models_library.errors_classes import OsparcErrorMixin
from common_library.errors_classes import OsparcErrorMixin


class WebServerBaseError(OsparcErrorMixin, Exception):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from datetime import datetime

from aiohttp import web
from common_library.error_codes import create_error_code
from models_library.basic_types import IdInt
from models_library.emails import LowerCaseEmailStr
from models_library.error_codes import create_error_code
from models_library.products import ProductName
from pydantic import (
BaseModel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from aiohttp import web
from aiohttp.web import RouteTableDef
from common_library.error_codes import create_error_code
from models_library.emails import LowerCaseEmailStr
from models_library.error_codes import create_error_code
from models_library.products import ProductName
from pydantic import (
BaseModel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from aiohttp import web
from aiohttp.web import RouteTableDef
from common_library.error_codes import create_error_code
from models_library.emails import LowerCaseEmailStr
from models_library.error_codes import create_error_code
from pydantic import BaseModel, Field, PositiveInt, SecretStr, validator
from servicelib.aiohttp import status
from servicelib.aiohttp.requests_validation import parse_request_body_as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import TypeAlias

from aiohttp import web
from models_library.error_codes import create_error_code
from common_library.error_codes import create_error_code
from models_library.projects import ProjectID
from models_library.projects_nodes_io import NodeID
from models_library.services import ServiceKey, ServiceVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from aiohttp import web
from aiohttp_session import get_session
from models_library.error_codes import create_error_code
from common_library.error_codes import create_error_code
from models_library.projects import ProjectID
from servicelib.aiohttp import status
from servicelib.aiohttp.typing_extension import Handler
Expand Down
4 changes: 2 additions & 2 deletions services/web/server/src/simcore_service_webserver/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
General utilities and helper functions
"""

import asyncio
import hashlib
import logging
Expand All @@ -13,8 +14,8 @@
from typing import Any, TypedDict, cast

import orjson
from common_library.error_codes import ErrorCodeStr
from models_library.basic_types import SHA1Str
from models_library.error_codes import ErrorCodeStr

_CURRENT_DIR = (
Path(sys.argv[0] if __name__ == "__main__" else __file__).resolve().parent
Expand Down Expand Up @@ -80,7 +81,6 @@ def now_str() -> str:


def to_datetime(snapshot: str) -> datetime:
#
return datetime.strptime(snapshot, DATETIME_FORMAT)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import logging

from aiohttp import web
from common_library.error_codes import create_error_code
from models_library.api_schemas_webserver.wallets import (
CreateWalletBodyParams,
PutWalletBodyParams,
WalletGet,
WalletGetWithAvailableCredits,
)
from models_library.error_codes import create_error_code
from models_library.users import UserID
from models_library.wallets import WalletID
from pydantic import Field
Expand Down

0 comments on commit cd6f545

Please sign in to comment.