-
Notifications
You must be signed in to change notification settings - Fork 1
[SPRINT-02-01] Add local SBOL document indexing entry point #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Gonza10V
merged 2 commits into
full_build
from
codex/add-local-sbol-document-indexing-support
May 18, 2026
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import inspect | ||
| import os | ||
| import sys | ||
| import unittest | ||
| from unittest.mock import patch | ||
|
|
||
| import sbol2 | ||
|
|
||
| sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../src'))) | ||
|
|
||
| from buildcompiler.buildcompiler import BuildCompiler | ||
| from buildcompiler.constants import RESTRICTION_ENZYME | ||
|
|
||
|
|
||
| class TestBuildCompilerLocalIndexing(unittest.TestCase): | ||
| def test_constructor_signature_unchanged(self): | ||
| params = list(inspect.signature(BuildCompiler.__init__).parameters.keys()) | ||
| self.assertEqual( | ||
| params, | ||
| ['self', 'collections', 'sbh_registry', 'auth_token', 'sbol_doc'], | ||
| ) | ||
|
|
||
| def test_from_local_documents_indexes_without_partshop(self): | ||
| collection_doc = sbol2.Document() | ||
| enzyme = sbol2.ComponentDefinition('BsaI') | ||
| enzyme.types = [sbol2.BIOPAX_PROTEIN] | ||
| enzyme.roles = [RESTRICTION_ENZYME] | ||
| collection_doc.add(enzyme) | ||
| implementation = sbol2.Implementation('BsaI_impl') | ||
| implementation.built = enzyme.identity | ||
| collection_doc.add(implementation) | ||
|
|
||
| with patch('sbol2.PartShop', side_effect=AssertionError('PartShop should not be constructed in local mode')): | ||
| compiler = BuildCompiler.from_local_documents([collection_doc]) | ||
|
|
||
| self.assertIsNone(compiler.sbh) | ||
| self.assertEqual(len(compiler.indexed_plasmids), 0) | ||
| self.assertEqual(len(compiler.indexed_backbones), 0) | ||
| self.assertEqual(len(compiler.restriction_enzyme_implementations), 1) | ||
| self.assertIsInstance(compiler.restriction_enzyme_implementations, list) | ||
| self.assertIsInstance(compiler.ligase_implementations, list) | ||
|
|
||
| def test_local_mode_raises_when_reference_missing(self): | ||
| doc = sbol2.Document() | ||
| strain = sbol2.ModuleDefinition('strain_missing_ref') | ||
| strain.roles = ['https://identifiers.org/ncit/NCIT:C14419'] | ||
| fc = strain.functionalComponents.create('plasmid_ref') | ||
| fc.definition = 'https://example.org/missing_plasmid/1' | ||
| doc.add(strain) | ||
|
|
||
| with self.assertRaises(ValueError) as ctx: | ||
| BuildCompiler.from_local_documents([doc]) | ||
|
|
||
| self.assertIn('Local mode does not pull from SynBioHub', str(ctx.exception)) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling
index_documentfor each local document invokes_index_current_document()over the entire accumulatedself.sbol_docevery time, so objects from earlier documents are indexed again on each subsequent call. Infrom_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 👍 / 👎.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
index_documentnow 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_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_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-L203Testing
python -m unittest tests.test_buildcompiler -vView task →