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(self): """List all registered steps in repository""" from zenml.utils import source_utils steps_dict = {} 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.STEPS].items(): # Get version from source version = source_utils.get_version_from_source( step_config[keys.StepKeys.SOURCE]) class_ = source_utils.get_class_path_from_source( step_config[keys.StepKeys.SOURCE]) # Add to set of versions if class_ in steps_dict: steps_dict[class_].add(version) else: steps_dict[class_] = {version} return steps_dict