Unverified Commit 593d2d20 authored by Junwei Sun's avatar Junwei Sun Committed by GitHub
Browse files

fix nnictl experiment delete (delete log folder in ~/.local/nnictl) (#2799)

parent bbb9137c
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
import os import os
import json import json
import shutil
from .constants import NNICTL_HOME_DIR from .constants import NNICTL_HOME_DIR
from .command_utils import print_error
class Config: class Config:
'''a util class to load and save config''' '''a util class to load and save config'''
...@@ -77,7 +79,13 @@ class Experiments: ...@@ -77,7 +79,13 @@ class Experiments:
def remove_experiment(self, expId): def remove_experiment(self, expId):
'''remove an experiment by id''' '''remove an experiment by id'''
if expId in self.experiments: if expId in self.experiments:
self.experiments.pop(expId) fileName = self.experiments.pop(expId).get('fileName')
if fileName:
logPath = os.path.join(NNICTL_HOME_DIR, fileName)
try:
shutil.rmtree(logPath)
except FileNotFoundError:
print_error('{0} does not exist.'.format(logPath))
self.write_file() self.write_file()
def get_all_experiments(self): def get_all_experiments(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment