def run_parts()

in asfyaml/asfyaml.py [0:0]


    def run_parts(self, validate_only: bool = False):
        """Runs every enabled and configured feature for the .asf.yaml file.
        If an exception is encountered, the processing will halt at the module that raised
        it, and an email with the error message(s) will be sent to the git client as well as
        private@$project.apache.org. The validate_only flag will cause run_parts to only run
        the validation part and then exit immediately afterwards"""
        # If this is a tag, abort!
        if self.is_tag:
            return

        # For each enabled feature, spin up validation and runtime processing if directives are found
        # for the feature inside our .asf.yaml file.
        features_to_run = []
        for feature_name, feature_yaml in self.yaml.items():
            if feature_name in self.enabled_features:
                feature_yaml_as_string = feature_yaml.as_yaml()
                feature_class = self.enabled_features[feature_name]
                # If the feature has a schema, validate the sub-yaml before running the feature.
                if hasattr(feature_class, "schema"):
                    try:
                        yaml_parsed = strictyaml.dirty_load(
                            feature_yaml_as_string,
                            feature_class.schema,
                            label=f"{self.repository.name}.git/.asf.yaml::{feature_name}",
                            allow_flow_style=True,
                        )
                    except strictyaml.exceptions.YAMLValidationError as e:
                        # feature_start = feature_yaml.start_line
                        # problem_line = feature_start + e.problem_mark.line
                        # problem_column = e.problem_mark.column
                        # TODO: Make this much more reader friendly!
                        raise ASFYAMLException(
                            repository=self.repository, branch=self.branch, feature=feature_name, error_message=str(e)
                        )
                else:
                    yaml_parsed = strictyaml.load(feature_yaml_as_string)
                # Everything seems in order, spin up an instance of the feature class for future use.
                feature = feature_class(self, yaml_parsed)
                features_to_run.append(feature)
                # Log that this feature is enabled, configured, and validated. For cross-feature access.
                self.features[str(feature_name)] = feature
            elif (
                feature_name != "meta"
            ):  # meta is reserved for asfyaml.py, all else needs a feature or it should break.
                raise KeyError(f"No such .asf.yaml feature: {feature_name}")
        # If validate_only, exit now
        if validate_only:
            return

        # If everything validated okay, we will sort the features by priority and then run them
        for feature in sorted(features_to_run, key=lambda x: x.priority):
            if DEBUG:
                print(f"Running feature: {feature.name}")
            try:
                feature.run()
            except strictyaml.YAMLValidationError as e:
                raise ASFYAMLException(
                    repository=self.repository, branch=self.branch, feature=feature.name, error_message=str(e)
                )
            except Exception as e:
                raise ASFYAMLException(
                    repository=self.repository, branch=self.branch, feature=feature.name, error_message=str(e)
                )