Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #819 from Avaiga/fix/#818-config-version-number-if…
Browse files Browse the repository at this point in the history
…-not-specified-in-cli

Fix/#818 - Config.core.version_number should be the correct version number even if not specified in the CLI
  • Loading branch information
trgiangdo authored Nov 8, 2023
2 parents 63fcfb7 + b062fa9 commit e63aba0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
17 changes: 12 additions & 5 deletions src/taipy/core/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ def run(self, force_restart=False):
with self.__class__.__lock_is_running:
self.__class__.__is_running = True

self.__update_and_check_config()
self.__update_core_section()
self.__manage_version()
self.__check_and_block_config()

if self._orchestrator is None:
self._orchestrator = _OrchestratorFactory._build_orchestrator()
Expand All @@ -81,16 +82,22 @@ def stop(self):
self.__class__.__is_running = False

@staticmethod
def __update_and_check_config():
def __update_core_section():
_CoreCLI.create_parser()
Config._applied_config._unique_sections[CoreSection.name]._update(_CoreCLI.parse_arguments())
Config.check()
Config.block_update()
_init_backup_file_with_storage_folder()

@staticmethod
def __manage_version():
_VersionManagerFactory._build_manager()._manage_version()
Config._applied_config._unique_sections[CoreSection.name]._update(
{"version_number": _VersionManagerFactory._build_manager()._get_latest_version()}
)

@staticmethod
def __check_and_block_config():
Config.check()
Config.block_update()
_init_backup_file_with_storage_folder()

def __start_dispatcher(self, force_restart):
if dispatcher := _OrchestratorFactory._build_dispatcher(force_restart=force_restart):
Expand Down
4 changes: 3 additions & 1 deletion tests/core/config/test_core_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from unittest.mock import patch

from src.taipy.core import Core
from src.taipy.core._version._version_manager_factory import _VersionManagerFactory
from taipy.config import Config
from tests.core.utils.named_temporary_file import NamedTemporaryFile

Expand All @@ -21,7 +22,7 @@ def test_core_section():
core = Core()
core.run()
assert Config.core.mode == "development"
assert Config.core.version_number == ""
assert Config.core.version_number == _VersionManagerFactory._build_manager()._get_development_version()
assert not Config.core.force
core.stop()

Expand Down Expand Up @@ -74,5 +75,6 @@ def test_clean_config():

assert core_config.mode == "development"
assert core_config.version_number == ""

assert core_config.force is False
assert core_config.properties == {}
9 changes: 6 additions & 3 deletions tests/core/test_core_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from src.taipy.core import Core
from src.taipy.core._version._version_manager import _VersionManager
from src.taipy.core._version._version_manager_factory import _VersionManagerFactory
from src.taipy.core.common._utils import _load_fct
from src.taipy.core.cycle._cycle_manager import _CycleManager
from src.taipy.core.data._data_manager import _DataManager
Expand All @@ -35,7 +36,7 @@ def test_core_cli_no_arguments():
core = Core()
core.run()
assert Config.core.mode == "development"
assert Config.core.version_number == ""
assert Config.core.version_number == _VersionManagerFactory._build_manager()._get_development_version()
assert not Config.core.force
core.stop()

Expand All @@ -45,6 +46,7 @@ def test_core_cli_development_mode():
core = Core()
core.run()
assert Config.core.mode == "development"
assert Config.core.version_number == _VersionManagerFactory._build_manager()._get_development_version()
core.stop()


Expand All @@ -53,6 +55,7 @@ def test_core_cli_dev_mode():
core = Core()
core.run()
assert Config.core.mode == "development"
assert Config.core.version_number == _VersionManagerFactory._build_manager()._get_development_version()
core.stop()


Expand All @@ -61,7 +64,7 @@ def test_core_cli_experiment_mode():
core = Core()
core.run()
assert Config.core.mode == "experiment"
assert Config.core.version_number == ""
assert Config.core.version_number == _VersionManagerFactory._build_manager()._get_latest_version()
assert not Config.core.force
core.stop()

Expand Down Expand Up @@ -92,7 +95,7 @@ def test_core_cli_production_mode():
core = Core()
core.run()
assert Config.core.mode == "production"
assert Config.core.version_number == ""
assert Config.core.version_number == _VersionManagerFactory._build_manager()._get_latest_version()
assert not Config.core.force
core.stop()

Expand Down
9 changes: 6 additions & 3 deletions tests/core/test_core_cli_with_sql_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from src.taipy.core import Core
from src.taipy.core._version._version_manager import _VersionManager
from src.taipy.core._version._version_manager_factory import _VersionManagerFactory
from src.taipy.core.common._utils import _load_fct
from src.taipy.core.cycle._cycle_manager import _CycleManager
from src.taipy.core.data._data_manager import _DataManager
Expand All @@ -35,7 +36,7 @@ def test_core_cli_no_arguments(init_sql_repo):
core = Core()
core.run()
assert Config.core.mode == "development"
assert Config.core.version_number == ""
assert Config.core.version_number == _VersionManagerFactory._build_manager()._get_development_version()
assert not Config.core.force
core.stop()

Expand All @@ -45,6 +46,7 @@ def test_core_cli_development_mode(init_sql_repo):
core = Core()
core.run()
assert Config.core.mode == "development"
assert Config.core.version_number == _VersionManagerFactory._build_manager()._get_development_version()
core.stop()


Expand All @@ -53,6 +55,7 @@ def test_core_cli_dev_mode(init_sql_repo):
core = Core()
core.run()
assert Config.core.mode == "development"
assert Config.core.version_number == _VersionManagerFactory._build_manager()._get_development_version()
core.stop()


Expand All @@ -61,7 +64,7 @@ def test_core_cli_experiment_mode(init_sql_repo):
core = Core()
core.run()
assert Config.core.mode == "experiment"
assert Config.core.version_number == ""
assert Config.core.version_number == _VersionManagerFactory._build_manager()._get_latest_version()
assert not Config.core.force
core.stop()

Expand Down Expand Up @@ -91,7 +94,7 @@ def test_core_cli_production_mode(init_sql_repo):
core = Core()
core.run()
assert Config.core.mode == "production"
assert Config.core.version_number == ""
assert Config.core.version_number == _VersionManagerFactory._build_manager()._get_latest_version()
assert not Config.core.force
core.stop()

Expand Down

0 comments on commit e63aba0

Please sign in to comment.