Repository: Avaiga/taipy
File: taipy/core/scenario/scenario.py (Python)

Code before:
        dag = self._build_dag()
        if dag.number_of_nodes() == 0:
            return True
        if not nx.is_directed_acyclic_graph(dag):
            return False
        for left_node, right_node in dag.edges:
            if (isinstance(left_node, DataNode) and isinstance(right_node, Task)) or (
                isinstance(left_node, Task) and isinstance(right_node, DataNode)
            ):
                continue
            return False
        return True

    def _add_tag(self, tag: str) -> None:
        self._tags = _Reloader()._reload("scenario", self)._tags
        self._tags.add(tag)

    def _remove_tag(self, tag: str) -> None:
        self._tags = _Reloader()._reload("scenario", self)._tags
        if self.has_tag(tag):
            self._tags.remove(tag)

    def _get_set_of_tasks(self) -> Set[Task]:
        return set(self.tasks.values())

    def _get_existing_data_nodes(self, additional:bool=False) -> Dict[str, DataNode]:
        if additional:
            return self.__get_additional_data_nodes(False)
        return self.__get_data_nodes(False)

    def __get_data_nodes(self, raise_not_existing: bool=True) -> Dict[str, DataNode]:
        data_nodes_dict = self.__get_additional_data_nodes(raise_not_existing)
        for _, task in self.__get_tasks(raise_not_existing).items():
            data_nodes_dict.update(task.data_nodes)
        return data_nodes_dict

    def __get_additional_data_nodes(self, raise_not_existing: bool=True) -> Dict[str, DataNode]:
        from ..data._data_manager_factory import _DataManagerFactory

        additional_data_nodes = {}
        non_existing_dns: List = []
        data_manager = _DataManagerFactory._build_manager()

        for dn_or_id in self._additional_data_nodes:
            dn = data_manager._get(dn_or_id, dn_or_id)

            if not isinstance(dn, DataNode):
                if raise_not_existing:
                    raise NonExistingDataNode(dn_or_id)
                non_existing_dns.append(dn_or_id)
                continue

Review comment (suggestion):
```suggestion
    def _get_existing_data_nodes(self, additional: bool = False) -> Dict[str, DataNode]:
```

Code after:
        dag = self._build_dag()
        if dag.number_of_nodes() == 0:
            return True
        if not nx.is_directed_acyclic_graph(dag):
            return False
        for left_node, right_node in dag.edges:
            if (isinstance(left_node, DataNode) and isinstance(right_node, Task)) or (
                isinstance(left_node, Task) and isinstance(right_node, DataNode)
            ):
                continue
            return False
        return True

    def _add_tag(self, tag: str) -> None:
        self._tags = _Reloader()._reload("scenario", self)._tags
        self._tags.add(tag)

    def _remove_tag(self, tag: str) -> None:
        self._tags = _Reloader()._reload("scenario", self)._tags
        if self.has_tag(tag):
            self._tags.remove(tag)

    def _get_set_of_tasks(self) -> Set[Task]:
        return set(self.tasks.values())

    def _get_existing_data_nodes(self, additional: bool = False) -> Dict[str, DataNode]:
        if additional:
            return self.__get_additional_data_nodes(raise_not_existing=False)
        return self.__get_data_nodes(False)

    def __get_data_nodes(self, raise_not_existing: bool = True) -> Dict[str, DataNode]:
        data_nodes_dict = self.__get_additional_data_nodes(raise_not_existing)
        for _, task in self.__get_tasks(raise_not_existing).items():
            data_nodes_dict.update(task.data_nodes)
        return data_nodes_dict

    def __get_additional_data_nodes(self, raise_not_existing: bool=True) -> Dict[str, DataNode]:
        from ..data._data_manager_factory import _DataManagerFactory

        additional_data_nodes = {}
        non_existing_dns: List = []
        data_manager = _DataManagerFactory._build_manager()

        for dn_or_id in self._additional_data_nodes:
            dn = data_manager._get(dn_or_id, dn_or_id)

            if not isinstance(dn, DataNode):
                if raise_not_existing:
                    raise NonExistingDataNode(dn_or_id)
                non_existing_dns.append(dn_or_id)
                continue