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

Attempt to improve config.pyi #1828

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions taipy/config/config.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -153,25 +153,20 @@ class Config:
def _from_json(cls, config_as_str: str) -> _Config:
""""""

@_Classproperty
def job_config(cls) -> JobConfig:
""""""
job_config: JobConfig
"""The configured job_config section(s)."""

@_Classproperty
def data_nodes(cls) -> Dict[str, DataNodeConfig]:
""""""
data_nodes: Dict[str, DataNodeConfig]
"""The configured data_nodes section(s)."""

@_Classproperty
def tasks(cls) -> Dict[str, TaskConfig]:
""""""
tasks: Dict[str, TaskConfig]
"""The configured tasks section(s)."""

@_Classproperty
def scenarios(cls) -> Dict[str, ScenarioConfig]:
""""""
scenarios: Dict[str, ScenarioConfig]
"""The configured scenarios section(s)."""

@_Classproperty
def core(cls) -> Dict[str, CoreSection]:
""""""
core: Dict[str, CoreSection]
"""The configured core section(s)."""

@staticmethod
def configure_scenario(
Expand Down
12 changes: 5 additions & 7 deletions taipy/config/stubs/generate_pyi.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,10 @@ def _generate_entity_and_property_maps(filename):
return entities_map, property_map


def _generate_acessors(base_pyi, property_map) -> str:
for property, cls in property_map.items():
return_template = f"Dict[str, {cls}]" if property != "job_config" else f"{cls}"
template = ("\t@_Classproperty\n" + f'\tdef {property}(cls) -> {return_template}:\n\t\t""""""\n').replace(
"\t", " "
)
def _generate_accessors(base_pyi, ppty_map) -> str:
for ppty, cls in ppty_map.items():
return_template = f"Dict[str, {cls}]" if ppty != "job_config" else f"{cls}"
template = f'\t{ppty}: {return_template}\n\t"""The configured {ppty} section(s)."""\n'.replace("\t", " ")
base_pyi += template + "\n"
return base_pyi

Expand All @@ -154,7 +152,7 @@ def _build_header(filename) -> str:
entities_map, property_map = _generate_entity_and_property_maps(config_init)
pyi = _build_header(header_file)
pyi = _build_base_config_pyi(base_config, pyi)
pyi = _generate_acessors(pyi, property_map)
pyi = _generate_accessors(pyi, property_map)
pyi = _build_entity_config_pyi(pyi, scenario_filename, entities_map["ScenarioConfig"])
pyi = _build_entity_config_pyi(pyi, dn_filename, entities_map["DataNodeConfig"])
pyi = _build_entity_config_pyi(pyi, task_filename, entities_map["TaskConfig"])
Expand Down