-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(study): normalize study path #2316
Conversation
@@ -66,9 +66,6 @@ def test_get(tmp_path: str, project_path) -> None: | |||
data = {"titi": 43} | |||
sub_route = "settings" | |||
|
|||
path = path_study / "settings" | |||
key = "titi" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These variables were unused
@@ -100,7 +97,6 @@ def test_get_cache(tmp_path: str) -> None: | |||
path_study.mkdir() | |||
(path_study / "settings").mkdir() | |||
(path_study / "study.antares").touch() | |||
path = path_study / "settings" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was unused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before merging we should generate a Desktop version to give to Alexander for him to try it
@@ -288,6 +289,23 @@ def __eq__(self, other: t.Any) -> bool: | |||
def to_json_summary(self) -> t.Any: | |||
return {"id": self.id, "name": self.name} | |||
|
|||
@validates("folder") # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sqlachemu doesn't provide a type for this decorator
if not path: | ||
return path | ||
pure_path = PurePath(path) | ||
return pure_path.as_posix() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: all this could be simplfied in one line:
return PurePath(path).as_posix() if path else path
The front end can't handle windows path, the desktop version on windows won't display the study hierarchy correctly.
The front end relies on the folder field of Study. This PR adds a validator to that field that normalize any path, including windows path to a posix path.