apollo_main.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import json
  2. from client.ApolloClient import ApolloClient
  3. client = ApolloClient("http://apolloconfig-internal.piaoquantv.com")
  4. def main():
  5. config_str = client.get_value(
  6. app_id="crawler-scheduler",
  7. cluster="default",
  8. namespace="application",
  9. key="hot.video.keywords.provide.task.config"
  10. )
  11. new_config_json = {}
  12. config_json = json.loads(config_str)
  13. account_filters = config_json['accountFilterMap']
  14. content_filters = config_json['contentFilterMap']
  15. pre_filter_threshold = config_json['preFilterThreshold']
  16. prompt_id = config_json['promptId']
  17. model_value_config = config_json['modelValueConfig']
  18. for merge_cate2 in config_json['mergeCate2PatternPlanIdMap']:
  19. type_json = config_json['mergeCate2PatternPlanIdMap'][merge_cate2]
  20. if merge_cate2 not in new_config_json:
  21. new_config_json[merge_cate2] = {}
  22. for produce_type in type_json:
  23. produce_plan_ids = type_json[produce_type]
  24. new_config_json[merge_cate2][produce_type] = {
  25. "accountFilters": account_filters,
  26. "contentFilters": content_filters,
  27. "preFilterThreshold": pre_filter_threshold,
  28. "promptId": prompt_id,
  29. "modelValueConfig": model_value_config,
  30. "producePlanIds": produce_plan_ids
  31. }
  32. print(json.dumps(new_config_json, indent=4, ensure_ascii=False))
  33. if __name__ == '__main__':
  34. main()