From d3cc142fb83456e59760b8152fa6bac6d9204664 Mon Sep 17 00:00:00 2001 From: kerthcet Date: Fri, 22 May 2026 23:53:58 +0100 Subject: [PATCH 1/2] remove useless code Signed-off-by: kerthcet --- alphatrion/log/log.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/alphatrion/log/log.py b/alphatrion/log/log.py index 7507782..05b3a2a 100644 --- a/alphatrion/log/log.py +++ b/alphatrion/log/log.py @@ -154,26 +154,17 @@ async def log_metrics(metrics: dict[str, float]): should_early_stop = False should_stop_on_target = False for key, value in metrics.items(): - if not isinstance(value, (int, float)): - # TODO: replace with logging library. - print( - f"Warning: Metric '{key}' has non-numeric value '{value}' and will be skipped for best metric tracking." - ) - continue - - float_value = float(value) - # Always call the should_checkpoint_on_best first because # it also updates the best metric. should_checkpoint |= exp.should_checkpoint_on_best( - metric_key=key, metric_value=float_value + metric_key=key, metric_value=value ) should_early_stop |= exp.should_early_stop( - metric_key=key, metric_value=float_value + metric_key=key, metric_value=value ) should_stop_on_target |= exp.should_stop_on_target_metric( - metric_key=key, metric_value=float_value + metric_key=key, metric_value=value ) if should_checkpoint: From 29ebf94291fd90dec2b97806168c74cc2dc87e66 Mon Sep 17 00:00:00 2001 From: kerthcet Date: Fri, 22 May 2026 23:54:43 +0100 Subject: [PATCH 2/2] fix lint Signed-off-by: kerthcet --- alphatrion/log/log.py | 4 +--- tests/integration/test_oci_backend.py | 4 +--- tests/unit/artifact/test_s3_backend.py | 8 ++++++-- tests/unit/experiment/test_experiment.py | 1 + 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/alphatrion/log/log.py b/alphatrion/log/log.py index 05b3a2a..96a9037 100644 --- a/alphatrion/log/log.py +++ b/alphatrion/log/log.py @@ -160,9 +160,7 @@ async def log_metrics(metrics: dict[str, float]): metric_key=key, metric_value=value ) - should_early_stop |= exp.should_early_stop( - metric_key=key, metric_value=value - ) + should_early_stop |= exp.should_early_stop(metric_key=key, metric_value=value) should_stop_on_target |= exp.should_stop_on_target_metric( metric_key=key, metric_value=value ) diff --git a/tests/integration/test_oci_backend.py b/tests/integration/test_oci_backend.py index bf76ff4..5350c03 100644 --- a/tests/integration/test_oci_backend.py +++ b/tests/integration/test_oci_backend.py @@ -435,9 +435,7 @@ async def test_load_checkpoint_nonexistent(artifact): # For OCI, trying to pull a non-existent tag should raise an error # (unlike S3 which returns [] when no files exist) with pytest.raises(RuntimeError, match="Failed to pull artifacts"): - await alpha.load_checkpoint( - id=exp_id, version="latest", output_dir=tmpdir - ) + await alpha.load_checkpoint(id=exp_id, version="latest", output_dir=tmpdir) @pytest.mark.asyncio diff --git a/tests/unit/artifact/test_s3_backend.py b/tests/unit/artifact/test_s3_backend.py index 385f81e..8cb0d37 100644 --- a/tests/unit/artifact/test_s3_backend.py +++ b/tests/unit/artifact/test_s3_backend.py @@ -351,7 +351,9 @@ def test_s3_backend_pull_version_folder(s3_client): # Pull the version folder output_dir = os.path.join(tmpdir, "download") result = artifact.pull( - repo_name="org123/team456/exp1/ckpt", version_or_filename="v1", output_dir=output_dir + repo_name="org123/team456/exp1/ckpt", + version_or_filename="v1", + output_dir=output_dir, ) # Verify all files were downloaded @@ -423,7 +425,9 @@ def test_s3_backend_pull_empty_version_folder(s3_client): with tempfile.TemporaryDirectory() as tmpdir: # Pull non-existent version folder result = artifact.pull( - repo_name="org123/team456/exp1/ckpt", version_or_filename="v999", output_dir=tmpdir + repo_name="org123/team456/exp1/ckpt", + version_or_filename="v999", + output_dir=tmpdir, ) # Should return empty list diff --git a/tests/unit/experiment/test_experiment.py b/tests/unit/experiment/test_experiment.py index f82720c..7544600 100644 --- a/tests/unit/experiment/test_experiment.py +++ b/tests/unit/experiment/test_experiment.py @@ -116,6 +116,7 @@ def test_config(self): ), ) + @pytest.mark.asyncio async def test_experiment_with_done(): init(