Beispiel #1
0
 def initialize_task_holder_for_scheduling(cls, role, party_id, components,
                                           common_task_info, provider_info):
     for component_name in components:
         task_info = {}
         task_info.update(common_task_info)
         task_info["component_name"] = component_name
         task_info["component_module"] = ""
         task_info["provider_info"] = provider_info
         task_info["component_parameters"] = {}
         TaskController.create_task(
             role=role,
             party_id=party_id,
             run_on_this_party=common_task_info["run_on_this_party"],
             task_info=task_info)
    def _run(self):
        result = {}
        dsl_parser = schedule_utils.get_job_dsl_parser(
            dsl=self.args.dsl,
            runtime_conf=self.args.runtime_conf,
            train_runtime_conf=self.args.train_runtime_conf,
            pipeline_dsl=self.args.pipeline_dsl)

        provider = ComponentProvider(**self.args.config["provider"])
        common_task_info = self.args.config["common_task_info"]
        log_msg = f"initialize the components: {self.args.config['components']}"
        LOGGER.info(
            start_log(log_msg,
                      role=self.args.role,
                      party_id=self.args.party_id))
        for component_name in self.args.config["components"]:
            result[component_name] = {}
            task_info = {}
            task_info.update(common_task_info)

            parameters, user_specified_parameters = ProviderManager.get_component_parameters(
                dsl_parser=dsl_parser,
                component_name=component_name,
                role=self.args.role,
                party_id=self.args.party_id,
                provider=provider)
            if parameters:
                task_info = {}
                task_info.update(common_task_info)
                task_info["component_name"] = component_name
                task_info["component_module"] = parameters["module"]
                task_info["provider_info"] = provider.to_dict()
                task_info["component_parameters"] = parameters
                TaskController.create_task(
                    role=self.args.role,
                    party_id=self.args.party_id,
                    run_on_this_party=common_task_info["run_on_this_party"],
                    task_info=task_info)
                result[component_name]["need_run"] = True
            else:
                # The party does not need to run, pass
                result[component_name]["need_run"] = False
        LOGGER.info(
            successful_log(log_msg,
                           role=self.args.role,
                           party_id=self.args.party_id))
        return result
Beispiel #3
0
 def initialize_tasks(cls,
                      job_id,
                      role,
                      party_id,
                      run_on_this_party,
                      initiator_role,
                      initiator_party_id,
                      job_parameters: RunParameters,
                      dsl_parser,
                      component_name=None,
                      task_version=None):
     common_task_info = {}
     common_task_info["job_id"] = job_id
     common_task_info["initiator_role"] = initiator_role
     common_task_info["initiator_party_id"] = initiator_party_id
     common_task_info["role"] = role
     common_task_info["party_id"] = party_id
     common_task_info["federated_mode"] = job_parameters.federated_mode
     common_task_info[
         "federated_status_collect_type"] = job_parameters.federated_status_collect_type
     if task_version:
         common_task_info["task_version"] = task_version
     if not component_name:
         components = dsl_parser.get_topology_components()
     else:
         components = [
             dsl_parser.get_component_info(component_name=component_name)
         ]
     for component in components:
         component_parameters = component.get_role_parameters()
         for parameters_on_party in component_parameters.get(
                 common_task_info["role"], []):
             if parameters_on_party.get(
                     'local',
                 {}).get('party_id') == common_task_info["party_id"]:
                 task_info = {}
                 task_info.update(common_task_info)
                 task_info["component_name"] = component.get_name()
                 TaskController.create_task(
                     role=role,
                     party_id=party_id,
                     run_on_this_party=run_on_this_party,
                     task_info=task_info)
Beispiel #4
0
def create_task(job_id, component_name, task_id, task_version, role, party_id):
    TaskController.create_task(role, party_id, True, request.json)
    return get_json_result(retcode=0, retmsg='success')