summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2018-12-24 12:48:27 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2018-12-30 00:19:08 -0800
commita9b69fa902a6cea4922c00c42053242314d28464 (patch)
tree6d96f4531b558a5214dc50e54b7389d188b65bb1 /lib
parentc1d7adaaac1b52ea59fdc7938c0f663fef5743fe (diff)
downloadspack-a9b69fa902a6cea4922c00c42053242314d28464.tar.gz
spack-a9b69fa902a6cea4922c00c42053242314d28464.tar.bz2
spack-a9b69fa902a6cea4922c00c42053242314d28464.tar.xz
spack-a9b69fa902a6cea4922c00c42053242314d28464.zip
ProviderIndex uses json instead of YAML
- indexes should use json, not YAML, to optimize for speed - only use YAML in human-editable files - this makes ProviderIndex consistent with other indexes
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/provider_index.py25
-rw-r--r--lib/spack/spack/repo.py4
-rw-r--r--lib/spack/spack/test/cmd/providers.py4
-rw-r--r--lib/spack/spack/test/provider_index.py6
4 files changed, 18 insertions, 21 deletions
diff --git a/lib/spack/spack/provider_index.py b/lib/spack/spack/provider_index.py
index 222f98c0d9..8b36eac717 100644
--- a/lib/spack/spack/provider_index.py
+++ b/lib/spack/spack/provider_index.py
@@ -6,13 +6,13 @@
"""
The ``virtual`` module contains utility classes for virtual dependencies.
"""
+
from itertools import product as iproduct
from six import iteritems
from pprint import pformat
import spack.error
-import spack.util.spack_yaml as syaml
-from ruamel.yaml.error import MarkedYAMLError
+import spack.util.spack_json as sjson
class ProviderIndex(object):
@@ -169,31 +169,26 @@ class ProviderIndex(object):
return all(c in result for c in common)
- def to_yaml(self, stream=None):
+ def to_json(self, stream=None):
provider_list = self._transform(
lambda vpkg, pset: [
vpkg.to_node_dict(), [p.to_node_dict() for p in pset]], list)
- syaml.dump({'provider_index': {'providers': provider_list}},
- stream=stream)
+ sjson.dump({'provider_index': {'providers': provider_list}}, stream)
@staticmethod
- def from_yaml(stream):
- try:
- yfile = syaml.load(stream)
- except MarkedYAMLError as e:
- raise spack.spec.SpackYAMLError(
- "error parsing YAML ProviderIndex cache:", str(e))
+ def from_json(stream):
+ data = sjson.load(stream)
- if not isinstance(yfile, dict):
- raise ProviderIndexError("YAML ProviderIndex was not a dict.")
+ if not isinstance(data, dict):
+ raise ProviderIndexError("JSON ProviderIndex data was not a dict.")
- if 'provider_index' not in yfile:
+ if 'provider_index' not in data:
raise ProviderIndexError(
"YAML ProviderIndex does not start with 'provider_index'")
index = ProviderIndex()
- providers = yfile['provider_index']['providers']
+ providers = data['provider_index']['providers']
index.providers = _transform(
providers,
lambda vpkg, plist: (
diff --git a/lib/spack/spack/repo.py b/lib/spack/spack/repo.py
index 0600a19ef9..663edf2bf8 100644
--- a/lib/spack/spack/repo.py
+++ b/lib/spack/spack/repo.py
@@ -276,14 +276,14 @@ class ProviderIndexer(Indexer):
return ProviderIndex()
def read(self, stream):
- self.index = ProviderIndex.from_yaml(stream)
+ self.index = ProviderIndex.from_json(stream)
def update(self, pkg_fullname):
self.index.remove_provider(pkg_fullname)
self.index.update(pkg_fullname)
def write(self, stream):
- self.index.to_yaml(stream)
+ self.index.to_json(stream)
class RepoIndex(object):
diff --git a/lib/spack/spack/test/cmd/providers.py b/lib/spack/spack/test/cmd/providers.py
index f547607315..d6c15e66e3 100644
--- a/lib/spack/spack/test/cmd/providers.py
+++ b/lib/spack/spack/test/cmd/providers.py
@@ -22,11 +22,13 @@ def test_it_just_runs(pkg):
@pytest.mark.parametrize('vpkg,provider_list', [
- (('mpi',), ['intel-mpi',
+ (('mpi',), ['charmpp@6.7.1:',
+ 'intel-mpi',
'intel-parallel-studio',
'mpich',
'mpich@1:',
'mpich@3:',
+ 'mpilander',
'mvapich2',
'openmpi',
'openmpi@1.6.5',
diff --git a/lib/spack/spack/test/provider_index.py b/lib/spack/spack/test/provider_index.py
index dfa9ef37fc..5b8fb38e91 100644
--- a/lib/spack/spack/test/provider_index.py
+++ b/lib/spack/spack/test/provider_index.py
@@ -25,14 +25,14 @@ from spack.provider_index import ProviderIndex
from spack.spec import Spec
-def test_yaml_round_trip(mock_packages):
+def test_provider_index_round_trip(mock_packages):
p = ProviderIndex(spack.repo.all_package_names())
ostream = StringIO()
- p.to_yaml(ostream)
+ p.to_json(ostream)
istream = StringIO(ostream.getvalue())
- q = ProviderIndex.from_yaml(istream)
+ q = ProviderIndex.from_json(istream)
assert p == q