Skip to content

Smart defaults not applied to Field cached attributes #67

Open
@mbarlow12

Description

@mbarlow12

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions