1
0
Эх сурвалжийг харах

Merge pull request #1662 from Avaiga/feature/cache-build-manager

feat: add lru_cache decorator to manager build functions
João André 9 сар өмнө
parent
commit
daa43df6d0

+ 3 - 0
taipy/core/_version/_version_manager_factory.py

@@ -9,6 +9,7 @@
 # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 # 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.
 # specific language governing permissions and limitations under the License.
 
 
+from functools import lru_cache
 from typing import Type
 from typing import Type
 
 
 from .._manager._manager_factory import _ManagerFactory
 from .._manager._manager_factory import _ManagerFactory
@@ -21,6 +22,7 @@ class _VersionManagerFactory(_ManagerFactory):
     __REPOSITORY_MAP = {"default": _VersionFSRepository}
     __REPOSITORY_MAP = {"default": _VersionFSRepository}
 
 
     @classmethod
     @classmethod
+    @lru_cache
     def _build_manager(cls) -> Type[_VersionManager]:
     def _build_manager(cls) -> Type[_VersionManager]:
         if cls._using_enterprise():
         if cls._using_enterprise():
             version_manager = _utils._load_fct(
             version_manager = _utils._load_fct(
@@ -36,5 +38,6 @@ class _VersionManagerFactory(_ManagerFactory):
         return version_manager  # type: ignore
         return version_manager  # type: ignore
 
 
     @classmethod
     @classmethod
+    @lru_cache
     def _build_repository(cls):
     def _build_repository(cls):
         return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()
         return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()

+ 3 - 0
taipy/core/cycle/_cycle_manager_factory.py

@@ -9,6 +9,7 @@
 # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 # 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.
 # specific language governing permissions and limitations under the License.
 
 
+from functools import lru_cache
 from typing import Type
 from typing import Type
 
 
 from .._manager._manager_factory import _ManagerFactory
 from .._manager._manager_factory import _ManagerFactory
@@ -21,6 +22,7 @@ class _CycleManagerFactory(_ManagerFactory):
     __REPOSITORY_MAP = {"default": _CycleFSRepository}
     __REPOSITORY_MAP = {"default": _CycleFSRepository}
 
 
     @classmethod
     @classmethod
+    @lru_cache
     def _build_manager(cls) -> Type[_CycleManager]:
     def _build_manager(cls) -> Type[_CycleManager]:
         if cls._using_enterprise():
         if cls._using_enterprise():
             cycle_manager = _load_fct(cls._TAIPY_ENTERPRISE_CORE_MODULE + ".cycle._cycle_manager", "_CycleManager")  # type: ignore
             cycle_manager = _load_fct(cls._TAIPY_ENTERPRISE_CORE_MODULE + ".cycle._cycle_manager", "_CycleManager")  # type: ignore
@@ -34,5 +36,6 @@ class _CycleManagerFactory(_ManagerFactory):
         return cycle_manager  # type: ignore
         return cycle_manager  # type: ignore
 
 
     @classmethod
     @classmethod
+    @lru_cache
     def _build_repository(cls):
     def _build_repository(cls):
         return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()
         return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()

+ 3 - 1
taipy/core/data/_data_manager_factory.py

@@ -8,7 +8,7 @@
 # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 # 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
 # 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.
 # specific language governing permissions and limitations under the License.
-
+from functools import lru_cache
 from typing import Type
 from typing import Type
 
 
 from .._manager._manager_factory import _ManagerFactory
 from .._manager._manager_factory import _ManagerFactory
@@ -21,6 +21,7 @@ class _DataManagerFactory(_ManagerFactory):
     __REPOSITORY_MAP = {"default": _DataFSRepository}
     __REPOSITORY_MAP = {"default": _DataFSRepository}
 
 
     @classmethod
     @classmethod
+    @lru_cache
     def _build_manager(cls) -> Type[_DataManager]:
     def _build_manager(cls) -> Type[_DataManager]:
         if cls._using_enterprise():
         if cls._using_enterprise():
             data_manager = _load_fct(cls._TAIPY_ENTERPRISE_CORE_MODULE + ".data._data_manager", "_DataManager")  # type: ignore
             data_manager = _load_fct(cls._TAIPY_ENTERPRISE_CORE_MODULE + ".data._data_manager", "_DataManager")  # type: ignore
@@ -34,5 +35,6 @@ class _DataManagerFactory(_ManagerFactory):
         return data_manager  # type: ignore
         return data_manager  # type: ignore
 
 
     @classmethod
     @classmethod
+    @lru_cache
     def _build_repository(cls):
     def _build_repository(cls):
         return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()
         return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()

+ 3 - 1
taipy/core/job/_job_manager_factory.py

@@ -8,7 +8,7 @@
 # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 # 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
 # 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.
 # specific language governing permissions and limitations under the License.
-
+from functools import lru_cache
 from typing import Type
 from typing import Type
 
 
 from .._manager._manager_factory import _ManagerFactory
 from .._manager._manager_factory import _ManagerFactory
@@ -21,6 +21,7 @@ class _JobManagerFactory(_ManagerFactory):
     __REPOSITORY_MAP = {"default": _JobFSRepository}
     __REPOSITORY_MAP = {"default": _JobFSRepository}
 
 
     @classmethod
     @classmethod
+    @lru_cache
     def _build_manager(cls) -> Type[_JobManager]:
     def _build_manager(cls) -> Type[_JobManager]:
         if cls._using_enterprise():
         if cls._using_enterprise():
             job_manager = _load_fct(cls._TAIPY_ENTERPRISE_CORE_MODULE + ".job._job_manager", "_JobManager")  # type: ignore
             job_manager = _load_fct(cls._TAIPY_ENTERPRISE_CORE_MODULE + ".job._job_manager", "_JobManager")  # type: ignore
@@ -34,5 +35,6 @@ class _JobManagerFactory(_ManagerFactory):
         return job_manager  # type: ignore
         return job_manager  # type: ignore
 
 
     @classmethod
     @classmethod
+    @lru_cache
     def _build_repository(cls):
     def _build_repository(cls):
         return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()
         return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()

+ 3 - 1
taipy/core/scenario/_scenario_manager_factory.py

@@ -8,7 +8,7 @@
 # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 # 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
 # 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.
 # specific language governing permissions and limitations under the License.
-
+from functools import lru_cache
 from typing import Type
 from typing import Type
 
 
 from .._manager._manager_factory import _ManagerFactory
 from .._manager._manager_factory import _ManagerFactory
@@ -21,6 +21,7 @@ class _ScenarioManagerFactory(_ManagerFactory):
     __REPOSITORY_MAP = {"default": _ScenarioFSRepository}
     __REPOSITORY_MAP = {"default": _ScenarioFSRepository}
 
 
     @classmethod
     @classmethod
+    @lru_cache
     def _build_manager(cls) -> Type[_ScenarioManager]:
     def _build_manager(cls) -> Type[_ScenarioManager]:
         if cls._using_enterprise():
         if cls._using_enterprise():
             scenario_manager = _load_fct(
             scenario_manager = _load_fct(
@@ -36,5 +37,6 @@ class _ScenarioManagerFactory(_ManagerFactory):
         return scenario_manager  # type: ignore
         return scenario_manager  # type: ignore
 
 
     @classmethod
     @classmethod
+    @lru_cache
     def _build_repository(cls):
     def _build_repository(cls):
         return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()
         return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()

+ 2 - 1
taipy/core/sequence/_sequence_manager_factory.py

@@ -8,7 +8,7 @@
 # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 # 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
 # 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.
 # specific language governing permissions and limitations under the License.
-
+from functools import lru_cache
 from typing import Type
 from typing import Type
 
 
 from .._manager._manager_factory import _ManagerFactory
 from .._manager._manager_factory import _ManagerFactory
@@ -18,6 +18,7 @@ from ._sequence_manager import _SequenceManager
 
 
 class _SequenceManagerFactory(_ManagerFactory):
 class _SequenceManagerFactory(_ManagerFactory):
     @classmethod
     @classmethod
+    @lru_cache
     def _build_manager(cls) -> Type[_SequenceManager]:  # type: ignore
     def _build_manager(cls) -> Type[_SequenceManager]:  # type: ignore
         if cls._using_enterprise():
         if cls._using_enterprise():
             sequence_manager = _load_fct(
             sequence_manager = _load_fct(

+ 3 - 1
taipy/core/submission/_submission_manager_factory.py

@@ -8,7 +8,7 @@
 # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 # 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
 # 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.
 # specific language governing permissions and limitations under the License.
-
+from functools import lru_cache
 from typing import Type
 from typing import Type
 
 
 from .._manager._manager_factory import _ManagerFactory
 from .._manager._manager_factory import _ManagerFactory
@@ -21,6 +21,7 @@ class _SubmissionManagerFactory(_ManagerFactory):
     __REPOSITORY_MAP = {"default": _SubmissionFSRepository}
     __REPOSITORY_MAP = {"default": _SubmissionFSRepository}
 
 
     @classmethod
     @classmethod
+    @lru_cache
     def _build_manager(cls) -> Type[_SubmissionManager]:
     def _build_manager(cls) -> Type[_SubmissionManager]:
         if cls._using_enterprise():
         if cls._using_enterprise():
             submission_manager = _load_fct(
             submission_manager = _load_fct(
@@ -37,5 +38,6 @@ class _SubmissionManagerFactory(_ManagerFactory):
         return submission_manager  # type: ignore
         return submission_manager  # type: ignore
 
 
     @classmethod
     @classmethod
+    @lru_cache
     def _build_repository(cls):
     def _build_repository(cls):
         return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()
         return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()

+ 3 - 1
taipy/core/task/_task_manager_factory.py

@@ -8,7 +8,7 @@
 # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 # 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
 # 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.
 # specific language governing permissions and limitations under the License.
-
+from functools import lru_cache
 from typing import Type
 from typing import Type
 
 
 from .._manager._manager_factory import _ManagerFactory
 from .._manager._manager_factory import _ManagerFactory
@@ -21,6 +21,7 @@ class _TaskManagerFactory(_ManagerFactory):
     __REPOSITORY_MAP = {"default": _TaskFSRepository}
     __REPOSITORY_MAP = {"default": _TaskFSRepository}
 
 
     @classmethod
     @classmethod
+    @lru_cache
     def _build_manager(cls) -> Type[_TaskManager]:
     def _build_manager(cls) -> Type[_TaskManager]:
         if cls._using_enterprise():
         if cls._using_enterprise():
             task_manager = _load_fct(cls._TAIPY_ENTERPRISE_CORE_MODULE + ".task._task_manager", "_TaskManager")  # type: ignore
             task_manager = _load_fct(cls._TAIPY_ENTERPRISE_CORE_MODULE + ".task._task_manager", "_TaskManager")  # type: ignore
@@ -34,5 +35,6 @@ class _TaskManagerFactory(_ManagerFactory):
         return task_manager  # type: ignore
         return task_manager  # type: ignore
 
 
     @classmethod
     @classmethod
+    @lru_cache
     def _build_repository(cls):
     def _build_repository(cls):
         return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()
         return cls._get_repository_with_repo_map(cls.__REPOSITORY_MAP)()