ballet.validation.common module

class ballet.validation.common.ChangeCollector(project, differ=None)[source]

Bases: object

Validate the features introduced in a proposed change set.

Parameters
  • project (Project) – project info

  • differ (Optional[Differ]) – specific differ to use; if not provided, will be determined automatically from the environment

collect_changes()[source]

Collect file and feature changes

Steps

  1. Collects the files that have changed in this pull request as compared to a comparison branch.

  2. Categorize these file changes into admissible or inadmissible file changes. Admissible file changes solely contribute python files to the contrib subdirectory.

  3. Collect features from admissible new files.

Return type

CollectedChanges

class ballet.validation.common.CollectedChanges(file_diffs, candidate_feature_diffs, valid_init_diffs, inadmissible_diffs, new_feature_info)[source]

Bases: tuple

candidate_feature_diffs: List[git.diff.Diff]

Alias for field number 1

file_diffs: git.diff.DiffIndex

Alias for field number 0

inadmissible_diffs: List[git.diff.Diff]

Alias for field number 3

new_feature_info: List[ballet.validation.common.NewFeatureInfo]

Alias for field number 4

valid_init_diffs: List[git.diff.Diff]

Alias for field number 2

class ballet.validation.common.NewFeatureInfo(importer, modname, modpath)[source]

Bases: tuple

importer: Callable[], module]

Alias for field number 0

modname: str

Alias for field number 1

modpath: str

Alias for field number 2

class ballet.validation.common.RandomFeaturePerformanceEvaluator(*args, p=0.3, seed=None)[source]

Bases: ballet.validation.base.FeaturePerformanceEvaluator

ballet.validation.common.check_from_class(check_class, obj, *checker_args, **checker_kwargs)[source]
ballet.validation.common.detect_differ(repo)[source]
ballet.validation.common.get_accepted_features(features, proposed_feature)[source]

Deselect candidate features from list of all features

Parameters
  • features (Collection[Feature]) – collection of all features in the ballet project: both accepted features and candidate ones that have not been accepted

  • proposed_feature (Feature) – candidate feature that has not been accepted

Return type

List[Feature]

Returns

list of features with the proposed feature not in it.

Raises

ballet.exc.BalletError – Could not deselect exactly the proposed feature.

ballet.validation.common.get_proposed_feature(project)[source]

Get the proposed feature

The path of the proposed feature is determined by diffing the project against a comparison branch, such as master. The feature is then imported from that path and returned.

Parameters

project (Project) – project info

Raises

ballet.exc.BalletError – more than one feature collected

ballet.validation.common.get_subclasses(cls)[source]
ballet.validation.common.load_spec(spec)[source]
Return type

Tuple[type, dict]

ballet.validation.common.subsample_data_for_validation(*args)[source]