Skip to content

Commit

Permalink
fix: failed tests due to config_id property change
Browse files Browse the repository at this point in the history
  • Loading branch information
trgiangdo committed Dec 20, 2023
1 parent 1f38b2b commit 97522d8
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 13 deletions.
6 changes: 5 additions & 1 deletion taipy/core/sequence/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(
super().__init__(subscribers)
self.id: SequenceId = sequence_id
self._tasks = tasks
self.owner_id = owner_id
self._owner_id = owner_id
self._parent_ids = parent_ids or set()
self._properties = _Properties(self, **properties)
self._version = version or _VersionManagerFactory._build_manager()._get_latest_version()
Expand Down Expand Up @@ -118,6 +118,10 @@ def data_nodes(self) -> Dict[str, DataNode]:
def parent_ids(self):
return self._parent_ids

@property
def owner_id(self):
return self._owner_id

@property
def version(self):
return self._version
Expand Down
3 changes: 2 additions & 1 deletion tests/core/_orchestrator/_dispatcher/test_job_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from unittest.mock import MagicMock

from pytest import raises

from taipy.config.config import Config
from taipy.core import DataNodeId, JobId, TaskId
from taipy.core._orchestrator._dispatcher._development_job_dispatcher import _DevelopmentJobDispatcher
Expand Down Expand Up @@ -146,7 +147,7 @@ def test_exception_in_writing_data():
job_id = JobId("id1")
output = MagicMock()
output.id = DataNodeId("output_id")
output.config_id = "my_raising_datanode"
output._config_id = "my_raising_datanode"
output._is_in_cache = False
output.write.side_effect = ValueError()
task = Task(config_id="name", properties={}, input=[], function=print, output=[output], id=task_id)
Expand Down
4 changes: 2 additions & 2 deletions tests/core/data/test_data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import pathlib

import pytest

from taipy.config.common.scope import Scope
from taipy.config.config import Config
from taipy.core._version._version_manager import _VersionManager
Expand All @@ -22,7 +23,6 @@
from taipy.core.data.in_memory import InMemoryDataNode
from taipy.core.data.pickle import PickleDataNode
from taipy.core.exceptions.exceptions import InvalidDataNodeType, ModelNotFound

from tests.core.utils.named_temporary_file import NamedTemporaryFile


Expand Down Expand Up @@ -346,7 +346,7 @@ def test_set(self):
assert _DataManager._exists(dn.id)

# changing data node attribute
dn.config_id = "foo"
dn._config_id = "foo"
assert dn.config_id == "foo"
_DataManager._set(dn)
assert len(_DataManager._get_all()) == 1
Expand Down
3 changes: 2 additions & 1 deletion tests/core/data/test_data_manager_with_sql_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import pathlib

import pytest

from taipy.config.common.scope import Scope
from taipy.config.config import Config
from taipy.core._version._version_manager import _VersionManager
Expand Down Expand Up @@ -162,7 +163,7 @@ def test_set(self, init_sql_repo):
assert _DataManager._exists(dn.id)

# changing data node attribute
dn.config_id = "foo"
dn._config_id = "foo"
assert dn.config_id == "foo"
_DataManager._set(dn)
assert len(_DataManager._get_all()) == 1
Expand Down
4 changes: 2 additions & 2 deletions tests/core/data/test_data_repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_load_all_with_filters(self, data_node, repo, init_sql_repo):

for i in range(10):
data_node.id = DataNodeId(f"data_node-{i}")
data_node.owner_id = f"task-{i}"
data_node._owner_id = f"task-{i}"
repository._save(data_node)
objs = repository._load_all(filters=[{"owner_id": "task-2"}])

Expand Down Expand Up @@ -119,7 +119,7 @@ def test_search(self, data_node, repo, init_sql_repo):

for i in range(10):
data_node.id = DataNodeId(f"data_node-{i}")
data_node.owner_id = f"task-{i}"
data_node._owner_id = f"task-{i}"
repository._save(data_node)

assert len(repository._load_all()) == 10
Expand Down
2 changes: 1 addition & 1 deletion tests/core/scenario/test_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ def test_auto_set_and_reload(cycle, current_datetime, task, data_node):
assert scenario.properties["temp_key_5"] == 0

new_datetime_2 = new_datetime + timedelta(5)
scenario.config_id = "foo"
scenario._config_id = "foo"
scenario.tasks = set()
scenario.additional_data_nodes = set()
scenario.remove_sequences([sequence_1_name])
Expand Down
5 changes: 3 additions & 2 deletions tests/core/task/test_task_repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import os

import pytest

from taipy.core.data._data_sql_repository import _DataSQLRepository
from taipy.core.exceptions import ModelNotFound
from taipy.core.task._task_fs_repository import _TaskFSRepository
Expand Down Expand Up @@ -63,7 +64,7 @@ def test_load_all_with_filters(self, data_node, repo, init_sql_repo):

for i in range(10):
task.id = TaskId(f"task-{i}")
task.owner_id = f"owner-{i}"
task._owner_id = f"owner-{i}"
repository._save(task)
objs = repository._load_all(filters=[{"owner_id": "owner-2"}])

Expand Down Expand Up @@ -140,7 +141,7 @@ def test_search(self, data_node, repo, init_sql_repo):

for i in range(10):
task.id = TaskId(f"task-{i}")
task.owner_id = f"owner-{i}"
task._owner_id = f"owner-{i}"
repository._save(task)

assert len(repository._load_all()) == 10
Expand Down
7 changes: 4 additions & 3 deletions tests/core/test_complex_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from unittest.mock import patch

import pandas as pd

import taipy.core.taipy as tp
from taipy.config import Config
from taipy.core import Core, Status
Expand Down Expand Up @@ -72,9 +73,9 @@ def return_a_number_with_sleep():
def test_skipped_jobs():
Config.configure_job_executions(mode=JobConfig._DEVELOPMENT_MODE)
_OrchestratorFactory._build_orchestrator()
input_config = Config.configure_data_node("input")
input_config = Config.configure_data_node("input_dn")
intermediate_config = Config.configure_data_node("intermediate")
output_config = Config.configure_data_node("output")
output_config = Config.configure_data_node("output_dn")
task_config_1 = Config.configure_task("first", mult_by_2, input_config, intermediate_config, skippable=True)
task_config_2 = Config.configure_task("second", mult_by_2, intermediate_config, output_config, skippable=True)
scenario_config = Config.configure_scenario("scenario", [task_config_1, task_config_2])
Expand All @@ -84,7 +85,7 @@ def test_skipped_jobs():
core.run()

scenario = tp.create_scenario(scenario_config)
scenario.input.write(2)
scenario.input_dn.write(2)
scenario.submit()
assert len(tp.get_jobs()) == 2
for job in tp.get_jobs():
Expand Down

0 comments on commit 97522d8

Please sign in to comment.