Skip to content

Commit e2aacd0

Browse files
authored
Merge pull request #1229 from VisLab/fix_extras
Started setting up of hed-schemas validation
2 parents 1f520e7 + 7035247 commit e2aacd0

5 files changed

Lines changed: 635 additions & 12 deletions

File tree

.github/workflows/spec_tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
continue-on-error: true
4545
run: |
4646
echo "::group::Bids Results"
47-
python -m unittest spec_tests/validate_bids.py
47+
python -m unittest spec_tests/test_bids_datasets.py
4848
echo "::endgroup::"
4949
5050
- name: Hed Cache Test

spec_tests/README.md

Lines changed: 93 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,50 @@ spec_tests/
1313
├── hed-tests/
1414
│ └── json_test_data/ # JSON test files from hed-tests repository
1515
├── hed-examples/
16-
│ └── datasets/ # BIDS datasets for validation testing
16+
│ └── datasets/ # BIDS datasets for validation testing
17+
├── hed-schemas/
18+
│ ├── standard_schema/ # Standard HED schemas in all formats
19+
│ └── library_schemas/ # HED library schemas
1720
├── test_sidecar.json # Already present
1821
├── test_errors.py # Tests HED validation against spec
1922
├── test_hed_cache.py # Tests HED schema caching
20-
└── validate_bids.py # Tests BIDS dataset validation
23+
└── test_bids_datasets.py # Tests BIDS dataset validation
2124
```
2225

2326
## Setup Instructions
2427

2528
### Option 1: Using Git Submodules (Recommended)
2629

27-
1. **Initialize Submodules**:
30+
1. **Initialize Submodules**:
31+
2832
```bash
2933
git submodule update --init --recursive
3034
```
31-
This will automatically clone the `hed-tests` and `hed-examples` repositories into the correct locations.
35+
36+
This will automatically clone the `hed-tests`, `hed-examples`, and `hed-schemas` repositories into the correct locations.
3237

3338
2. **Update Submodules** (when needed):
39+
3440
```bash
3541
git submodule update --remote
3642
```
3743

3844
### Option 2: Manual Setup (Alternative)
3945

40-
1. **Clone Required Repositories**:
46+
1. **Clone Required Repositories**:
47+
4148
- Clone the `hed-tests` repository to `spec_tests/hed-tests/`
4249
- Clone the `hed-examples` repository to `spec_tests/hed-examples/`
50+
- Clone the `hed-schemas` repository to `spec_tests/hed-schemas/`
51+
52+
2. **Verify Setup**:
4353

44-
2. **Verify Setup**:
4554
- Run `python spec_tests/check_setup.py` to verify all required directories exist
4655

4756
## Running Spec Tests
4857

4958
### From Command Line:
59+
5060
```bash
5161
# Run all spec tests
5262
python -m unittest discover spec_tests -v
@@ -57,32 +67,105 @@ python -m unittest spec_tests.test_hed_cache -v
5767

5868
### From VS Code:
5969

60-
1. **Right-click Method**:
70+
1. **Right-click Method**:
71+
6172
- Right-click on the `spec_tests` folder in VS Code Explorer
6273
- Select "Run Tests" from the context menu
6374

6475
2. **Using Tasks**:
76+
6577
- Open Command Palette (Ctrl+Shift+P)
6678
- Type "Tasks: Run Task"
6779
- Select "Run Spec Tests"
6880

6981
3. **Test Explorer**:
82+
7083
- Open the Test Explorer panel
7184
- Tests should be discovered in both `tests/` and `spec_tests/` directories
7285

86+
## Schema Loading Test Script
87+
88+
The `try_loading_all_schemas.py` script provides comprehensive testing of schema loading capabilities across all formats and versions from the `hed-schemas` submodule.
89+
90+
### Usage
91+
92+
```bash
93+
# Test all schemas (releases and prereleases, all formats)
94+
python spec_tests/try_loading_all_schemas.py
95+
96+
# Test only release schemas (exclude prereleases)
97+
python spec_tests/try_loading_all_schemas.py --exclude-prereleases
98+
99+
# Test only prerelease schemas
100+
python spec_tests/try_loading_all_schemas.py --prerelease-only
101+
102+
# Test standard schemas only (no libraries)
103+
python spec_tests/try_loading_all_schemas.py --standard-only
104+
105+
# Test a specific library
106+
python spec_tests/try_loading_all_schemas.py --library lang
107+
108+
# Test a specific format
109+
python spec_tests/try_loading_all_schemas.py --format xml
110+
111+
# Combine filters
112+
python spec_tests/try_loading_all_schemas.py --library lang --format xml --exclude-prereleases
113+
114+
# Show detailed success messages
115+
python spec_tests/try_loading_all_schemas.py --verbose
116+
```
117+
118+
### Command-Line Options
119+
120+
- `--format {xml,mediawiki,json,tsv,all}`: Test specific format only (default: all)
121+
- `--library NAME`: Test specific library only (default: all)
122+
- `--standard-only`: Test only standard schemas (no libraries)
123+
- `--exclude-prereleases`: Exclude prerelease schemas (releases only)
124+
- `--prerelease-only`: Test only prerelease schemas
125+
- `--verbose`: Show detailed success messages for each schema
126+
127+
### Output
128+
129+
The script displays schemas organized by type (standard/library) and release status (release/prerelease):
130+
131+
```
132+
STANDARD SCHEMAS
133+
XML (6): HED8.0.0.xml, HED8.1.0.xml, HED8.2.0.xml, ...
134+
135+
LIBRARY SCHEMAS
136+
LANG:
137+
XML (3): HED_lang_1.0.0.xml, HED_lang_1.1.0.xml, ...
138+
139+
STANDARD PRERELEASE SCHEMAS
140+
XML (1): HED8.5.0.xml
141+
142+
LIBRARY PRERELEASE SCHEMAS
143+
LANG:
144+
XML (1): HED_lang_1.2.0.xml
145+
```
146+
147+
### Exit Codes
148+
149+
- **0**: All schemas loaded successfully
150+
- **1**: One or more schemas failed to load (causes CI failure)
151+
- **130**: User interrupted (Ctrl+C)
152+
153+
This makes the script suitable for use in GitHub Actions workflows to automatically detect schema loading issues.
154+
73155
## Notes
74156

75157
- The `test_hed_cache.py` tests should work immediately as they don't require the submodule content
76-
- The `test_errors.py` and `validate_bids.py` tests require the submodule content to be present
158+
- The `test_errors.py` and `test_bids_datasets.py` tests require the submodule content to be present
77159
- On GitHub Actions, the submodules are automatically checked out via the workflow configuration
78160
- Locally, initialize submodules using `git submodule update --init --recursive`
79-
- The `spec_tests/hed-tests/` directory is gitignored to prevent committing submodule content directly
161+
- All three submodule directories (`hed-tests`, `hed-examples`, `hed-schemas`) are gitignored to prevent committing submodule content directly
80162
- Use `git submodule update --remote` to pull the latest changes from the submodule repositories
81163

82164
## Troubleshooting
83165

84166
If spec tests aren't showing up in VS Code:
167+
85168
1. Make sure VS Code Python extension is installed
86169
2. Ensure the workspace Python interpreter is set to `.venv/Scripts/python.exe`
87170
3. Try refreshing the test discovery: Command Palette → "Test: Refresh Tests"
88-
4. Check that the required directory structure exists using the check script
171+
4. Check that the required directory structure exists using the check script

spec_tests/check_setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def main():
8585
print("⚠️ Some directories are missing, but spec_tests can still run partially.")
8686
print("Tests that require missing content will be skipped gracefully.")
8787
print("\nCurrently available: test_hed_cache.py (works without submodules)")
88-
print("Currently skipped: test_errors.py, validate_bids.py (need submodule content)")
88+
print("Currently skipped: test_errors.py, test_bids_datasets.py (need submodule content)")
8989
print("\nTo set up full spec_tests using submodules:")
9090
print(" git submodule update --init --recursive")
9191
print("\nAlternatively, manually clone:")

0 commit comments

Comments
 (0)