Architecture: package dependencies ================================== *Page kind: Explanation (C4 component level).* This page shows which of the monorepo's own top-level Python packages import which others, which dependency rules are enforced, and which are still open decisions. The context and container levels (lab users, SerialEM, storage servers, Viking, the build hosts) are on the umbrella site, https://connectomes.pitt.edu/. Package contents are in :doc:`packages/index`. Every edge below comes from the import graph, not from this page's author. To check a statement here, regenerate the graph and the rule results with the monorepo's Python:: venv\pyre314\Scripts\python.exe -I .cursor\skills\nornir-improve-loop\architecture.py graph venv\pyre314\Scripts\python.exe -I .cursor\skills\nornir-improve-loop\architecture.py check The graph lists each edge with its import count and the files that make it; the counts are not repeated here. Components ---------- A component is a top-level package that sits directly in a ``nornir-*`` submodule folder (or ``dm4``). .. list-table:: :header-rows: 1 :widths: 28 24 48 * - Package - Folder - Role * - ``nornir_shared`` - ``nornir-shared`` - Base library under every other package (logging, console output, MQTT telemetry helpers). * - ``nornir_pools`` - ``nornir-pools`` - Thread and process pools. * - ``nornir_imageregistration`` - ``nornir-imageregistration`` - Image registration, transforms, mosaics. * - ``nornir_volumemodel`` - ``nornir-volumemodel`` - Volume model library. * - ``dm4`` - ``dm4`` - DM4 image reader. * - ``annotation_crops`` - ``nornir-buildmanager`` - Annotation crop export, shipped in the build manager's folder as its own package. * - ``nornir_buildmanager`` - ``nornir-buildmanager`` - Application: ``nornir-build`` pipelines. * - ``pyre`` - ``nornir-pyre`` - Application: Pyre registration GUI. * - ``nornir_web`` - ``nornir-web`` - Application: web front end. * - ``cherrypyhost`` - ``nornir-web`` - CherryPy host, shipped in the web folder as its own package. * - ``nornir_dashboard`` - ``nornir-builddashboard`` - Application: build dashboard. * - ``nornir_volumecontroller`` - ``nornir-volumecontroller`` - Application: volume controller. Dependencies ------------ Each row is one package and the packages it imports, taken from the graph's edges. .. list-table:: :header-rows: 1 :widths: 30 70 * - Package - Imports * - ``pyre`` - ``nornir_imageregistration``, ``nornir_pools``, ``nornir_shared`` * - ``nornir_buildmanager`` - ``annotation_crops``, ``dm4``, ``nornir_imageregistration``, ``nornir_pools``, ``nornir_shared`` * - ``nornir_web`` - ``nornir_imageregistration``, ``nornir_shared`` * - ``nornir_dashboard`` - ``nornir_shared`` * - ``nornir_volumecontroller`` - ``nornir_imageregistration``, ``nornir_volumemodel`` * - ``nornir_imageregistration`` - ``nornir_pools``, ``nornir_shared`` * - ``nornir_pools`` - ``nornir_shared``, ``nornir_imageregistration`` (one guarded lazy import; see the open decision below) * - ``nornir_volumemodel`` - ``nornir_shared`` * - ``nornir_shared`` - none of the other packages * - ``dm4``, ``annotation_crops``, ``cherrypyhost`` - none of the other packages The applications are at the top, ``nornir_imageregistration`` and the other libraries sit in the middle, and ``nornir_shared`` is the base. Enforced rules -------------- The contracts are in ``.importlinter`` at the monorepo root, each with a one-line reason. They run through ``architecture.py check`` (not plain ``lint-imports``, which needs every package installed). All four held when the page was written. .. list-table:: :header-rows: 1 :widths: 28 72 * - Contract - Meaning * - ``apps-independent`` - ``pyre``, ``nornir_buildmanager``, ``nornir_web``, ``nornir_dashboard``, ``nornir_volumecontroller`` and ``cherrypyhost`` never import each other; each ships and deploys on its own. * - ``package-layers`` - Applications above ``nornir_imageregistration`` / ``nornir_volumemodel`` / ``dm4`` / ``annotation_crops`` above ``nornir_shared``; a lower layer never imports a higher one. * - ``shared-is-base`` - ``nornir_shared`` imports no other package of the monorepo. * - ``pools-below-apps`` - ``nornir_pools`` imports no application and no sibling library other than ``nornir_imageregistration``. Open decisions -------------- These rules fail against the code today, so they are not in ``.importlinter`` and carry no exemption. Each is waiting for a decision (no decision records exist yet under ``docs/decisions/``). - ``arch-pools-layer``: ``nornir_pools`` should sit below ``nornir_imageregistration``. One guarded lazy import in ``nornir-pools/nornir_pools/__init__.py`` (``ConfigureForkPoolWorker``, for forked workers) points back up. It is the only package-level cycle (``nornir_imageregistration`` and ``nornir_pools``). Options: an exemption cited by its decision record, a worker-init hook in ``nornir_pools`` that ``nornir_imageregistration`` registers, or no rule. - ``arch-acyclic-nornir_imageregistration``, ``arch-acyclic-nornir_buildmanager``, ``arch-acyclic-pyre``, ``arch-acyclic-nornir_shared``: each package has cycles between its own subpackages (the graph's ``subpackageCycles``). Options per package: break the cycles first, then add the ``acyclic_siblings`` contract, or no rule.