Skip to content

Commit

Permalink
Don't delete previous directory (useless)
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonMarechal25 committed Oct 24, 2023
1 parent 2f1c008 commit 6f6775a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
13 changes: 5 additions & 8 deletions src/python/antares_xpansion/full_run_driver.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

from typing import List
import os
import subprocess
import sys
from pathlib import Path
from typing import List

from antares_xpansion.benders_driver import BendersDriver
from antares_xpansion.problem_generator_driver import ProblemGeneratorDriver
from antares_xpansion.logger import step_logger
from antares_xpansion.problem_generator_driver import ProblemGeneratorDriver
from antares_xpansion.study_output_cleaner import StudyOutputCleaner
import os
from pathlib import Path


class FullRunDriver:
Expand All @@ -29,9 +29,6 @@ def prepare_drivers(self, output_path: Path,
"""
problem generation step : getnames + lp_namer
"""
# Pb Gen pre-step
self.problem_generation_driver.clear_old_log()

self.problem_generation_driver.is_relaxed = problem_generation_is_relaxed

self.keep_mps = benders_keep_mps
Expand Down
27 changes: 14 additions & 13 deletions src/python/antares_xpansion/problem_generator_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

import os
import shutil
import subprocess
import sys
from dataclasses import dataclass
Expand Down Expand Up @@ -66,26 +65,30 @@ def launch(self, output_path: Path, is_relaxed: bool):
"""
problem generation step : getnames + lp_namer
"""
self.clear_old_log()
self.logger.info("Problem Generation")
self.output_path = output_path

self.create_lp_dir()

self.is_relaxed = is_relaxed
self._lp_step()

def set_output_path(self, output_path):
self._output_path = output_path
self.xpansion_output_dir = output_path.parent / \
(output_path.stem + "-Xpansion")
self._lp_path = os.path.normpath(
os.path.join(self.xpansion_output_dir, 'lp'))

if output_path.exists():
self._output_path = output_path
self.xpansion_output_dir = output_path.parent / \
(output_path.stem + "-Xpansion")
os.makedirs(self.xpansion_output_dir)
self._lp_path = os.path.normpath(
os.path.join(self.xpansion_output_dir, 'lp'))
else:
raise ProblemGeneratorDriver.OutputPathError(
f"{output_path} not found")

def get_output_path(self):
return self._output_path

def clear_old_log(self):
if (os.path.isfile(str(self.lp_namer_exe_path) + '.log')):
os.remove(str(self.lp_namer_exe_path) + '.log')

def _lp_step(self):
"""
copies area and interco files and launches the lp_namer
Expand All @@ -101,8 +104,6 @@ def _lp_step(self):
"ERROR: exited lpnamer with status %d" % returned_l.returncode)

def create_lp_dir(self):
if os.path.isdir(self._lp_path):
shutil.rmtree(self._lp_path)
os.makedirs(self._lp_path)

def lp_namer_options(self):
Expand Down

0 comments on commit 6f6775a

Please sign in to comment.