Skip to content

Commit

Permalink
Remove useless async operations
Browse files Browse the repository at this point in the history
Signed-off-by: Sylvain Leclerc <[email protected]>
  • Loading branch information
sylvlecl committed Sep 2, 2024
1 parent 922f08f commit 6eb8469
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions antarest/core/filesystem_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class MountPointDTO(
message: str = Field("", description="A message describing the status of the mount point")

@classmethod
async def from_path(cls, name: str, path: Path) -> "MountPointDTO":
def from_path(cls, name: str, path: Path) -> "MountPointDTO":
obj = cls(name=name, path=path)
try:
obj.total_bytes, obj.used_bytes, obj.free_bytes = shutil.disk_usage(obj.path)
Expand Down Expand Up @@ -335,9 +335,7 @@ async def list_mount_points(fs: FilesystemName) -> t.Sequence[MountPointDTO]:
"""

mount_dirs = _get_mount_dirs(fs)
tasks = [MountPointDTO.from_path(name, path) for name, path in mount_dirs.items()]
ws = await asyncio.gather(*tasks)
return ws
return [MountPointDTO.from_path(name, path) for name, path in mount_dirs.items()]

@bp.get(
"/{fs}/{mount}",
Expand Down Expand Up @@ -365,7 +363,7 @@ async def get_mount_point(fs: FilesystemName, mount: MountPointName) -> MountPoi
"""

mount_dir = _get_mount_dir(fs, mount)
return await MountPointDTO.from_path(mount, mount_dir)
return MountPointDTO.from_path(mount, mount_dir)

@bp.get(
"/{fs}/{mount}/ls",
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/filesystem_blueprint/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_init(self) -> None:
def test_from_path__missing_file(self) -> None:
name = "foo"
path = Path("/path/to/workspaces/internal_studies")
dto = asyncio.run(MountPointDTO.from_path(name, path))
dto = MountPointDTO.from_path(name, path)
assert dto.name == name
assert dto.path == path
assert dto.total_bytes == 0
Expand All @@ -65,7 +65,7 @@ def test_from_path__missing_file(self) -> None:

def test_from_path__file(self, tmp_path: Path) -> None:
name = "foo"
dto = asyncio.run(MountPointDTO.from_path(name, tmp_path))
dto = MountPointDTO.from_path(name, tmp_path)
total_bytes, used_bytes, free_bytes = shutil.disk_usage(tmp_path)
assert dto.name == name
assert dto.path == tmp_path
Expand Down

0 comments on commit 6eb8469

Please sign in to comment.