Skip to content

Commit

Permalink
Merge pull request Avaiga#101 from Avaiga/feature/#736-remove-sequenc…
Browse files Browse the repository at this point in the history
…e-model-and-repositories

core/feature/#736 remove sequence config
  • Loading branch information
toan-quach authored Aug 25, 2023
2 parents eb5056e + 3b86549 commit 2f19a89
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 58 deletions.
34 changes: 1 addition & 33 deletions src/taipy/config/config.pyi
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 Expand Up @@ -250,38 +250,6 @@ class Config:
The new default scenario configuration.
"""

@staticmethod
def configure_sequence(id: str, task_configs: Union[TaskConfig, List[TaskConfig]], **properties) -> "SequenceConfig":
"""Configure a new sequence configuration.
Parameters:
id (str): The unique identifier of the new sequence configuration.
task_configs (Union[TaskConfig^, List[TaskConfig^]]): The list of the task
configurations that make this new sequence. This can be a single task
configuration object if this sequence holds a single task.
**properties (dict[str, any]): A keyworded variable length list of additional arguments.
Returns:
The new sequence configuration.
"""

@staticmethod
def set_default_sequence_configuration(task_configs: Union[TaskConfig, List[TaskConfig]], **properties) -> "SequenceConfig":
"""Set the default values for sequence configurations.
This function creates the *default sequence configuration* object,
where all sequence configuration objects will find their default
values when needed.
Parameters:
task_configs (Union[TaskConfig^, List[TaskConfig^]]): The list of the task
configurations that make the default sequence configuration. This can be
a single task configuration object if this sequence holds a single task.
**properties (dict[str, any]): A keyworded variable length list of additional arguments.
Returns:
The default sequence configuration.
"""

@staticmethod
def set_default_data_node_configuration(
storage_type: str, scope: Optional[Scope] = None, validity_period: Optional[timedelta] = None, **properties
Expand Down
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 2f19a89

Please sign in to comment.