Skip to content

Commit

Permalink
make json a default value
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBelthle committed Jul 5, 2024
1 parent c67be90 commit eaece0c
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion antarest/study/common/studystorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion antarest/study/storage/abstract_storage_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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 != [""]:
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion antarest/study/storage/rawstudy/model/filesystem/inode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions antarest/study/storage/rawstudy/model/filesystem/lazy_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion tests/storage/repository/filesystem/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit eaece0c

Please sign in to comment.