-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix type issues #9
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from typing import Optional, Set | ||
from typing import Optional, Set, Dict, Any, List | ||
|
||
from hailtop import aiotools | ||
from hailtop.aiocloud import aiogoogle | ||
|
@@ -72,8 +72,8 @@ def __init__(self, db: Database, machine_name_prefix: str, task_manager: aiotool | |
self.namespace = namespace | ||
|
||
self.zone_success_rate = ZoneSuccessRate() | ||
self.region_info = None | ||
self.zones = [] | ||
self.region_info: Optional[Dict[str, Dict[str, Any]]] = None | ||
self.zones: List[str] = [] | ||
|
||
async def shutdown(self): | ||
try: | ||
|
@@ -91,6 +91,7 @@ def get_zone(self, cores: int, worker_local_ssd_data_disk: bool, worker_pd_ssd_d | |
global_live_total_cores_mcpu = self.inst_coll_manager.global_live_total_cores_mcpu | ||
if global_live_total_cores_mcpu // 1000 < 1_000: | ||
return self.resource_manager.default_location | ||
assert self.region_info is not None # FIXME: this reveals a race condition: if update_region_quotas does not run before we get_zone this will fail | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should really be fixed by using an async factory method to ensure reg_info is never |
||
return get_zone(self.region_info, self.zone_success_rate, cores, worker_local_ssd_data_disk, worker_pd_ssd_data_disk_size_gb) | ||
|
||
async def process_activity_logs(self): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
from typing import Optional, Any, TypeVar, Generic | ||
import abc | ||
import logging | ||
from typing import TYPE_CHECKING, Optional, Any | ||
|
||
if TYPE_CHECKING: | ||
from ..instance_config import InstanceConfig | ||
from .instance import Instance # pylint: disable=cyclic-import | ||
from .instance import Instance | ||
|
||
|
||
log = logging.getLogger('compute_manager') | ||
|
@@ -26,7 +24,10 @@ def __init__(self, state: str, full_spec: Any, last_state_change_timestamp_msecs | |
self.last_state_change_timestamp_msecs = last_state_change_timestamp_msecs | ||
|
||
|
||
class CloudResourceManager(abc.ABC): | ||
T = TypeVar('T') | ||
|
||
|
||
class CloudResourceManager(Generic[T]): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't quite right. The structure we have is a bit complicated and prepare_vm and create_vm really shouldn't be two separate functions. |
||
default_location: str | ||
|
||
@abc.abstractmethod | ||
|
@@ -44,17 +45,17 @@ def prepare_vm(self, | |
worker_type: Optional[str] = None, | ||
cores: Optional[int] = None, | ||
location: Optional[str] = None, | ||
) -> Optional['InstanceConfig']: | ||
) -> Optional[T]: | ||
pass | ||
|
||
@abc.abstractmethod | ||
async def create_vm(self, instance_config: 'InstanceConfig'): | ||
async def create_vm(self, instance_config: T): | ||
pass | ||
|
||
@abc.abstractmethod | ||
async def delete_vm(self, instance: 'Instance'): | ||
async def delete_vm(self, instance: Instance): | ||
pass | ||
|
||
@abc.abstractmethod | ||
async def get_vm_state(self, instance: 'Instance') -> VMState: | ||
async def get_vm_state(self, instance: Instance) -> VMState: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an escape hatch. I accidentally fell into rabbit hole of cleaning up the instance config situation so that it was both easier to read and easier to type, but it was a rather large change so I abandoned it.