Skip to content

feat(silo): add python bindings#1133

Merged
Taepper merged 1 commit intomainfrom
python-bindings
Feb 6, 2026
Merged

feat(silo): add python bindings#1133
Taepper merged 1 commit intomainfrom
python-bindings

Conversation

@Taepper
Copy link
Copy Markdown
Collaborator

@Taepper Taepper commented Feb 2, 2026

resolves #1126

Summary

This adds python bindings. For now, these are not published, but instead installable from source using pip install . from the project root.

The api remains rather limited for now, but remains to be extended in the future

PR Checklist

  • All necessary documentation has been adapted or there is an issue to do so.
  • The implemented feature is covered by an appropriate test.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 2, 2026

This is a preview of the changelog of the next release. If this branch is not up-to-date with the current main branch, the changelog may not be accurate. Rebase your branch on the main branch to get the most accurate changelog.

Note that this might contain changes that are on main, but not yet released.

Changelog:

0.9.8 (2026-02-06)

Features

  • silo: add python bindings (3aa73e0)

@Taepper Taepper force-pushed the python-bindings branch 2 times, most recently from 7bf69c4 to 48e2141 Compare February 3, 2026 08:08
Comment thread python/tests/conftest.py Outdated
Comment thread python/tests/test_database.py Outdated
Comment thread README.md
Comment thread pyproject.toml
Comment thread CMakeLists.txt
Copy link
Copy Markdown
Contributor

@fengelniederhammer fengelniederhammer left a comment

Choose a reason for hiding this comment

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

Looks good in general!

Comment thread python/tests/test_database.py Outdated
Comment thread python/pysilo/database.pyx Outdated
Comment thread python/pysilo/database.pyx Outdated
Comment thread README.md Outdated
Comment thread src/silo/database.cpp
Comment thread src/silo/database.cpp Outdated
Comment thread src/silo/database.cpp
Comment thread src/silo/database.test.cpp Outdated
Comment thread src/silo/database.test.cpp Outdated
Copy link
Copy Markdown
Contributor

@fengelniederhammer fengelniederhammer left a comment

Choose a reason for hiding this comment

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

Looks good 👍

I found a little bug when testing it from the Python REPL, but I think that's rather a bug in the existing SILO code:

  • call appendDataFromString with invalid JSON -> I saw an expected exception.
  • call appendDataFromString again with valid JSON -> I saw an unexpected exception
>>> db = Database()
>>> db.create_nucleotide_sequence_table(table_name="sequences", primary_key_name="id", sequence_name="main", reference_sequence="ACTG")
>>> db.append_data_from_string("sequences", '{"id": "1", "main": {"sequence": "ACGG"}}')
Traceback (most recent call last):
  File "pysilo/database.pyx", line 195, in pysilo.database.PyDatabase.append_data_from_string
RuntimeError: When getting field 'insertions' in column field 'main' got error: NO_SUCH_FIELD: The JSON field referenced does not exist in this object. - current line: {"id": "1", "main": {"sequence": "ACGG"}}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pysilo/database.pyx", line 197, in pysilo.database.PyDatabase.append_data_from_string
RuntimeError: Failed to append data: When getting field 'insertions' in column field 'main' got error: NO_SUCH_FIELD: The JSON field referenced does not exist in this object. - current line: {"id": "1", "main": {"sequence": "ACGG"}}
>>> db.print_all_data("sequences")
>>> db.append_data_from_string("sequences", '{"id": "1", "main": {"sequence": "ACGG", "insertions": []}}')
Traceback (most recent call last):
  File "pysilo/database.pyx", line 195, in pysilo.database.PyDatabase.append_data_from_string
RuntimeError: string_columns id has invalid size 2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pysilo/database.pyx", line 197, in pysilo.database.PyDatabase.append_data_from_string
RuntimeError: Failed to append data: string_columns id has invalid size 2
>>> db.print_all_data("sequences")
{"id":"1","main":"ACGG"}

Comment thread Makefile Outdated
@Taepper
Copy link
Copy Markdown
Collaborator Author

Taepper commented Feb 6, 2026

I found a little bug when testing it from the Python REPL, but I think that's rather a bug in the existing SILO code:

call appendDataFromString with invalid JSON -> I saw an expected exception.
call appendDataFromString again with valid JSON -> I saw an unexpected exception

Oh, this is definitely not nice. We should specify that, for now, all exceptions thrown invalidate the current database. I added this to the error message:
The database object might be invalid now. Any further operations can lead to undefined behavior.

and added #1139

@Taepper Taepper merged commit bb7ca5a into main Feb 6, 2026
11 checks passed
@Taepper Taepper deleted the python-bindings branch February 6, 2026 09:39
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.

Add python bindings that are buildable from source

2 participants