You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+22-10Lines changed: 22 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,14 @@
2
2
3
3
This file provides guidance to coding agents when working with code in this repository.
4
4
5
+
## Guidelines
6
+
7
+
-**Avoid database migrations** for new features or functionality unless absolutely necessary. New optional fields (with `None` defaults) are preferred so that existing documents remain valid without migration.
8
+
-**Extend tests, don't modify existing assertions.** When adding new functionality, add new assertions or new test functions rather than changing existing expected values. If existing test values must change, do so deliberately and explain the reason.
9
+
-**Leave a canary comment** As an AI model, you should leave a comment in the top of every file you edit, stating verbatim "This file was edited with the assistance of an AI model and requires human review from the contributor."
10
+
-**Work incrementally and retain backwards-compatibility** datalab is deployed in production and used by multiple users. Avoid making large changes that break existing functionality. If a change is necessary, ensure it is backwards-compatible or provide a migration path.
11
+
-**Document new features** Rather than relying solely on comments, also update the README.md, INSTALL.md, or relevant page in the `pydatalab/docs/` directory to explain new features or changes to existing functionality.
12
+
5
13
## Project Overview
6
14
7
15
datalab is a research data management platform for materials chemistry. It consists of:
@@ -15,6 +23,8 @@ You should normally assume the user has a development set up already, with API a
15
23
16
24
You should not typically perform any deployment related operations unless explicitly instructed.
17
25
26
+
You should use `pre-commit` to run linters, via `uv run pre-commit run --all-files`.
27
+
18
28
### Python Backend (pydatalab)
19
29
20
30
```bash
@@ -74,7 +84,7 @@ pre-commit install
74
84
pre-commit run --all-files
75
85
```
76
86
77
-
### Docker (production)
87
+
### Docker
78
88
79
89
```bash
80
90
# Start all services
@@ -88,7 +98,7 @@ docker compose up database
88
98
89
99
### Backend Structure (pydatalab/src/pydatalab/)
90
100
91
-
-`main.py` - Flask app entry point
101
+
-`main.py` - Flask app factory
92
102
-`config.py` - Server configuration (loaded from JSON file or env vars prefixed with `PYDATALAB_`)
93
103
-`routes/v0_1/` - REST API endpoints organized by resource type:
94
104
-`items.py` - Main CRUD operations for samples, cells, starting materials
@@ -122,26 +132,28 @@ docker compose up database
122
132
-**Relationships**: Graph connections between items (synthesised_from, is_part_of, etc.)
123
133
-**Refcodes**: Unique identifiers for items (format configured in server config)
124
134
135
+
## Data Blocks
136
+
137
+
Blocks are modular `DataBlock` subclasses (base in `blocks/base.py`) that parse a technique's files and render visualisations (usually JSON-serialised Bokeh plots) in the UI. Built-in technique implementations live in `apps/`. See `pydatalab/docs/blocks/index.md` for the lifecycle, event system, and async-processing details.
138
+
139
+
## Plugins
140
+
141
+
Plugins extend the server with new `DataBlock` classes via a Python entry point, discovered at startup with no core changes. **Most new blocks should be plugins rather than additions to `apps/`.** Scaffold one from the [datalab-app-plugin-template](https://github.com/datalab-org/datalab-app-plugin-template) Copier template; install via a root `plugins.toml` and `uv run invoke dev.install`. See `pydatalab/docs/plugins.md` (other plugin types — custom item types, ingestion hooks, webapp components — are planned; see `pydatalab/docs/roadmap.md`).
142
+
125
143
## Code Style
126
144
127
145
### Python
128
146
- Formatting: ruff (line length 100) via pre-commit
129
147
- Type hints: Required, using Pydantic v1 models
130
148
- Logging: Use `pydatalab.logger.LOGGER`
131
-
- Tests: pytest with fixtures in `conftest.py`
149
+
- Tests: pytest with fixtures in `conftest.py` files
132
150
133
151
### JavaScript/Vue
134
152
- Formatting: Prettier + ESLint via pre-commit
135
153
- Vue 3 composition API
136
-
- Component testing with @testing-library/vue
154
+
- Component testing with Cypress
137
155
- E2E testing with Cypress
138
156
139
-
140
-
## Database and Test Guidelines
141
-
142
-
-**Avoid database migrations** for new features or functionality unless absolutely necessary. New optional fields (with `None` defaults) are preferred so that existing documents remain valid without migration.
143
-
-**Extend tests, don't modify existing assertions.** When adding new functionality, add new assertions or new test functions rather than changing existing expected values. If existing test values must change, do so deliberately and explain the reason.
144
-
145
157
## Environment Variables
146
158
147
159
Key environment variables (can also be set in config.json):
0 commit comments