From 98d6fee2ea4ced8ddcdd590016d48f2fd295987a Mon Sep 17 00:00:00 2001 From: Gene Huang Date: Wed, 11 Dec 2024 11:27:18 -0800 Subject: [PATCH] Changes `FnConfig.make` to `FnConfig.make_lazy_fn` to be more explicit. PiperOrigin-RevId: 705176891 --- ml_metrics/_src/aggregates/classification_test.py | 2 +- ml_metrics/_src/aggregates/retrieval_test.py | 2 +- ml_metrics/_src/chainables/lazy_fns.py | 2 +- ml_metrics/_src/chainables/lazy_fns_test.py | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ml_metrics/_src/aggregates/classification_test.py b/ml_metrics/_src/aggregates/classification_test.py index 4237dcf7..d962d507 100644 --- a/ml_metrics/_src/aggregates/classification_test.py +++ b/ml_metrics/_src/aggregates/classification_test.py @@ -849,7 +849,7 @@ def test_fn_config_to_lazy_fn_by_module(self): metrics=("recall", "precision"), input_type="multiclass-multioutput", ), - ).make() + ).make_lazy_fn() ) self.assertEqual( classification.SamplewiseClassification( # pytype: disable=wrong-arg-types diff --git a/ml_metrics/_src/aggregates/retrieval_test.py b/ml_metrics/_src/aggregates/retrieval_test.py index ecaa2abe..e0ba8fec 100644 --- a/ml_metrics/_src/aggregates/retrieval_test.py +++ b/ml_metrics/_src/aggregates/retrieval_test.py @@ -371,7 +371,7 @@ def test_fn_config_to_lazy_fn_by_module(self): fn="TopKRetrieval", module="ml_metrics._src.aggregates.retrieval", kwargs=dict(metrics=("recall", "precision")), - ).make() + ).make_lazy_fn() ) self.assertEqual( retrieval.TopKRetrieval(metrics=("recall", "precision")), # pytype: disable=wrong-arg-types diff --git a/ml_metrics/_src/chainables/lazy_fns.py b/ml_metrics/_src/chainables/lazy_fns.py index 78d59340..3fa19fef 100644 --- a/ml_metrics/_src/chainables/lazy_fns.py +++ b/ml_metrics/_src/chainables/lazy_fns.py @@ -263,7 +263,7 @@ class FnConfig: def from_json_str(cls, json_str: str): return cls(**json.loads(json_str)) - def make(self): + def make_lazy_fn(self): if self.module: actual_fn = getattr(importlib.import_module(self.module), self.fn) else: diff --git a/ml_metrics/_src/chainables/lazy_fns_test.py b/ml_metrics/_src/chainables/lazy_fns_test.py index 714b9e5c..f94d3944 100644 --- a/ml_metrics/_src/chainables/lazy_fns_test.py +++ b/ml_metrics/_src/chainables/lazy_fns_test.py @@ -394,7 +394,9 @@ def test_external_makeable(self): def test_fn_config_to_lazy_fn_direct(self): self.assertEqual( 2, - lazy_fns.maybe_make(lazy_fns.FnConfig(fn='len', args=[[1, 2]]).make()), + lazy_fns.maybe_make( + lazy_fns.FnConfig(fn='len', args=[[1, 2]]).make_lazy_fn() + ), ) def test_makeable_lazy_fn(self):