model_predict_analyse.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import argparse
  2. import sys
  3. import gzip
  4. from hdfs import InsecureClient
  5. client = InsecureClient("http://master-1-1.c-7f31a3eea195cb73.cn-hangzhou.emr.aliyuncs.com:9870")
  6. def read_predict(hdfs_path):
  7. for file in client.list(hdfs_path):
  8. with client.read(file, encoding="utf-8") as reador:
  9. with gzip.GzipFile(fileobj=reador, mode="rb") as gz_file:
  10. content = gz_file.read().decode("utf-8")
  11. print(f"Content of {file}:\n {content}")
  12. def _main():
  13. with client.read("/dw/recommend/model/34_ad_predict_data/20241004_351_0927_1003_1000/*",
  14. encoding="utf-8") as reader:
  15. content = reader.read()
  16. print(content)
  17. if __name__ == '__main__':
  18. # parser = argparse.ArgumentParser(description="model_predict_analyse.py")
  19. # parser.add_argument("-p", "--predict_path_list", type=list, help="config file path")
  20. # args = parser.parse_args()
  21. #
  22. # predict_path_list = args.predict_path_list
  23. # # 判断参数是否正常
  24. # if len(predict_path_list) != 2:
  25. # sys.exit(1)
  26. _main()