pipeline-upload.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 os
  17. from pipeline.backend.pipeline import PipeLine
  18. from pipeline.utils.tools import load_job_config
  19. def main(config="../../config.yaml", namespace=""):
  20. # obtain config
  21. if isinstance(config, str):
  22. config = load_job_config(config)
  23. parties = config.parties
  24. guest = parties.guest[0]
  25. data_base = config.data_base_dir
  26. # partition for data storage
  27. partition = 4
  28. # table name and namespace, used in FATE job configuration
  29. dense_data = {"name": "breast_hetero_guest", "namespace": f"experiment{namespace}"}
  30. tag_data = {"name": "tag_value_1", "namespace": f"experiment{namespace}"}
  31. pipeline_upload = PipeLine().set_initiator(role="guest", party_id=guest).set_roles(guest=guest)
  32. # add upload data info
  33. # path to csv file(s) to be uploaded
  34. pipeline_upload.add_upload_data(file=os.path.join(data_base, "examples/data/breast_hetero_guest.csv"),
  35. table_name=dense_data["name"], # table name
  36. namespace=dense_data["namespace"], # namespace
  37. head=1, partition=partition, # data info
  38. id_delimiter=",")
  39. pipeline_upload.add_upload_data(file=os.path.join(data_base, "examples/data/tag_value_1000_140.csv"),
  40. table_name=tag_data["name"],
  41. namespace=tag_data["namespace"],
  42. head=0, partition=partition,
  43. id_delimiter=",")
  44. # upload both data
  45. pipeline_upload.upload(drop=1)
  46. if __name__ == "__main__":
  47. main()