Repository navigation
PyMOL plugin: edit only the targeted object, and align console commands with the panel - #22
AtharvaTilewale wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
- bridge.py: make _replace_pymol_object transactional for untracked objects
(rename-load-delete) so a failed replacement restores an object the user
loaded directly with cmd.load, not just plugin-tracked objects.
- commands.py: aw_load now uses build_load_config's default assembly ('1'),
matching the GUI Load dialog, instead of assembly='first'.
- state.py: pop_snapshot refuses to resurrect an object deleted directly in
PyMOL, mirroring get_synced_array's forget-on-delete behaviour.
- tests/conftest.py: guard the real 'import pymol' (not just find_spec) in
try/except, setting collect_ignore_glob on any import failure.
- tests/test_review_fixes.py: add regression tests for each fix.
|
Thanks — all four points addressed in the latest commit:
Four regression tests, each failing before and passing after. |
- bridge.py: make _replace_pymol_object transactional for untracked objects
(rename-load-delete) so a failed replacement restores an object the user
loaded directly with cmd.load, not just plugin-tracked objects.
- commands.py: aw_load now uses build_load_config's default assembly ('1'),
matching the GUI Load dialog, instead of assembly='first'.
- state.py: pop_snapshot refuses to resurrect an object deleted directly in
PyMOL, mirroring get_synced_array's forget-on-delete behaviour.
- tests/conftest.py: guard the real 'import pymol' (not just find_spec) in
try/except, setting collect_ignore_glob on any import failure.
- tests/test_review_fixes.py: add regression tests for each fix.
37d2459 to
f2e87c8
Compare
Addresses the second review on RosettaCommons#22: the conftest caught every Exception, so a regression in finish_launching() or in the plugin's own imports would quietly ignore the whole PyMOL test package and give a false-green run. The guard now covers only the dependency check (import pymol, from pymol import cmd) and only the errors it raises (ImportError, OSError). Launch failures and plugin import errors propagate and fail collection. Tests cover both kinds of unusable PyMOL and both kinds of regression.
- aw_load always used the rcsb preset, which silently discards saved annotations (inverse_folding.cif: 0 of 105 sequence-conditioned atoms kept). It now infers the preset like the Load dialog. - aw_insert_segment anchored an 'after' insertion on the first selected atom; the panel uses the last. - The plugin test package now ignores itself when PyMOL is missing. Its module-level importorskip ended the whole pytest session during collection.
- selection_to_indices takes the target object and restricts the selection to it; every panel, wizard, editor and aw_* caller passes the object it edits, so atoms of another loaded object with the same identity keys are no longer mapped into the active document (F05). aw_delete/aw_insert_segment restrict to the target object and no longer fall back to the unrestricted selection (F06). A missing selection returns [] so buttons show "No selection" instead of raising CmdException (F32). - load_structure and combine_visible load into PyMOL first (deleting any existing object of that name) and commit STATE only on success; a fresh load gets a new document and undo history (F07). Object names are converted with cmd.get_legal_name, so no ghost object is tracked (F14). - Reset Res ID, chain assignment and protonation go through STATE.set_array so the structure version is bumped and stale picked keys are rejected (F15). - aw_save uses the same validation, pre-save hooks and chain_iid writer as the GUI via a new Qt-free saving module (F16). - Bond and pair atom picking switches PyMOL to atom selection mode while picking and rejects multi-atom or other-object selections (F18). - An object deleted in PyMOL is forgotten instead of being reloaded (F22).
- bridge.py: make _replace_pymol_object transactional for untracked objects
(rename-load-delete) so a failed replacement restores an object the user
loaded directly with cmd.load, not just plugin-tracked objects.
- commands.py: aw_load now uses build_load_config's default assembly ('1'),
matching the GUI Load dialog, instead of assembly='first'.
- state.py: pop_snapshot refuses to resurrect an object deleted directly in
PyMOL, mirroring get_synced_array's forget-on-delete behaviour.
- tests/conftest.py: guard the real 'import pymol' (not just find_spec) in
try/except, setting collect_ignore_glob on any import failure.
- tests/test_review_fixes.py: add regression tests for each fix.
Addresses the second review on RosettaCommons#22: the conftest caught every Exception, so a regression in finish_launching() or in the plugin's own imports would quietly ignore the whole PyMOL test package and give a false-green run. The guard now covers only the dependency check (import pymol, from pymol import cmd) and only the errors it raises (ImportError, OSError). Launch failures and plugin import errors propagate and fail collection. Tests cover both kinds of unusable PyMOL and both kinds of regression.
f2e87c8 to
df3ea24
Compare
|
Rebased onto current No conflicts; 23 of the 27 new tests fail against |

What this fixes
Edits could land on the wrong object.
selection_to_indicesmappedcmd.get_model(selection)atoms onto one object's index map by(chain, res_id, ins_code, atom_name). With two structures loaded, atoms selected in one were applied to the other. Reproduced: two copies ofmotif_scaffolding.cif, 3 atoms selected inobjB,aw_deletewithobjAactive → 3 atoms deleted fromobjA.selection_to_indicestakes the object it edits and evaluates(sel) and model <obj>. Every plugin caller passes it: panel delete and insert, charge, chain and bond wizards, editors andaw_*commands._selection_to_indices_for_active, which restricted toSTATE.activeand then fell back to the unrestricted selection, is removed.selection 'sele' matched no atoms in 'objA'.Other fixes
aw_loadalways used thercsbpreset, which discards saved annotations: 0 of 105 sequence-conditioned atoms kept oninverse_folding.cif. It now infers the preset like the Load dialog.aw_insert_segmentanchored an after insertion on the first selected atom; the panel uses the last.aw_savenow shares the GUI save path through a new Qt-freesaving.py(chain_disambiguation, pre-save hooks, issue reporting), so homo-oligomer saves work.panel.register_pre_save_hookis re-exported, so providers are unchanged.cmd.get_legal_nameinstead of leaving a ghost entry in STATE. For example,firstbecomesfirst_.STATE.set_array, which bumps the version, so atoms picked before the edit are rejected.sele. Previously it took the residue's first atom (N).seleshows the existing No selection warning instead of raisingCmdExceptionout of a Qt slot.importorskipended the entire pytest session during collection.Validation
unitsuite: 406 passed, 19 skipped, 0 failed.ruffis clean.packages/pymol-plugin/tests/test_review_fixes.py, all failing on Fix CI: open rebuilt examples as Annotated CIF and protonate them #20's code and passing here.Design choices to check
obj_nameargument toselection_to_indicesis optional, so existing tests that pass already-qualified selections work unchanged.cmd.load.mouse_selection_modeis not restored. This is the same lifetime gap the timer already has.