Skip to content

Commit

Permalink
chore: cleanup print statements and reuse join method
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Hagg committed May 5, 2021
1 parent 6ff1891 commit a4f286b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
15 changes: 8 additions & 7 deletions powersimdata/scenario/delete.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os

from powersimdata.data_access.data_access import LocalDataAccess
from powersimdata.scenario.state import State
from powersimdata.utility import server_setup
Expand Down Expand Up @@ -40,22 +38,25 @@ def delete_scenario(self, confirm=True):
self._scenario_list_manager.delete_entry(scenario_id)
self._execute_list_manager.delete_entry(scenario_id)

print("--> Deleting scenario input data on server")
print("--> Deleting scenario input data")
target = self._data_access.match_scenario_files(scenario_id, "input")
self._data_access.remove(target, recursive=False, confirm=confirm)

print("--> Deleting scenario output data on server")
print("--> Deleting scenario output data")
target = self._data_access.match_scenario_files(scenario_id, "output")
self._data_access.remove(target, recursive=False, confirm=confirm)

# Delete temporary folder enclosing simulation inputs
print("--> Deleting temporary folder on server")
print("--> Deleting temporary folder")
tmp_dir = self._data_access.match_scenario_files(scenario_id, "tmp")
self._data_access.remove(tmp_dir, recursive=True, confirm=confirm)

print("--> Deleting input and output data on local machine")
target = os.path.join(server_setup.LOCAL_DIR, "data", "**", f"{scenario_id}_*")
LocalDataAccess().remove(target, recursive=False, confirm=confirm)
local_data_acces = LocalDataAccess()
target = local_data_acces.join(
server_setup.LOCAL_DIR, "data", "**", f"{scenario_id}_*"
)
local_data_acces.remove(target, recursive=False, confirm=confirm)

# Delete attributes
self._clean()
Expand Down
3 changes: 2 additions & 1 deletion powersimdata/scenario/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ def __init__(self, data_access, scenario_info, grid, ct):

def create_folder(self):
"""Creates folder on server that will enclose simulation inputs."""
print("--> Creating temporary folder on server for simulation inputs")
description = self._data_access.description
print(f"--> Creating temporary folder on {description} for simulation inputs")
self._data_access.makedir(self.TMP_DIR)

def prepare_mpc_file(self):
Expand Down

0 comments on commit a4f286b

Please sign in to comment.