Skip to content

Commit

Permalink
Merge pull request #5 from DS4SD/chore-update-dependencies
Browse files Browse the repository at this point in the history
chore: Update dependencies
  • Loading branch information
dolfim-ibm authored May 23, 2022
2 parents bcc9e1e + c558028 commit 3d96de3
Show file tree
Hide file tree
Showing 4 changed files with 328 additions and 302 deletions.
11 changes: 6 additions & 5 deletions mognet/backend/redis_result_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@
from typing import Any, AnyStr, Dict, Iterable, List, Optional, Set
from uuid import UUID

import aioredis
from aioredis.exceptions import TimeoutError, ConnectionError
from pydantic.tools import parse_raw_as
from redis.asyncio import Redis, from_url
from redis.exceptions import ConnectionError, TimeoutError

from mognet.backend.backend_config import Encoding, ResultBackendConfig
from mognet.backend.base_result_backend import AppParameters, BaseResultBackend
from mognet.exceptions.base_exceptions import NotConnected
from mognet.exceptions.result_exceptions import ResultValueLost
from mognet.model.result import Result, ResultValueHolder
from mognet.model.result_state import READY_STATES, ResultState
from mognet.tools.urls import censor_credentials
from pydantic.tools import parse_raw_as

_log = logging.getLogger(__name__)

Expand Down Expand Up @@ -83,7 +84,7 @@ def __init__(self, config: ResultBackendConfig, app: AppParameters) -> None:
self._retry_lock = asyncio.Lock()

@property
def _redis(self) -> aioredis.Redis:
def _redis(self) -> Redis:
if self.__redis is None:
raise NotConnected

Expand Down Expand Up @@ -402,7 +403,7 @@ async def _close_waiters(self):

async def _create_redis(self):
_log.debug("Creating Redis connection")
redis: aioredis.Redis = await aioredis.from_url(
redis: Redis = await from_url(
self._url,
max_connections=self.config.redis.max_connections,
)
Expand Down
14 changes: 8 additions & 6 deletions mognet/state/redis_state_backend.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import logging
import json
from typing import Any, Optional, TYPE_CHECKING, TypeVar
import aioredis
import logging
from typing import TYPE_CHECKING, Any, Optional, TypeVar

from redis.asyncio import Redis, from_url

from mognet.exceptions.base_exceptions import NotConnected
from mognet.state.state_backend_config import StateBackendConfig
from mognet.state.base_state_backend import BaseStateBackend
from mognet.state.state_backend_config import StateBackendConfig
from mognet.tools.urls import censor_credentials

if TYPE_CHECKING:
Expand All @@ -25,7 +27,7 @@ def __init__(self, config: StateBackendConfig, app: "App") -> None:
self.app = app

@property
def _redis(self) -> aioredis.Redis:
def _redis(self) -> Redis:
if self.__redis is None:
raise NotConnected

Expand Down Expand Up @@ -110,7 +112,7 @@ async def __aexit__(self, *args, **kwargs):
await self.close()

async def connect(self):
redis: aioredis.Redis = aioredis.from_url(
redis: Redis = from_url(
self.config.redis.url,
max_connections=self.config.redis.max_connections,
)
Expand Down
Loading

0 comments on commit 3d96de3

Please sign in to comment.