Skip to content

Commit 8087312

Browse files
authored
Merge pull request #294 from dandi/devendorize
Vendor-Configurable Metadata Models
2 parents 8dff37f + 33ac781 commit 8087312

26 files changed

+4620
-255
lines changed

.github/workflows/test.yml

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,32 @@ on:
99
jobs:
1010
test:
1111
runs-on: ${{ matrix.os }}
12-
env:
13-
NO_ET: 1
14-
DATACITE_DEV_PASSWORD: ${{ secrets.DATACITE_DEV_PASSWORD }}
12+
defaults:
13+
run:
14+
shell: bash
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
os:
19-
- windows-latest
20-
- ubuntu-latest
21-
- macos-latest
22-
python:
23-
- 3.9
24-
- '3.10'
25-
- '3.11'
26-
- '3.12'
18+
os: [windows-latest, ubuntu-latest, macos-latest]
19+
python: ['3.9', '3.10', '3.11', '3.12']
20+
vendored_env: [unvendored]
21+
include:
22+
- os: ubuntu-latest
23+
python: '3.9'
24+
vendored_env: dandi
25+
instance_name: DANDI
26+
instance_identifier: 'RRID:SCR_017571'
27+
doi_prefix: '10.80507'
28+
- os: ubuntu-latest
29+
python: '3.9'
30+
vendored_env: ember-dandi
31+
instance_name: EMBER-DANDI
32+
instance_identifier: 'RRID:SCR_026700'
33+
doi_prefix: '10.82754'
34+
- os: ubuntu-latest
35+
python: '3.9'
36+
vendored_env: ember-dandi-no-doi
37+
instance_name: EMBER-DANDI
2738
steps:
2839
- name: Set up environment
2940
uses: actions/checkout@v5
@@ -42,7 +53,36 @@ jobs:
4253
python -m pip install --upgrade pip wheel
4354
python -m pip install --upgrade tox
4455
56+
# Set only if matrix.instance_name is defined
57+
- name: Set DANDI_INSTANCE_NAME
58+
if: ${{ matrix.instance_name }}
59+
run: echo "DANDI_INSTANCE_NAME=${{ matrix.instance_name }}" >> "$GITHUB_ENV"
60+
61+
# Set only if matrix.instance_identifier is defined
62+
- name: Set DANDI_INSTANCE_IDENTIFIER
63+
if: ${{ matrix.instance_identifier }}
64+
run: echo "DANDI_INSTANCE_IDENTIFIER=${{ matrix.instance_identifier }}" >> "$GITHUB_ENV"
65+
66+
# Set only if matrix.doi_prefix is defined
67+
- name: Set DANDI_DOI_PREFIX
68+
if: ${{ matrix.doi_prefix }}
69+
run: echo "DANDI_DOI_PREFIX=${{ matrix.doi_prefix }}" >> "$GITHUB_ENV"
70+
71+
- name: Set DANDI DataCite credentials
72+
if: ${{ matrix.vendored_env == 'dandi' }}
73+
run: |
74+
echo "DATACITE_DEV_LOGIN=${{ secrets.DATACITE_DEV_DANDI_LOGIN }}" >> "$GITHUB_ENV"
75+
echo "DATACITE_DEV_PASSWORD=${{ secrets.DATACITE_DEV_DANDI_PASSWORD }}" >> "$GITHUB_ENV"
76+
77+
- name: Set EMBER DataCite credentials
78+
if: ${{ matrix.vendored_env == 'ember-dandi' }}
79+
run: |
80+
echo "DATACITE_DEV_LOGIN=${{ secrets.DATACITE_DEV_EMBER_LOGIN }}" >> "$GITHUB_ENV"
81+
echo "DATACITE_DEV_PASSWORD=${{ secrets.DATACITE_DEV_EMBER_PASSWORD }}" >> "$GITHUB_ENV"
82+
4583
- name: Run all tests
84+
env:
85+
NO_ET: 1
4686
run: tox -e py -- -s --cov-report=xml
4787

4888
- name: Upload coverage to Codecov

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,27 @@ Important files in this repository include:
3030
- [metadata.py](./dandischema/metadata.py) - contains functions for validating, migrating, and aggregating metadata
3131
- [datacite package](./dandischema/datacite) - contains functions for converting Dandiset metadata to DataCite metadata
3232

33+
## Customization with Vendor Information
34+
35+
The DANDI metadata models defined in this library can be customized with vendor-specific information.
36+
The parameters of the customization are defined by the fields of the `Config` class in
37+
[dandischema/conf.py](./dandischema/conf.py). The `Config` class is a subclass of
38+
[`pydantic_settings.BaseSettings`](https://docs.pydantic.dev/latest/concepts/pydantic_settings/),
39+
and the values of the fields in an instance of the `Config` class can be set through environment
40+
variables and `.env` files, as documented in
41+
[the Pydantic Settings documentation](https://docs.pydantic.dev/latest/concepts/pydantic_settings/).
42+
Specifically,
43+
44+
- The value of a field is set from an environment variable with the same name, case-insensitively,
45+
as one of the aliases of the field. For example, the `instance_name` field can be set from
46+
the `DANDI_INSTANCE_NAME` or `DJANGO_DANDI_INSTANCE_NAME` environment variable.
47+
- A value of a complex type (e.g., `list`, `set`, `dict`) should be expressed as a JSON-encoded string
48+
in an environment variable. For example, the value for the `licenses` field, which is of
49+
type `set`, can be set from the `DANDI_LICENSES` environment variable defined as the following:
50+
```shell
51+
export DANDI_LICENSES='["spdx:CC0-1.0", "spdx:CC-BY-4.0"]'
52+
```
53+
3354
## Resources
3455

3556
* To learn how to interact with the DANDI archive,

dandischema/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
__all__ = ["__version__", "migrate", "validate"]
1+
__all__ = ["__version__"]
22

33
from ._version import __version__
4-
from .metadata import migrate, validate

0 commit comments

Comments
 (0)