Beispiel #1
0
def test_add_scorers(mocker):
    initial_scorers = [mocker.Mock()]
    tracker = TravaTracker(scorers=initial_scorers)
    new_scorers = [mocker.Mock(), mocker.Mock()]
    tracker.add_scorers(scorers=new_scorers)

    assert tracker.scorers == (initial_scorers + new_scorers)
Beispiel #2
0
def test_track_model_artifact(mocker, model_id):
    serializer = mocker.Mock()
    tracker = TravaTracker(scorers=[])
    model = mocker.Mock()
    tracker.track_model_artifact(model_id=model_id,
                                 model=model,
                                 serializer=serializer)

    serializer.save.assert_called_once_with(model=model, path=mocker.ANY)
Beispiel #3
0
def test_if_enabled_false(mocker, model_id):
    tracker = TravaTracker(scorers=[])
    tracker.disable()

    mocks = _mocks_for_subclass_calls(mocker=mocker,
                                      tracker=tracker,
                                      model_id=model_id)
    parameters = _parameters_for_methods(mocker=mocker, model_id=model_id)

    calls = [
        getattr(tracker, method_name)(**params)
        for method_name, params in parameters.items()
    ]

    assert len(mocks) == len(calls)
    [mock.assert_not_called() for mock in mocks]
Beispiel #4
0
    def __init__(
        self,
        logger: Optional[TravaLogger] = None,
        tracker: Optional[TravaTracker] = None,
        results_handlers: List[ResultsHandler] = None,
    ):
        self._logger = logger or TravaLogger()
        self._tracker: TravaTracker = tracker or TravaTracker(scorers=[])
        self._results_handlers = results_handlers or []

        self._results: Dict[str, ModelResult] = {}
Beispiel #5
0
def test_is_enabled():
    tracker = TravaTracker(scorers=[])
    assert tracker.is_enabled
    tracker.disable()
    assert not tracker.is_enabled
    tracker.enable()
    assert tracker.is_enabled
Beispiel #6
0
 def _track_evaluators(evaluators: List[Evaluator], model_id: str, tracker: TravaTracker):
     tracker.start_tracking(model_id=model_id)
     main_model_results = ModelResult(model_id=model_id, evaluators=evaluators)
     tracker.track_model_results(model_results=main_model_results)
     tracker.end_tracking(model_id=model_id)
Beispiel #7
0
def trava_tracker():
    return TravaTracker(scorers=[])