Skip to content

auto-triage: guard bio1 objective assignment in reconstruct (issue #23)#4

Draft
jplfaria wants to merge 1 commit into
mainfrom
auto-triage/issue-23-bio1-objective-missing
Draft

auto-triage: guard bio1 objective assignment in reconstruct (issue #23)#4
jplfaria wants to merge 1 commit into
mainfrom
auto-triage/issue-23-bio1-objective-missing

Conversation

@jplfaria

Copy link
Copy Markdown
Contributor

Summary

  • Replaces unconditional model.objective = "bio1" in the reconstruct task with _set_biomass_objective() helper that falls back gracefully when bio1 is absent.
  • Applies the same fix to the subprocess fallback job_scripts/reconstruct.py.
  • Removes the duplicate try/except at line 1266 of tasks.py in favour of the shared helper.

Root cause

build_metabolic_model does not guarantee the biomass reaction is always named bio1. For models built from non-standard templates or sparse genomes the biomass reaction may be named differently (bio2, BIOMASS_*, etc.), causing cobra to raise ValueError: invalid objective.

Fixes ModelSEED/modelseed-api-ops#23

Test plan

  • New unit tests in tests/unit/test_set_biomass_objective.py cover: bio1 present, bio1 absent with fallback, no biomass reactions (silent skip), empty model.
  • Run pytest tests/unit/ locally.

Models built from non-standard templates may not have a 'bio1'
reaction, causing ValueError: invalid objective at save time.
Use _set_biomass_objective() which falls back to the first biomass-like
reaction and silently skips if none is found.

Fixes ModelSEED/modelseed-api-ops#23

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant