<commit_before>from cloudify import ctx
from cloudify.workflows import ctx as workflow_ctx
from cloudify.decorators import workflow
import json


def log(**kwargs):
    ctx.logger.info("Log interface")


@workflow
def customwf( nodes_to_runon, operations_to_execute, **kwargs):

    ctx = workflow_ctx
    ctx.logger.info("Starting Custom Workflow")

    nodes =  json.loads(nodes_to_runon)
    operations = json.loads(operations_to_execute)
    ctx.logger.info("Nodes {} on Operations {}".format(nodes, operations))
    # update interface on the config node
    graph = ctx.graph_mode()

    sequence = graph.sequence()
    for node in ctx.nodes:
        if node.id in nodes:
            for instance in node.instances:
                for operation in operations:
                    ctx.logger.info("Running operation {} on instance {} of node {}".format(operation ,instance.id, node.id))
                    operation_task = instance.execute_operation( operation )
                    sequence.add(operation_task)

    graph.execute()<commit_msg>Update tasks.py<commit_after>from cloudify import ctx
from cloudify.workflows import ctx as workflow_ctx
from cloudify.decorators import workflow
import json


def log(**kwargs):
    ctx.logger.info("Log interface")


@workflow
def customwf( nodes_to_runon, operations_to_execute, **kwargs):

    ctx = workflow_ctx
    ctx.logger.info("Starting Custom Workflow")

    try:
        nodes =  json.loads(nodes_to_runon)
    except TypeError:
        ctx.logger.info("Nodes not in Jsaon trying directly")
        nodes = nodes_to_runon

    try:
        operations = json.loads(operations_to_execute)
    except TypeError:
            ctx.logger.info("operations not in Jsaon trying directly")
            operations = operations_to_execute

    ctx.logger.info("Nodes {} on Operations {}".format(nodes, operations))
    # update interface on the config node
    graph = ctx.graph_mode()


    sequence = graph.sequence()
    for opnode in nodes:

      for node in ctx.nodes:
        if node.id == opnode:
          for instance in node.instances:
            for operation in operations:
                ctx.logger.info("Running operation {} on instance {} of node {}".format(operation ,instance.id, node.id))
                operation_task = instance.execute_operation( operation )
                sequence.add(operation_task)
            
    graph.execute()
{'fraction_non_alphanumeric': 0.0904939809049398, 'fraction_numerical': 0.0, 'mean_word_length': 2.83147853736089, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5778407', 'n_tokens_mistral': 672, 'n_tokens_neox': 641, 'n_words': 185}