session_utils.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 argparse
  17. from fate_flow.utils.log_utils import schedule_logger
  18. from fate_arch import session
  19. class SessionStop(object):
  20. @classmethod
  21. def run(cls):
  22. parser = argparse.ArgumentParser()
  23. parser.add_argument('--session', required=True, type=str, help="session manager id")
  24. parser.add_argument('--computing', help="computing engine", type=str)
  25. parser.add_argument('--federation', help="federation engine", type=str)
  26. parser.add_argument('--storage', help="storage engine", type=str)
  27. parser.add_argument('-c', '--command', required=True, type=str, help="command")
  28. args = parser.parse_args()
  29. session_id = args.session
  30. fate_job_id = session_id.split('_')[0]
  31. with session.Session(session_id=session_id,
  32. options={"logger": schedule_logger(fate_job_id)}) as sess:
  33. sess.destroy_all_sessions()
  34. if __name__ == '__main__':
  35. SessionStop.run()