Cleanup spack.schema (#42815)
* Move spec_list into its own file, instead of __init__.py * Remove spack.schema.spack This module was introduced in #33960 It's almost an exact duplicate of spack.schema.env, and is not used anywhere. * Fix typo
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							fe07645e3b
						
					
				
				
					commit
					d49cbecf8c
				
			@@ -6,7 +6,6 @@
 | 
			
		||||
import warnings
 | 
			
		||||
 | 
			
		||||
import llnl.util.lang
 | 
			
		||||
import llnl.util.tty
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# jsonschema is imported lazily as it is heavy to import
 | 
			
		||||
@@ -62,25 +61,3 @@ def _deprecated_properties(validator, deprecated, instance, schema):
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Validator = llnl.util.lang.Singleton(_make_validator)
 | 
			
		||||
 | 
			
		||||
spec_list_schema = {
 | 
			
		||||
    "type": "array",
 | 
			
		||||
    "default": [],
 | 
			
		||||
    "items": {
 | 
			
		||||
        "anyOf": [
 | 
			
		||||
            {
 | 
			
		||||
                "type": "object",
 | 
			
		||||
                "additionalProperties": False,
 | 
			
		||||
                "properties": {
 | 
			
		||||
                    "matrix": {
 | 
			
		||||
                        "type": "array",
 | 
			
		||||
                        "items": {"type": "array", "items": {"type": "string"}},
 | 
			
		||||
                    },
 | 
			
		||||
                    "exclude": {"type": "array", "items": {"type": "string"}},
 | 
			
		||||
                },
 | 
			
		||||
            },
 | 
			
		||||
            {"type": "string"},
 | 
			
		||||
            {"type": "null"},
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,7 @@
 | 
			
		||||
"""
 | 
			
		||||
from typing import Any, Dict
 | 
			
		||||
 | 
			
		||||
import spack.schema
 | 
			
		||||
from .spec_list import spec_list_schema
 | 
			
		||||
 | 
			
		||||
#: Properties for inclusion in other schemas
 | 
			
		||||
properties: Dict[str, Any] = {
 | 
			
		||||
@@ -20,7 +20,7 @@
 | 
			
		||||
        "items": {
 | 
			
		||||
            "type": "object",
 | 
			
		||||
            "properties": {"when": {"type": "string"}},
 | 
			
		||||
            "patternProperties": {r"^(?!when$)\w*": spack.schema.spec_list_schema},
 | 
			
		||||
            "patternProperties": {r"^(?!when$)\w*": spec_list_schema},
 | 
			
		||||
        },
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -16,11 +16,11 @@
 | 
			
		||||
import spack.schema.merged
 | 
			
		||||
import spack.schema.projections
 | 
			
		||||
 | 
			
		||||
from .spec_list import spec_list_schema
 | 
			
		||||
 | 
			
		||||
#: Top level key in a manifest file
 | 
			
		||||
TOP_LEVEL_KEY = "spack"
 | 
			
		||||
 | 
			
		||||
projections_scheme = spack.schema.projections.properties["projections"]
 | 
			
		||||
 | 
			
		||||
properties: Dict[str, Any] = {
 | 
			
		||||
    "spack": {
 | 
			
		||||
        "type": "object",
 | 
			
		||||
@@ -34,7 +34,7 @@
 | 
			
		||||
            # extra environment schema properties
 | 
			
		||||
            {
 | 
			
		||||
                "include": {"type": "array", "default": [], "items": {"type": "string"}},
 | 
			
		||||
                "specs": spack.schema.spec_list_schema,
 | 
			
		||||
                "specs": spec_list_schema,
 | 
			
		||||
            },
 | 
			
		||||
        ),
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,46 +0,0 @@
 | 
			
		||||
# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
 | 
			
		||||
# Spack Project Developers. See the top-level COPYRIGHT file for details.
 | 
			
		||||
#
 | 
			
		||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
 | 
			
		||||
 | 
			
		||||
"""Schema for spack environment
 | 
			
		||||
 | 
			
		||||
.. literalinclude:: _spack_root/lib/spack/spack/schema/spack.py
 | 
			
		||||
   :lines: 20-
 | 
			
		||||
"""
 | 
			
		||||
from typing import Any, Dict
 | 
			
		||||
 | 
			
		||||
from llnl.util.lang import union_dicts
 | 
			
		||||
 | 
			
		||||
import spack.schema
 | 
			
		||||
import spack.schema.gitlab_ci as ci_schema  # DEPRECATED
 | 
			
		||||
import spack.schema.merged as merged_schema
 | 
			
		||||
 | 
			
		||||
#: Properties for inclusion in other schemas
 | 
			
		||||
properties: Dict[str, Any] = {
 | 
			
		||||
    "spack": {
 | 
			
		||||
        "type": "object",
 | 
			
		||||
        "default": {},
 | 
			
		||||
        "additionalProperties": False,
 | 
			
		||||
        "properties": union_dicts(
 | 
			
		||||
            # Include deprecated "gitlab-ci" section
 | 
			
		||||
            ci_schema.properties,
 | 
			
		||||
            # merged configuration scope schemas
 | 
			
		||||
            merged_schema.properties,
 | 
			
		||||
            # extra environment schema properties
 | 
			
		||||
            {
 | 
			
		||||
                "include": {"type": "array", "default": [], "items": {"type": "string"}},
 | 
			
		||||
                "specs": spack.schema.spec_list_schema,
 | 
			
		||||
            },
 | 
			
		||||
        ),
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#: Full schema with metadata
 | 
			
		||||
schema = {
 | 
			
		||||
    "$schema": "http://json-schema.org/draft-07/schema#",
 | 
			
		||||
    "title": "Spack environment file schema",
 | 
			
		||||
    "type": "object",
 | 
			
		||||
    "additionalProperties": False,
 | 
			
		||||
    "properties": properties,
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										24
									
								
								lib/spack/spack/schema/spec_list.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								lib/spack/spack/schema/spec_list.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
			
		||||
# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
 | 
			
		||||
# Spack Project Developers. See the top-level COPYRIGHT file for details.
 | 
			
		||||
#
 | 
			
		||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
 | 
			
		||||
matrix_schema = {"type": "array", "items": {"type": "array", "items": {"type": "string"}}}
 | 
			
		||||
 | 
			
		||||
spec_list_schema = {
 | 
			
		||||
    "type": "array",
 | 
			
		||||
    "default": [],
 | 
			
		||||
    "items": {
 | 
			
		||||
        "anyOf": [
 | 
			
		||||
            {
 | 
			
		||||
                "type": "object",
 | 
			
		||||
                "additionalProperties": False,
 | 
			
		||||
                "properties": {
 | 
			
		||||
                    "matrix": matrix_schema,
 | 
			
		||||
                    "exclude": {"type": "array", "items": {"type": "string"}},
 | 
			
		||||
                },
 | 
			
		||||
            },
 | 
			
		||||
            {"type": "string"},
 | 
			
		||||
            {"type": "null"},
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user