-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KeyError: 'CONTROL' #970
Comments
Thanks for the report. Could you please try to run the exact same script, but change the top-level keys in the parameters = Dict({
'CONTROL': {
'calculation': 'scf',
'verbosity': 'high'
},
'SYSTEM': {
'ecutwfc': cutoff_wfc, # wave function cutoff in Ry
'ecutrho': cutoff_rho, # density cutoff in Ry
},
}) Notice that |
hi Sebastiaan, |
I am a bit surprised that you mention that this used to work for you. I did some testing and this behavior goes back to at least v3.3.0. The problem is that the I noted this problematic behavior already 5 years ago: #121 |
@sphuber I agree that we need to make sure the casing is consistent. Else anywhere you check an input parameter or setting (not just in One idea I was still toying with was to "fix" the casing using a serializer: import warnings
from aiida.engine import WorkChain
from aiida_quantumespresso.calculations import _uppercase_dict as uppercase_dict
class MyWorkChain(WorkChain):
@classmethod
def define(cls, spec):
super().define(spec)
# Define the inputs
spec.input(
'input_parameters',
valid_type=orm.Dict,
required=True,
serializer=cls.serialize_input_parameters,
)
# Define the outline of the work chain
spec.outline(
cls.report_input,
)
def report_input(self):
self.report(f"Input parameters: {self.inputs.input_parameters.get_dict()}")
@staticmethod
def serialize_input_parameters(value):
"""Validate the input parameters."""
input_parameters = value.get_dict()
has_lowercase = any(any(char.islower() for char in key) for key in input_parameters.keys())
if has_lowercase:
warnings.warn("At least one top-level key has a lowercase character. Setting to uppercase.")
return orm.Dict(dict=uppercase_dict(input_parameters, 'parameters')) But I quickly reliased that serializers only act upon non- Is there a feature for updating an input port that I'm now aware of? Would it make sense to allow this for the current My thinking is that we can enforce the casing on the fly, warning the user that we made these changes. At least @unkcpz seems to also think this is the way to go. ^^ EDIT: Also: I don't think we have to wait for v5.0 to enforce this, since running with lowercase will most likely not work anywhere? |
No, the serializers would be it.
Perhaps. The request has been made before to make it act on non- One concrete downside of allowing |
Thanks @sphuber, you make some valid points. I agree that adapting the Instead let's:
Side note: Part of me likes the idea of having serializers and users just passing in regular Python types (or e.g. a |
The idea has been floated to add the
This was the very reason that we originally decided against this. Also for not adding this automatic serialization to process functions. However, as of v2.3 we actually added the
And what are those conventions? 😄 Upper- or lowercase? |
I am trying a test installation of aiida with qe espresson (7.0,7.1 soon 7.2) and I am getting the error above, full trace is below. (I did not have issues in the past)
the script I test with is also below.
calculation itself runs correctly
The text was updated successfully, but these errors were encountered: