Skip to content

Commit

Permalink
Fix bug in the 'rename' command (Cmd-Line tool)
Browse files Browse the repository at this point in the history
the 'rename' command only worked when the model to be renamed had an
evaluation history file created, which makes no sense. Users should be
able to rename their models anytime, regardless of whether your model
has been evaluated or not.
  • Loading branch information
sergioburdisso committed Feb 15, 2020
1 parent 66a0c4a commit cd42b61
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions pyss3/cmd_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,15 @@ def do_rename(self, args):
"""
Rename the current model with a given name.
usage:
rename NEW_MODEL_NAME
required arguments:
NEW_MODEL_NAME the model's new name
"""
"""
Rename the current model with a given name.
usage:
rename NEW_MODEL_NAME
Expand All @@ -1352,26 +1361,25 @@ def do_rename(self, args):
if len(args) == 1:
m_folder = CLF.__models_folder__
m_name = CLF.__name__
m_ext = STR_MODEL_EXT
model_file = path.join(m_folder, "%s.%s" % (m_name, m_ext))
model_new_file = path.join(m_folder, "%s.%s" % (args[0], m_ext))
rh_ext = RESULT_HISTORY_EXT
rh_file = path.join(m_folder, m_name + rh_ext)
rh_new_file = path.join(m_folder, args[0] + rh_ext)

rename = True
if path.exists(rh_new_file):
if path.exists(model_new_file):
print()
Print.warn(WARN_OVERWRITE, False)
if input() != 'Y':
rename = False

if rename:
rename_file(rh_file, rh_new_file)

m_ext = STR_MODEL_EXT
model_file = path.join(m_folder, "%s.%s" % (m_name, m_ext))
model_new_file = path.join(
m_folder, "%s.%s" % (args[0], m_ext)
)
rename_file(model_file, model_new_file)
if path.exists(rh_file):
rename_file(rh_file, rh_new_file)
if path.exists(model_file):
rename_file(model_file, model_new_file)
CLF.__name__ = args[0]
else:
Print.error(ERROR_WAN % (1, len(args)))
Expand Down

0 comments on commit cd42b61

Please sign in to comment.