Пример #1
0
def _collect_and_consume_cray_manifest_files(manifest_file=None,
                                             manifest_directory=None,
                                             dry_run=False,
                                             fail_on_error=False):

    manifest_files = []
    if manifest_file:
        manifest_files.append(manifest_file)

    manifest_dirs = []
    if manifest_directory:
        manifest_dirs.append(manifest_directory)

    if os.path.isdir(cray_manifest.default_path):
        tty.debug(
            "Cray manifest path {0} exists: collecting all files to read.".
            format(cray_manifest.default_path))
        manifest_dirs.append(cray_manifest.default_path)
    else:
        tty.debug("Default Cray manifest directory {0} does not exist.".format(
            cray_manifest.default_path))

    for directory in manifest_dirs:
        for fname in os.listdir(directory):
            if fname.endswith('.json'):
                fpath = os.path.join(directory, fname)
                tty.debug("Adding manifest file: {0}".format(fpath))
                manifest_files.append(os.path.join(directory, fpath))

    if not manifest_files:
        raise NoManifestFileError(
            "--file/--directory not specified, and no manifest found at {0}".
            format(cray_manifest.default_path))

    for path in manifest_files:
        tty.debug("Reading manifest file: " + path)
        try:
            cray_manifest.read(path, not dry_run)
        except (spack.compilers.UnknownCompilerError,
                spack.error.SpackError) as e:
            if fail_on_error:
                raise
            else:
                tty.warn("Failure reading manifest file: {0}"
                         "\n\t{1}".format(path, str(e)))
Пример #2
0
def test_read_old_manifest_v1_2(tmpdir, mutable_config, mock_packages,
                                mutable_database):
    """Test reading a file using the older format
    ('version' instead of 'schema-version').
    """
    manifest_dir = str(tmpdir.mkdir('manifest_dir'))
    manifest_file_path = os.path.join(manifest_dir, 'test.json')
    with open(manifest_file_path, 'w') as manifest_file:
        manifest_file.write("""\
{
  "_meta": {
    "file-type": "cray-pe-json",
    "system-type": "EX",
    "version": "1.3"
  },
  "specs": []
}
""")
    cray_manifest.read(manifest_file_path, True)
Пример #3
0
def test_read_cray_manifest_twice_no_compiler_duplicates(
        tmpdir, mutable_config, mock_packages, mutable_database):
    if spack.config.get('config:concretizer') == 'clingo':
        pytest.skip("The ASP-based concretizer is currently picky about "
                    " OS matching and will fail.")

    with tmpdir.as_cwd():
        test_db_fname = 'external-db.json'
        with open(test_db_fname, 'w') as db_file:
            json.dump(create_manifest_content(), db_file)

        # Read the manifest twice
        cray_manifest.read(test_db_fname, True)
        cray_manifest.read(test_db_fname, True)

        compilers = spack.compilers.all_compilers()
        filtered = list(
            c for c in compilers
            if c.spec == spack.spec.CompilerSpec('*****@*****.**'))
        assert (len(filtered) == 1)
Пример #4
0
def test_read_cray_manifest(
        tmpdir, mutable_config, mock_packages, mutable_database):
    """Check that (a) we can read the cray manifest and add it to the Spack
       Database and (b) we can concretize specs based on that.
    """
    if spack.config.get('config:concretizer') == 'clingo':
        pytest.skip("The ASP-based concretizer is currently picky about "
                    " OS matching and will fail.")

    with tmpdir.as_cwd():
        test_db_fname = 'external-db.json'
        with open(test_db_fname, 'w') as db_file:
            json.dump(create_manifest_content(), db_file)
        cray_manifest.read(test_db_fname, True)
        query_specs = spack.store.db.query('openmpi')
        assert any(x.dag_hash() == 'openmpifakehasha' for x in query_specs)

        concretized_specs = spack.cmd.parse_specs(
            'depends-on-openmpi %[email protected] arch=test-redhat6-x86_64'
            ' ^/openmpifakehasha'.split(),
            concretize=True)
        assert concretized_specs[0]['hwloc'].dag_hash() == 'hwlocfakehashaaa'