Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions src/extremeweatherbench/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,44 +977,3 @@ def _safe_concat(
return pd.concat(valid_dfs, ignore_index=ignore_index)
else:
return pd.DataFrame(columns=OUTPUT_COLUMNS)


def _parallel_serial_config_check(
n_jobs: Optional[int] = None,
parallel_config: Optional[dict] = None,
) -> Optional[dict]:
"""Check if running in serial or parallel mode.

Args:
n_jobs: The number of jobs to run in parallel. If None, defaults to the
joblib backend default value. If 1, the workflow will run serially.
parallel_config: Optional dictionary of joblib parallel configuration. If
provided, this takes precedence over n_jobs. If not provided and n_jobs is
specified, a default config with loky backend is used.
Returns:
None if running in serial mode, otherwise a dictionary of joblib parallel
configuration.
"""
# Determine if running in serial or parallel mode
# Serial: n_jobs=1 or (parallel_config with n_jobs=1)
# Parallel: n_jobs>1 or (parallel_config with n_jobs>1)
is_serial = (
(n_jobs == 1)
or (parallel_config is not None and parallel_config.get("n_jobs") == 1)
or (n_jobs is None and parallel_config is None)
)
logger.debug("Running in %s mode.", "serial" if is_serial else "parallel")

if not is_serial:
# Build parallel_config if not provided
if parallel_config is None and n_jobs is not None:
logger.debug(
"No parallel_config provided, using loky backend and %s jobs.",
n_jobs,
)
parallel_config = {"backend": "loky", "n_jobs": n_jobs}
# If running in serial mode, set parallel_config to None if not already
else:
parallel_config = None
# Return the maybe updated kwargs
return parallel_config
20 changes: 0 additions & 20 deletions tests/test_evaluate_cli.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
"""Tests for the evaluate_cli interface."""

import pickle
import tempfile
import textwrap
from pathlib import Path
from unittest import mock

import click.testing
import pandas as pd
import pytest

Expand All @@ -23,23 +20,6 @@ def suppress_cli_output():
yield


@pytest.fixture
def runner():
"""Create a Click test runner with output suppression."""
return click.testing.CliRunner()


@pytest.fixture
def temp_config_dir():
"""Create a temporary directory for config files and test outputs.

This ensures all test files are created in temporary directories and automatically
cleaned up after each test.
"""
with tempfile.TemporaryDirectory() as temp_dir:
yield Path(temp_dir)


@pytest.fixture
def sample_config_py(temp_config_dir):
"""Create a sample Python config file."""
Expand Down
Loading