operation_client.py 1.8 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 OperationClient(object):
  20. @classmethod
  21. def get_job_conf(cls, job_id, role, party_id, component_name=None, task_id=None, task_version=None):
  22. json_body = {
  23. "job_id": job_id,
  24. "role": role,
  25. "party_id": party_id,
  26. }
  27. if component_name is not None and task_id is not None and task_version is not None:
  28. json_body.update({
  29. "component_name": component_name,
  30. "task_id": task_id,
  31. "task_version": task_version,
  32. })
  33. response = api_utils.local_api(
  34. job_id=job_id,
  35. method='POST',
  36. endpoint='/operation/job_config/get',
  37. json_body=json_body,
  38. )
  39. return response.get("data")
  40. @classmethod
  41. def load_json_conf(cls, job_id, config_path):
  42. response = api_utils.local_api(
  43. job_id=job_id,
  44. method='POST',
  45. endpoint='/operation/json_conf/load'.format(
  46. ),
  47. json_body={"config_path": config_path})
  48. return response.get("data")