damccorm commented on code in PR #38215: URL: https://github.com/apache/beam/pull/38215#discussion_r3312695683
########## sdks/python/apache_beam/ml/transforms/mltransform_tests_requirements.txt: ########## @@ -1,4 +1,3 @@ -# # Licensed to the Apache Software Foundation (ASF) under one or more Review Comment: Why are we putting this here? Can we just rely on https://github.com/apache/beam/blob/master/sdks/python/setup.py If we do need this, we should put it next to the examples which require it. ########## sdks/python/apache_beam/ml/anomaly/transforms_test.py: ########## @@ -116,6 +116,24 @@ def _keyed_result_is_equal_to( return a[0] == b[0] and _unkeyed_result_is_equal_to(a[1], b[1]) +def _prediction_metadata_is_equal_to( + a: AnomalyPrediction, b: AnomalyPrediction): + return a.model_id == b.model_id and a.threshold == b.threshold and \ + a.info == b.info and a.source_predictions == b.source_predictions + + +def _unkeyed_result_metadata_is_equal_to(a: AnomalyResult, b: AnomalyResult): + return a.example._asdict() == b.example._asdict() and \ + len(a.predictions) == len(b.predictions) and all( + _prediction_metadata_is_equal_to(a_pred, b_pred) + for a_pred, b_pred in zip(a.predictions, b.predictions)) + + +def _keyed_result_metadata_is_equal_to( + a: tuple[int, AnomalyResult], b: tuple[int, AnomalyResult]): + return a[0] == b[0] and _unkeyed_result_metadata_is_equal_to(a[1], b[1]) Review Comment: Is this file's changes actually related to the current PR? Should it be a separate PR? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
