Skip to content

Commit

Permalink
Delete workspace step folder if exists (#119)
Browse files Browse the repository at this point in the history
* Delete workspace step folder if exists

* Update bash.py
  • Loading branch information
krishnaa05 authored Dec 19, 2024
1 parent b3b3bc5 commit 47eb0b4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/thor/maestro/bash.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json
from pathlib import Path
import subprocess
import shutil

from thor.maestro.baton import JobManager

Expand Down Expand Up @@ -124,16 +125,19 @@ def expose_env_vars(self, release_version, env_dict):
os.environ[k] = str(v)
return None

def make_clean_workspace(self, num_steps:int):
def make_clean_workspace(self, num_step: int):
"""
Checks to see if there's a valid 'workspace' dir in the cwd.
If so, deletes and recreates it, otherwise, just creates it.
"""
workspace_path = Path('./workspace')
self.workspace_abs_path = workspace_path.resolve()
workspace_path.mkdir(exist_ok=True)
for i in range(1, num_steps+1):
(workspace_path / str(i)).mkdir(exist_ok=True)
# Delete folder if exists and create a new folder
folder_path = (workspace_path / str(num_step))
if os.path.exists(folder_path) and os.path.isdir(folder_path):
shutil.rmtree(folder_path)
folder_path.mkdir()
if DEVELOPMENT == "true":
script_target_file_name = "workspace/shell_script_target.txt"
target_absolute_path = os.path.join(os.getcwd(), script_target_file_name)
Expand Down

0 comments on commit 47eb0b4

Please sign in to comment.