pipeline-upload-extend-sid.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. extend_sid=True)
  40. pipeline_upload.add_upload_data(file=os.path.join(data_base, "examples/data/tag_value_1000_140.csv"),
  41. table_name=tag_data["name"],
  42. namespace=tag_data["namespace"],
  43. head=0, partition=partition,
  44. id_delimiter=",",
  45. extend_sid=True)
  46. # upload both data
  47. pipeline_upload.upload(drop=1)
  48. if __name__ == "__main__":
  49. main()