__init__.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637
  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.entity import RetCode
  17. from fate_flow.entity.run_status import FederatedSchedulingStatusCode
  18. class SchedulerBase():
  19. @classmethod
  20. def return_federated_response(cls, federated_response):
  21. retcode_set = set()
  22. for dest_role in federated_response.keys():
  23. for party_id in federated_response[dest_role].keys():
  24. retcode_set.add(federated_response[dest_role][party_id]["retcode"])
  25. if len(retcode_set) == 1 and RetCode.SUCCESS in retcode_set:
  26. federated_scheduling_status_code = FederatedSchedulingStatusCode.SUCCESS
  27. elif RetCode.EXCEPTION_ERROR in retcode_set:
  28. federated_scheduling_status_code = FederatedSchedulingStatusCode.ERROR
  29. elif RetCode.NOT_EFFECTIVE in retcode_set:
  30. federated_scheduling_status_code = FederatedSchedulingStatusCode.NOT_EFFECTIVE
  31. elif RetCode.SUCCESS in retcode_set:
  32. federated_scheduling_status_code = FederatedSchedulingStatusCode.PARTIAL
  33. else:
  34. federated_scheduling_status_code = FederatedSchedulingStatusCode.FAILED
  35. return federated_scheduling_status_code, federated_response