Closed smithsp closed 4 years ago
How about this?
import omas
ods = omas.ODS()
ods.consistency_check = 'warn'
ods['nbi']['unit']['this_path_does_not_exist'] = 2
ods.consistency_check = True
I get the output:
Not a valid IMAS 3.25.0 location: nbi.unit.this_path_does_not_exist
Not a valid IMAS 3.25.0 location: nbi.unit.this_path_does_not_exist
Not a valid IMAS 3.25.0 location: nbi.unit.this_path_does_not_exist
Not a valid IMAS 3.25.0 location: nbi.unit.this_path_does_not_exist
Not a valid IMAS 3.25.0 location: nbi.unit.this_path_does_not_exist
Not a valid IMAS 3.25.0 location: nbi.unit.this_path_does_not_exist
Traceback (most recent call last):
File "test_omas.py", line 5, in <module>
ods.consistency_check = True
File "/home/smithsp/omas/omas/omas_core.py", line 371, in consistency_check
self.getraw(item).consistency_check = consistency_value_propagate
File "/home/smithsp/omas/omas/omas_core.py", line 371, in consistency_check
self.getraw(item).consistency_check = consistency_value_propagate
File "/home/smithsp/omas/omas/omas_core.py", line 358, in consistency_check
raise LookupError(underline_last(text, len('LookupError: ')) + '\n' + options)
LookupError: Not a valid IMAS 3.25.0 location: nbi.unit.this_path_does_not_exist
^^^^^^^^^^^^^^^^^^^^^^^^
A numerical index is needed with n>=0
(These were done on the fix_consistency_check branch.)
fixed with #81
@orso82, these results actually appeared even on the branch of #81 , so #81 did not fix these problems.
I read better now what this issue was about. The OMAS behavior was as intended. No ODS with consistency_check=True
can violate the IMAS schema. As you pointed out the error was raised when you get out of the omas_environment
with consistency_check=False
, which is the expected behavior. I have improved the error message to make it clearer that this a feature and not a bug.
Note that there is some coding in OMFIT that is similar to what I tried with the context, and that should probably be modified or removed.
Is the following supposed to work?
I get the error:
when the context exits.