permission_utils.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. from fate_flow.db.component_registry import ComponentRegistry
  2. from fate_flow.entity.permission_parameters import DataSet
  3. from fate_flow.hook.common.parameters import PermissionCheckParameters
  4. from fate_flow.utils import schedule_utils, job_utils
  5. def get_permission_parameters(role, party_id, src_role, src_party_id, job_info) -> PermissionCheckParameters:
  6. dsl = job_info['dsl']
  7. runtime_conf = job_info['runtime_conf']
  8. train_runtime_conf = job_info['train_runtime_conf']
  9. dsl_parser = schedule_utils.get_job_dsl_parser(
  10. dsl=dsl,
  11. runtime_conf=runtime_conf,
  12. train_runtime_conf=train_runtime_conf
  13. )
  14. provider_detail = ComponentRegistry.REGISTRY
  15. job_providers = dsl_parser.get_job_providers(provider_detail=provider_detail)
  16. component_parameters = job_utils.get_component_parameters(job_providers, dsl_parser, provider_detail, role, int(party_id))
  17. dataset_dict = job_utils.get_job_dataset(False, role, int(party_id), runtime_conf.get("role"), dsl_parser.get_args_input())
  18. dataset_list = []
  19. if dataset_dict.get(role, {}).get(int(party_id)):
  20. for _, v in dataset_dict[role][int(party_id)].items():
  21. dataset_list.append(DataSet(namespace=v.split('.')[0], name=v.split('.')[1]))
  22. component_list = job_utils.get_job_all_components(dsl)
  23. return PermissionCheckParameters(
  24. src_role=src_role,
  25. src_party_id=src_party_id,
  26. role=role,
  27. party_id=party_id,
  28. initiator=runtime_conf['initiator'],
  29. roles=runtime_conf['role'],
  30. component_list=component_list,
  31. dataset_list=dataset_list,
  32. runtime_conf=runtime_conf,
  33. dsl=dsl,
  34. component_parameters=component_parameters
  35. )