Skip to content

Commit

Permalink
Use pathlib in smoke tests and setup.py (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelGrupp authored Jan 6, 2024
1 parent 2616620 commit 09269ff
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 25 deletions.
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
import sys
import shutil
import subprocess as sp
from pathlib import Path

# monkey patch because setuptools entry_points are slow as fuck
# https://github.com/ninjaaron/fast-entry_points
import fastentrypoints # pylint: disable=unused-import

HERE = os.path.abspath(os.path.dirname(__file__))
HERE = Path(__file__).absolute().parent


def activate_argcomplete():
Expand Down Expand Up @@ -49,7 +50,7 @@ def finalize_options(self):
def run(self):
try:
print("Removing previous dist/ ...")
shutil.rmtree(os.path.join(HERE, "dist"))
shutil.rmtree(HERE / "dist")
except OSError:
pass
print("Building source distribution...")
Expand All @@ -68,7 +69,7 @@ def run(self):
author_email="[email protected]",
url="https://github.com/MichaelGrupp/evo",
license="GPLv3",
long_description=open(os.path.join(HERE, "README.md")).read(),
long_description=open(HERE / "README.md").read(),
long_description_content_type="text/markdown",
keywords=[
"SLAM", "odometry", "trajectory", "evaluation", "metric",
Expand Down
14 changes: 7 additions & 7 deletions test/ape_rpe_smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import os
import shutil
import subprocess as sp
from pathlib import Path

tmp_dir = "tmp"
cfg_dir = "cfg/ape_rpe"
here = os.path.dirname(os.path.abspath(__file__))
tmp_dir = Path("tmp")
cfg_dir = Path("cfg/ape_rpe")
here = Path(__file__).absolute().parent

# always run in script location
os.chdir(here)
Expand All @@ -23,9 +24,8 @@
try:
for m in metrics:
for d in data:
for cfg in os.listdir(cfg_dir):
os.mkdir(tmp_dir)
cfg = os.path.join(cfg_dir, cfg)
for cfg in cfg_dir.iterdir():
tmp_dir.mkdir(exist_ok=True)
cmd = "{} {} -c {}".format(m, d, cfg)
print("[smoke test] {}".format(cmd))
output = sp.check_output(cmd.split(" "), cwd=here)
Expand All @@ -34,5 +34,5 @@
print(e.output.decode("utf-8"))
raise
finally:
if os.path.exists(tmp_dir):
if tmp_dir.exists():
shutil.rmtree(tmp_dir)
14 changes: 7 additions & 7 deletions test/res_smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import os
import shutil
import subprocess as sp
from pathlib import Path

tmp_dir = "tmp"
cfg_dir = "cfg/res"
here = os.path.dirname(os.path.abspath(__file__))
tmp_dir = Path("tmp")
cfg_dir = Path("cfg/res")
here = Path(__file__).absolute().parent

# always run in script location
os.chdir(here)
Expand All @@ -19,9 +20,8 @@

try:
for d in data:
for cfg in os.listdir(cfg_dir):
os.mkdir(tmp_dir)
cfg = os.path.join(cfg_dir, cfg)
for cfg in cfg_dir.iterdir():
tmp_dir.mkdir(exist_ok=True)
cmd = "evo_res {} -c {}".format(d, cfg)
print("[smoke test] {}".format(cmd))
output = sp.check_output(cmd.split(" "), cwd=here)
Expand All @@ -30,5 +30,5 @@
print(e.output.decode("utf-8"))
raise
finally:
if os.path.exists(tmp_dir):
if tmp_dir.exists():
shutil.rmtree(tmp_dir)
16 changes: 8 additions & 8 deletions test/traj_smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import glob
import shutil
import subprocess as sp
from pathlib import Path

tmp_dir = "tmp"
common_cfg_dir = "cfg/traj/common"
here = os.path.dirname(os.path.abspath(__file__))
tmp_dir = Path("tmp")
common_cfg_dir = Path("cfg/traj/common")
here = Path(__file__).absolute().parent

# always run in script location
os.chdir(here)
Expand All @@ -23,10 +24,9 @@

try:
for d in data.keys():
for cfg_dir in (common_cfg_dir, data[d]):
for cfg in os.listdir(cfg_dir):
os.mkdir(tmp_dir)
cfg = os.path.join(cfg_dir, cfg)
for cfg_dir in (common_cfg_dir, Path(data[d])):
for cfg in cfg_dir.iterdir():
tmp_dir.mkdir(exist_ok=True)
cmd = "{} -c {}".format(d, cfg)
print("[smoke test] {}".format(cmd))
output = sp.check_output(cmd.split(" "), cwd=here)
Expand All @@ -39,5 +39,5 @@
"./*.tum")
for traj_file in traj_files:
os.remove(traj_file)
if os.path.exists(tmp_dir):
if tmp_dir.exists():
shutil.rmtree(tmp_dir)

0 comments on commit 09269ff

Please sign in to comment.