Skip to content

Commit

Permalink
Forcing cleaning of input/output folders for every run. [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
dbouget committed Feb 17, 2023
1 parent 816133b commit 2a3225a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
16 changes: 15 additions & 1 deletion Raidionics/Raidionics/src/RaidionicsLogic.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,15 @@ def executeDocker(self, dockerName, modelName, dataPath, iodict, inputs, outputs
if self.logic_task == 'diagnosis':
dataPath = '/home/ubuntu/Raidionics-segmenter/resources'

# Cleaning input/output folders for every run
if os.path.exists(SharedResources.getInstance().data_path):
shutil.rmtree(SharedResources.getInstance().data_path)
os.makedirs(SharedResources.getInstance().data_path)

if os.path.exists(SharedResources.getInstance().output_path):
shutil.rmtree(SharedResources.getInstance().output_path)
os.makedirs(SharedResources.getInstance().output_path)

# if widgetPresent:
# self.cmdStartEvent()
try:
Expand Down Expand Up @@ -372,7 +381,8 @@ def executeDocker(self, dockerName, modelName, dataPath, iodict, inputs, outputs
fileName = 'input_t1gd' + self.file_extension_docker
inputDict[item] = fileName
input_timestamp_order = iodict[item]["timestamp_order"]
os.makedirs(str(os.path.join(SharedResources.getInstance().data_path, "T" + input_timestamp_order)))
os.makedirs(str(os.path.join(SharedResources.getInstance().data_path,
"T" + input_timestamp_order)), exist_ok=True)
sitk.WriteImage(img, str(os.path.join(SharedResources.getInstance().data_path,
"T" + input_timestamp_order, fileName)))
except Exception as e:
Expand Down Expand Up @@ -433,6 +443,10 @@ def updateOutput(self, iodict, outputs, widgets):
created_files.append(file)
break

if len(created_files) == 0:
logging.warning("No results were generated! If no other error message was printed, it might indicate an"
"issue with Docker. Make sure the Docker service is running.")

for item in iodict:
if iodict[item]["iotype"] == "output":
if iodict[item]["type"] == "volume":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self, parent=None):
self.setLayout(self.base_layout)
self.setup_connections()
# self.on_diagnosis_selection(0)
self.json_diagnoses = []
self.populate_local_diagnosis()
self.populate_cloud_diagnosis()

Expand Down Expand Up @@ -239,7 +240,7 @@ def on_cloud_diagnosis_download_selected(self):

def find_json_model(self, selected_model_name):
json_model = None
for m in self.jsonModels:
for m in self.json_diagnoses:
if m['name'] == selected_model_name:
json_model = m
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, parent=None):
self.setLayout(self.base_layout)
self.setup_connections()
# self.on_model_selection(0)
self.jsonModels = []
self.populate_local_models()
self.populate_cloud_models()

Expand Down

0 comments on commit 2a3225a

Please sign in to comment.