From eaece0c06ba8117544e5ce06a520defaeedc9f0c Mon Sep 17 00:00:00 2001 From: belthlemar Date: Fri, 5 Jul 2024 18:58:11 +0200 Subject: [PATCH] make json a default value --- antarest/study/common/studystorage.py | 2 +- antarest/study/storage/abstract_storage_service.py | 2 +- .../storage/rawstudy/model/filesystem/folder_node.py | 8 ++++---- .../storage/rawstudy/model/filesystem/ini_file_node.py | 2 +- antarest/study/storage/rawstudy/model/filesystem/inode.py | 2 +- .../study/storage/rawstudy/model/filesystem/lazy_node.py | 6 +++--- .../storage/rawstudy/model/filesystem/matrix/matrix.py | 2 +- .../model/filesystem/matrix/output_series_matrix.py | 2 +- .../storage/rawstudy/model/filesystem/raw_file_node.py | 4 +++- .../rawstudy/model/filesystem/root/input/areas/list.py | 2 +- .../root/output/simulation/ts_numbers/ts_numbers_data.py | 2 +- .../study/storage/variantstudy/variant_study_service.py | 2 +- tests/storage/repository/filesystem/utils.py | 4 +++- 13 files changed, 22 insertions(+), 18 deletions(-) diff --git a/antarest/study/common/studystorage.py b/antarest/study/common/studystorage.py index f3170e1be8..fc7c9bbdac 100644 --- a/antarest/study/common/studystorage.py +++ b/antarest/study/common/studystorage.py @@ -30,7 +30,7 @@ def get( metadata: T, url: str = "", depth: int = 3, - format: str = "", + format: str = "json", ) -> JSON: """ Entry point to fetch data inside study. diff --git a/antarest/study/storage/abstract_storage_service.py b/antarest/study/storage/abstract_storage_service.py index 08ee83287b..da386b4699 100644 --- a/antarest/study/storage/abstract_storage_service.py +++ b/antarest/study/storage/abstract_storage_service.py @@ -116,7 +116,7 @@ def get_study_information( tags=[tag.label for tag in study.tags], ) - def get(self, metadata: T, url: str = "", depth: int = 3, format: str = "", use_cache: bool = True) -> JSON: + def get(self, metadata: T, url: str = "", depth: int = 3, format: str = "json", use_cache: bool = True) -> JSON: """ Entry point to fetch data inside study. Args: diff --git a/antarest/study/storage/rawstudy/model/filesystem/folder_node.py b/antarest/study/storage/rawstudy/model/filesystem/folder_node.py index a16790a57f..449ea4b683 100644 --- a/antarest/study/storage/rawstudy/model/filesystem/folder_node.py +++ b/antarest/study/storage/rawstudy/model/filesystem/folder_node.py @@ -52,7 +52,7 @@ def _forward_get( self, url: t.List[str], depth: int = -1, - format: str = "", + format: str = "json", get_node: bool = False, ) -> t.Union[JSON, INode[JSON, SUB_JSON, JSON]]: children = self.build() @@ -75,7 +75,7 @@ def _forward_get( raise ValueError("Multiple nodes requested") def _expand_get( - self, depth: int = -1, format: str = "", get_node: bool = False + self, depth: int = -1, format: str = "json", get_node: bool = False ) -> t.Union[JSON, INode[JSON, SUB_JSON, JSON]]: if get_node: return self @@ -93,7 +93,7 @@ def _get( self, url: t.Optional[t.List[str]] = None, depth: int = -1, - format: str = "", + format: str = "json", get_node: bool = False, ) -> t.Union[JSON, INode[JSON, SUB_JSON, JSON]]: if url and url != [""]: @@ -102,7 +102,7 @@ def _get( return self._expand_get(depth, format, get_node) def get( - self, url: t.Optional[t.List[str]] = None, depth: int = -1, expanded: bool = False, format: str = "" + self, url: t.Optional[t.List[str]] = None, depth: int = -1, expanded: bool = False, format: str = "json" ) -> JSON: output = self._get(url=url, depth=depth, format=format, get_node=False) assert not isinstance(output, INode) diff --git a/antarest/study/storage/rawstudy/model/filesystem/ini_file_node.py b/antarest/study/storage/rawstudy/model/filesystem/ini_file_node.py index 949ec5a9b6..e4a0d586af 100644 --- a/antarest/study/storage/rawstudy/model/filesystem/ini_file_node.py +++ b/antarest/study/storage/rawstudy/model/filesystem/ini_file_node.py @@ -133,7 +133,7 @@ def _get_filtering_kwargs(self, url: t.List[str]) -> t.Dict[str, str]: return {} def get( - self, url: t.Optional[t.List[str]] = None, depth: int = -1, expanded: bool = False, format: str = "" + self, url: t.Optional[t.List[str]] = None, depth: int = -1, expanded: bool = False, format: str = "json" ) -> SUB_JSON: output = self._get(url, depth, expanded, get_node=False) assert not isinstance(output, INode) diff --git a/antarest/study/storage/rawstudy/model/filesystem/inode.py b/antarest/study/storage/rawstudy/model/filesystem/inode.py index 10d6c44237..14c748b401 100644 --- a/antarest/study/storage/rawstudy/model/filesystem/inode.py +++ b/antarest/study/storage/rawstudy/model/filesystem/inode.py @@ -25,7 +25,7 @@ def get( url: Optional[List[str]] = None, depth: int = -1, expanded: bool = False, - format: str = "", + format: str = "json", ) -> G: """ Ask data inside tree. diff --git a/antarest/study/storage/rawstudy/model/filesystem/lazy_node.py b/antarest/study/storage/rawstudy/model/filesystem/lazy_node.py index 87b1253fa3..4c3f156368 100644 --- a/antarest/study/storage/rawstudy/model/filesystem/lazy_node.py +++ b/antarest/study/storage/rawstudy/model/filesystem/lazy_node.py @@ -61,7 +61,7 @@ def _get( url: Optional[List[str]] = None, depth: int = -1, expanded: bool = False, - format: str = "", + format: str = "json", get_node: bool = False, ) -> Union[Union[str, G], INode[G, S, V]]: self._assert_url_end(url) @@ -82,7 +82,7 @@ def _get( return self.load(url, depth, expanded, format) def get( - self, url: Optional[List[str]] = None, depth: int = -1, expanded: bool = False, format: str = "" + self, url: Optional[List[str]] = None, depth: int = -1, expanded: bool = False, format: str = "json" ) -> Union[str, G]: output = self._get(url, depth, expanded, format, get_node=False) assert not isinstance(output, INode) @@ -136,7 +136,7 @@ def load( url: Optional[List[str]] = None, depth: int = -1, expanded: bool = False, - format: str = "", + format: str = "json", ) -> G: """ Fetch data on disk. diff --git a/antarest/study/storage/rawstudy/model/filesystem/matrix/matrix.py b/antarest/study/storage/rawstudy/model/filesystem/matrix/matrix.py index 5b5008f224..18d41422df 100644 --- a/antarest/study/storage/rawstudy/model/filesystem/matrix/matrix.py +++ b/antarest/study/storage/rawstudy/model/filesystem/matrix/matrix.py @@ -90,7 +90,7 @@ def denormalize(self) -> None: self.get_link_path().unlink() def load( - self, url: Optional[List[str]] = None, depth: int = -1, expanded: bool = False, format: str = "" + self, url: Optional[List[str]] = None, depth: int = -1, expanded: bool = False, format: str = "json" ) -> Union[bytes, JSON]: file_path, tmp_dir = self._get_real_file_path() if format == "bytes": diff --git a/antarest/study/storage/rawstudy/model/filesystem/matrix/output_series_matrix.py b/antarest/study/storage/rawstudy/model/filesystem/matrix/output_series_matrix.py index c05c240a67..976b8347d7 100644 --- a/antarest/study/storage/rawstudy/model/filesystem/matrix/output_series_matrix.py +++ b/antarest/study/storage/rawstudy/model/filesystem/matrix/output_series_matrix.py @@ -131,7 +131,7 @@ def check_errors( return errors def load( - self, url: Optional[List[str]] = None, depth: int = -1, expanded: bool = False, format: str = "" + self, url: Optional[List[str]] = None, depth: int = -1, expanded: bool = False, format: str = "json" ) -> Union[bytes, JSON]: try: file_path, tmp_dir = self._get_real_file_path() diff --git a/antarest/study/storage/rawstudy/model/filesystem/raw_file_node.py b/antarest/study/storage/rawstudy/model/filesystem/raw_file_node.py index 0056929f82..7207949898 100644 --- a/antarest/study/storage/rawstudy/model/filesystem/raw_file_node.py +++ b/antarest/study/storage/rawstudy/model/filesystem/raw_file_node.py @@ -24,7 +24,9 @@ def get_lazy_content( ) -> str: return f"file://{self.config.path.name}" - def load(self, url: Optional[List[str]] = None, depth: int = -1, expanded: bool = False, format: str = "") -> bytes: + def load( + self, url: Optional[List[str]] = None, depth: int = -1, expanded: bool = False, format: str = "json" + ) -> bytes: file_path, tmp_dir = self._get_real_file_path() if file_path.exists(): diff --git a/antarest/study/storage/rawstudy/model/filesystem/root/input/areas/list.py b/antarest/study/storage/rawstudy/model/filesystem/root/input/areas/list.py index 90c7df8027..f67c287c16 100644 --- a/antarest/study/storage/rawstudy/model/filesystem/root/input/areas/list.py +++ b/antarest/study/storage/rawstudy/model/filesystem/root/input/areas/list.py @@ -20,7 +20,7 @@ def get_node(self, url: Optional[List[str]] = None) -> INode[List[str], List[str return self def get( - self, url: Optional[List[str]] = None, depth: int = -1, expanded: bool = False, format: str = "" + self, url: Optional[List[str]] = None, depth: int = -1, expanded: bool = False, format: str = "json" ) -> List[str]: if self.config.zip_path: path, tmp_dir = self._extract_file_to_tmp_dir() diff --git a/antarest/study/storage/rawstudy/model/filesystem/root/output/simulation/ts_numbers/ts_numbers_data.py b/antarest/study/storage/rawstudy/model/filesystem/root/output/simulation/ts_numbers/ts_numbers_data.py index 910f8126ff..41f15ce975 100644 --- a/antarest/study/storage/rawstudy/model/filesystem/root/output/simulation/ts_numbers/ts_numbers_data.py +++ b/antarest/study/storage/rawstudy/model/filesystem/root/output/simulation/ts_numbers/ts_numbers_data.py @@ -9,7 +9,7 @@ class TsNumbersVector(LazyNode[List[int], List[int], JSON]): def load( - self, url: Optional[List[str]] = None, depth: int = -1, expanded: bool = False, format: str = "" + self, url: Optional[List[str]] = None, depth: int = -1, expanded: bool = False, format: str = "json" ) -> List[int]: file_path, tmp_dir = self._get_real_file_path() diff --git a/antarest/study/storage/variantstudy/variant_study_service.py b/antarest/study/storage/variantstudy/variant_study_service.py index 62f2c54e95..ddb53be8e0 100644 --- a/antarest/study/storage/variantstudy/variant_study_service.py +++ b/antarest/study/storage/variantstudy/variant_study_service.py @@ -464,7 +464,7 @@ def _get_variants_parents(self, id: str, params: RequestParameters) -> t.List[St return output_list def get( - self, metadata: VariantStudy, url: str = "", depth: int = 3, format: str = "", use_cache: bool = True + self, metadata: VariantStudy, url: str = "", depth: int = 3, format: str = "json", use_cache: bool = True ) -> JSON: """ Entry point to fetch data inside study. diff --git a/tests/storage/repository/filesystem/utils.py b/tests/storage/repository/filesystem/utils.py index c46a6997c4..5fdd991195 100644 --- a/tests/storage/repository/filesystem/utils.py +++ b/tests/storage/repository/filesystem/utils.py @@ -28,7 +28,9 @@ def get_node( ) -> INode[int, int, int]: return self - def get(self, url: Optional[List[str]] = None, depth: int = -1, expanded: bool = False, format: str = "") -> int: + def get( + self, url: Optional[List[str]] = None, depth: int = -1, expanded: bool = False, format: str = "json" + ) -> int: return self.value def save(self, data: int, url: Optional[List[str]] = None) -> None: