Args:
        task (Node)
        child_id (fw_id)

    Returns:
        int
    """
    children = task.get_children()
    for child in children:
        if child.get_fw_id() == child_id:
            return True
    return False


# For testing the clustering
swarmpad = SwarmPad()
swarmpad.reset('', require_password=False)

filename = '/Users/randika/Documents/FYP/SwarmForm/swarmform/examples/cluster_examples/test_workflow.yaml'
# create the Firework consisting of a custom "Addition" task
unclustered_sf = SwarmFlow.from_file(filename)

# store workflow
swarmpad.add_sf(unclustered_sf)
sf = swarmpad.get_sf_by_id(unclustered_sf.sf_id)
sf_dag = DAG(sf)

clusterd_wf = cluster_wf_in_hrab(sf_dag, 3)
print(clusterd_wf)
Beispiel #2
0
from swarmform import SwarmPad
from fireworks import Firework, ScriptTask, FWorker
from fireworks.core.rocket_launcher import launch_rocket

if __name__ == "__main__":
    # set up the SwarmPad and reset it
    swarmpad = SwarmPad()
    swarmpad.reset('', require_password=False)

    # create the Firework consisting of a custom "Addition" task
    firework = Firework(ScriptTask.from_str('echo "hello"'))

    # store workflow
    swarmpad.add_sf(firework)

    # Retrieve SwarmFlow from the SwarmPad
    sf = swarmpad.get_sf_by_id(1)

    sf = swarmpad.get_sf_by_name('Unnamed FW')

    # Run the swarmFlow
    launch_rocket(swarmpad, FWorker())