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 data config checker for property value types #2328

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

joaoandre-avaiga
Copy link
Collaborator

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Related Tickets & Documents

How to reproduce the issue

Please replace this line with instructions on how to reproduce the issue or test the feature.

Other branches or releases that this needs to be backported

Describe which projects this change will impact and that needs to be backported.

Checklist

We encourage you to keep the code coverage percentage at 80% and above.

  • Does this solution meet the acceptance criteria of the related issue?
  • Is the related issue checklist completed?
  • Does this PR adds unit tests for the developed code? If not, why?
  • End-to-End tests have been added or updated?
  • Was the documentation updated, or a dedicated issue for documentation created? (If applicable)
  • Is the release notes updated? (If applicable)

Copy link
Member

@jrobinAV jrobinAV left a comment

Choose a reason for hiding this comment

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

Minor remark.

Otherwise it s greatly neat!

if property_types := data_node_config._PROPERTIES_TYPES.get(data_node_config.storage_type):
for prop_key, prop_type in property_types.items():
prop_value = data_node_config.properties.get(prop_key) if data_node_config.properties else None
if prop_value and not isinstance(prop_value, prop_type):
Copy link
Member

Choose a reason for hiding this comment

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

prop_type is the value in the _PROPERTIES_TYPES dictionary. Today, it must be a Python type.

Can we imagine prop_type being either a type or a list of types? Then, we should check that the type of prop_value is among the types in the prop_type list of types.

Does it make sense, or is it just over-engineering?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

isinstance can take a tuple of type as the second parameter. So we only need to define the proprety as a tuple of expected types and it should be good to go. I had to do that for a couple of properties already.

@jrobinAV jrobinAV added Core Related to Taipy Core 🟨 Priority: Medium Not blocking but should be addressed Core: ⚙️ Configuration labels Dec 13, 2024
@joaoandre-avaiga joaoandre-avaiga force-pushed the feature/#2298-add-value-config-checker branch from c82433d to 70c47f1 Compare December 22, 2024 20:11
@joaoandre-avaiga joaoandre-avaiga marked this pull request as ready for review December 22, 2024 20:11
Copy link
Contributor

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
19471 16975 87% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
taipy/core/config/checkers/_data_node_config_checker.py 98% 🟢
taipy/core/config/data_node_config.py 99% 🟢
TOTAL 98% 🟢

updated for commit: 70c47f1 by action🐍

f"`{prop_key}` of DataNodeConfig `{data_node_config_id}` must be"
f" populated with a serializable Callable function but not a lambda.",
)
def _check_property_types(self, data_node_config_id: str, data_node_config: DataNodeConfig):
Copy link
Member

Choose a reason for hiding this comment

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

can you help propagate this change on enterprise as well? I'm quite certain it will fail on enterprise :D thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core: ⚙️ Configuration Core Related to Taipy Core 🟨 Priority: Medium Not blocking but should be addressed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add checker to check value type of configuration properties
4 participants