Skip to content
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

Closed
wants to merge 5 commits into from
Closed

Conversation

Sealwing
Copy link
Collaborator

No description provided.

@@ -0,0 +1,10 @@
type ParameterName = str
type ParameterDisplayName = str
type AnyParameterName = str
Copy link
Collaborator

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:
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦆

Copy link
Collaborator

@a-alferov a-alferov Nov 21, 2024

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
Copy link
Member

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?

Copy link
Collaborator Author

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"])
Copy link
Member

@kuhella kuhella Nov 24, 2024

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)

Copy link
Collaborator Author

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]])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also seems strange

Comment on lines +233 to +234
def to_payload(self: Self) -> dict:
payload = deepcopy(self._current_data)
Copy link
Member

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?

Copy link
Collaborator Author

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()
Copy link
Member

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)
Copy link
Member

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

@Sealwing Sealwing closed this Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants