Skip to content

Deduplicate block __setattr__ logging paths and add regression tests #106

@wshlavacek

Description

@wshlavacek

Summary

Several model/network block classes have near-duplicate __setattr__ implementations for updating named items and warning on invalid assignments. This came up while working on the now-closed PR #100 (block-setattr-logging-dedup). Rather than reviving that stale branch directly, this issue captures the underlying cleanup opportunity.

Suggested cleanup

  • Deduplicate the repeated block __setattr__ paths in bionetgen/modelapi/blocks.py and bionetgen/network/blocks.py behind a shared helper or similarly small abstraction.
  • Preserve existing warning text/behavior for numeric assignment failures, especially parameter value and compartment size warnings.
  • Route remaining invalid-assignment warnings consistently through BNGLogger rather than mixing logger calls and print(...).
  • Add focused regression tests covering invalid assignments for model and network block subclasses.

Why

This is not an urgent bug fix, but it would reduce maintenance risk in fragile legacy block code. The main value is preventing future behavior drift when similar warning/update logic is changed in one block class but not another.

Notes

The stale branch/closed PR may still be useful as a reference, but the eventual fix should be based on current main rather than reopening that branch as-is.

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