Description
Since Field:cache_attributes
is called at initialization, all attributes defined on self
in that method aren't updated in the call to SmartDefault:apply
.
I've confirmed this by investigating the following from within Field:run
after Field:finalize_process_graph
is called:
$> self.attr('num_prod_wells') # result of the smart default for 'num_prod_wells'
> <Quantity(10449, 'dimensionless')>
$> self.num_prod_wells
> <Quantity(24.0, 'dimensionless')>
Thus, any process that references a property on the Field
object won't be reading the updated value.
The fix is pretty small: call Field:cache_attributes
immediately after SmartDefault.apply_defaults()
. This would update all the direct references found in the codebase.
EDIT: All children of the field call cache_attributes
before the smart defaults are applied, so their properties retain the original default values. Options for fixes:
- no properties are directly referenced, update all instances of
attr_object.some_attribute
toattr_object.attr('some_attribute')
- use
@property
(reference) to always fetch a computed value - leverage
__getattr__
and or__getattribute__
to forward arbitrary property access to the field object
For the latter 2, there would still be ways to cache the values if needed.