Skip to content

Commit 29c1efd

Browse files
committed
refactor: rip out all panel apps, FastAPI for endpoints
1 parent 0aaa98e commit 29c1efd

21 files changed

Lines changed: 789 additions & 4431 deletions

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ credential_source = EcsContainer
2222
EOF
2323

2424
EXPOSE 8000
25-
ENTRYPOINT ["sh", "-c", "panel serve src/aind_metadata_viz/app.py src/aind_metadata_viz/view.py src/aind_metadata_viz/query.py src/aind_metadata_viz/upgrade.py src/aind_metadata_viz/fiber_viewer.py --static-dirs images=src/aind_metadata_viz/images --plugins aind_metadata_viz.endpoints --address 0.0.0.0 --port 8000 --allow-websocket-origin ${ALLOW_WEBSOCKET_ORIGIN} --keep-alive 10000 --index app.py"]
25+
ENTRYPOINT ["uvicorn", "aind_metadata_viz.main:app", "--host", "0.0.0.0", "--port", "8000"]

README.md

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,93 @@
22

33
[metadata visualizations](https://metadata-portal.allenneuraldynamics.org/)
44

5-
## Validation endpoints
5+
## REST API
6+
7+
The portal exposes a REST API served by FastAPI/uvicorn.
8+
9+
### Gather endpoint
10+
11+
Gathers and validates metadata from the metadata service for a given subject.
12+
13+
- `POST /gather` — body is a JSON object with required `subject_id` and `project_name`
14+
- Optional body keys: `metadata_service_url`, `modalities` (list), `tags` (list), `group`, `restrictions`, `data_summary`, `acquisition_start_time`
15+
16+
```python
17+
response = requests.post(
18+
"https://metadata-portal.allenneuraldynamics-test.org/gather",
19+
json={"subject_id": "123456", "project_name": "MyProject"},
20+
)
21+
print(response.json())
22+
```
23+
24+
### Upgrade endpoint
25+
26+
`POST /upgrade` accepts a `metadata.json` dict and runs it through [`aind-metadata-upgrader`](https://github.com/AllenNeuralDynamics/aind-metadata-upgrader). It always returns original and upgraded JSON side by side for each field, even when some fields fail.
27+
28+
```python
29+
import requests, json
30+
31+
with open("metadata.json") as f:
32+
metadata = json.load(f)
33+
34+
response = requests.post(
35+
"https://metadata-portal.allenneuraldynamics.org/upgrade",
36+
json=metadata,
37+
)
38+
result = response.json()
39+
# result["overall_success"] — True if all fields upgraded cleanly
40+
# result["overall_error"] — error string if the full upgrade failed
41+
# result["partial_success"] — True if at least one field succeeded
42+
# result["files_tested"] — per-field breakdown
43+
```
44+
45+
### Query endpoints
46+
47+
- `GET /upgrade-query` — Build a query using the LLM query builder.
48+
- `POST /retrieve-records` — Run a query against the metadata store.
49+
50+
Optional query parameters for `/retrieve-records`:
51+
- `names_only=true` — return only asset names
52+
- `limit=<int>` — limit number of results (default 0 = no limit)
53+
- `projection=<json>` — JSON object specifying which fields to include/exclude
54+
55+
```python
56+
response = requests.post(
57+
"https://metadata-portal.allenneuraldynamics-test.org/retrieve-records",
58+
params={"limit": 10, "projection": '{"subject.subject_id": 1, "name": 1}'},
59+
json={"subject.subject_id": "123456"},
60+
)
61+
print(response.json())
62+
```
63+
64+
### Contributions endpoints
65+
66+
Stores and retrieves [CRediT](https://credit.niso.org/) authorship contributions for a project, versioned via SQLite.
67+
68+
| Endpoint | Description |
69+
|---|---|
70+
| `GET /contributions/get?project=<name>` | Latest contribution data (JSON by default) |
71+
| `GET /contributions/get?project=<name>&format=yaml` | Latest contribution data as YAML |
72+
| `GET /contributions/get?project=<name>&commit=<hash>` | Contribution data at a specific commit |
73+
| `GET /contributions/get?project=<name>&history=true` | List of all commits, newest first |
74+
| `GET /contributions/get?doi=<doi>` | Look up a project by DOI |
75+
| `POST /contributions/post?project=<name>[&message=<msg>][&password=<hash>]` | Store a new version; body is JSON or YAML |
76+
| `GET /contributions/token?doi=<doi>&type=add_author\|edit_author[&author=<name>][&days=<n>][&password=<hash>]` | Create a scoped token for a project |
77+
| `GET /contributions/author-image?author=<name>` | Returns the S3 key for an author's headshot |
78+
79+
## Local dev
80+
81+
```sh
82+
uv sync --extra dev
83+
uvicorn aind_metadata_viz.main:app --reload
84+
```
85+
86+
## CI/CD
87+
88+
```sh
89+
docker build -t aind-metadata-viz .
90+
docker run -p 8000:8000 aind-metadata-viz
91+
```
692

793
The metadata portal hosts validation endpoints for the latest [`aind-data-schema`](https://github.com/AllenNeuralDynamics/aind-data-schema) release. You can hit these endpoints with:
894

pyproject.toml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,24 @@ dynamic = ["version"]
1818

1919
dependencies = [
2020
'pydantic<=2.11.0',
21-
'panel>=1.8.2',
22-
'altair',
21+
'fastapi',
22+
'uvicorn[standard]',
2323
'aind-data-schema>=2.6.0,<3',
2424
'aind-data-access-api[docdb]',
2525
'zombie-squirrel>=0.28.6,<1',
2626
'aind-metadata-validator>=0.11.6,<2',
27-
'flask',
28-
'langchain',
29-
'langchain_aws',
3027
'aind-metadata-upgrader>=0.15.23,<1',
3128
'numpy<2.0',
32-
'vl-convert-python',
33-
'biodata-query[panel] @ git+https://github.com/AllenNeuralDynamics/biodata-query.git@v0.6.1',
29+
'biodata-query @ git+https://github.com/AllenNeuralDynamics/biodata-query.git@v0.6.1',
3430
'boto3',
31+
'requests',
3532
]
3633

3734
[project.optional-dependencies]
3835
dev = [
39-
'black',
40-
'coverage',
41-
'flake8',
42-
'interrogate',
43-
'isort',
44-
'furo',
4536
'pytest',
37+
'httpx',
38+
'coverage',
4639
]
4740

4841
[tool.setuptools.packages.find]

0 commit comments

Comments
 (0)