1- [ ![ CI] ( https://github.com/DiamondLightSource/smartem-decisions/actions/workflows/ci.yml/badge.svg )] (
2- https://github.com/DiamondLightSource/smartem-decisions/actions/workflows/ci.yml )
3- [ ![ Coverage] ( https://codecov.io/gh/DiamondLightSource/smartem-decisions/branch/main/graph/badge.svg )] (
4- https://codecov.io/gh/DiamondLightSource/smartem-decisions )
1+ [ ![ Built with Claude Code] ( https://img.shields.io/badge/Built%20with-Claude%20Code-6366f1?logo=claude )] ( https://claude.ai/code )
2+ [ ![ CI] ( https://github.com/DiamondLightSource/smartem-decisions/actions/workflows/ci.yml/badge.svg )] ( https://github.com/DiamondLightSource/smartem-decisions/actions/workflows/ci.yml )
3+ [ ![ Coverage] ( https://codecov.io/gh/DiamondLightSource/smartem-decisions/branch/main/graph/badge.svg )] ( https://codecov.io/gh/DiamondLightSource/smartem-decisions )
54[ ![ License] ( https://img.shields.io/badge/License-Apache%202.0-blue.svg )] ( https://opensource.org/licenses/Apache-2.0 )
65
76# SmartEM Decisions
87
9- A comprehensive system for smart data collection and processing in cryo-electron microscopy, designed to optimize
10- acquisition workflows through intelligent decision-making and real-time data analysis.
8+ A comprehensive system for smart data collection and processing in cryo-electron microscopy, designed to optimise acquisition workflows through intelligent decision-making and real-time data analysis.
119
1210## Quick Links
1311
1412Source | < https://github.com/DiamondLightSource/smartem-decisions >
1513:---: | :---:
1614Docker | ` docker run ghcr.io/DiamondLightSource/smartem-backend:latest `
17- Documentation | < https://DiamondLightSource.github.io/smartem-decisions >
15+ Documentation | < https://DiamondLightSource.github.io/smartem-devtools >
1816Releases | < https://github.com/DiamondLightSource/smartem-decisions/releases >
1917Project Board | < https://github.com/orgs/DiamondLightSource/projects/33/views/1 >
20- Test Datasets | < https://gitlab.diamond.ac.uk/scisoft/cryoem/smartem-decisions-test-datasets >
2118
2219## System Components
2320
@@ -28,203 +25,31 @@ Test Datasets | <https://gitlab.diamond.ac.uk/scisoft/cryoem/smartem-decisions
2825
2926## Quick Start
3027
31- ``` python
32- from smartem_backend._version import __version__
33-
34- print (f " Hello smartem_backend { __version__ } " )
35- ```
36-
37- ## Architecture Overview
38-
39- ``` mermaid
40- flowchart TD
41- %% Equipment and Data Collection Layer
42- subgraph facility["Diamond Light Source Facility"]
43- microscope["Cryo-EM Microscope"]
44- athena_hw["Athena Hardware"]
45- epu["EPU Software<br/>(ThermoFisher)"]
46- gpfs[("GPFS Storage")]
47- end
48-
49- %% Agent Layer
50- subgraph agent["smartem_agent (Windows)"]
51- fs_watcher["File System Watcher"]
52- fs_parser["EPU Data Parser"]
53- sse_client["SSE Client"]
54- end
55-
56- %% Backend Services Layer
57- subgraph backend["smartem_backend (Kubernetes)"]
58- api_server["FastAPI Server<br/>SSE + HTTP API"]
59- consumer["RabbitMQ Consumer"]
60- conn_mgr["Connection Manager"]
61- end
62-
63- %% Infrastructure Layer
64- subgraph infra["Infrastructure (Kubernetes)"]
65- db[("PostgreSQL<br/>Sessions & Instructions")]
66- mq[("RabbitMQ<br/>Event Streaming")]
67- log["Logging<br/>(Graylog)"]
68- end
69-
70- %% Additional Packages
71- common["smartem_common<br/>(Shared Schemas)"]
72- athena_api["athena_api<br/>(API Client)"]
73-
74- %% Data Flow Connections
75- microscope --> epu
76- athena_hw --> microscope
77- epu --> gpfs
78- gpfs --> fs_watcher
79- fs_watcher --> fs_parser
80- fs_parser --> sse_client
81-
82- %% External Processing → RabbitMQ → Backend
83- subgraph external["External Processing Systems"]
84- ml_pipeline["ML Pipeline<br/>(Quality Predictions)"]
85- image_proc["Image Processing<br/>(Motion/CTF/Particles)"]
86- end
87-
88- ml_pipeline -.->|"Model Predictions<br/>Parameter Updates"| mq
89- image_proc -.->|"Processing Results<br/>Quality Metrics"| mq
90-
91- %% Backend Communication
92- sse_client <-.->|"SSE Streams &<br/>HTTP ACKs"| api_server
93-
94- %% Backend Internal
95- api_server --> db
96- api_server --> mq
97- api_server --> log
98- consumer --> db
99- consumer --> mq
100- conn_mgr --> db
101-
102- %% External Integration
103- api_server --> athena_api
104- athena_api -.->|"Control Commands<br/>(reorder, skip)"| athena_hw
105-
106- %% Package Dependencies
107- backend -.-> common
108- agent -.-> common
109-
110- %% Styling
111- classDef facility fill:#e8f5e8,stroke:#28a745,stroke-width:2px
112- classDef agent fill:#fff5e6,stroke:#e67e22,stroke-width:2px
113- classDef backend fill:#e6f3ff,stroke:#0066cc,stroke-width:2px
114- classDef infra fill:#f5f5f5,stroke:#666,stroke-width:2px
115- classDef packages fill:#f9f9f9,stroke:#999,stroke-width:1px
116- classDef external fill:#f8f9fa,stroke:#6c757d,stroke-width:2px
117-
118- class facility facility
119- class agent agent
120- class backend backend
121- class infra infra
122- class common,athena_api packages
123- class external,ml_pipeline,image_proc external
124- ```
125-
126- ## Development Setup
127-
12828``` bash
129- # venv and requirements
29+ # Create virtual environment and install
13030python -m venv .venv
13131source .venv/bin/activate
132- pip install -e .[dev] # or .[backend] for production
32+ pip install -e .[dev]
13333
134- # Start services with verbosity controls:
135- python -m smartem_backend.api_server # HTTP API server
136- python -m smartem_backend.consumer -v # Message queue consumer with INFO logging
137- python -m smartem_agent watch /path/to/data -v # File watcher with INFO logging
138-
139- # For testing file watcher with simulated EPU data:
140- python tools/fsrecorder/fsrecorder.py replay recording.tar.gz /path/to/data --fast
141-
142- # For testing external message processing:
143- python tools/external_message_simulator.py list-messages # See available message types
144- python tools/external_message_simulator.py workflow-simulation --gridsquare-id " DEV_001"
145-
146- # For testing agent-backend communication:
147- python tools/sse_client_example.py # Test SSE instruction delivery
34+ # Start services
35+ python -m smartem_backend.api_server # HTTP API server
36+ python -m smartem_backend.consumer -v # Message queue consumer
14837```
14938
150- ## Administrative Utilities
151-
152- After installation with ` pip install -e .[all] ` , the following command-line utilities are available for system administration and maintenance:
153-
154- ### Agent Communication Management
155-
156- - ** ` smartem.agent-cleanup ` ** - Data lifecycle and cleanup operations for agent communication data
157- ``` bash
158- # Check current database usage and statistics
159- smartem.agent-cleanup --operation=stats
160-
161- # Run full cleanup with scientific retention policy (7-year audit trail)
162- smartem.agent-cleanup --operation=cleanup --policy=scientific
163-
164- # Run cleanup with development retention policy (shorter retention)
165- smartem.agent-cleanup --operation=cleanup --policy=development
166-
167- # Clean only stale connections
168- smartem.agent-cleanup --operation=connections
169-
170- # Preview what would be cleaned without making changes
171- smartem.agent-cleanup --operation=cleanup --dry-run
172- ```
173-
174- ### ML Model and Prediction Management
175-
176- - ** ` smartem.register-prediction-model ` ** - Register new machine learning prediction models
177- ``` bash
178- smartem.register-prediction-model " ResNet-50" " Deep learning model for cryo-EM image quality assessment"
179- ```
180-
181- - ** ` smartem.init-model-weight ` ** - Initialize model weights for specific grids
182- ``` bash
183- smartem.init-model-weight --help # View available options
184- ```
185-
186- - ** ` smartem.random-model-predictions ` ** - Generate test predictions for development and testing
187- ``` bash
188- smartem.random-model-predictions --help # View available options
189- ```
190-
191- - ** ` smartem.random-prior-updates ` ** - Simulate prior updates for testing workflows
192- ``` bash
193- smartem.random-prior-updates --help # View available options
194- ```
195-
196- ### Development and Integration Tools
197-
198- - ** ` smartem_agent_tools ` ** - Agent development and debugging utilities
199-
200- ### Data Retention Policies
201-
202- The ` smartem.agent-cleanup ` utility supports two built-in retention policies:
203-
204- - ** Scientific Compliance** (default): Conservative retention suitable for scientific research
205- - Connections: 48 hours
206- - Instructions: 365 days
207- - Completed sessions: 2 years
208- - Acknowledgements: 7 years (regulatory compliance)
39+ ## Documentation
20940
210- - ** Development** : Shorter retention for development environments
211- - Connections: 4 hours
212- - Instructions: 7 days
213- - Completed sessions: 14 days
214- - Acknowledgements: 30 days
41+ Full documentation: < https://DiamondLightSource.github.io/smartem-devtools >
21542
216- All utilities include comprehensive ` --help ` documentation for detailed usage instructions.
43+ - [ Backend API Server] ( https://diamondlightsource.github.io/smartem-devtools/backend/api-server )
44+ - [ Agent Deployment] ( https://diamondlightsource.github.io/smartem-devtools/agent/deployment )
45+ - [ Admin Utilities] ( https://diamondlightsource.github.io/smartem-devtools/backend/admin-utilities )
46+ - [ Data Retention Policies] ( https://diamondlightsource.github.io/smartem-devtools/operations/data-retention )
47+ - [ Kubernetes Deployment] ( https://diamondlightsource.github.io/smartem-devtools/operations/kubernetes )
21748
218- ## More Information
49+ ## Contributing
21950
220- For detailed documentation including:
51+ See the [ contribution guide ] ( https://diamondlightsource.github.io/smartem-devtools/development/contributing ) for development workflow and code standards.
22152
222- - [ Logging Configuration] ( docs/how-to/configure-logging.md )
223- - [ Running Backend Services] ( docs/how-to/run-backend.md )
224- - [ Running Agent Services] ( docs/how-to/run-agent.md )
225- - [ EPU Data Structure Explanations] ( docs/explanations/epu-data-structures.md )
226- - [ Kubernetes Deployment] ( docs/how-to/deploy-kubernetes.md )
227- - [ Development Tools] ( docs/how-to/development-tools.md )
228- - And more...
53+ ## Licence
22954
230- See https://DiamondLightSource.github.io/smartem-decisions for complete documentation.
55+ Apache-2.0
0 commit comments