diff --git a/batch/batch/cloud/azure/driver/resource_manager.py b/batch/batch/cloud/azure/driver/resource_manager.py index 67109dcfb4e..6d9200391c6 100644 --- a/batch/batch/cloud/azure/driver/resource_manager.py +++ b/batch/batch/cloud/azure/driver/resource_manager.py @@ -131,9 +131,6 @@ def instance_config( location, ) - def instance_config_from_dict(self, data: dict) -> AzureSlimInstanceConfig: - return AzureSlimInstanceConfig.from_dict(data) - async def create_vm( self, file_store: FileStore, diff --git a/batch/batch/cloud/gcp/driver/resource_manager.py b/batch/batch/cloud/gcp/driver/resource_manager.py index b144be3fd78..8407620d73f 100644 --- a/batch/batch/cloud/gcp/driver/resource_manager.py +++ b/batch/batch/cloud/gcp/driver/resource_manager.py @@ -105,9 +105,6 @@ def instance_config( location, ) - def instance_config_from_dict(self, data: dict) -> GCPSlimInstanceConfig: - return GCPSlimInstanceConfig.from_dict(data) - async def create_vm( self, file_store: FileStore, diff --git a/batch/batch/cloud/gcp/instance_config.py b/batch/batch/cloud/gcp/instance_config.py index f4a3340cc64..3eb8b314a5f 100644 --- a/batch/batch/cloud/gcp/instance_config.py +++ b/batch/batch/cloud/gcp/instance_config.py @@ -2,7 +2,7 @@ from ...driver.billing_manager import ProductVersions from ...instance_config import InstanceConfig -from .resource_utils import family_worker_type_cores_to_gcp_machine_type, gcp_machine_type_to_parts +from .resource_utils import gcp_machine_type_to_parts from .resources import ( GCPComputeResource, GCPDynamicSizedDiskResource, @@ -103,57 +103,17 @@ def region_for(self, location: str) -> str: @staticmethod def from_dict(data: dict) -> 'GCPSlimInstanceConfig': - if data['version'] < 4: - disks = data['disks'] - assert len(disks) == 2, data - assert disks[0]['boot'] - boot_disk_size_gb = disks[0]['size'] - assert not disks[1]['boot'] - local_ssd_data_disk = disks[1]['type'] == 'local-ssd' - data_disk_size_gb = disks[1]['size'] - job_private = data['job-private'] - preemptible = data['instance']['preemptible'] - machine_type = family_worker_type_cores_to_gcp_machine_type( - data['instance']['family'], - data['instance']['type'], - data['instance']['cores'], - ) - instance_family = data['instance']['family'] - else: - machine_type = data['machine_type'] - preemptible = data['preemptible'] - local_ssd_data_disk = data['local_ssd_data_disk'] - data_disk_size_gb = data['data_disk_size_gb'] - boot_disk_size_gb = data['boot_disk_size_gb'] - job_private = data['job_private'] - - machine_type_parts = gcp_machine_type_to_parts(machine_type) - assert machine_type_parts is not None, machine_type - instance_family = machine_type_parts.machine_family - - resources = data.get('resources') - if resources is None: - assert data['version'] < 5, data - - preemptible_str = 'preemptible' if preemptible else 'nonpreemptible' - - if local_ssd_data_disk: - data_disk_resource = GCPStaticSizedDiskResource('disk/local-ssd/1', data_disk_size_gb) - else: - data_disk_resource = GCPStaticSizedDiskResource('disk/pd-ssd/1', data_disk_size_gb) - - # hard coded product versions "/1" are for backwards compatibility - resources = [ - GCPComputeResource(f'compute/{instance_family}-{preemptible_str}/1'), - GCPMemoryResource(f'memory/{instance_family}-{preemptible_str}/1'), - GCPStaticSizedDiskResource('disk/pd-ssd/1', boot_disk_size_gb), - data_disk_resource, - GCPDynamicSizedDiskResource('disk/pd-ssd/1'), - GCPServiceFeeResource('service-fee/1'), - GCPIPFeeResource('ip-fee/1024/1'), - ] - else: - resources = [gcp_resource_from_dict(data) for data in resources] + assert data['version'] == GCP_INSTANCE_CONFIG_VERSION + + machine_type = data['machine_type'] + preemptible = data['preemptible'] + local_ssd_data_disk = data['local_ssd_data_disk'] + data_disk_size_gb = data['data_disk_size_gb'] + boot_disk_size_gb = data['boot_disk_size_gb'] + job_private = data['job_private'] + + assert 'resources' in data and data['resources'] is not None + resources = [gcp_resource_from_dict(data) for data in data['resources']] return GCPSlimInstanceConfig( machine_type, diff --git a/batch/batch/driver/resource_manager.py b/batch/batch/driver/resource_manager.py index 9e4957029b3..38c6c2bbe95 100644 --- a/batch/batch/driver/resource_manager.py +++ b/batch/batch/driver/resource_manager.py @@ -84,10 +84,6 @@ def instance_config( ) -> InstanceConfig: raise NotImplementedError - @abc.abstractmethod - def instance_config_from_dict(self, data: dict) -> InstanceConfig: - raise NotImplementedError - @abc.abstractmethod async def create_vm( self,