Repository navigation
Add pydeserver --twin: serve frames from the de-twin digital twin - #59
Merged
CSSFrancis merged 5 commits intoSep 24, 2026
Merged
Conversation
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
`pydeserver --twin` hands the simulated server to de-twin's deapi face, so clients get realistic frames (detector model, references, a simulated column and specimen) instead of the built-in fake data. Remaining options go to the twin (--camera, --specimen, --soap-port, ...). de-twin is an optional `twin` extra (Python >= 3.10); without it the flag explains how to install it.
Adds a gallery example that drives the microscope and the camera together: atlas at 2000x, find the holes in the holey carbon, move the stage to each one with de_microscope (the DE-TEM-Channel client) and image it at 8000x. It runs against `pydeserver --twin --soap-port 5002`; its output figure is included because the gallery does not execute it (de_microscope is not on PyPI). Also fixes --twin dropping every all-digit option (e.g. the value of --soap-port): only the leading positional port is removed now.
CSSFrancis
force-pushed
the
feat/digital-twin-server
branch
from
September 24, 2026 21:28
b050978 to
12cd483
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds an option to the simulated DE Server to serve frames from de-twin (on PyPI as
de-twin0.1.0), a digital twin of a Direct Electron camera on a TEM.What changes
pydeserver --twinhands the server to de-twin's deapi face. Any other options go to the twin (--camera,--specimen,--seed,--holder,--soap-port, …).Instrument …metadata. Clients connect exactly as before (usingMmf = False).de-twinis a new optionaltwinextra, limited to Python ≥ 3.10 (de-twin's minimum), so the default install and deapi's Python 3.8 support are unchanged. Without the extra,--twinprints how to install it and exits with code 2.--deapi-loopoption), so--twinis stripped fromsys.argvbefore handing over, to avoid recursion.doc/help/pyDEServer.rst) are updated, and the changelog entries are towncrier fragments (upcoming_changes/59.new_feature.rst,59.doc.rst).Tests
New file
deapi/tests/test_fake_server/test_twin_server.py:python -m deapi.simulated_server.initialize_server <port> --twin --camera DESim, connects a realClient, and checks the sensor size, a rendered (non-constant) 1024² frame and the instrument metadata. It skips when de-twin isn't installed; CI installs only--extra tests, so it skips there unless the CI install adds thetwinextra.Locally with
.[tests,twin]on Python 3.12: the full suite as CI runs it gives 51 passed and 128 skipped (the skips need a real DE-Server).test_fake_serveralone gives 8 passed.Example: imaging holes with the digital twin
examples/digital_twin/imaging_holes_with_the_digital_twin_sgskip.pydrives the microscope and the camera together:de_microscope(the DE-TEM-Channel client) and image it at 8000×.It runs against
pydeserver --twin --soap-port 5002. Against a real instrument only the addresses change.de_microscopeisn't on PyPI, so the gallery shows this example without executing it (_sgskip). The figure it produces is included asdoc/_static/digital_twin_holes.png. When I ran it, 9 holes were found and the 4 visited were centred to within about 20 px of a 4096 px frame.This commit also fixes a bug in the first one:
--twindropped every all-digit option, including the value of--soap-port. Only the leading positional port is removed now, and a new test covers the pass-through.