Skip to content

Commit

Permalink
remove unused WSL for maintainabilty
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Jan 10, 2025
1 parent d3c4a65 commit 4309b93
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 38 deletions.
File renamed without changes.
File renamed without changes.
17 changes: 4 additions & 13 deletions src/gemini3d/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from __future__ import annotations
from datetime import datetime, timedelta
from pathlib import Path, PurePosixPath
from pathlib import Path
import shutil
import os
import subprocess
Expand All @@ -13,7 +13,6 @@
import numpy as np

from .utils import filename2datetime
from . import wsl


EXE_PATHS = [
Expand Down Expand Up @@ -67,13 +66,8 @@ def executable(name: str, root: Path | None = None) -> Path:
for n in exe_paths:
e = p / n / name
logging.debug(f"checking {e} for existance and executable permission")
if wsl.is_wsl_path(p):
# shutil.which() doesn't work on WSL paths
if e.is_file():
return wsl.win_path2wsl_path(e) # type: ignore
else:
if exe := shutil.which(e, path=p / n):
return Path(exe)
if exe := shutil.which(e, path=p / n):
return Path(exe)

raise FileNotFoundError(f"{name} not found, search paths: {paths}")

Expand All @@ -89,10 +83,7 @@ def gemini_exe(name: str = "gemini3d.run", root: Path | None = None) -> Path:
exe = executable(name, root)

# %% ensure Gemini3D executable is runnable
if os.name == "nt" and isinstance(exe, PurePosixPath):
cmd0 = ["wsl", str(exe), "-h"]
else:
cmd0 = [str(exe), "-h"]
cmd0 = [str(exe), "-h"]

ret = subprocess.run(
cmd0,
Expand Down
12 changes: 4 additions & 8 deletions src/gemini3d/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
import subprocess
import shutil
from math import prod
from pathlib import Path, PurePosixPath
import numpy as np
from pathlib import Path
import numpy

from . import find
from . import model
from . import write
from . import read
from . import wsl
from .utils import git_meta


Expand Down Expand Up @@ -74,10 +73,7 @@ def runner(pr: dict[str, typing.Any]) -> None:
gemexe = find.gemini_exe(pr.get("gemexe", ""))
logging.info(f"gemini executable: {gemexe}")

if os.name == "nt" and isinstance(gemexe, PurePosixPath):
cmd = ["wsl", str(gemexe), str(wsl.win_path2wsl_path(out_dir))]
else:
cmd = [str(gemexe), str(out_dir)]
cmd = [str(gemexe), str(out_dir)]

# %% attempt dry run, but don't fail in case intended for HPC
logging.info("Gemini dry run command:")
Expand Down Expand Up @@ -144,7 +140,7 @@ def memory_estimate(path: Path) -> int:
grid_size = 0

for k, v in gs.items():
if k == "lx" or not isinstance(v, (tuple, list, np.ndarray)) or not v:
if k == "lx" or not isinstance(v, (tuple, list, numpy.ndarray)) or not v:
continue
print(k, v, grid_size)
grid_size += int(prod(v))
Expand Down
14 changes: 2 additions & 12 deletions src/gemini3d/msis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
"""

from __future__ import annotations
from pathlib import Path, PurePosixPath
from pathlib import Path
import subprocess
import logging
import typing as T
import os

import numpy as np
import h5py
import xarray

from . import find
from . import wsl


def get_msis_features(exe: Path) -> dict[str, bool]:
Expand Down Expand Up @@ -89,15 +87,7 @@ def msis_setup(p: dict[str, T.Any], xg: dict[str, T.Any]) -> xarray.Dataset:
f.create_dataset("/alt", shape=xg["lx"], dtype=np.float32, data=alt_km)
f.create_dataset("/msis_version", dtype=np.int32, data=msis_version)
# %% run MSIS
if os.name == "nt" and isinstance(msis_exe, PurePosixPath):
cmd = [
"wsl",
str(msis_exe),
str(wsl.win_path2wsl_path(msis_infile)),
str(wsl.win_path2wsl_path(msis_outfile)),
]
else:
cmd = [str(msis_exe), str(msis_infile), str(msis_outfile)]
cmd = [str(msis_exe), str(msis_infile), str(msis_outfile)]

logging.info(" ".join(cmd))
subprocess.check_call(cmd, text=True)
Expand Down
5 changes: 0 additions & 5 deletions src/gemini3d/tests/intg/test_dryrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import pytest
from pytest import approx
from pathlib import PurePosixPath
import os

import gemini3d
import gemini3d.run
Expand All @@ -27,9 +25,6 @@ def test_memory(name, bref, helpers):
def test_mpiexec():
exe = find.gemini_exe()

if os.name == "nt" and isinstance(exe, PurePosixPath):
pytest.skip("WSL check_mpiexec() not implemented")

mpiexec = job.check_mpiexec("mpiexec", exe)
assert isinstance(mpiexec, str)

Expand Down

0 comments on commit 4309b93

Please sign in to comment.