@@ -49,17 +49,14 @@ def define(cls, spec):
4949 """Define the process specification."""
5050
5151 super ().define (spec )
52- spec .expose_inputs (PwCalculation , namespace = 'pw' , exclude = ('kpoints' ,))
53- spec .input (
54- 'kpoints' ,
55- valid_type = orm .KpointsData ,
56- required = False ,
57- help = 'An explicit k-points list or mesh. Either this or `kpoints_distance` has to be provided.' ,
52+
53+ spec .expose_inputs (PwCalculation , exclude = ('kpoints' , 'metadata' ))
54+ spec .inputs .create_port_namespace ('options' ).absorb (
55+ PwCalculation .spec ().inputs .get_port ('metadata.options' )
5856 )
59- spec .input (
60- 'kpoints_distance' ,
61- valid_type = orm .Float ,
62- required = False ,
57+ spec .input ('kpoints' , valid_type = orm .KpointsData , required = False ,
58+ help = 'An explicit k-points list or mesh. Either this or `kpoints_distance` has to be provided.' )
59+ spec .input ('kpoints_distance' , valid_type = orm .Float , required = False ,
6360 help = 'The minimum desired distance in 1/Å between k-points in reciprocal space. The explicit k-points will '
6461 'be generated automatically by a calculation function based on the input structure.' ,
6562 )
@@ -207,15 +204,16 @@ def get_builder_from_protocol(
207204 natoms = len (structure .sites )
208205
209206 # Update the parameters based on the protocol inputs
210- parameters = inputs ['pw' ]['parameters' ]
207+ parameters = inputs ['parameters' ]
208+
209+ if overrides and 'pseudos' in overrides :
211210
212- if overrides and 'pseudos' in overrides .get ('pw' , {}):
213- pseudos = overrides ['pw' ]['pseudos' ]
211+ pseudos = overrides ['pseudos' ]
214212
215213 if sorted (pseudos .keys ()) != sorted (structure .get_kind_names ()):
216214 raise ValueError (f'`pseudos` override needs one value for each of the { len (structure .kinds )} kinds.' )
217215
218- system_overrides = overrides [ 'pw' ] .get ('parameters' , {}).get ('SYSTEM' , {})
216+ system_overrides = overrides .get ('parameters' , {}).get ('SYSTEM' , {})
219217
220218 if not all (key in system_overrides for key in ('ecutwfc' , 'ecutrho' )):
221219 raise ValueError (
@@ -280,30 +278,29 @@ def get_builder_from_protocol(
280278
281279 # If overrides are provided, they are considered absolute
282280 if overrides :
283- parameter_overrides = overrides .get ('pw' , {}). get ( ' parameters' , {})
281+ parameter_overrides = overrides .get ('parameters' , {})
284282 parameters = recursive_merge (parameters , parameter_overrides )
285283
286284 # if tot_magnetization in overrides , remove starting_magnetization from parameters
287285 if parameters .get ('SYSTEM' , {}).get ('tot_magnetization' ) is not None :
288286 parameters .setdefault ('SYSTEM' , {}).pop ('starting_magnetization' , None )
289287
290- metadata = inputs ['pw' ]['metadata' ]
288+ inputs_options = inputs ['options' ]
289+ inputs_options = cls .set_default_resources (inputs_options , code .computer .scheduler_type )
291290
292291 if options :
293- metadata ['options' ] = recursive_merge (metadata ['options' ], options )
294-
295- metadata ['options' ] = cls .set_default_resources (metadata ['options' ], code .computer .scheduler_type )
292+ inputs_options = recursive_merge (inputs ['options' ], options )
296293
297294 builder = cls .get_builder ()
298- builder . pw ['code' ] = code
299- builder . pw ['pseudos' ] = pseudos
300- builder . pw ['structure' ] = structure
301- builder . pw ['parameters' ] = orm .Dict (parameters )
302- builder . pw [ 'metadata ' ] = metadata
303- if 'settings' in inputs [ 'pw' ] :
304- builder . pw ['settings' ] = orm .Dict (inputs [ 'pw' ] ['settings' ])
305- if 'parallelization' in inputs [ 'pw' ] :
306- builder . pw ['parallelization' ] = orm .Dict (inputs [ 'pw' ] ['parallelization' ])
295+ builder ['code' ] = code
296+ builder ['pseudos' ] = pseudos
297+ builder ['structure' ] = structure
298+ builder ['parameters' ] = orm .Dict (parameters )
299+ builder [ 'options ' ] = inputs_options
300+ if 'settings' in inputs :
301+ builder ['settings' ] = orm .Dict (inputs ['settings' ])
302+ if 'parallelization' in inputs :
303+ builder ['parallelization' ] = orm .Dict (inputs ['parallelization' ])
307304 builder .clean_workdir = orm .Bool (inputs ['clean_workdir' ])
308305 if 'kpoints' in inputs :
309306 builder .kpoints = inputs ['kpoints' ]
@@ -324,7 +321,10 @@ def setup(self):
324321 default namelists for the ``parameters`` are set to empty dictionaries if not specified.
325322 """
326323 super ().setup ()
327- self .ctx .inputs = AttributeDict (self .exposed_inputs (PwCalculation , 'pw' ))
324+ self .ctx .inputs = AttributeDict (self .exposed_inputs (PwCalculation ))
325+ self .ctx .inputs .metadata = AttributeDict ({'options' : self .inputs .options })
326+ if 'disable_cache' in self .inputs .metadata :
327+ self .ctx .inputs .metadata .disable_cache = self .inputs .metadata .disable_cache
328328
329329 self .ctx .inputs .parameters = self .ctx .inputs .parameters .get_dict ()
330330 self .ctx .inputs .parameters .setdefault ('CONTROL' , {})
@@ -354,7 +354,7 @@ def validate_kpoints(self):
354354 kpoints = self .inputs .kpoints
355355 except AttributeError :
356356 inputs = {
357- 'structure' : self .inputs .pw . structure ,
357+ 'structure' : self .inputs .structure ,
358358 'distance' : self .inputs .kpoints_distance ,
359359 'force_parity' : self .inputs .get ('kpoints_force_parity' , orm .Bool (False )),
360360 'metadata' : {'call_link_label' : 'create_kpoints_from_distance' },
0 commit comments