Exemplo n.º 1
0
 def __init__(self):
     Task.__init__(self, Mock(), Mock())
     self.src_code = ""
     self.extra_data = {}
     self.test_finished = False
     self.results = None
     self.tmp_dir = None
Exemplo n.º 2
0
    def __init__(self,
                 src_code,
                 task_definition,
                 node_name,
                 environment,
                 resource_size=0,
                 owner_address="",
                 owner_port=0,
                 owner_key_id="",
                 max_pending_client_results=MAX_PENDING_CLIENT_RESULTS):
        """Create more specific task implementation

        """

        self.task_definition = task_definition
        task_timeout = task_definition.full_task_timeout
        deadline = timeout_to_deadline(task_timeout)
        th = TaskHeader(
            node_name=node_name,
            task_id=task_definition.task_id,
            task_owner_address=owner_address,
            task_owner_port=owner_port,
            task_owner_key_id=owner_key_id,
            environment=environment,
            task_owner=Node(),
            deadline=deadline,
            subtask_timeout=task_definition.subtask_timeout,
            resource_size=resource_size,
            estimated_memory=task_definition.estimated_memory,
            max_price=task_definition.max_price,
            docker_images=task_definition.docker_images,
        )

        Task.__init__(self, th, src_code)

        self.task_resources = list()

        self.total_tasks = 0
        self.last_task = 0

        self.num_tasks_received = 0
        self.subtasks_given = {}
        self.num_failed_subtasks = 0

        self.full_task_timeout = task_timeout
        self.counting_nodes = {}

        self.root_path = None

        self.stdout = {
        }  # for each subtask keep info about stdout received from computing node
        self.stderr = {
        }  # for each subtask keep info about stderr received from computing node
        self.results = {
        }  # for each subtask keep info about files containing results

        self.res_files = {}
        self.tmp_dir = None
        self.verificator = self.VERIFICATOR_CLASS()
        self.max_pending_client_results = max_pending_client_results
Exemplo n.º 3
0
    def __init__(self, client_id, params, num_subtasks, public_key):
        """Creates a new dummy task
        :param string client_id: client id
        :param DummyTaskParameters params: task parameters
        1024 hashes on average
        """
        task_id = idgenerator.generate_id(public_key)
        owner_address = ''
        owner_port = 0
        owner_key_id = encode_hex(public_key)[2:]
        environment = self.ENVIRONMENT_NAME
        header = TaskHeader(task_id=task_id,
                            environment=environment,
                            task_owner=Node(node_name=client_id,
                                            pub_addr=owner_address,
                                            pub_port=owner_port,
                                            key=owner_key_id),
                            deadline=timeout_to_deadline(14400),
                            subtask_timeout=1200,
                            subtasks_count=num_subtasks,
                            resource_size=params.shared_data_size +
                            params.subtask_data_size,
                            estimated_memory=0,
                            max_price=MIN_PRICE)

        # load the script to be run remotely from the file in the current dir
        script_path = path.join(path.dirname(__file__), 'computation.py')
        with open(script_path, 'r') as f:
            src_code = f.read()
            src_code += '\noutput = run_dummy_task(' \
                'data_file, subtask_data, difficulty, result_size, tmp_path)'

        from apps.dummy.task.dummytaskstate import DummyTaskDefinition
        from apps.dummy.task.dummytaskstate import DummyTaskDefaults
        task_definition = DummyTaskDefinition(DummyTaskDefaults())
        Task.__init__(self, header, src_code, task_definition)

        self.task_id = task_id
        self.task_params = params
        self.task_resources = []
        self.resource_parts = {}

        self.shared_data_file = None
        self.subtasks_count = num_subtasks
        self.total_tasks = self.subtasks_count
        self.subtask_ids = []
        self.subtask_data = {}
        self.subtask_results = {}
        self.assigned_nodes = {}
        self.assigned_subtasks = {}
        self.total_tasks = 1
        self._lock = Lock()
Exemplo n.º 4
0
    def __init__(self, client_id, params, num_subtasks):
        """Creates a new dummy task
        :param string client_id: client id
        :param DummyTaskParameters params: task parameters
        1024 hashes on average
        """
        task_id = SimpleAuth.generate_uuid().get_hex()
        owner_address = ''
        owner_port = 0
        owner_key_id = ''
        environment = self.ENVIRONMENT_NAME
        header = TaskHeader(
            client_id, task_id,
            owner_address, owner_port, owner_key_id, environment,
            task_owner=Node(),
            deadline=timeout_to_deadline(14400),
            subtask_timeout=1200,
            resource_size=params.shared_data_size + params.subtask_data_size,
            estimated_memory=0,
            max_price=MIN_PRICE)

        # load the script to be run remotely from the file in the current dir
        script_path = path.join(path.dirname(__file__), 'computation.py')
        with open(script_path, 'r') as f:
            src_code = f.read()
            src_code += '\noutput = run_dummy_task(' \
                        'data_file, subtask_data, difficulty, result_size)'

        Task.__init__(self, header, src_code)

        self.task_id = task_id
        self.task_params = params
        self.task_resources = []
        self.resource_parts = {}

        self.shared_data_file = None
        self.total_subtasks = num_subtasks
        self.subtask_ids = []
        self.subtask_data = {}
        self.subtask_results = {}
        self.assigned_nodes = {}
        self.assigned_subtasks = {}
        self._lock = Lock()