Skip to content

Commit

Permalink
try to fix typing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
stepansergeevitch committed Jan 22, 2024
1 parent 8ae61fc commit 17c1b0b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
8 changes: 5 additions & 3 deletions src/firebolt/service/V1/base.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from typing import Optional
from typing import TYPE_CHECKING, Optional

from firebolt.client import ClientV1 as Client
from firebolt.service.manager import ResourceManager

if TYPE_CHECKING:
from firebolt.service.manager import ResourceManager


class BaseService:
def __init__(self, resource_manager: ResourceManager):
def __init__(self, resource_manager: "ResourceManager"):
self.resource_manager = resource_manager

@property
Expand Down
8 changes: 5 additions & 3 deletions src/firebolt/service/V1/region.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from typing import Dict, List
from typing import TYPE_CHECKING, Dict, List

from firebolt.model.V1.region import Region, RegionKey
from firebolt.service.manager import ResourceManager
from firebolt.service.V1.base import BaseService
from firebolt.utils.urls import REGIONS_URL
from firebolt.utils.util import cached_property

if TYPE_CHECKING:
from firebolt.service.manager import ResourceManager


class RegionService(BaseService):
def __init__(self, resource_manager: ResourceManager):
def __init__(self, resource_manager: "ResourceManager"):
"""
Service to manage AWS regions (us-east-1, etc)
Expand Down
24 changes: 11 additions & 13 deletions src/firebolt/service/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@
)
from firebolt.common import Settings
from firebolt.db import connect
from firebolt.service.V1.binding import BindingService
from firebolt.service.V1.database import DatabaseService as DatabaseServiceV1
from firebolt.service.V1.engine import EngineService as EngineServiceV1
from firebolt.service.V1.provider import get_provider_id
from firebolt.service.V1.region import RegionService
from firebolt.service.V2.database import DatabaseService as DatabaseServiceV2
from firebolt.service.V2.engine import EngineService as EngineServiceV2
from firebolt.service.V2.instance_type import InstanceTypeService
from firebolt.utils.util import fix_url_schema

DEFAULT_TIMEOUT_SECONDS: int = 60 * 2
Expand Down Expand Up @@ -127,34 +134,25 @@ def __init__(

def _init_services_v2(self) -> None:
# avoid circular import
from firebolt.service.V2.database import DatabaseService
from firebolt.service.V2.engine import EngineService
from firebolt.service.V2.instance_type import InstanceTypeService

# Cloud Platform Resources (AWS)
self.instance_types = InstanceTypeService(resource_manager=self)

# Firebolt Resources
self.databases = DatabaseService(resource_manager=self)
self.engines = EngineService(resource_manager=self)
self.databases = DatabaseServiceV2(resource_manager=self)
self.engines = EngineServiceV2(resource_manager=self)

# Not applicable to V2
self.provider_id = None

def _init_services_v1(self) -> None:
# avoid circular import
from firebolt.service.V1.binding import BindingService
from firebolt.service.V1.database import DatabaseService
from firebolt.service.V1.engine import EngineService
from firebolt.service.V1.region import RegionService

# Cloud Platform Resources (AWS)
self.regions = RegionService(resource_manager=self) # type: ignore

# Firebolt Resources
self.bindings = BindingService(resource_manager=self) # type: ignore
self.engines = EngineService(resource_manager=self) # type: ignore
self.databases = DatabaseService(resource_manager=self) # type: ignore
self.engines = EngineServiceV1(resource_manager=self) # type: ignore
self.databases = DatabaseServiceV1(resource_manager=self) # type: ignore

self.provider_id = get_provider_id(client=self._client)

Expand Down

0 comments on commit 17c1b0b

Please sign in to comment.