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

✨ feat: add providers for ConfigTrees using pydantic-settings #8

Open
wants to merge 5 commits into
base: devel
Choose a base branch
from

Conversation

guptadev21
Copy link
Member

No description provided.

@guptadev21 guptadev21 requested review from a team as code owners January 28, 2025 08:30
@guptadev21 guptadev21 requested review from ankitrgadiya and smrutisenapati and removed request for a team January 28, 2025 08:30
@guptadev21 guptadev21 force-pushed the feat/configtree-pydantic branch from e935313 to 62430a5 Compare February 3, 2025 09:00
@guptadev21 guptadev21 force-pushed the feat/configtree-pydantic branch from 62430a5 to 5b5abd6 Compare February 4, 2025 05:55
Comment on lines 25 to 27
self.client = Client(config=config)
self.tree_name = tree_name
self.local_file = local_file
Copy link
Member

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.

Suggested change
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

Copy link
Member

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.

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

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.

Copy link
Member Author

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.

Copy link
Member

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

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.

Suggested change
api_with_project: bool = True,
with_project: bool = True,

Comment on lines +31 to +36
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")
Copy link
Member

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.

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

Choose a reason for hiding this comment

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

This was not addressed.

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.

2 participants