Skip to content

[SPRINT-02-01] Add local SBOL document indexing entry point#100

Merged
Gonza10V merged 2 commits into
full_buildfrom
codex/add-local-sbol-document-indexing-support
May 18, 2026
Merged

[SPRINT-02-01] Add local SBOL document indexing entry point#100
Gonza10V merged 2 commits into
full_buildfrom
codex/add-local-sbol-document-indexing-support

Conversation

@Gonza10V
Copy link
Copy Markdown
Contributor

@Gonza10V Gonza10V commented May 8, 2026

Motivation

  • Provide a first-class seam so BuildCompiler can index already-loaded sbol2.Document objects without requiring SynBioHub credentials, a real sbol2.PartShop, auth tokens, or network access.
  • Preserve existing constructor/SynBioHub behavior while avoiding hidden network pull calls when users opt for a local-document workflow.

Description

  • Added BuildCompiler.from_local_documents(collection_docs, design_doc=None) which creates an instance with self.sbh = None, merges supplied documents, and indexes them without constructing sbol2.PartShop (file: src/buildcompiler/buildcompiler.py).
  • Introduced index_document(), _index_current_document(), _merge_document(), and _resolve_object() so both URI/SynBioHub and local-document indexing share the same indexing/walk logic while local mode explicitly raises when a referenced object is missing instead of calling pull (file: src/buildcompiler/buildcompiler.py).
  • Replaced direct get_or_pull usages used during indexing with the new _resolve_object() helper so local mode never triggers a network fetch, and merged documents are appended safely while handling duplicate-URI collisions.
  • Added unit tests tests/test_buildcompiler.py that assert constructor signature compatibility, that local indexing does not construct PartShop and indexes local enzyme/implementation entries, and that a clear error is raised when a referenced SBOL object is missing.

Testing

  • Ran python -m unittest tests.test_buildcompiler -v which passed (all new local-indexing tests OK).
  • Ran python -m unittest discover -s tests which failed due to unrelated network-dependent behavior in existing tests (SynBioHub pulls and remote SBOL validator calls) and not due to the local-indexing change.
  • Ran pytest tests/unit tests/integration -k "local and index" which selected no tests in this repository layout (no matching pytest selection), and ran ruff check . which surfaced pre-existing lint issues unrelated to this change.

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b4fb2cae2d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/buildcompiler/buildcompiler.py Outdated

def index_document(self, collection_doc: sbol2.Document):
self._merge_document(collection_doc)
self._index_current_document()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid re-indexing previously merged local documents

Calling index_document for each local document invokes _index_current_document() over the entire accumulated self.sbol_doc every time, so objects from earlier documents are indexed again on each subsequent call. In from_local_documents([doc1, doc2, ...]) this produces duplicated plasmid/enzyme/ligase entries (e.g., the first doc’s implementations are appended multiple times), which corrupts downstream workflow inputs and counts.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex good catch, please solve this issue. The package has functionalities to add objects to a SBOL Document if they are not ready there to avoid errors of adding the same item twice.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

  • Fixed local document indexing so index_document now indexes only the newly provided document after merge, instead of re-indexing the entire accumulated SBOL document each time (which caused duplicates). src/buildcompiler/buildcompiler.pyL102-L105
  • Refactored indexing flow by introducing _index_document_objects(source_doc) and routing _index_current_document() through it, preserving full-document behavior for SynBioHub collection indexing while enabling incremental local indexing safely. src/buildcompiler/buildcompiler.pyL146-L154
  • Added _append_implementation_once(...) and used it when attaching implementations to plasmids/backbones and enzyme implementation lists, preventing duplicate implementation entries if the same implementation is encountered again. src/buildcompiler/buildcompiler.pyL149-L203
  • Added a regression test that reproduces the multi-document local indexing scenario and verifies prior documents are not re-indexed when subsequent docs are processed. tests/test_buildcompiler.pyL44-L67

Testing

  • python -m unittest tests.test_buildcompiler -v

View task →

@Gonza10V Gonza10V merged commit fa0a2b5 into full_build May 18, 2026
2 of 6 checks passed
@Gonza10V Gonza10V deleted the codex/add-local-sbol-document-indexing-support branch May 18, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant