Skip to content

Commit

Permalink
Properly keep or clean mps/svf
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonMarechal25 committed Jan 17, 2025
1 parent 9dfcf23 commit db3c016
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/python/antares_xpansion/study_output_cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ def get_master_path(dirpath: Path) -> Path:


def get_tmp_master_path(master_path: Path) -> Path:
return Path(master_path.parent, master_path.stem + '.tmp')
if (master_path.suffix == ".mps"):
return Path(master_path.parent, master_path.stem + '.tmp')
else:
return Path(master_path.parent, master_path.stem + '.stmp')


class StudyOutputCleaner:
Expand All @@ -42,19 +45,20 @@ def clean_lpnamer_step(study_output: Path):

@staticmethod
def clean_benders_step(study_output: Path):

last_master_path = get_last_master_path(study_output)
master_path = get_master_path(study_output)
tmp_last_master_path = get_tmp_master_path(last_master_path)
tmp_master_path = get_tmp_master_path(master_path)
#For .mps and .svf. Rename master_last_iteration.mps to master_last_iteration.tmp or master_last_iteration.stmp
#Rename master.mps to master.tmp or master.stmp

lp_dir = study_output / 'lp'
rename_master(last_master_path, tmp_last_master_path)
rename_master(master_path, tmp_master_path)
remove_files_containing_str_from_dir('.mps', lp_dir)
remove_files_containing_str_from_dir('.svf', lp_dir)
rename_master(tmp_master_path, master_path)
rename_master(tmp_last_master_path, last_master_path)
for k in [".mps", ".svf"]:
last_master = get_last_master_path(study_output).with_suffix(k)
master = get_master_path(study_output).with_suffix(k)
tmp_last_master = get_tmp_master_path(last_master)
tmp_master = get_tmp_master_path(master)
rename_master(last_master, tmp_last_master)
rename_master(master, tmp_master)
remove_files_containing_str_from_dir(k, lp_dir)
rename_master(tmp_master, master)
rename_master(tmp_last_master, last_master)

remove_files_containing_str_from_dir('.lp', lp_dir)
remove_files_containing_str_from_dir(".zip", lp_dir)
Expand Down

0 comments on commit db3c016

Please sign in to comment.