def init_next_workchain(self): """Initialize the next workchain.""" # Elevate iteration index self.ctx.iteration += 1 # Check that the context inputs exists try: self.ctx.inputs except AttributeError: raise ValueError( 'No input dictionary was defined in self.ctx.inputs') # Take the exposed inputs and add them to the context input. This would # be the inputs you supply to this workchain self.ctx.inputs.update(self.exposed_inputs(self._next_workchain)) # We did not expose the structure as we would like to set this # from the supplied structures input. Just choose any item in the # structures dictionary and asign that to the next run. item = random.choice(list(self.ctx.structures.keys())) self.ctx.inputs.structure = self.ctx.structures.pop(item) # Make sure we do not have any floating dict (convert to Dict etc.) self.ctx.inputs = prepare_process_inputs(self.ctx.inputs)
def init_next_workchain(self): """Initialize the next workchain.""" try: self.ctx.inputs except AttributeError: raise ValueError( 'No input dictionary was defined in self.ctx.inputs') # Add exposed inputs self.ctx.inputs.update(self.exposed_inputs(self._next_workchain)) # Make sure we do not have any floating dict (convert to Dict) self.ctx.inputs = prepare_process_inputs(self.ctx.inputs)
def run_calculation(self): """Run a new calculation, taking the input dictionary from the context at self.ctx.inputs.""" self.ctx.iteration += 1 try: unwrapped_inputs = self.ctx.inputs except AttributeError: raise ValueError( 'no calculation input dictionary was defined in self.ctx.inputs' ) inputs = prepare_process_inputs(unwrapped_inputs) running = self.submit(self._calculation, **inputs) self.report('launching {}<{}> iteration #{}'.format( self._calculation.__name__, running.pk, self.ctx.iteration)) # pylint: disable=not-callable return self.to_context(calculations=append_(running))
def init_next_workchain(self): """Initialize the next workchain calculation.""" if not self.ctx.is_converged: self.ctx.iteration += 1 try: self.ctx.inputs except AttributeError: raise ValueError( 'no input dictionary was defined in self.ctx.inputs') # Set structure self.ctx.inputs.structure = self.ctx.current_structure # Add exposed inputs self.ctx.inputs.update(self.exposed_inputs(self._next_workchain)) # Make sure we do not have any floating dict (convert to Dict etc.) self.ctx.inputs_ready = prepare_process_inputs(self.ctx.inputs, namespaces=['verify'])