本文整理汇总了Python中spack.spec.Spec.to_yaml方法的典型用法代码示例。如果您正苦于以下问题:Python Spec.to_yaml方法的具体用法?Python Spec.to_yaml怎么用?Python Spec.to_yaml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spack.spec.Spec
的用法示例。
在下文中一共展示了Spec.to_yaml方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_install_mix_cli_and_files
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import to_yaml [as 别名]
def test_install_mix_cli_and_files(clispecs, filespecs, tmpdir):
args = clispecs
for spec in filespecs:
filepath = tmpdir.join(spec + '.yaml')
args = ['-f', str(filepath)] + args
s = Spec(spec)
s.concretize()
with filepath.open('w') as f:
s.to_yaml(f)
install(*args, fail_on_error=False)
assert install.returncode == 0
示例2: test_yaml_subdag
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import to_yaml [as 别名]
def test_yaml_subdag(config, builtin_mock):
spec = Spec('mpileaks^mpich+debug')
spec.concretize()
yaml_spec = Spec.from_yaml(spec.to_yaml())
for dep in ('callpath', 'mpich', 'dyninst', 'libdwarf', 'libelf'):
assert spec[dep].eq_dag(yaml_spec[dep])
示例3: test_yaml_subdag
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import to_yaml [as 别名]
def test_yaml_subdag(self):
spec = Spec('mpileaks^mpich+debug')
spec.concretize()
yaml_spec = Spec.from_yaml(spec.to_yaml())
for dep in ('callpath', 'mpich', 'dyninst', 'libdwarf', 'libelf'):
self.assertTrue(spec[dep].eq_dag(yaml_spec[dep]))
示例4: test_ordered_read_not_required_for_consistent_dag_hash
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import to_yaml [as 别名]
def test_ordered_read_not_required_for_consistent_dag_hash(
config, builtin_mock
):
"""Make sure ordered serialization isn't required to preserve hashes.
For consistent hashes, we require that YAML and json documents
have their keys serialized in a deterministic order. However, we
don't want to require them to be serialized in order. This
ensures that is not required.
"""
specs = ['mpileaks ^zmpi', 'dttop', 'dtuse']
for spec in specs:
spec = Spec(spec)
spec.concretize()
#
# Dict & corresponding YAML & JSON from the original spec.
#
spec_dict = spec.to_dict()
spec_yaml = spec.to_yaml()
spec_json = spec.to_json()
#
# Make a spec with reversed OrderedDicts for every
# OrderedDict in the original.
#
reversed_spec_dict = reverse_all_dicts(spec.to_dict())
#
# Dump to YAML and JSON
#
yaml_string = syaml.dump(spec_dict, default_flow_style=False)
reversed_yaml_string = syaml.dump(reversed_spec_dict,
default_flow_style=False)
json_string = sjson.dump(spec_dict)
reversed_json_string = sjson.dump(reversed_spec_dict)
#
# Do many consistency checks
#
# spec yaml is ordered like the spec dict
assert yaml_string == spec_yaml
assert json_string == spec_json
# reversed string is different from the original, so it
# *would* generate a different hash
assert yaml_string != reversed_yaml_string
assert json_string != reversed_json_string
# build specs from the "wrongly" ordered data
round_trip_yaml_spec = Spec.from_yaml(yaml_string)
round_trip_json_spec = Spec.from_json(json_string)
round_trip_reversed_yaml_spec = Spec.from_yaml(
reversed_yaml_string
)
round_trip_reversed_json_spec = Spec.from_yaml(
reversed_json_string
)
# TODO: remove this when build deps are in provenance.
spec = spec.copy(deps=('link', 'run'))
# specs are equal to the original
assert spec == round_trip_yaml_spec
assert spec == round_trip_json_spec
assert spec == round_trip_reversed_yaml_spec
assert spec == round_trip_reversed_json_spec
assert round_trip_yaml_spec == round_trip_reversed_yaml_spec
assert round_trip_json_spec == round_trip_reversed_json_spec
# dag_hashes are equal
assert spec.dag_hash() == round_trip_yaml_spec.dag_hash()
assert spec.dag_hash() == round_trip_json_spec.dag_hash()
assert spec.dag_hash() == round_trip_reversed_yaml_spec.dag_hash()
assert spec.dag_hash() == round_trip_reversed_json_spec.dag_hash()