-
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
ADCM-6125 Configs management #14
Conversation
@@ -0,0 +1,10 @@ | |||
type ParameterName = str | |||
type ParameterDisplayName = str | |||
type AnyParameterName = str |
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.
How does this type differ from ParameterName
?
ROOT_PREFIX = "/" | ||
|
||
|
||
def set_nested_config_value[T](config: dict[str, Any], level_names: LevelNames, value: T) -> T: |
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.
Do you think we should somehow highlight functions that change objects on the fly?
assert isinstance(root_dict.value, dict) | ||
root_dict.set(None) | ||
assert root_dict.value is None | ||
assert config["root_dict", ValueWrapper].value is None |
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.
🦆
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.
config["group"].__getitem__
- group
config["group"]["filed"].set/value
- simple value
config["group"]["field"].set/value/sync/desync
- simple value from CHG (Config Host Group)
@@ -0,0 +1,346 @@ | |||
from abc import abstractmethod |
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.
Do we plan to add License?
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.
Yes, as I know, but it should be done in one place with licence checkring, etc.
|
||
# Edit "root" values | ||
|
||
config["root_int", ValueWrapper].set(new_config["root_int"]) |
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.
seems strange, user must set value without wrapping to ValueWrapper.
config["root_int"].set(new_config["root_int"].value)
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.
user can do this, it's for type checking purposes
I'd make it more clear later
|
||
# inner type won't be checked (list), | ||
# but here we pretend "to be 100% sure" it's `list`, not `None` | ||
config["root_list", ValueWrapper].set([*config["root_list", ValueWrapper, list].value, new_config["root_list"][-1]]) |
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.
also seems strange
def to_payload(self: Self) -> dict: | ||
payload = deepcopy(self._current_data) |
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.
purpose of this method (I see that it copy)? what problem solve this method?
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.
protection of internals from change mostly
|
||
# Check all values are changed | ||
|
||
config_for_save = config.to_payload() |
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.
what is motivation
json_field = main_group["inner_json"] | ||
assert isinstance(json_field, ValueWrapper) | ||
assert isinstance(json_field.value, dict) | ||
new_value = deepcopy(json_field.value) |
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.
why we use deepcopy ? seems should be new_value = json_field.value
No description provided.