def test_stage_out_to_operation_folder(self, mocker, operation_factory, simulator_factory, pse_burst_configuration_factory): burst = pse_burst_configuration_factory(self.test_project) op = operation_factory(test_user=self.test_user, test_project=self.test_project) op.fk_operation_group = burst.fk_operation_group dao.store_entity(op) sim_folder, sim_gid = simulator_factory(op=op) burst.simulator_gid = sim_gid.hex dao.store_entity(burst) output_path = self._do_operation_launch(op, sim_gid, mocker, is_pse=True) def _stage_out_dummy(dir, sim_gid): return [ os.path.join(output_path, enc_file) for enc_file in os.listdir(output_path) ] mocker.patch.object(HPCSchedulerClient, '_stage_out_results', _stage_out_dummy) sim_results_files, metric_op, metric_file = HPCSchedulerClient.stage_out_to_operation_folder( None, op, sim_gid) assert op.id != metric_op.id assert os.path.exists(metric_file) assert len(sim_results_files) == 1 assert os.path.exists(sim_results_files[0])
def _operation_finished(operation, simulator_gid): op_ident = dao.get_operation_process_for_operation(operation.id) # TODO: Handle login job = Job( Transport(os.environ[HPCSchedulerClient.CSCS_LOGIN_TOKEN_ENV_KEY]), op_ident.job_id) operation = dao.get_operation_by_id(operation.id) folder = HPCSchedulerClient.storage_interface.get_project_folder( operation.project.name) storage_interface = StorageInterface() if storage_interface.encryption_enabled(): storage_interface.inc_project_usage_count(folder) storage_interface.sync_folders(folder) try: sim_h5_filenames, metric_op, metric_h5_filename = \ HPCSchedulerClient.stage_out_to_operation_folder(job.working_dir, operation, simulator_gid) operation.mark_complete(STATUS_FINISHED) dao.store_entity(operation) HPCSchedulerClient().update_db_with_results( operation, sim_h5_filenames, metric_op, metric_h5_filename) except OperationException as exception: HPCOperationService.LOGGER.error(exception) HPCOperationService._operation_error(operation) finally: if storage_interface.encryption_enabled(): storage_interface.sync_folders(folder) storage_interface.set_project_inactive(operation.project)
def _operation_finished(operation, simulator_gid): op_ident = dao.get_operation_process_for_operation(operation.id) # TODO: Handle login job = Job( Transport(os.environ[HPCSchedulerClient.CSCS_LOGIN_TOKEN_ENV_KEY]), op_ident.job_id) sim_h5_filenames, metric_op, metric_h5_filename = \ HPCSchedulerClient.stage_out_to_operation_folder(job.working_dir, operation, simulator_gid) operation.mark_complete(STATUS_FINISHED) dao.store_entity(operation) HPCSchedulerClient().update_db_with_results(operation, sim_h5_filenames, metric_op, metric_h5_filename)