Example #1
0
def from_yaml_to_current(yaml_str: str) -> current.RunDescriber:
    """
    Deserialize a YAML string into a RunDescriber of the current version
    """
    yaml = YAML()
    # yaml.load returns an OrderedDict, but we need a dict
    ser = cast(RunDescriberDicts, dict(yaml.load(yaml_str)))
    return from_dict_to_current(ser)
Example #2
0
 def from_yaml(cls, yaml_str: str) -> 'RunDescriber':
     """
     Parse a yaml string (the return of `to_yaml`) into a RunDescriber
     object
     """
     yaml = YAML()
     # yaml.load returns an OrderedDict, but we need a dict
     ser = dict(yaml.load(yaml_str))
     return cls.deserialize(ser)
Example #3
0
def test_yaml_creation_and_loading(some_paramspecs):
    yaml = YAML()
    for group in some_paramspecs.values():
        paramspecs = group.values()
        idp = InterDependencies(*paramspecs)
        desc = RunDescriber(interdeps=idp)

        yaml_str = desc.to_yaml()
        assert isinstance(yaml_str, str)
        ydict = dict(yaml.load(yaml_str))
        assert list(ydict.keys()) == ['interdependencies']

        new_desc = RunDescriber.from_yaml(yaml_str)
        assert new_desc == desc
Example #4
0
def test_yaml_creation_and_loading(some_interdeps):

    yaml = YAML()

    for idps in some_interdeps:
        desc = RunDescriber(interdeps=idps)

        yaml_str = serial.to_yaml_for_storage(desc)
        assert isinstance(yaml_str, str)
        ydict = dict(yaml.load(yaml_str))
        assert list(ydict.keys()) == ['version', 'interdependencies']
        assert ydict['version'] == serial.STORAGE_VERSION

        new_desc = serial.from_yaml_to_current(yaml_str)
        assert new_desc == desc