Skip to content

Make _recompile derived state computed from _changes #74

@wshlavacek

Description

@wshlavacek

Location:

  • bionetgen/modelapi/blocks.py:46 (docstring on _recompile)
  • bionetgen/modelapi/blocks.py:142 (reset_compilation_tags body)

Original markers:

_recompile : bool
    a tag that tells a potential future simulator if the model
    needs to be recompiled. TODO: has to be computed from _changes
    property upon get request.
def reset_compilation_tags(self) -> None:
    # TODO: Make these properties such that it checks each
    # item for changes/recompile tags
    # for item in self.items:
    #     self.items[item]._recompile = False
    #     self.items[item]._changes = {}

_recompile is currently an imperative bool flag set to True in add_item and reset by reset_compilation_tags. It can drift out of sync with the actual _changes dict — e.g. if items are mutated through their own _changes machinery without going through the block's add_item path.

Recent context: 8de992a (Deduplicate block __setattr__ via shared helper) routed all 17 subclass setters through _set_item_attribute, which uniformly writes self._changes[name] = value. That makes _changes the canonical source of truth for "this block has been edited," which in turn makes deriving _recompile straightforward.

What would unblock this: convert _recompile to a @property that returns bool(self._changes) (or any(item._recompile for item in self.items.values()) if per-item tracking is required). Apply the same shape for cascading resets across child items if needed.

Discovered during: non-Atomizer TODO/FIXME triage sweep, 2026-05-08.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions