Skip to content

Commit cdf2b3b

Browse files
slurm fix
1 parent 6879e7e commit cdf2b3b

4 files changed

Lines changed: 21 additions & 12 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""Lightweight path helpers for LPJmL / TWSO baseline CSVs (no torch import)."""
2+
3+
from __future__ import annotations
4+
5+
from pathlib import Path
6+
7+
from cybench.config import PATH_DATA_DIR
8+
9+
LPJML_FILE_STEM = "lpjml"
10+
TWSO_FILE_STEM = "twso"
11+
12+
13+
def lpjml_csv_path(crop: str, country: str, data_dir: str | Path = PATH_DATA_DIR) -> Path:
14+
return Path(data_dir) / crop / country / f"{LPJML_FILE_STEM}_{crop}_{country}.csv"
15+
16+
17+
def twso_csv_path(crop: str, country: str, data_dir: str | Path = PATH_DATA_DIR) -> Path:
18+
return Path(data_dir) / crop / country / f"{TWSO_FILE_STEM}_{crop}_{country}.csv"

cybench/models/lpjml_model.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313
from cybench.config import KEY_LOC, KEY_TARGET, KEY_YEAR, PATH_DATA_DIR
1414
from cybench.datasets.dataset import PandasDataset
15+
from cybench.models.baseline_csv_paths import lpjml_csv_path
1516
from cybench.models.model import BaseModel
1617
from cybench.models.persistence import load_pickle, save_pickle
1718

1819
log = logging.getLogger(__name__)
1920

20-
LPJML_FILE_STEM = "lpjml"
2121
LPJML_COL_RAINFED = "lpj_yield_rainfed"
2222
LPJML_COL_IRRIGATED = "lpj_yield_irrigated"
2323
LPJML_VARIANTS = ("rainfed", "irrigated")
@@ -36,10 +36,6 @@ class _LocationCalibration(_MomentCalibration):
3636
n_years: int
3737

3838

39-
def lpjml_csv_path(crop: str, country: str, data_dir: str | Path = PATH_DATA_DIR) -> Path:
40-
return Path(data_dir) / crop / country / f"{LPJML_FILE_STEM}_{crop}_{country}.csv"
41-
42-
4339
def _resolve_lpj_yield_series(df: pd.DataFrame, variant: str) -> pd.Series:
4440
"""Pick rainfed, irrigated, or rainfed-with-irrigated fallback."""
4541
if variant not in LPJML_VARIANTS:

cybench/models/twso_model.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from cybench.config import CROP_CALENDAR_DATES, KEY_LOC, KEY_TARGET, KEY_YEAR, PATH_DATA_DIR
1212
from cybench.datasets.alignment import compute_crop_season_window
1313
from cybench.datasets.dataset import PandasDataset
14+
from cybench.models.baseline_csv_paths import twso_csv_path
1415
from cybench.models.lpjml_model import (
1516
_LocationCalibration,
1617
_MomentCalibration,
@@ -22,7 +23,6 @@
2223

2324
log = logging.getLogger(__name__)
2425

25-
TWSO_FILE_STEM = "twso"
2626
TWSO_COL = "twso"
2727
TWSO_SCALE = 0.001
2828
DEFAULT_START_OF_SEQUENCE = "sos-60"
@@ -34,10 +34,6 @@
3434
DEFAULT_MAX_DAYS_BEFORE_EOS = 14
3535

3636

37-
def twso_csv_path(crop: str, country: str, data_dir: str | Path = PATH_DATA_DIR) -> Path:
38-
return Path(data_dir) / crop / country / f"{TWSO_FILE_STEM}_{crop}_{country}.csv"
39-
40-
4137
def crop_calendar_csv_path(
4238
crop: str, country: str, data_dir: str | Path = PATH_DATA_DIR
4339
) -> Path:

cybench/runs/slurm/generate_job_manifest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212

1313
import cybench.config as config
1414
from cybench.config import DATASETS
15-
from cybench.models.lpjml_model import lpjml_csv_path
16-
from cybench.models.twso_model import twso_csv_path
15+
from cybench.models.baseline_csv_paths import lpjml_csv_path, twso_csv_path
1716
from cybench.runs.slurm.benchmark_completion_lib import (
1817
JobRow,
1918
check_screening_years,

0 commit comments

Comments
 (0)