Skip to content

Commit

Permalink
Merge pull request #1662 from Avaiga/feature/cache-build-manager
Browse files Browse the repository at this point in the history
feat: add lru_cache decorator to manager build functions
  • Loading branch information
joaoandre-avaiga authored Aug 14, 2024
2 parents e2bd93a + a58c179 commit daa43df
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 6 deletions.
3 changes: 3 additions & 0 deletions taipy/core/_version/_version_manager_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

from functools import lru_cache
from typing import Type

from .._manager._manager_factory import _ManagerFactory
Expand All @@ -21,6 +22,7 @@ class _VersionManagerFactory(_ManagerFactory):
__REPOSITORY_MAP = {"default": _VersionFSRepository}

@classmethod
@lru_cache
def _build_manager(cls) -> Type[_VersionManager]:
if cls._using_enterprise():
version_manager = _utils._load_fct(
Expand All @@ -36,5 +38,6 @@ def _build_manager(cls) -> Type[_VersionManager]:
return version_manager # type: ignore

@classmethod
@lru_cache
def _build_repository(cls):
return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()
3 changes: 3 additions & 0 deletions taipy/core/cycle/_cycle_manager_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

from functools import lru_cache
from typing import Type

from .._manager._manager_factory import _ManagerFactory
Expand All @@ -21,6 +22,7 @@ class _CycleManagerFactory(_ManagerFactory):
__REPOSITORY_MAP = {"default": _CycleFSRepository}

@classmethod
@lru_cache
def _build_manager(cls) -> Type[_CycleManager]:
if cls._using_enterprise():
cycle_manager = _load_fct(cls._TAIPY_ENTERPRISE_CORE_MODULE + ".cycle._cycle_manager", "_CycleManager") # type: ignore
Expand All @@ -34,5 +36,6 @@ def _build_manager(cls) -> Type[_CycleManager]:
return cycle_manager # type: ignore

@classmethod
@lru_cache
def _build_repository(cls):
return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()
4 changes: 3 additions & 1 deletion taipy/core/data/_data_manager_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

from functools import lru_cache
from typing import Type

from .._manager._manager_factory import _ManagerFactory
Expand All @@ -21,6 +21,7 @@ class _DataManagerFactory(_ManagerFactory):
__REPOSITORY_MAP = {"default": _DataFSRepository}

@classmethod
@lru_cache
def _build_manager(cls) -> Type[_DataManager]:
if cls._using_enterprise():
data_manager = _load_fct(cls._TAIPY_ENTERPRISE_CORE_MODULE + ".data._data_manager", "_DataManager") # type: ignore
Expand All @@ -34,5 +35,6 @@ def _build_manager(cls) -> Type[_DataManager]:
return data_manager # type: ignore

@classmethod
@lru_cache
def _build_repository(cls):
return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()
4 changes: 3 additions & 1 deletion taipy/core/job/_job_manager_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

from functools import lru_cache
from typing import Type

from .._manager._manager_factory import _ManagerFactory
Expand All @@ -21,6 +21,7 @@ class _JobManagerFactory(_ManagerFactory):
__REPOSITORY_MAP = {"default": _JobFSRepository}

@classmethod
@lru_cache
def _build_manager(cls) -> Type[_JobManager]:
if cls._using_enterprise():
job_manager = _load_fct(cls._TAIPY_ENTERPRISE_CORE_MODULE + ".job._job_manager", "_JobManager") # type: ignore
Expand All @@ -34,5 +35,6 @@ def _build_manager(cls) -> Type[_JobManager]:
return job_manager # type: ignore

@classmethod
@lru_cache
def _build_repository(cls):
return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()
4 changes: 3 additions & 1 deletion taipy/core/scenario/_scenario_manager_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

from functools import lru_cache
from typing import Type

from .._manager._manager_factory import _ManagerFactory
Expand All @@ -21,6 +21,7 @@ class _ScenarioManagerFactory(_ManagerFactory):
__REPOSITORY_MAP = {"default": _ScenarioFSRepository}

@classmethod
@lru_cache
def _build_manager(cls) -> Type[_ScenarioManager]:
if cls._using_enterprise():
scenario_manager = _load_fct(
Expand All @@ -36,5 +37,6 @@ def _build_manager(cls) -> Type[_ScenarioManager]:
return scenario_manager # type: ignore

@classmethod
@lru_cache
def _build_repository(cls):
return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()
3 changes: 2 additions & 1 deletion taipy/core/sequence/_sequence_manager_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

from functools import lru_cache
from typing import Type

from .._manager._manager_factory import _ManagerFactory
Expand All @@ -18,6 +18,7 @@

class _SequenceManagerFactory(_ManagerFactory):
@classmethod
@lru_cache
def _build_manager(cls) -> Type[_SequenceManager]: # type: ignore
if cls._using_enterprise():
sequence_manager = _load_fct(
Expand Down
4 changes: 3 additions & 1 deletion taipy/core/submission/_submission_manager_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

from functools import lru_cache
from typing import Type

from .._manager._manager_factory import _ManagerFactory
Expand All @@ -21,6 +21,7 @@ class _SubmissionManagerFactory(_ManagerFactory):
__REPOSITORY_MAP = {"default": _SubmissionFSRepository}

@classmethod
@lru_cache
def _build_manager(cls) -> Type[_SubmissionManager]:
if cls._using_enterprise():
submission_manager = _load_fct(
Expand All @@ -37,5 +38,6 @@ def _build_manager(cls) -> Type[_SubmissionManager]:
return submission_manager # type: ignore

@classmethod
@lru_cache
def _build_repository(cls):
return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()
4 changes: 3 additions & 1 deletion taipy/core/task/_task_manager_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

from functools import lru_cache
from typing import Type

from .._manager._manager_factory import _ManagerFactory
Expand All @@ -21,6 +21,7 @@ class _TaskManagerFactory(_ManagerFactory):
__REPOSITORY_MAP = {"default": _TaskFSRepository}

@classmethod
@lru_cache
def _build_manager(cls) -> Type[_TaskManager]:
if cls._using_enterprise():
task_manager = _load_fct(cls._TAIPY_ENTERPRISE_CORE_MODULE + ".task._task_manager", "_TaskManager") # type: ignore
Expand All @@ -34,5 +35,6 @@ def _build_manager(cls) -> Type[_TaskManager]:
return task_manager # type: ignore

@classmethod
@lru_cache
def _build_repository(cls):
return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()

0 comments on commit daa43df

Please sign in to comment.