pipeline-upload-anonymous.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. pipeline_upload = PipeLine().set_initiator(role="guest", party_id=guest).set_roles(guest=guest)
  31. # add upload data info
  32. # path to csv file(s) to be uploaded
  33. pipeline_upload.add_upload_data(file=os.path.join(data_base, "examples/data/breast_hetero_guest.csv"),
  34. table_name=dense_data["name"], # table name
  35. namespace=dense_data["namespace"], # namespace
  36. head=1, partition=partition, # data info
  37. id_delimiter=",",
  38. with_meta=True,
  39. meta={
  40. "with_label": True,
  41. "label_name": "y"
  42. }
  43. )
  44. # upload both data
  45. pipeline_upload.upload(drop=1)
  46. if __name__ == "__main__":
  47. main()