model_loader_param.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. from pipeline.param.base_param import BaseParam
  16. class CheckpointParam(BaseParam):
  17. def __init__(self, model_id: str = None, model_version: str = None, component_name: str = None,
  18. step_index: int = None, step_name: str = None):
  19. super().__init__()
  20. self.model_id = model_id
  21. self.model_version = model_version
  22. self.component_name = component_name
  23. self.step_index = step_index
  24. self.step_name = step_name
  25. if self.step_index is not None:
  26. self.step_index = int(self.step_index)
  27. def check(self):
  28. for i in ('model_id', 'model_version', 'component_name'):
  29. if getattr(self, i) is None:
  30. return False
  31. # do not set step_index and step_name at the same time
  32. if self.step_index is not None:
  33. return self.step_name is None
  34. return self.step_name is not None