check_all_api.py 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. import sys
  17. import requests
  18. import json
  19. from fate_flow.settings import HOST, API_VERSION, HTTP_PORT
  20. fate_flow_server_host = 'http://{}:{}/{}'.format(HOST, HTTP_PORT, API_VERSION)
  21. job_id = sys.argv[1]
  22. role = sys.argv[2]
  23. party_id = int(sys.argv[3])
  24. base_request_data = {'job_id': job_id, 'role': role, 'party_id': party_id}
  25. print('job id is {}'.format(job_id))
  26. # data view
  27. print('job data view')
  28. response = requests.post('{}/tracking/job/data_view'.format(fate_flow_server_host), json=base_request_data)
  29. print(response.json())
  30. response = requests.post('{}/job/data/view/query'.format(fate_flow_server_host), json=base_request_data)
  31. print(response.json())
  32. # dependency
  33. print('dependency')
  34. response = requests.post('{}/pipeline/dag/dependency'.format(fate_flow_server_host),
  35. json={'job_id': job_id, 'role': role, 'party_id': party_id})
  36. dependency_response = response.json()
  37. print(json.dumps(dependency_response))
  38. print()
  39. for component_name in dependency_response['data']['component_list']:
  40. print('component name is {}'.format(component_name))
  41. base_request_data['component_name'] = component_name
  42. # metrics
  43. print('metrics')
  44. response = requests.post('{}/tracking/component/metrics'.format(fate_flow_server_host), json=base_request_data)
  45. print(response.json())
  46. print('metrics return {}'.format(response.json()))
  47. print()
  48. if response.json()['retcode'] == 0 and response.json()['retmsg'] != "no data":
  49. for metric_namespace, metric_names in response.json()['data'].items():
  50. base_request_data['metric_namespace'] = metric_namespace
  51. for metric_name in metric_names:
  52. base_request_data['metric_name'] = metric_name
  53. response = requests.post('{}/tracking/component/metric_data'.format(fate_flow_server_host), json=base_request_data)
  54. if response.json()['retcode'] == 0 :
  55. print('{} {} metric data:'.format(metric_namespace, metric_name))
  56. print(response.json())
  57. else:
  58. print('{} {} no metric data!'.format(metric_namespace, metric_name))
  59. print()
  60. # parameters
  61. print('parameters')
  62. response = requests.post('{}/tracking/component/parameters'.format(fate_flow_server_host), json=base_request_data)
  63. print(response.json())
  64. print('parameters retcode {}'.format(response.json()['retcode']))
  65. # model
  66. print('output model')
  67. response = requests.post('{}/tracking/component/output/model'.format(fate_flow_server_host), json=base_request_data)
  68. print(response.json())
  69. print('output model retcode {}'.format(response.json()['retcode']))
  70. # data
  71. print('output data')
  72. response = requests.post('{}/tracking/component/output/data'.format(fate_flow_server_host), json=base_request_data)
  73. print(response.json())
  74. print('output data retcode {}'.format(response.json()['retcode']))
  75. print()
  76. response = requests.post('{}/tracking/component/output/data/table'.format(fate_flow_server_host), json=base_request_data)
  77. print(response.json())