control_client.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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.utils.log_utils import getLogger
  17. from fate_flow.utils import api_utils
  18. LOGGER = getLogger()
  19. class ControllerClient(object):
  20. @classmethod
  21. def update_job(cls, job_info):
  22. LOGGER.info("request update job {} on {} {}".format(job_info["job_id"], job_info["role"], job_info["party_id"]))
  23. response = api_utils.local_api(
  24. job_id=job_info["job_id"],
  25. method='POST',
  26. endpoint='/party/{}/{}/{}/update'.format(
  27. job_info["job_id"],
  28. job_info["role"],
  29. job_info["party_id"]
  30. ),
  31. json_body=job_info)
  32. return response
  33. @classmethod
  34. def report_task(cls, task_info):
  35. LOGGER.info("request update job {} task {} {} on {} {}".format(task_info["job_id"], task_info["task_id"],
  36. task_info["task_version"], task_info["role"],
  37. task_info["party_id"]))
  38. response = api_utils.local_api(
  39. job_id=task_info["job_id"],
  40. method='POST',
  41. endpoint='/party/{}/{}/{}/{}/{}/{}/report'.format(
  42. task_info["job_id"],
  43. task_info["component_name"],
  44. task_info["task_id"],
  45. task_info["task_version"],
  46. task_info["role"],
  47. task_info["party_id"]
  48. ),
  49. json_body=task_info)
  50. return response