зеркало из https://github.com/microsoft/lisa.git
Replace unhashable defaults in dataclasses
This commit is contained in:
Родитель
fe0c8c6b07
Коммит
7c8c43725a
|
@ -79,7 +79,7 @@ def _get_environment_id() -> int:
|
|||
class EnvironmentMessage(MessageBase):
|
||||
type: str = "Environment"
|
||||
name: str = ""
|
||||
runbook: schema.Environment = schema.Environment()
|
||||
runbook: schema.Environment = field(default_factory=schema.Environment)
|
||||
status: EnvironmentStatus = EnvironmentStatus.New
|
||||
log_folder: Path = Path()
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
import re
|
||||
from dataclasses import dataclass, field
|
||||
from functools import partial
|
||||
from typing import Any, List, Type
|
||||
|
||||
from dataclasses_json import dataclass_json
|
||||
|
@ -93,7 +94,7 @@ class Nvme(Feature):
|
|||
class NvmeSettings(FeatureSettings):
|
||||
type: str = "Nvme"
|
||||
disk_count: search_space.CountSpace = field(
|
||||
default=search_space.IntRange(min=0),
|
||||
default_factory=partial(search_space.IntRange, min=0),
|
||||
metadata=field_metadata(decoder=search_space.decode_count_space),
|
||||
)
|
||||
|
||||
|
|
|
@ -764,21 +764,21 @@ class NodeSpace(search_space.RequirementMixin, TypedSchema, ExtendableSchemaMixi
|
|||
name: str = ""
|
||||
is_default: bool = field(default=False)
|
||||
node_count: search_space.CountSpace = field(
|
||||
default=search_space.IntRange(min=1),
|
||||
default_factory=partial(search_space.IntRange, min=1),
|
||||
metadata=field_metadata(decoder=search_space.decode_count_space),
|
||||
)
|
||||
core_count: search_space.CountSpace = field(
|
||||
default=search_space.IntRange(min=1),
|
||||
default_factory=partial(search_space.IntRange, min=1),
|
||||
metadata=field_metadata(decoder=search_space.decode_count_space),
|
||||
)
|
||||
memory_mb: search_space.CountSpace = field(
|
||||
default=search_space.IntRange(min=512),
|
||||
default_factory=partial(search_space.IntRange, min=512),
|
||||
metadata=field_metadata(decoder=search_space.decode_count_space),
|
||||
)
|
||||
disk: Optional[DiskOptionSettings] = None
|
||||
network_interface: Optional[NetworkInterfaceOptionSettings] = None
|
||||
gpu_count: search_space.CountSpace = field(
|
||||
default=search_space.IntRange(min=0),
|
||||
default_factory=partial(search_space.IntRange, min=0),
|
||||
metadata=field_metadata(decoder=search_space.decode_count_space),
|
||||
)
|
||||
# all features on requirement should be included.
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
|
||||
import logging
|
||||
import unittest
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import dataclass, field
|
||||
from functools import partial
|
||||
from typing import Any, List, Optional, TypeVar
|
||||
|
||||
from lisa.search_space import (
|
||||
|
@ -30,7 +31,7 @@ class MockSchema:
|
|||
|
||||
@dataclass
|
||||
class MockItem(RequirementMixin):
|
||||
number: CountSpace = IntRange(min=1, max=5)
|
||||
number: CountSpace = field(default_factory=partial(IntRange, min=1, max=5))
|
||||
|
||||
def check(self, capability: Any) -> ResultReason:
|
||||
assert isinstance(capability, MockItem), f"actual: {type(capability)}"
|
||||
|
|
Загрузка…
Ссылка в новой задаче