Generated from aind-library-template
Project description
aind-metadata-extractor
Install
You should only install the dependencies for the specific extractor you plan to run. You can see the list of available extractors in the pyproject.toml file or in the folders in src/aind_metadata/extractor
During installation pass the extractor as an optional dependency:
pip install 'aind-metadata-extractor[<your-extractor>]'
Develop
To build a new extractor, define a new output model in the models/ folder. Then create a new extractor folder and inherit from BaseExtractor. Implement the functions:
.run_job()should store the metadata output object (matching the model) in self.metadata and return a dictionary with themodel_dump()contents._extract()should perform the actual data loading, metadata-service calls, etc, necessary to build the metadata model and return it
Your extractor comes with an inherited function .write() which writes the metadata to the file .json.
Testing
When testing locally you only need to run your own tests (i.e. coverage run -m unittest discover -s tests/<new-extractor>). Do not modify the tests for other extractors in your PRs.
Before opening a PR, modify the file test_and_lint.yml and add a new test-group:
test-group: ['core', 'smartspim', 'mesoscope', 'utils', '<new-extractor>']
Then add the test-group settings below that:
- test-group: '<new-extractor>'
dependencies: '[dev,<new-extractor>]'
test-path: 'tests/<new-extractor>'
test-pattern: 'test_*.py'
When running on GitHub, all of the test groups will be run independently with their separate dependencies and then their coverage results are gathered together in a final step.
Run
Each extractor uses a JobSettings object to collect necessary information about data and metadata files to create an Extractor which is run by calling .extract(). For example, for smartspim:
from pathlib import Path
from aind_metadata_extractor.smartspim.job_settings import JobSettings
from aind_metadata_extractor.smartspim.extractor import SmartspimExtractor
DATA_DIR = Path("<path-to-your-data>)
job_settings=JobSettings(
subject_id="786846",
metadata_service_path="http://aind-metadata-service/slims/smartspim_imaging",
input_source=DATA_DIR+"SmartSPIM_786846_2025-04-22_16-44-50",
output_directory=".",
slims_datetime="2025-0422T18:30:08.915000Z"
)
extractor = SmartspimExtractor(job_settings=job_settings)
extractor.run_job()
extractor.write()
The results will be saved in smartspin.json
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aind_metadata_extractor-0.3.2.tar.gz.
File metadata
- Download URL: aind_metadata_extractor-0.3.2.tar.gz
- Upload date:
- Size: 51.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f24c9915aae4d94a3ef3f8c48b9ce7f5f03489f5e9cf3eb5e93b08439664ccca
|
|
| MD5 |
4699e83c528da50aefc6721a6c675897
|
|
| BLAKE2b-256 |
8e27ded6479ce5389d443848ac0205e8b78054d558ab927eeec40be13cb69e38
|
File details
Details for the file aind_metadata_extractor-0.3.2-py3-none-any.whl.
File metadata
- Download URL: aind_metadata_extractor-0.3.2-py3-none-any.whl
- Upload date:
- Size: 58.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96732ce488ad8001bf3c9bc747dc2e2bbb8572a4658040e4383b0c1dcef56d4e
|
|
| MD5 |
6df4cd1a62d4a63b1f40c21a3ed20348
|
|
| BLAKE2b-256 |
6bb8b8b6f585302e792da5c492639b64273d83c3e978f69031661dfea9a13366
|