Exemple #1
0
def test_setup_filebacked(tmpdir):
    from yadage.state_providers.localposix import LocalFSProvider
    from packtivity.statecontexts.posixfs_context import LocalFSState
    import os
    localprovider = LocalFSProvider(
        LocalFSState(readwrite=[
            os.path.join(str(tmpdir), 'rw_one'),
            os.path.join(str(tmpdir), 'rw_two')
        ],
                     readonly=[
                         os.path.join(str(tmpdir), 'ro_one'),
                         os.path.join(str(tmpdir), 'ro_two')
                     ]),
        init_states=[
            LocalFSState(readwrite=[
                os.path.join(str(tmpdir), 'init_rw_one'),
                os.path.join(str(tmpdir), 'init_rw_two')
            ],
                         readonly=[
                             os.path.join(str(tmpdir), 'init_ro_one'),
                             os.path.join(str(tmpdir), 'init_ro_two')
                         ])
        ])
    assert LocalFSProvider.fromJSON(localprovider.json(),
                                    {}).json() == localprovider.json()
def test_setup_filebacked(tmpdir):
    from yadage.state_providers.localposix import LocalFSProvider
    from packtivity.statecontexts.posixfs_context import LocalFSState
    import os
    localprovider = LocalFSProvider(

        LocalFSState(
            readwrite = [
                os.path.join(str(tmpdir),'rw_one'),
                os.path.join(str(tmpdir),'rw_two')
            ],
            readonly = [
                os.path.join(str(tmpdir),'ro_one'),
                os.path.join(str(tmpdir),'ro_two')
            ]
        )
        ,
        init_states = [
            LocalFSState(
                    readwrite = [
                        os.path.join(str(tmpdir),'init_rw_one'),
                        os.path.join(str(tmpdir),'init_rw_two')
                    ],
                    readonly = [
                        os.path.join(str(tmpdir),'init_ro_one'),
                        os.path.join(str(tmpdir),'init_ro_two')
                    ]
            )
        ]
    )
    assert LocalFSProvider.fromJSON(localprovider.json(),{}).json() == localprovider.json()
Exemple #3
0
def test_applicable():
    data = yadage.workflow_loader.workflow('workflow.yml',
                                           'tests/testspecs/local-helloworld')
    wflow = YadageWorkflow.createFromJSON(
        data, LocalFSProvider(LocalFSState(['/workdir']), ensure=False))
    wflow.view().init({'par': 'value'})
    assert wflow.rules[-1].applicable(wflow) == True
Exemple #4
0
def test_serialize_offsetstage():
    data = yadage.workflow_loader.workflow("workflow.yml",
                                           "tests/testspecs/nestedmapreduce")
    wflow = YadageWorkflow.createFromJSON(
        data, LocalFSProvider(LocalFSState(["/workdir"]), ensure=False))
    wflow.view().init({"input": [1, 2, 3]})
    for x in wflow.rules:
        assert OffsetStage.fromJSON(x.json()).json() == x.json()
Exemple #5
0
def test_getRule():
    data  = yadage.workflow_loader.workflow('workflow.yml','tests/testspecs/nestedmapreduce')
    wflow = YadageWorkflow.createFromJSON(data,LocalFSProvider(LocalFSState(['/workdir']), ensure = False))
    wflow.view().init({'input':[1,2,3]})

    assert wflow.view().getRule(identifier = wflow.rules[0].identifier) == wflow.rules[0]
    assert wflow.view().getRule(name = wflow.rules[0].rule.name, offset = '') == wflow.rules[0]
    assert wflow.view().getRule(name = 'nonexistent') == None
Exemple #6
0
def test_applicable():
    data = yadage.workflow_loader.workflow(
        "workflow.yml", "tests/testspecs/local-helloworld"
    )
    wflow = YadageWorkflow.createFromJSON(
        data, LocalFSProvider(LocalFSState(["/workdir"]), ensure=False)
    )
    wflow.view().init({"par": "value"})
    assert wflow.rules[-1].applicable(wflow) == True
Exemple #7
0
def test_serialize_deserialize():
    data = yadage.workflow_loader.workflow('workflow.yml',
                                           'tests/testspecs/local-helloworld')
    wflow = YadageWorkflow.createFromJSON(
        data, LocalFSProvider(LocalFSState(['/workdir']), ensure=False))
    wflow.view().init({'hello': 'world'})
    assert wflow.rules[0].rule.json()
    assert wflow.rules[1].rule.json()

    assert JsonStage.fromJSON(
        wflow.rules[0].rule.json()).json() == wflow.rules[0].rule.json()
Exemple #8
0
def test_getRule():
    data = yadage.workflow_loader.workflow("workflow.yml",
                                           "tests/testspecs/nestedmapreduce")
    wflow = YadageWorkflow.createFromJSON(
        data, LocalFSProvider(LocalFSState(["/workdir"]), ensure=False))
    wflow.view().init({"input": [1, 2, 3]})

    assert wflow.view().getRule(
        identifier=wflow.rules[0].identifier) == wflow.rules[0]
    assert (wflow.view().getRule(name=wflow.rules[0].rule.name,
                                 offset="") == wflow.rules[0])
    assert wflow.view().getRule(name="nonexistent") == None
Exemple #9
0
def test_init():
    data  = yadage.workflow_loader.workflow('workflow.yml','tests/testspecs/nestedmapreduce')
    wflow = YadageWorkflow.createFromJSON(data,LocalFSProvider(LocalFSState(['/workdir']), ensure = False))
    view  = wflow.view()

    nrules_before = len(wflow.rules)
    view.init({'hello':'world'})
    nrules_after = len(wflow.rules)
    assert nrules_before + 1 == nrules_after
    view.rules[-1].apply(wflow)

    matches = view.query('init',view.steps)
    assert len(matches) == 1
Exemple #10
0
def test_serialize_deserialize():
    data = yadage.workflow_loader.workflow(
        "workflow.yml", "tests/testspecs/local-helloworld"
    )
    wflow = YadageWorkflow.createFromJSON(
        data, LocalFSProvider(LocalFSState(["/workdir"]), ensure=False)
    )
    wflow.view().init({"hello": "world"})
    assert wflow.rules[0].rule.json()
    assert wflow.rules[1].rule.json()

    assert (
        JsonStage.fromJSON(wflow.rules[0].rule.json()).json()
        == wflow.rules[0].rule.json()
    )
Exemple #11
0
def test_init():
    data = yadage.workflow_loader.workflow("workflow.yml",
                                           "tests/testspecs/nestedmapreduce")
    wflow = YadageWorkflow.createFromJSON(
        data, LocalFSProvider(LocalFSState(["/workdir"]), ensure=False))
    view = wflow.view()

    nrules_before = len(wflow.rules)
    view.init({"hello": "world"})
    nrules_after = len(wflow.rules)
    assert nrules_before + 1 == nrules_after
    view.rules[-1].apply(wflow)

    matches = view.query("init", view.steps)
    assert len(matches) == 1
Exemple #12
0
def localfs_state_provider(tmpdir):
    return LocalFSProvider(LocalFSState([tmpdir.dirname]), ensure=True)