def get_step_by_version(self, step_type: Union[Type, Text], version: Text): """ Gets a Step object by version. There might be many objects of a particular Step registered in many pipelines. This function just returns the first configuration that it matches. Args: step_type: either a string specifying full path to the step or a class path. version: either sha pin or standard ZenML version pin. """ from zenml.utils import source_utils from zenml.steps.base_step import BaseStep type_str = source_utils.get_module_path_from_class(step_type) for file_path in self.get_pipeline_file_paths(): c = yaml_utils.read_yaml(file_path) for step_name, step_config in c[keys.GlobalKeys.PIPELINE][ keys.PipelineKeys.STEPS].items(): # Get version from source class_ = source_utils.get_class_path_from_source( step_config[keys.StepKeys.SOURCE]) source_version = source_utils.get_version_from_source( step_config[keys.StepKeys.SOURCE]) if class_ == type_str and version == source_version: return BaseStep.from_config(step_config)
def get_step_versions_by_type(self, step_type: Union[Type, Text]): """ List all registered steps in repository by step_type. Args: step_type: either a string specifying full path to the step or a class path. """ from zenml.utils import source_utils type_str = source_utils.get_module_path_from_class(step_type) steps_dict = self.get_step_versions() if type_str not in steps_dict: raise Exception(f'Type {type_str} not available. Available types: ' f'{list(steps_dict.keys())}') return steps_dict[type_str]