@@ -119,13 +119,16 @@ def on_new_button_clicked(self):
119119 else :
120120 break
121121
122- # Create the new experiment and refresh the View
122+ # Create the new experiment and refresh the view
123123 if not self ._experiments_manager .add_experiment (experiment_name ):
124+ logger .error ('[MLC_MANAGER] [NEW_EXPERIMENT] - Experiment {0} could not be created. '
125+ 'Check it to be correct in your workspace' .format (experiment_name ))
124126 QMessageBox .critical (self , 'New Experiment' ,
125- ( 'Experiment {0} already exists but has errors . '
126- 'Check it to be correct in your workspace'
127- .format (experiment_name ) ))
127+ 'Experiment {0} could not be created . '
128+ 'Check the experiment to be correct in your workspace'
129+ .format (experiment_name ))
128130 return
131+
129132 self ._refresh_experiment_list_view ()
130133 self ._clean_experiment_selection ()
131134
@@ -151,8 +154,68 @@ def on_open_button_clicked(self):
151154 experiment .show ()
152155
153156 def on_clone_button_clicked (self ):
154- logger .debug ("[MLC_MANAGER] [CLONE_BUTTON] - Open button clicked" )
155- # TODO
157+ logger .debug ("[MLC_MANAGER] [CLONE_BUTTON] - Clone button clicked" )
158+ cloned_experiment = ""
159+ dialog_ok = False
160+
161+ if self ._experiment_selected is None :
162+ logger .info ("[MLC MANAGER] [OPEN_BUTTON] - No experiment was selected yet. Don't do anything" )
163+ return
164+ experiment_name = self ._experiment_selected
165+
166+ while True :
167+ cloned_experiment , dialog_ok = QInputDialog .getText (self , 'Clone Experiment' ,
168+ 'Enter the name of the new cloned experiment:' )
169+
170+ if dialog_ok :
171+ if cloned_experiment == "" :
172+ logger .info ('[MLC_MANAGER] [CLONE_EXPERIMENT] - Cloned experiment name cannot an empty string.' )
173+ msg_ok = QMessageBox .information (self , 'Clone Experiment' ,
174+ 'Cloned experiment name experiment cannot be an empty string. '
175+ 'Please, insert a valid name' ,
176+ QMessageBox .Ok | QMessageBox .Cancel ,
177+ QMessageBox .Ok )
178+
179+ if msg_ok == QMessageBox .Ok :
180+ continue
181+ else :
182+ break
183+
184+ # Check if the experiment already exists
185+ if cloned_experiment in self ._experiments_manager .get_experiment_list ():
186+ msg_ok = QMessageBox .question (self , 'Clone Experiment' ,
187+ ('The cloned experiment name has already been taken. '
188+ 'Do you want to create the project with a different name?' ),
189+ QMessageBox .Yes | QMessageBox .No ,
190+ QMessageBox .Yes )
191+ if msg_ok == QMessageBox .Yes :
192+ continue
193+ else :
194+ break
195+
196+ # Create the new experiment and refresh the View
197+ if not self ._experiments_manager .clone_experiment (experiment_name , cloned_experiment ):
198+ logger .error ('[MLC_MANAGER] [CLONE_EXPERIMENT] - Experiment {0} could not be created. '
199+ 'Check it to be correct in your workspace' .format (experiment_name ))
200+ QMessageBox .critical (self , 'Clone Experiment' ,
201+ 'Experiment {0} could not be cloned. '
202+ 'Check the experiment to be correct in your workspace'
203+ .format (experiment_name ))
204+ return
205+
206+ self ._refresh_experiment_list_view ()
207+ self ._clean_experiment_selection ()
208+
209+ QMessageBox .information (self , 'Clone Experiment' ,
210+ 'Experiment {0} was succesfully cloned. Cloned Experiment: {1}'
211+ .format (experiment_name , cloned_experiment ))
212+ logger .debug ('[MLC_MANAGER] [CLONE_EXPERIMENT] - Experiment {0} was succesfully cloned. '
213+ 'Cloned Experiment {1}' .format (experiment_name , cloned_experiment ))
214+ return
215+ else :
216+ break
217+ logger .debug ('[MLC_MANAGER] New experiment could not be cloned' )
218+
156219
157220 def on_remove_button_clicked (self ):
158221 logger .debug ("[MLC_MANAGER] [REMOVE_EXPERIMENT] - Remove button clicked" )
0 commit comments