remove unused from_value methods

As final implementation, no need to create capability from value. The
capability should be defined, if it's needed. If a capability is not
defined, a node uses default capability.
This commit is contained in:
Chi Song 2020-09-22 13:35:25 +08:00
Родитель 929fbc0326
Коммит ce3d0682bd
2 изменённых файлов: 0 добавлений и 36 удалений

Просмотреть файл

@ -72,18 +72,6 @@ class EnvironmentSpace(search_space.RequirementMixin):
return result
@classmethod
def from_value(cls, value: Any) -> Any:
assert isinstance(value, EnvironmentSpace), f"actual: {type(value)}"
env = EnvironmentSpace()
env.nodes = value.nodes
if value.nodes:
env.nodes = list()
for value_capability in value.nodes:
env.nodes.append(schema.NodeSpace.from_value(value_capability))
return env
def _generate_min_capability(self, capability: Any) -> Any:
env = EnvironmentSpace(topology=self.topology)
assert isinstance(capability, EnvironmentSpace), f"actual: {type(capability)}"

Просмотреть файл

@ -471,30 +471,6 @@ class NodeSpace(search_space.RequirementMixin, ExtendableSchemaMixin):
return result
@classmethod
def from_value(cls, value: Any) -> Any:
assert isinstance(value, NodeSpace), f"actual: {type(value)}"
node = NodeSpace()
node.node_count = value.node_count
node.core_count = value.core_count
node.memory_mb = value.memory_mb
node.disk_count = value.disk_count
node.nic_count = value.nic_count
node.gpu_count = value.gpu_count
if value.features:
for feature in value.features:
if feature.enabled or feature.can_disable:
if not node.features:
node.features = search_space.SetSpace[Feature]()
node.features.add(feature)
else:
if not node.excluded_features:
node.excluded_features = search_space.SetSpace[Feature]()
node.excluded_features.add(feature)
return node
def expand_by_node_count(self) -> List[Any]:
# expand node count in requirement to one,
# so that's easy to compare equalation later.