-
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
✨ feat: add providers for ConfigTrees using pydantic-settings #8
base: devel
Are you sure you want to change the base?
Conversation
e935313
to
62430a5
Compare
62430a5
to
5b5abd6
Compare
pydantic_source/source.py
Outdated
self.client = Client(config=config) | ||
self.tree_name = tree_name | ||
self.local_file = local_file |
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.
suggestion: Consider making all the fields and methods private.
self.client = Client(config=config) | |
self.tree_name = tree_name | |
self.local_file = local_file | |
self._client = Client(config=config) | |
self._tree_name = tree_name | |
self._local_file = local_file |
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.
Some fields and methods are still public.
pydantic_source/source.py
Outdated
def _extract_data_local(self, input_data: Dict[str, Any] = None) -> Dict[str, Any]: | ||
for key, value in input_data.items(): | ||
if isinstance(value, dict): | ||
if "value" in 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.
todo: This is incorrect check. This will take the following dictionary:
{
"key": {
"value": 45
}
}
and convert it into this
{
"key": 45
}
It does not check for the presence of metadata. We need to keep the logic exactly like CLI otherwise the behaviour will be incorrect.
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.
So I will take that method and remove metadata part and return only content.
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.
This was not addressed.
config: Configuration, | ||
tree_name: str = "default", | ||
key_prefix: str = "", | ||
api_with_project: bool = True, |
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.
nitpick: Let's keep it same as the SDK.
api_with_project: bool = True, | |
with_project: bool = True, |
self.config_tree = self.load_config_tree() | ||
|
||
processed_data = self._process_config_tree(raw_data=self.config_tree) | ||
|
||
if processed_data is None: | ||
raise ValueError("processed_data cannot be 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.
suggestion: Consider moving this in the _load_config_tree() method itself. We don't use the self.config_tree anywhere except for passing to process_config_tree.
We can call the _process_config_tree inside the load_config_tree and return the processed dictionary directly.
pydantic_source/source.py
Outdated
def _extract_data_local(self, input_data: Dict[str, Any] = None) -> Dict[str, Any]: | ||
for key, value in input_data.items(): | ||
if isinstance(value, dict): | ||
if "value" in 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.
This was not addressed.
No description provided.