You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 to attr_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.
The text was updated successfully, but these errors were encountered:
Since
Field:cache_attributes
is called at initialization, all attributes defined onself
in that method aren't updated in the call toSmartDefault:apply
.I've confirmed this by investigating the following from within
Field:run
afterField:finalize_process_graph
is called:Thus, any process that references a property on the
Field
object won't be reading the updated value.The fix is pretty small: callField:cache_attributes
immediately afterSmartDefault.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:attr_object.some_attribute
toattr_object.attr('some_attribute')
@property
(reference) to always fetch a computed value__getattr__
and or__getattribute__
to forward arbitrary property access to the field objectFor the latter 2, there would still be ways to cache the values if needed.
The text was updated successfully, but these errors were encountered: