Skip to content

Commit

Permalink
Add dimensions from nomenclature.yaml to CLI validate-project
Browse files Browse the repository at this point in the history
  • Loading branch information
dc-almeida committed Oct 31, 2024
1 parent 6d32bf1 commit 777a2c5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions nomenclature/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import yaml

from nomenclature.definition import DataStructureDefinition
from nomenclature.config import NomenclatureConfig
from nomenclature.processor import (
DataValidator,
RegionProcessor,
Expand Down Expand Up @@ -144,12 +145,16 @@ def assert_valid_structure(
f"Definitions directory not found: {path / definitions}"
)

if dimensions == (): # if "dimensions" were not specified
dimensions = [x.stem for x in (path / definitions).iterdir() if x.is_dir()]
if not dimensions: # if "dimensions" were not specified
if path / "nomenclature.yaml" in path.iterdir():
dimensions = NomenclatureConfig.from_file(
path / "nomenclature.yaml"
).dimensions
if not dimensions:
raise FileNotFoundError(
f"`definitions` directory is empty: {path / definitions}"
)
dimensions = [x.stem for x in (path / definitions).iterdir() if x.is_dir()]
if not dimensions:
raise FileNotFoundError(f"`definitions` directory is empty: {definitions}")

_check_mappings(path, definitions, dimensions, mappings)
_check_processor_directory(
path,
Expand Down

0 comments on commit 777a2c5

Please sign in to comment.