pipeline_manager.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #
  2. # Copyright 2019 The FATE Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. from fate_flow.settings import stat_logger
  17. from fate_flow.utils import detect_utils, schedule_utils
  18. from fate_flow.operation.job_saver import JobSaver
  19. def pipeline_dag_dependency(job_info):
  20. try:
  21. detect_utils.check_config(job_info, required_arguments=["party_id", "role"])
  22. component_need_run = {}
  23. if job_info.get('job_id'):
  24. jobs = JobSaver.query_job(job_id=job_info["job_id"], party_id=job_info["party_id"], role=job_info["role"])
  25. if not jobs:
  26. raise Exception('query job {} failed'.format(job_info.get('job_id', '')))
  27. job = jobs[0]
  28. dsl_parser = schedule_utils.get_job_dsl_parser(dsl=job.f_dsl,
  29. runtime_conf=job.f_runtime_conf_on_party,
  30. train_runtime_conf=job.f_train_runtime_conf)
  31. tasks = JobSaver.query_task(job_id=job_info["job_id"], party_id=job_info["party_id"], role=job_info["role"], only_latest=True)
  32. for task in tasks:
  33. need_run = task.f_component_parameters.get("ComponentParam", {}).get("need_run", True)
  34. component_need_run[task.f_component_name] = need_run
  35. else:
  36. dsl_parser = schedule_utils.get_job_dsl_parser(dsl=job_info.get('job_dsl', {}),
  37. runtime_conf=job_info.get('job_runtime_conf', {}),
  38. train_runtime_conf=job_info.get('job_train_runtime_conf', {}))
  39. dependency = dsl_parser.get_dependency()
  40. dependency["component_need_run"] = component_need_run
  41. return dependency
  42. except Exception as e:
  43. stat_logger.exception(e)
  44. raise e