Skip to content

Commit

Permalink
move tmp deletion back to cleanup where it should be
Browse files Browse the repository at this point in the history
  • Loading branch information
vtnate committed Dec 26, 2023
1 parent 1762e66 commit 96658d7
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions geojson_modelica_translator/modelica/modelica_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,6 @@ def _subprocess_call_to_docker(self, run_path: Path, action: str) -> int:
# Remind user why the simulation didn't complete
raise SystemExit("Simulation stopped by user KeyboardInterrupt")
finally:
# While we're still working here, remove the 'tmp' folder that was created by 5G simulations,
# because it will have different permissions than the user running the container (especially in CI)
if (run_path / 'tmp' / 'temperatureResponseMatrix').exists():
print(f'Removing {run_path / "tmp" / "temperatureResponseMatrix"}...')
(run_path / 'tmp').chmod(0o666)
shutil.rmtree(run_path / 'tmp' / 'temperatureResponseMatrix')
# check if the tmp folder is empty now, and if so remove
if not any((run_path / 'tmp').iterdir()):
(run_path / 'tmp').rmdir()
os.chdir(curdir)
stdout_log.close()
logger.debug('Closed stdout.log')
Expand Down Expand Up @@ -429,3 +420,15 @@ def cleanup_path(self, path: Path, model_name: str, **kwargs: dict) -> None:
for pattern in remove_files_glob:
for f in path.glob(pattern): # type: ignore
Path(f).unlink(missing_ok=True)

# Remove the 'tmp' folder that was created by 5G simulations,
# because it will have different permissions than the user running the container (especially in CI)
if (path / 'tmp' / 'temperatureResponseMatrix').is_dir():
# print(f'Removing {path / "tmp" / "temperatureResponseMatrix/"}...')
# print(os.stat(path / 'tmp').st_mode)
(path / 'tmp').chmod(0o777)
# print(os.stat(path / 'tmp').st_mode)
shutil.rmtree(path / 'tmp' / 'temperatureResponseMatrix')
# check if the tmp folder is empty now, and if so remove
if not any((path / 'tmp').iterdir()):
(path / 'tmp').rmdir()

0 comments on commit 96658d7

Please sign in to comment.