Skip to content

Commit

Permalink
remove sequence config
Browse files Browse the repository at this point in the history
  • Loading branch information
Toan Quach authored and Toan Quach committed Aug 25, 2023
1 parent eb5056e commit 931b670
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 25 deletions.
31 changes: 7 additions & 24 deletions stubs/generate_pyi.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,11 @@ def _build_base_config_pyi(filename, base_pyi):
lines = _get_file_lines(filename)
tree = _get_file_ast(filename)

class_lineno = [
f.lineno
for f in ast.walk(tree)
if isinstance(f, ast.ClassDef) and f.name == "Config"
]
class_lineno = [f.lineno for f in ast.walk(tree) if isinstance(f, ast.ClassDef) and f.name == "Config"]
begin_class, end_class = _get_function_delimiters(class_lineno[0] - 1, lines)

base_pyi += "".join(lines[begin_class:end_class])
functions = [
f.lineno
for f in ast.walk(tree)
if isinstance(f, ast.FunctionDef) and not f.name.startswith("__")
]
functions = [f.lineno for f in ast.walk(tree) if isinstance(f, ast.FunctionDef) and not f.name.startswith("__")]

for ln in functions:
begin_line, end_line = _get_function_delimiters(ln - 1, lines)
Expand Down Expand Up @@ -112,9 +104,7 @@ def _generate_entity_and_property_maps(filename):
property_map = {}
entity_tree = _get_file_ast(filename)
functions = [
f
for f in ast.walk(entity_tree)
if isinstance(f, ast.Call) and getattr(f.func, "id", "") == "_inject_section"
f for f in ast.walk(entity_tree) if isinstance(f, ast.Call) and getattr(f.func, "id", "") == "_inject_section"
]

for f in functions:
Expand All @@ -134,10 +124,9 @@ def _generate_entity_and_property_maps(filename):
def _generate_acessors(base_pyi, property_map):
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", " ")
template = ("\t@_Classproperty\n" + f'\tdef {property}(cls) -> {return_template}:\n\t\t""""""\n').replace(
"\t", " "
)
base_pyi += template + "\n"
return base_pyi

Expand All @@ -152,7 +141,6 @@ def _build_header(filename):
config_init = Path("taipy-core/src/taipy/core/config/__init__.py")
base_config = "src/taipy/config/config.py"

sequence_filename = "taipy-core/src/taipy/core/config/sequence_config.py"
dn_filename = "taipy-core/src/taipy/core/config/data_node_config.py"
job_filename = "taipy-core/src/taipy/core/config/job_config.py"
scenario_filename = "taipy-core/src/taipy/core/config/scenario_config.py"
Expand All @@ -162,12 +150,7 @@ def _build_header(filename):
pyi = _build_header(header_file)
pyi = _build_base_config_pyi(base_config, pyi)
pyi = _generate_acessors(pyi, property_map)
pyi = _build_entity_config_pyi(
pyi, scenario_filename, entities_map["ScenarioConfig"]
)
pyi = _build_entity_config_pyi(
pyi, sequence_filename, entities_map["SequenceConfig"]
)
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"])
pyi = _build_entity_config_pyi(pyi, job_filename, entities_map["JobConfig"])
Expand Down
2 changes: 1 addition & 1 deletion stubs/pyi_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import json
from typing import Any, Callable, Dict, List, Optional, Union

from taipy.core.config import DataNodeConfig, JobConfig, ScenarioConfig, SequenceConfig, TaskConfig
from taipy.core.config import DataNodeConfig, JobConfig, ScenarioConfig, TaskConfig

from .checker.issue_collector import IssueCollector
from .common._classproperty import _Classproperty
Expand Down

0 comments on commit 931b670

Please sign in to comment.