apollo_main.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. pre_filter_search_accounts = config_json['preFilterSearchAccountIds']
  19. for merge_cate2 in config_json['mergeCate2PatternPlanIdMap']:
  20. type_json = config_json['mergeCate2PatternPlanIdMap'][merge_cate2]
  21. if merge_cate2 not in new_config_json:
  22. new_config_json[merge_cate2] = {}
  23. new_config_json[merge_cate2] = {
  24. "accountFilters": account_filters,
  25. "contentFilters": content_filters,
  26. "preFilterThreshold": pre_filter_threshold,
  27. "promptId": prompt_id,
  28. "modelValueConfig": model_value_config,
  29. "patternProducePlanIdsMap": type_json,
  30. "preFilterSearchAccountIds": pre_filter_search_accounts
  31. }
  32. print(json.dumps(new_config_json, indent=4, ensure_ascii=False))
  33. if __name__ == '__main__':
  34. main()