summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2024-02-23 19:23:54 +0100
committerGitHub <noreply@github.com>2024-02-23 10:23:54 -0800
commitd49cbecf8c336322eccdb767d4128dd7a8feecd0 (patch)
tree003ef46e004d77d7821f62c2151cdf0a1937043e /lib
parentfe07645e3b122dfb0e5772ca6c568b69b0743f11 (diff)
downloadspack-d49cbecf8c336322eccdb767d4128dd7a8feecd0.tar.gz
spack-d49cbecf8c336322eccdb767d4128dd7a8feecd0.tar.bz2
spack-d49cbecf8c336322eccdb767d4128dd7a8feecd0.tar.xz
spack-d49cbecf8c336322eccdb767d4128dd7a8feecd0.zip
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
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/schema/__init__.py23
-rw-r--r--lib/spack/spack/schema/definitions.py4
-rw-r--r--lib/spack/spack/schema/env.py6
-rw-r--r--lib/spack/spack/schema/spack.py46
-rw-r--r--lib/spack/spack/schema/spec_list.py24
5 files changed, 29 insertions, 74 deletions
diff --git a/lib/spack/spack/schema/__init__.py b/lib/spack/spack/schema/__init__.py
index d6df072117..03fe4039a8 100644
--- a/lib/spack/spack/schema/__init__.py
+++ b/lib/spack/spack/schema/__init__.py
@@ -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 _make_validator():
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"},
- ]
- },
-}
diff --git a/lib/spack/spack/schema/definitions.py b/lib/spack/spack/schema/definitions.py
index 1f8b8b4833..8f0699a175 100644
--- a/lib/spack/spack/schema/definitions.py
+++ b/lib/spack/spack/schema/definitions.py
@@ -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 @@ properties: Dict[str, Any] = {
"items": {
"type": "object",
"properties": {"when": {"type": "string"}},
- "patternProperties": {r"^(?!when$)\w*": spack.schema.spec_list_schema},
+ "patternProperties": {r"^(?!when$)\w*": spec_list_schema},
},
}
}
diff --git a/lib/spack/spack/schema/env.py b/lib/spack/spack/schema/env.py
index 676fbeb277..d2df795a3d 100644
--- a/lib/spack/spack/schema/env.py
+++ b/lib/spack/spack/schema/env.py
@@ -16,11 +16,11 @@ import spack.schema.gitlab_ci # DEPRECATED
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 @@ properties: Dict[str, Any] = {
# extra environment schema properties
{
"include": {"type": "array", "default": [], "items": {"type": "string"}},
- "specs": spack.schema.spec_list_schema,
+ "specs": spec_list_schema,
},
),
}
diff --git a/lib/spack/spack/schema/spack.py b/lib/spack/spack/schema/spack.py
deleted file mode 100644
index 7d5a13c17e..0000000000
--- a/lib/spack/spack/schema/spack.py
+++ /dev/null
@@ -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,
-}
diff --git a/lib/spack/spack/schema/spec_list.py b/lib/spack/spack/schema/spec_list.py
new file mode 100644
index 0000000000..67d6b2745a
--- /dev/null
+++ b/lib/spack/spack/schema/spec_list.py
@@ -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"},
+ ]
+ },
+}