stac-validator 3.10.2__tar.gz → 4.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {stac_validator-3.10.2/stac_validator.egg-info → stac_validator-4.0.0}/PKG-INFO +407 -37
- {stac_validator-3.10.2 → stac_validator-4.0.0}/README.md +404 -36
- {stac_validator-3.10.2 → stac_validator-4.0.0}/pyproject.toml +5 -3
- stac_validator-4.0.0/stac_validator/batch_validator.py +351 -0
- {stac_validator-3.10.2 → stac_validator-4.0.0}/stac_validator/stac_validator.py +174 -32
- {stac_validator-3.10.2 → stac_validator-4.0.0}/stac_validator/utilities.py +43 -2
- {stac_validator-3.10.2 → stac_validator-4.0.0}/stac_validator/validate.py +7 -2
- {stac_validator-3.10.2 → stac_validator-4.0.0/stac_validator.egg-info}/PKG-INFO +407 -37
- {stac_validator-3.10.2 → stac_validator-4.0.0}/stac_validator.egg-info/SOURCES.txt +3 -0
- stac_validator-4.0.0/stac_validator.egg-info/entry_points.txt +2 -0
- {stac_validator-3.10.2 → stac_validator-4.0.0}/stac_validator.egg-info/requires.txt +2 -0
- stac_validator-4.0.0/tests/test_batch_validator.py +386 -0
- stac_validator-4.0.0/tests/test_schema_cache.py +91 -0
- {stac_validator-3.10.2 → stac_validator-4.0.0}/tests/test_sys_exit.py +24 -2
- {stac_validator-3.10.2 → stac_validator-4.0.0}/tests/test_validate_dict.py +29 -0
- stac_validator-3.10.2/stac_validator.egg-info/entry_points.txt +0 -2
- {stac_validator-3.10.2 → stac_validator-4.0.0}/LICENSE +0 -0
- {stac_validator-3.10.2 → stac_validator-4.0.0}/setup.cfg +0 -0
- {stac_validator-3.10.2 → stac_validator-4.0.0}/stac_validator/__init__.py +0 -0
- {stac_validator-3.10.2 → stac_validator-4.0.0}/stac_validator.egg-info/dependency_links.txt +0 -0
- {stac_validator-3.10.2 → stac_validator-4.0.0}/stac_validator.egg-info/top_level.txt +0 -0
- {stac_validator-3.10.2 → stac_validator-4.0.0}/tests/test_assets.py +0 -0
- {stac_validator-3.10.2 → stac_validator-4.0.0}/tests/test_config.py +0 -0
- {stac_validator-3.10.2 → stac_validator-4.0.0}/tests/test_core.py +0 -0
- {stac_validator-3.10.2 → stac_validator-4.0.0}/tests/test_custom.py +0 -0
- {stac_validator-3.10.2 → stac_validator-4.0.0}/tests/test_default.py +0 -0
- {stac_validator-3.10.2 → stac_validator-4.0.0}/tests/test_extensions.py +0 -0
- {stac_validator-3.10.2 → stac_validator-4.0.0}/tests/test_header.py +0 -0
- {stac_validator-3.10.2 → stac_validator-4.0.0}/tests/test_links.py +0 -0
- {stac_validator-3.10.2 → stac_validator-4.0.0}/tests/test_pydantic.py +0 -0
- {stac_validator-3.10.2 → stac_validator-4.0.0}/tests/test_recursion.py +0 -0
- {stac_validator-3.10.2 → stac_validator-4.0.0}/tests/test_validate_collections.py +0 -0
- {stac_validator-3.10.2 → stac_validator-4.0.0}/tests/test_validate_item_collection.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: stac_validator
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0.0
|
|
4
4
|
Summary: A package to validate STAC files
|
|
5
5
|
Author: James Banting
|
|
6
6
|
Author-email: Jonathan Healy <jonathan.d.healy@gmail.com>
|
|
@@ -21,6 +21,7 @@ Requires-Dist: jsonschema>=4.23.0
|
|
|
21
21
|
Requires-Dist: click>=8.1.8
|
|
22
22
|
Requires-Dist: referencing>=0.35.1
|
|
23
23
|
Requires-Dist: pyYAML>=6.0.1
|
|
24
|
+
Requires-Dist: tqdm>=4.66.0
|
|
24
25
|
Provides-Extra: dev
|
|
25
26
|
Requires-Dist: black; extra == "dev"
|
|
26
27
|
Requires-Dist: pytest; extra == "dev"
|
|
@@ -33,6 +34,7 @@ Requires-Dist: mypy; extra == "dev"
|
|
|
33
34
|
Requires-Dist: types-attrs; extra == "dev"
|
|
34
35
|
Requires-Dist: types-requests; extra == "dev"
|
|
35
36
|
Requires-Dist: types-jsonschema; extra == "dev"
|
|
37
|
+
Requires-Dist: types-tqdm; extra == "dev"
|
|
36
38
|
Provides-Extra: pydantic
|
|
37
39
|
Requires-Dist: stac-pydantic>=3.3.0; extra == "pydantic"
|
|
38
40
|
Dynamic: license-file
|
|
@@ -61,7 +63,10 @@ Dynamic: license-file
|
|
|
61
63
|
- [Supported STAC Versions](#versions-supported)
|
|
62
64
|
- [Usage](#usage)
|
|
63
65
|
- [CLI](#cli)
|
|
66
|
+
- [Legacy Validation](#legacy-validation)
|
|
67
|
+
- [Batch Validation](#batch-validation)
|
|
64
68
|
- [Python](#python)
|
|
69
|
+
- [Schema Cache Settings](#schema-cache-settings)
|
|
65
70
|
- [Examples](#additional-examples)
|
|
66
71
|
- [Core Validation](#--core)
|
|
67
72
|
- [Custom Schema](#--custom)
|
|
@@ -181,7 +186,37 @@ $ stac-validator --help
|
|
|
181
186
|
```
|
|
182
187
|
|
|
183
188
|
```bash
|
|
184
|
-
Usage: stac-validator [OPTIONS]
|
|
189
|
+
Usage: stac-validator [OPTIONS] COMMAND [ARGS]...
|
|
190
|
+
|
|
191
|
+
STAC Validator - Validate STAC files against the STAC specification.
|
|
192
|
+
|
|
193
|
+
Usage:
|
|
194
|
+
stac-validator validate <file> [options]
|
|
195
|
+
stac-validator batch <files> [options]
|
|
196
|
+
stac-validator batch <file> --feature-collection [options]
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
Options:
|
|
200
|
+
--help Show this message and exit.
|
|
201
|
+
|
|
202
|
+
Commands:
|
|
203
|
+
batch Validate multiple STAC files concurrently using all available...
|
|
204
|
+
validate Main function for the `stac-validator` command line tool.
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**Validate Command**
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
$ stac-validator validate --help
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
Usage: stac-validator validate [OPTIONS] STAC_FILE
|
|
215
|
+
|
|
216
|
+
Validate a STAC file against the STAC specification.
|
|
217
|
+
|
|
218
|
+
Prints validation results to the console as JSON. Exits with status code 0
|
|
219
|
+
if valid, 1 if invalid.
|
|
185
220
|
|
|
186
221
|
Options:
|
|
187
222
|
--core Validate core stac object only without
|
|
@@ -193,6 +228,8 @@ Options:
|
|
|
193
228
|
with default mode.
|
|
194
229
|
-c, --custom TEXT Validate against a custom schema (local
|
|
195
230
|
filepath or remote schema).
|
|
231
|
+
-sc, --schema-config TEXT Validate against a custom schema config
|
|
232
|
+
(local filepath or remote schema config).
|
|
196
233
|
-s, --schema-map <TEXT TEXT>...
|
|
197
234
|
Schema path to replaced by (local) schema
|
|
198
235
|
path during validation. Can be used multiple
|
|
@@ -215,84 +252,415 @@ Options:
|
|
|
215
252
|
--no_output Do not print output to console.
|
|
216
253
|
--log_file TEXT Save full recursive output to log file
|
|
217
254
|
(local filepath).
|
|
218
|
-
--pydantic Validate using stac-pydantic models for
|
|
219
|
-
type checking and validation.
|
|
220
|
-
--schema-config TEXT Path to a YAML or JSON schema config file.
|
|
255
|
+
--pydantic Validate using stac-pydantic models for
|
|
256
|
+
enhanced type checking and validation.
|
|
221
257
|
--verbose Enable verbose output. This will output
|
|
222
258
|
additional information during validation.
|
|
259
|
+
--schema-cache-size INTEGER Max number of schema entries to cache in
|
|
260
|
+
memory. Use 0 to disable schema caching.
|
|
261
|
+
Defaults to 16.
|
|
223
262
|
--help Show this message and exit.
|
|
224
263
|
```
|
|
225
264
|
|
|
226
|
-
|
|
265
|
+
**Batch Command**
|
|
227
266
|
|
|
228
|
-
|
|
267
|
+
```bash
|
|
268
|
+
$ stac-validator batch --help
|
|
269
|
+
```
|
|
229
270
|
|
|
230
|
-
```
|
|
231
|
-
|
|
271
|
+
```bash
|
|
272
|
+
Usage: stac-validator batch [OPTIONS] FILES...
|
|
232
273
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
274
|
+
Validate multiple STAC files concurrently using all available CPU cores.
|
|
275
|
+
|
|
276
|
+
This command uses multiprocessing to validate STAC files in parallel,
|
|
277
|
+
bypassing Python's Global Interpreter Lock (GIL) for maximum performance.
|
|
278
|
+
Each CPU core gets its own schema cache, which is warmed up on the first
|
|
279
|
+
file and reused for subsequent files.
|
|
280
|
+
|
|
281
|
+
Examples:
|
|
282
|
+
|
|
283
|
+
# Validate all JSON files in a directory
|
|
284
|
+
$ stac-validator batch *.json
|
|
285
|
+
|
|
286
|
+
# Validate specific files
|
|
287
|
+
$ stac-validator batch file1.json file2.json file3.json
|
|
288
|
+
|
|
289
|
+
# Validate a GeoJSON FeatureCollection (validates each feature individually)
|
|
290
|
+
$ stac-validator batch --feature-collection sample_data/sentinel-cogs_0_100.json
|
|
291
|
+
|
|
292
|
+
# Use only 4 cores
|
|
293
|
+
$ stac-validator batch *.json --cores 4
|
|
294
|
+
|
|
295
|
+
# Disable progress bar
|
|
296
|
+
$ stac-validator batch *.json --no-progress
|
|
297
|
+
|
|
298
|
+
Options:
|
|
299
|
+
--cores INTEGER Number of CPU cores to use for parallel validation.
|
|
300
|
+
Defaults to all available cores.
|
|
301
|
+
--no-progress Disable progress bar during validation.
|
|
302
|
+
--no-output Do not print output to console.
|
|
303
|
+
--feature-collection Treat files as GeoJSON FeatureCollections and validate
|
|
304
|
+
each feature individually.
|
|
305
|
+
--verbose Show full JSON output for all items. By default, only
|
|
306
|
+
invalid items are shown.
|
|
307
|
+
--schema-cache-size INTEGER Max number of schema entries to cache
|
|
308
|
+
per worker process. Use 0 to disable
|
|
309
|
+
schema caching. Defaults to 16.
|
|
310
|
+
--help Show this message and exit.
|
|
236
311
|
```
|
|
237
|
-
|
|
312
|
+
|
|
313
|
+
#### Legacy Validation
|
|
314
|
+
|
|
315
|
+
The `validate` command is the main legacy validation tool with comprehensive options:
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
# Basic single file validation
|
|
319
|
+
$ stac-validator validate path/to/stac_file.json
|
|
320
|
+
|
|
321
|
+
# Validate with custom schema
|
|
322
|
+
$ stac-validator validate item.json --custom /path/to/schema.json
|
|
323
|
+
|
|
324
|
+
# Recursively validate all related STAC objects
|
|
325
|
+
$ stac-validator validate catalog.json --recursive --max-depth 5
|
|
326
|
+
|
|
327
|
+
# Validate collections endpoint response
|
|
328
|
+
$ stac-validator validate https://example.com/collections --collections
|
|
329
|
+
|
|
330
|
+
# Validate item collection response
|
|
331
|
+
$ stac-validator validate https://example.com/search --item-collection --pages 10
|
|
332
|
+
|
|
333
|
+
# Validate with extensions and links
|
|
334
|
+
$ stac-validator validate item.json --extensions --links --assets
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
**Options include:**
|
|
338
|
+
- `--core` - Validate core STAC only (skip extensions)
|
|
339
|
+
- `--extensions` - Validate extensions only
|
|
340
|
+
- `--links` - Validate link objects
|
|
341
|
+
- `--assets` - Validate asset objects
|
|
342
|
+
- `--recursive` - Recursively validate related STAC objects
|
|
343
|
+
- `--custom` - Validate against custom schema
|
|
344
|
+
- `--schema-map` - Replace schema URLs during validation
|
|
345
|
+
- `--collections` - Validate /collections endpoint response
|
|
346
|
+
- `--item-collection` - Validate item collection responses
|
|
347
|
+
- `--pydantic` - Use Pydantic models for validation
|
|
348
|
+
- `--schema-cache-size` - Configure schema cache size
|
|
349
|
+
- And more (see `stac-validator validate --help`)
|
|
350
|
+
|
|
351
|
+
#### Batch Validation
|
|
352
|
+
|
|
353
|
+
The `batch` command validates multiple STAC files concurrently using multiprocessing to bypass Python's Global Interpreter Lock (GIL). This enables **10-100x performance improvement** over single-threaded validation by utilizing all available CPU cores.
|
|
354
|
+
|
|
355
|
+
**Architecture:**
|
|
356
|
+
|
|
357
|
+
- **Multiprocessing:** Each CPU core runs an independent Python process
|
|
358
|
+
- **Per-worker schema cache:** Each worker maintains its own LRU cache of downloaded schemas (default 16 per worker)
|
|
359
|
+
- **Cache warmup:** First file on each worker downloads schemas, subsequent files use cached copies
|
|
360
|
+
- **Configurable cache:** Use `--schema-cache-size` to adjust cache size per worker (0 = disabled)
|
|
361
|
+
- **Linear scaling:** Performance scales linearly with available cores (e.g., 8 cores = ~8x faster)
|
|
362
|
+
- **Container-aware:** Automatically detects Docker/ECS CPU limits via `os.sched_getaffinity()`
|
|
363
|
+
|
|
364
|
+
**Basic Usage**
|
|
365
|
+
|
|
366
|
+
```bash
|
|
367
|
+
# Validate all JSON files in current directory
|
|
368
|
+
$ stac-validator batch *.json
|
|
369
|
+
|
|
370
|
+
# Validate specific files
|
|
371
|
+
$ stac-validator batch item1.json item2.json item3.json
|
|
372
|
+
|
|
373
|
+
# Validate a FeatureCollection (extracts and validates each feature)
|
|
374
|
+
$ stac-validator batch collection.json --feature-collection
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
**Options**
|
|
378
|
+
|
|
379
|
+
```bash
|
|
380
|
+
# Use specific number of cores
|
|
381
|
+
$ stac-validator batch *.json --cores 4
|
|
382
|
+
|
|
383
|
+
# Reserve cores for OS (useful on local machines)
|
|
384
|
+
$ stac-validator batch *.json --cores -1 # Uses all cores minus 1
|
|
385
|
+
|
|
386
|
+
# Disable progress bar (for CI/CD environments)
|
|
387
|
+
$ stac-validator batch *.json --no-progress
|
|
388
|
+
|
|
389
|
+
# Suppress JSON output (show only summary)
|
|
390
|
+
$ stac-validator batch *.json --no-output
|
|
391
|
+
|
|
392
|
+
# Configure schema cache size per worker (default: 16 schemas per worker)
|
|
393
|
+
$ stac-validator batch *.json --schema-cache-size 32
|
|
394
|
+
|
|
395
|
+
# Disable schema caching entirely
|
|
396
|
+
$ stac-validator batch *.json --schema-cache-size 0
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
**How It Works**
|
|
400
|
+
|
|
401
|
+
1. **Startup:** Detects available CPU cores (respects Docker limits)
|
|
402
|
+
2. **Distribution:** Distributes files across worker processes
|
|
403
|
+
3. **Validation:** Each worker validates files independently
|
|
404
|
+
4. **Schema Caching:** Each worker maintains its own LRU cache (default 16 schemas per worker)
|
|
405
|
+
- First file on a worker: schemas are fetched and cached
|
|
406
|
+
- Subsequent files: schemas are reused from cache (no network/disk I/O)
|
|
407
|
+
- Total memory: up to `cores × schema_cache_size` schemas in memory
|
|
408
|
+
5. **Results:** Aggregates results and displays summary statistics
|
|
409
|
+
|
|
410
|
+
**Example Output**
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
$ stac-validator batch --feature-collection sample_data/sentinel-cogs_0_100.json
|
|
238
414
|
[
|
|
239
415
|
{
|
|
240
|
-
"
|
|
241
|
-
"
|
|
242
|
-
"
|
|
243
|
-
"
|
|
244
|
-
]
|
|
245
|
-
"valid_stac": true,
|
|
246
|
-
"asset_type": "COLLECTION",
|
|
247
|
-
"validation_method": "default"
|
|
416
|
+
"path": "sample_data/sentinel-cogs_0_100.json[0]",
|
|
417
|
+
"valid_stac": false,
|
|
418
|
+
"errors": [
|
|
419
|
+
"'eo:bands' does not match any of the regexes: '^(?!eo:)'. Error is in properties "
|
|
420
|
+
]
|
|
248
421
|
}
|
|
249
422
|
]
|
|
423
|
+
|
|
424
|
+
Validation Summary:
|
|
425
|
+
Total files: 100
|
|
426
|
+
CPU cores used: 16
|
|
427
|
+
✅ Valid: 99
|
|
428
|
+
❌ Invalid: 1
|
|
429
|
+
|
|
430
|
+
Failed validations:
|
|
431
|
+
sample_data/sentinel-cogs_0_100.json[0]
|
|
432
|
+
- 'eo:bands' does not match any of the regexes: '^(?!eo:)'. Error is in properties
|
|
433
|
+
|
|
434
|
+
Validation completed in 1.10s
|
|
250
435
|
```
|
|
251
436
|
|
|
252
|
-
**
|
|
437
|
+
**Performance Characteristics**
|
|
438
|
+
|
|
439
|
+
| Scenario | Single-threaded | Batch (8 cores) | Speedup |
|
|
440
|
+
|----------|-----------------|-----------------|---------|
|
|
441
|
+
| 100 items | ~5 seconds | ~1 second | 5x |
|
|
442
|
+
| 1000 items | ~50 seconds | ~6 seconds | 8x |
|
|
443
|
+
| 10000 items | ~500 seconds | ~60 seconds | 8x |
|
|
444
|
+
|
|
445
|
+
*Times vary based on schema complexity and network latency for first download*
|
|
446
|
+
|
|
447
|
+
**Python API**
|
|
448
|
+
|
|
449
|
+
```python
|
|
450
|
+
from stac_validator.batch_validator import validate_concurrently
|
|
451
|
+
|
|
452
|
+
# Validate files
|
|
453
|
+
results = validate_concurrently(
|
|
454
|
+
["item1.json", "item2.json", "item3.json"],
|
|
455
|
+
max_workers=None, # Auto-detect cores
|
|
456
|
+
show_progress=True
|
|
457
|
+
)
|
|
458
|
+
|
|
459
|
+
# Validate FeatureCollections
|
|
460
|
+
results = validate_concurrently(
|
|
461
|
+
["collection.json"],
|
|
462
|
+
feature_collection=True,
|
|
463
|
+
max_workers=8
|
|
464
|
+
)
|
|
465
|
+
|
|
466
|
+
# Process results
|
|
467
|
+
for result in results:
|
|
468
|
+
if result["valid_stac"]:
|
|
469
|
+
print(f"✅ {result['path']}")
|
|
470
|
+
else:
|
|
471
|
+
print(f"❌ {result['path']}")
|
|
472
|
+
for error in result.get("errors", []):
|
|
473
|
+
print(f" - {error}")
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
**Use Cases**
|
|
477
|
+
|
|
478
|
+
- **Bulk ingestion:** Validate thousands of STAC items from ESA, Copernicus, or other catalogs
|
|
479
|
+
- **CI/CD pipelines:** Validate entire dataset collections in GitHub Actions or AWS CodePipeline
|
|
480
|
+
- **Data quality checks:** Periodically validate all items in a STAC catalog
|
|
481
|
+
- **Migration validation:** Verify all items when upgrading STAC versions
|
|
482
|
+
- **API preprocessing:** Validate incoming FeatureCollections before storage (see FastAPI integration)
|
|
483
|
+
|
|
484
|
+
### Python
|
|
485
|
+
|
|
486
|
+
**Single File Validation**
|
|
253
487
|
|
|
254
488
|
```python
|
|
255
489
|
from stac_validator import stac_validator
|
|
256
490
|
|
|
491
|
+
# Remote source
|
|
492
|
+
stac = stac_validator.StacValidate("https://raw.githubusercontent.com/stac-utils/pystac/main/tests/data-files/examples/0.9.0/collection-spec/examples/landsat-collection.json")
|
|
493
|
+
stac.run()
|
|
494
|
+
print(stac.message)
|
|
495
|
+
|
|
496
|
+
# Local file
|
|
257
497
|
stac = stac_validator.StacValidate("tests/test_data/1beta1/sentinel2.json", extensions=True)
|
|
258
498
|
stac.run()
|
|
259
499
|
print(stac.message)
|
|
260
500
|
```
|
|
501
|
+
|
|
502
|
+
**Dictionary Validation**
|
|
503
|
+
|
|
261
504
|
```python
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
505
|
+
from stac_validator import stac_validator
|
|
506
|
+
|
|
507
|
+
stac = stac_validator.StacValidate()
|
|
508
|
+
stac.validate_dict(item_dict)
|
|
509
|
+
print(stac.message)
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
**Batch Validation - List of Dictionaries**
|
|
513
|
+
|
|
514
|
+
For validating dictionaries directly without managing temp files, use `validate_dicts()`:
|
|
515
|
+
|
|
516
|
+
```python
|
|
517
|
+
from stac_validator.batch_validator import validate_dicts
|
|
518
|
+
|
|
519
|
+
items = [
|
|
520
|
+
{"type": "Feature", "stac_version": "1.1.0", ...},
|
|
521
|
+
{"type": "Feature", "stac_version": "1.1.0", ...},
|
|
522
|
+
{"type": "Feature", "stac_version": "1.1.0", ...},
|
|
273
523
|
]
|
|
524
|
+
|
|
525
|
+
# Validate all items concurrently (temp files handled internally)
|
|
526
|
+
results = validate_dicts(items, max_workers=None, show_progress=True)
|
|
527
|
+
|
|
528
|
+
print(f"Total: {len(results)}")
|
|
529
|
+
print(f"Valid: {sum(1 for r in results if r['valid_stac'])}")
|
|
530
|
+
print(f"Invalid: {sum(1 for r in results if not r['valid_stac'])}")
|
|
531
|
+
|
|
532
|
+
# Process results
|
|
533
|
+
for result in results:
|
|
534
|
+
if result["valid_stac"]:
|
|
535
|
+
print(f"✅ Valid")
|
|
536
|
+
else:
|
|
537
|
+
print(f"❌ Invalid: {result.get('errors', [])}")
|
|
274
538
|
```
|
|
275
539
|
|
|
276
|
-
**
|
|
540
|
+
**Parameters:**
|
|
541
|
+
- `items` - List of STAC item dictionaries
|
|
542
|
+
- `max_workers` - CPU cores to use (None = auto-detect, positive int = specific cores, negative int = all minus N)
|
|
543
|
+
- `show_progress` - Display progress bar (default: True)
|
|
544
|
+
- `chunk_size` - Number of items to process at a time to bound disk and memory usage (default: 1000)
|
|
545
|
+
|
|
546
|
+
**Batch Validation - FeatureCollection (Concurrent with Multiprocessing)**
|
|
547
|
+
|
|
548
|
+
For FeatureCollection validation with multiprocessing, use `validate_concurrently()` with `feature_collection=True`:
|
|
549
|
+
|
|
550
|
+
```python
|
|
551
|
+
from stac_validator.batch_validator import validate_concurrently
|
|
552
|
+
|
|
553
|
+
# Validate FeatureCollection files directly (10-100x faster for large collections)
|
|
554
|
+
results = validate_concurrently(
|
|
555
|
+
["collection1.json", "collection2.json"],
|
|
556
|
+
feature_collection=True, # Expand and validate each feature
|
|
557
|
+
max_workers=None # Auto-detect cores
|
|
558
|
+
)
|
|
559
|
+
|
|
560
|
+
print(f"Total features: {len(results)}")
|
|
561
|
+
print(f"Valid: {sum(1 for r in results if r['valid_stac'])}")
|
|
562
|
+
print(f"Invalid: {sum(1 for r in results if not r['valid_stac'])}")
|
|
563
|
+
|
|
564
|
+
# Process results
|
|
565
|
+
for result in results:
|
|
566
|
+
if result["valid_stac"]:
|
|
567
|
+
print(f"✅ Feature valid")
|
|
568
|
+
else:
|
|
569
|
+
print(f"❌ Feature invalid: {result.get('errors', [])}")
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
**Batch Validation - Multiple Files**
|
|
573
|
+
|
|
574
|
+
```python
|
|
575
|
+
from stac_validator.batch_validator import validate_concurrently
|
|
576
|
+
|
|
577
|
+
files = [
|
|
578
|
+
"item1.json",
|
|
579
|
+
"item2.json",
|
|
580
|
+
"item3.json",
|
|
581
|
+
]
|
|
582
|
+
|
|
583
|
+
# Validate files concurrently using all available CPU cores
|
|
584
|
+
results = validate_concurrently(
|
|
585
|
+
files,
|
|
586
|
+
max_workers=None, # Auto-detect cores
|
|
587
|
+
show_progress=True
|
|
588
|
+
)
|
|
589
|
+
|
|
590
|
+
# Process results
|
|
591
|
+
for result in results:
|
|
592
|
+
if result["valid_stac"]:
|
|
593
|
+
print(f"✅ {result['path']}")
|
|
594
|
+
else:
|
|
595
|
+
print(f"❌ {result['path']}: {result.get('errors', [])}")
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
**Batch Validation - FeatureCollection Files**
|
|
599
|
+
|
|
600
|
+
```python
|
|
601
|
+
from stac_validator.batch_validator import validate_concurrently
|
|
602
|
+
|
|
603
|
+
files = ["collection1.json", "collection2.json"]
|
|
604
|
+
|
|
605
|
+
# Validate FeatureCollections by extracting and validating each feature
|
|
606
|
+
results = validate_concurrently(
|
|
607
|
+
files,
|
|
608
|
+
feature_collection=True,
|
|
609
|
+
max_workers=8
|
|
610
|
+
)
|
|
611
|
+
|
|
612
|
+
# Results show feature index: "collection1.json[0]", "collection1.json[1]", etc.
|
|
613
|
+
for result in results:
|
|
614
|
+
print(f"{result['path']}: {'✅' if result['valid_stac'] else '❌'}")
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
**Item Collection Validation**
|
|
277
618
|
|
|
278
619
|
```python
|
|
279
620
|
from stac_validator import stac_validator
|
|
280
621
|
|
|
281
622
|
stac = stac_validator.StacValidate()
|
|
282
|
-
stac.
|
|
623
|
+
stac.validate_item_collection_dict(item_collection_dict)
|
|
283
624
|
print(stac.message)
|
|
284
625
|
```
|
|
285
626
|
|
|
286
|
-
**
|
|
627
|
+
**Configure Schema Cache Size**
|
|
287
628
|
|
|
288
629
|
```python
|
|
289
630
|
from stac_validator import stac_validator
|
|
631
|
+
from stac_validator.utilities import set_schema_cache_size
|
|
632
|
+
|
|
633
|
+
# Set once at app startup (process-wide)
|
|
634
|
+
set_schema_cache_size(16) # use 0 to disable caching
|
|
290
635
|
|
|
291
636
|
stac = stac_validator.StacValidate()
|
|
292
|
-
stac.
|
|
637
|
+
stac.validate_dict(dictionary)
|
|
293
638
|
print(stac.message)
|
|
294
639
|
```
|
|
295
640
|
|
|
641
|
+
|
|
642
|
+
### Schema Cache Settings
|
|
643
|
+
|
|
644
|
+
- Default schema cache size is 16 entries.
|
|
645
|
+
- Use `--schema-cache-size` in the CLI or `set_schema_cache_size(...)` in Python to override it.
|
|
646
|
+
- Use `0` to disable schema caching.
|
|
647
|
+
|
|
648
|
+
Use `set_schema_cache_size` once at application startup:
|
|
649
|
+
|
|
650
|
+
```python
|
|
651
|
+
from stac_validator.utilities import set_schema_cache_size
|
|
652
|
+
|
|
653
|
+
# Examples:
|
|
654
|
+
set_schema_cache_size(16) # small cache for low-memory deployments
|
|
655
|
+
set_schema_cache_size(64) # moderate cache for long-running services
|
|
656
|
+
set_schema_cache_size(0) # disable schema caching
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
Notes:
|
|
660
|
+
- `StacValidate()` and `validate_dict()` do not accept a cache-size parameter.
|
|
661
|
+
- Changing cache size at runtime replaces the cache instance and drops existing cached entries.
|
|
662
|
+
- In multi-worker deployments, configure cache size in each worker process.
|
|
663
|
+
|
|
296
664
|
## Deployment
|
|
297
665
|
|
|
298
666
|
### Docker
|
|
@@ -566,11 +934,13 @@ The following organizations have contributed time and/or funding to support the
|
|
|
566
934
|
- [Healy Hyperspatial](https://healy-hyperspatial.github.io/)
|
|
567
935
|
- [Radiant Earth Foundation](https://radiant.earth/)
|
|
568
936
|
- [Sparkgeo](https://sparkgeo.com/)
|
|
937
|
+
- [CloudFerro](https://cloudferro.com/)
|
|
569
938
|
|
|
570
939
|
<p align="left">
|
|
571
940
|
<a href="https://healy-hyperspatial.github.io/"><img src="https://raw.githubusercontent.com/stac-utils/stac-fastapi-elasticsearch-opensearch/refs/heads/main/assets/hh-logo-blue.png" alt="Healy Hyperspatial" height="100" hspace="20"></a>
|
|
572
941
|
<a href="https://radiant.earth/"><img src="assets/radiant-earth.webp" alt="Radiant Earth Foundation" height="100" hspace="20"></a>
|
|
573
942
|
<a href="https://sparkgeo.com/"><img src="assets/sparkgeo_logo.jpeg" alt="Sparkgeo" height="100" hspace="20"></a>
|
|
943
|
+
<a href="https://cloudferro.com/"><img src="assets/cloudferro-logo.png" alt="CloudFerro" height="110" hspace="20"></a>
|
|
574
944
|
</p>
|
|
575
945
|
|
|
576
946
|
|