Skip to content

Commit

Permalink
Study listing improvements (refacto, new ui components, add import) (#…
Browse files Browse the repository at this point in the history
…420)

* Refacto study listing view

Signed-off-by: Paul Bui-Quang <[email protected]>

* Fix tests

Signed-off-by: Paul Bui-Quang <[email protected]>

* Fix linter

Signed-off-by: Paul Bui-Quang <[email protected]>
  • Loading branch information
pl-buiquang authored Jul 13, 2021
1 parent 4f284bc commit f9714f2
Show file tree
Hide file tree
Showing 24 changed files with 631 additions and 371 deletions.
10 changes: 8 additions & 2 deletions antarest/storage/business/raw_study_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,18 @@ def create_study(self, metadata: RawStudy) -> RawStudy:
metadata.path = str(path_study)
return metadata

def copy_study(self, src_meta: RawStudy, dest_meta: RawStudy) -> RawStudy:
def copy_study(
self,
src_meta: RawStudy,
dest_meta: RawStudy,
with_outputs: bool = False,
) -> RawStudy:
"""
Copy study to a new destination
Args:
src_meta: source study
dest_meta: destination study
with_outputs: indicate weither to copy the output or not
Returns: destination study
Expand All @@ -277,7 +283,7 @@ def copy_study(self, src_meta: RawStudy, dest_meta: RawStudy) -> RawStudy:
shutil.copytree(src_path, dest_path)

output = dest_path / "output"
if output.exists():
if not with_outputs and output.exists():
shutil.rmtree(output)

_, study = self.study_factory.create_from_fs(
Expand Down
6 changes: 5 additions & 1 deletion antarest/storage/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ def copy_study(
dest_study_name: str,
group_ids: List[str],
params: RequestParameters,
with_outputs: bool = False,
) -> str:
"""
Copy study to an other location.
Expand All @@ -328,6 +329,7 @@ def copy_study(
dest_study_name: destination study
group_ids: group to attach on new study
params: request parameters
with_outputs: indicate if outputs should be copied too
Returns:
Expand All @@ -353,7 +355,9 @@ def copy_study(
version=src_study.version,
)

study = self.study_service.copy_study(src_study, dest_study)
study = self.study_service.copy_study(
src_study, dest_study, with_outputs
)
self._save_study(study, params.user, group_ids)
self.event_bus.push(
Event(EventType.STUDY_CREATED, study.to_json_summary())
Expand Down
4 changes: 3 additions & 1 deletion antarest/storage/web/studies_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def import_study(
def copy_study(
uuid: str,
dest: str,
with_outputs: bool = False,
groups: Optional[str] = None,
current_user: JWTUser = Depends(auth.get_current_user),
) -> Any:
Expand All @@ -105,10 +106,11 @@ def copy_study(
src_uuid=source_uuid_sanitized,
dest_study_name=destination_name_sanitized,
group_ids=group_ids,
with_outputs=with_outputs,
params=params,
)

return f"/studies/{destination_uuid}"
return destination_uuid

@bp.post(
"/studies",
Expand Down
2 changes: 1 addition & 1 deletion conf/gunicorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
loglevel = "info"
errorlog = "-"
accesslog = "-"
preload_app = False
preload_app = False
2 changes: 1 addition & 1 deletion tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_main(app: FastAPI):

# Study delete
client.delete(
f"/v1{copied.json()}",
f"/v1/studies/{copied.json()}",
headers={
"Authorization": f'Bearer {george_credentials["access_token"]}'
},
Expand Down
2 changes: 1 addition & 1 deletion tests/storage/integration/test_STA_mini.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def test_sta_mini_copy(storage_service) -> None:
)

assert result.status_code == HTTPStatus.CREATED.value
uuid = result.json()[len("/studies/") :]
uuid = result.json()

parameters = RequestParameters(user=ADMIN)
data_source = storage_service.get(source_study_name, "/", -1, parameters)
Expand Down
1 change: 1 addition & 0 deletions tests/storage/web/test_studies_bp.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def test_copy_study(tmp_path: Path, storage_service_builder) -> None:
src_uuid="existing-study",
dest_study_name="study-copied",
group_ids=[],
with_outputs=False,
params=PARAMS,
)
assert result.status_code == HTTPStatus.CREATED.value
Expand Down
3 changes: 2 additions & 1 deletion webapp/public/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
"backButton": "Back",
"closeButton": "Close",
"save": "Save",
"edit": "Edit"
"edit": "Edit",
"copy": "Copy"
}
4 changes: 3 additions & 1 deletion webapp/public/locales/en/studymanager.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
"failtorunstudy": "Failed to run study",
"studylaunched": "{{studyname}} launched !",
"savedatasuccess": "Data saved with success",
"failtosavedata": "Failed to save data"
"failtosavedata": "Failed to save data",
"failtocopystudy": "Failed to copy study",
"studycopiedsuccess": "Success copying study"
}
3 changes: 2 additions & 1 deletion webapp/public/locales/fr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
"backButton": "Retour",
"closeButton": "Fermer",
"save": "Sauvegarder",
"edit": "Editer"
"edit": "Editer",
"copy": "Copie"
}
4 changes: 3 additions & 1 deletion webapp/public/locales/fr/studymanager.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
"failtorunstudy": "Echec du lancement de l'étude",
"studylaunched": "{{studyname}} lancée !",
"savedatasuccess": "Données sauvegardées avec succès",
"failtosavedata": "Erreur lors de la sauvegarde des données"
"failtosavedata": "Erreur lors de la sauvegarde des données",
"failtocopystudy": "Erreur lors de la copie de l'étude",
"studycopiedsuccess": "Etude copiée avec succès"
}
7 changes: 7 additions & 0 deletions webapp/src/App/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import { createMuiTheme } from '@material-ui/core';

export const TOOLBAR_HEIGHT = '48px';

export const jobStatusColors = {
'JobStatus.RUNNING': 'orange',
'JobStatus.PENDING': 'orange',
'JobStatus.SUCCESS': 'green',
'JobStatus.FAILED': 'red',
};

export default createMuiTheme({
overrides: {
MuiToolbar: {
Expand Down
181 changes: 0 additions & 181 deletions webapp/src/components/StudyListing/StudyBlockSummaryView.tsx

This file was deleted.

Loading

0 comments on commit f9714f2

Please sign in to comment.