diff --git a/litesoph/common/task.py b/litesoph/common/task.py index 04652cbd..e9c7a36e 100644 --- a/litesoph/common/task.py +++ b/litesoph/common/task.py @@ -191,7 +191,14 @@ def run_job_local(self,cmd): def connect_to_network(self, *args, **kwargs): self.submit_network = SubmitNetwork(self, *args, **kwargs) - def run_job_network(): + def run_job_network(self,): + pass + + def post_run(self,): + """ + Called at the end of the task when proceed button is pressed. + Usually to copy engine files to task directory, write the code here. + """ pass def read_log(self, file): diff --git a/litesoph/common/workflows_data.py b/litesoph/common/workflows_data.py index 09053b63..12324990 100644 --- a/litesoph/common/workflows_data.py +++ b/litesoph/common/workflows_data.py @@ -154,8 +154,8 @@ class step: 'properties':['mo_population'], }, {'laser': True}), - step(2 ,2 ,tt.COMPUTE_SPECTRUM), - step(3 ,3 ,tt.MO_POPULATION)], + step(2 ,2 ,tt.MO_POPULATION), + ], "dependency_map": {'0' : None, '1' : '0', diff --git a/litesoph/engines/gpaw/gpaw_input.py b/litesoph/engines/gpaw/gpaw_input.py index 2754cc0c..39b82243 100644 --- a/litesoph/engines/gpaw/gpaw_input.py +++ b/litesoph/engines/gpaw/gpaw_input.py @@ -59,7 +59,8 @@ "atoms.center(vacuum={vacuum})\n", """ -initial_calc = GPAW(mode='{mode}', xc='{xc}', txt='no_of_electrons.out') +#This initial_calc is just to compute the no. of electrons. The gs and td will take the params inputted by the user. +initial_calc = GPAW(mode='lcao', xc='PBE', txt='no_of_electrons.out') atoms.set_calculator(initial_calc) atoms.get_potential_energy() diff --git a/litesoph/engines/octopus/octopus_task.py b/litesoph/engines/octopus/octopus_task.py index 1aa8d900..e617bc84 100644 --- a/litesoph/engines/octopus/octopus_task.py +++ b/litesoph/engines/octopus/octopus_task.py @@ -445,6 +445,8 @@ def get_engine_log(self): def plot(self,**kwargs): """Method related to plot in post-processing""" + self.post_run() + if self.task_name == tt.COMPUTE_SPECTRUM: energy_min = self.task_info.param['e_min'] energy_max = self.task_info.param['e_max'] @@ -507,8 +509,6 @@ def run_job_local(self,cmd): return cmd = cmd + ' ' + self.BASH_filename self.submit_local.run_job(cmd) - if self.check_run_status()[0]: - self.post_run() def get_ksd_popln(self): td_info = self.dependent_tasks[1] @@ -628,6 +628,7 @@ def compute_avg_spectra(self): def plot(self, data_type='average', **kwargs): """Method to plot average, summed, or subtracted spectrum based on polarization status.""" from litesoph.visualization.plot_spectrum import plot_spectrum + self.post_run() energy_min = self.task_info.param['e_min'] energy_max = self.task_info.param['e_max'] @@ -716,7 +717,8 @@ def generate_tas_data(self): delay_list,spectrum_data_list=get_spectrums_delays(self.task_info,self.dependent_tasks,self.project_dir,self.only_workflow_dirpath) prepare_tas_data(spectrum_data_list,delay_list,contour_x_data_file,contour_y_data_file,contour_z_data_file) - def plot(self,delay_min=None,delay_max=None,freq_min=None,freq_max=None): + def plot(self,delay_min=None,delay_max=None,freq_min=None,freq_max=None): + self.post_run() from litesoph.visualization.plot_spectrum import contour_plot x_data = np.loadtxt(self.project_dir.parent /self.only_workflow_dirpath/ (self.task_info.output.get('contour_x_data'))) y_data = np.loadtxt(self.project_dir.parent /self.only_workflow_dirpath/ (self.task_info.output.get('contour_y_data'))) diff --git a/litesoph/gui/workflow_controller.py b/litesoph/gui/workflow_controller.py index 64b1f832..58ff30b8 100644 --- a/litesoph/gui/workflow_controller.py +++ b/litesoph/gui/workflow_controller.py @@ -45,9 +45,31 @@ def start(self, workflow_manager: WorkflowManager): self.task_mode_workflow = self.workflow_manager.task_mode self.workmanager_page = self.project_controller.workmanager_page self.start_task() - + + def check_pg(self): + # Make it False so that you can queue multiple jobs. + # Change to True under parental guidance only + PG_PROCEED = False + if hasattr(self.task_controller.task, 'submit_network') and self.task_controller.task.submit_network is not None: + is_remote_job_done = PG_PROCEED or (self.task_controller.task.submit_network.check_job_status()) + if not is_remote_job_done: + messagebox.showwarning(title='Warning', message="The task has not yet completed. Please wait for the task to complete on the remote machine.") + # TODO: Check if the task output is valid or not? + # messagebox.showerror(title= 'Error', message = "Task output is not valid.") + return True + return False def show_workmanager_page(self, *_): + if hasattr(self, 'task_controller') and self.check_pg(): + return + try: + self.task_controller.task.post_run() + except: + messagebox.showwarning( + title = "Warning", + message = "There was some error running post run tasks for current task."+ + "Possiblity that some output files couldn't be copyied to task folder." + ) self.workmanager_page._var['select_wf_option'].set(value=2) self.workmanager_page.tkraise() self.app.proceed_button.config(command= self.start_task, state = 'normal') @@ -262,23 +284,20 @@ def start_task(self, *_): self.workflow_navigation_view.start(block_id) self.task_controller.set_task(self.workflow_manager, task_view) - def check_pg(self): - # Make it False so that you can queue multiple jobs. - PG_PROCEED = False - if hasattr(self.task_controller.task, 'submit_network') and self.task_controller.task.submit_network is not None: - is_remote_job_done = PG_PROCEED or (self.task_controller.task.submit_network.check_job_status()) - if not is_remote_job_done: - messagebox.showwarning(title='Warning', message="The task has not yet completed. Please wait for the task to complete on the remote machine.") - # TODO: Check if the task output is valid or not? - # messagebox.showerror(title= 'Error', message = "Task output is not valid.") - return True - return False - def next_task(self): # Make it False so that you can queue multiple jobs. if self.check_pg(): return self.app.proceed_button.config(state = 'disabled') + + try: + self.task_controller.task.post_run() + except: + messagebox.showwarning( + title = "Warning", + message = "There was some error running post run tasks for current task."+ + "Possiblity that some output files couldn't be copyied to task folder." + ) try: self.workflow_manager.next() except TaskSetupError as e: @@ -307,4 +326,4 @@ def get_task_controller( task_view, workflow_controller, app) -> TaskController: else: task_controller = TaskController - return task_controller(workflow_controller, app) \ No newline at end of file + return task_controller(workflow_controller, app)