Skip to content

Commit c98ec9c

Browse files
committed
Refactor dependencies and installation for modular environments
- Update `pyproject.toml`: - Move heavy ML libraries (TensorFlow, Torch, H2O, etc.) from base dependencies to a new `standard` extra. - Define `ts` extra for time-series specific libraries. - Pin `scikit-learn` to 1.6.x and `numpy` < 2.0.0. - Update `install.sh`: - Default to installing `[test,standard]`. - Add pre-installation step for heavy dependencies to improve pip resolution speed. - Implement constraint-based installation for time-series mode. - Add `pytest.ini`: Configure to exclude time-series tests by default. - Add `run_ts_tests.sh`: Helper script for running time-series tests.
1 parent 61319c1 commit c98ec9c

4 files changed

Lines changed: 60 additions & 30 deletions

File tree

install.sh

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Default values for standard installation
44
ENV_NAME="ml_grid_env"
5-
EXTRAS="[test]"
5+
EXTRAS="[test,standard]"
66
INSTALL_TYPE="standard"
77
PROXY_MODE=false
88

@@ -86,16 +86,39 @@ python -m pip install --upgrade pip 'setuptools<70.0.0' wheel "${pip_base_args[@
8686
# Increase the resolver backtrack depth to handle the large, complex dependency
8787
# graph (TensorFlow + PyTorch + AutoGluon + FastAI + aeon[all_extras] etc.).
8888
# PIP_RESOLVER_MAX_BACKTRACK is honoured by pip >= 23.3.
89-
export PIP_RESOLVER_MAX_BACKTRACK=10000
89+
export PIP_RESOLVER_MAX_BACKTRACK=1000000
9090

9191
# Pre-install heavy dependencies to simplify graph resolution
9292
echo "Pre-installing heavy dependencies..."
93-
python -m pip install "tensorflow==2.20.0" "torch==2.10.0" "nvidia-cuda-nvcc-cu12" "h2o>=3.46.0.5" "scikit-learn>=1.5.2,<1.6" "${pip_base_args[@]}" || print_error_and_exit "Failed to pre-install frameworks."
93+
python -m pip install "tensorflow==2.20.0" "torch==2.10.0" "nvidia-cuda-nvcc-cu12" "h2o>=3.46.0.5" "scikit-learn>=1.6.0,<1.7" "${pip_base_args[@]}" || print_error_and_exit "Failed to pre-install frameworks."
94+
95+
if [ "$INSTALL_TYPE" = "time-series" ]; then
96+
echo "Pre-installing time-series dependencies to simplify graph resolution..."
97+
CONSTRAINTS_FILE="ts-constraints.txt"
98+
99+
# Pre-install the top-level heavy time-series libraries.
100+
# This allows pip to resolve their complex dependencies in a dedicated step
101+
# before the final project installation. These are the main libraries
102+
# from the '[project.optional-dependencies].ts' section in pyproject.toml.
103+
python -m pip install \
104+
"aeon>=1.2.0" \
105+
"tsfresh" \
106+
"prophet==1.1.3" \
107+
"pmdarima==2.0.3" \
108+
"gluonts>=0.14.0" \
109+
"${pip_base_args[@]}" || print_error_and_exit "Failed to install heavy time-series libraries."
110+
111+
echo "Generating constraints file to pin pre-installed packages..."
112+
pip freeze > "$CONSTRAINTS_FILE"
113+
fi
94114

95115
# Install the project in editable mode along with testing dependencies.
96116
# This reads all dependencies from pyproject.toml.
97117
echo "Installing project dependencies ($EXTRAS)..."
98118
pip_install_args=("--no-build-isolation" "-e" ".$EXTRAS")
119+
if [ "$INSTALL_TYPE" = "time-series" ]; then
120+
pip_install_args+=("-c" "$CONSTRAINTS_FILE")
121+
fi
99122
if [ "$PROXY_MODE" = true ]; then
100123
pip_install_args+=("--trusted-host" "dh-cap02" "-i" "http://dh-cap02:8008/mirrors/ml_binary_classification_gridsearch_hyperOpt" "--retries" "5" "--timeout" "60")
101124
fi

pyproject.toml

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,38 +24,17 @@ dependencies = [
2424
# Core data and ML libraries
2525
"pandas>=2.2.0,<2.4.0",
2626
"polars", #==1.9.0
27-
"numpy>=1.26.4,<2.0.0",
28-
"scikit-learn>=1.5.2,<1.6",
27+
"numpy>=1.26.4,<2.0.0", # Pinned to avoid breaking changes in v2
28+
"scikit-learn>=1.6.0,<1.7", # Pinned to support autogluon.timeseries dependencies
2929
"imbalanced-learn>=0.12.4",
30-
31-
# ML frameworks and dependencies
32-
"keras>=3.0.0",
33-
"tensorflow>=2.16.0", # Relaxed to allow resolution
34-
"torch>=2.2.0", # Relaxed to allow resolution
35-
"torchvision>=0.15.0", # Updated: compatible with torch 2.x
36-
"tab_transformer_pytorch>=0.3.0",
37-
"lightgbm>=4.5.0",
38-
"xgboost>=2.1.1",
39-
"catboost>=1.2.7",
40-
"h2o>=3.46.0.5",
4130
"scikeras>=0.13.0",
42-
"autogluon.tabular",
43-
"tpot==0.12.2",
44-
"FLAML",
45-
"autokeras",
46-
"spacy>=3.8.0", # Force modern spacy for pydantic v2 compatibility
47-
"fastai",
48-
"ray>=2.43.0,<2.53.0",
4931

5032
# Hyperparameter optimization and feature tools
5133
"hyperopt",#==0.2.7",
5234
"scikit-optimize>=0.10.2",
5335
"shap>=0.46.0",
5436
"pyimpetus>=4.1.2",
55-
"fitter>=1.7.1",
5637
"fuzzysearch>=0.7.3",
57-
# "simbsig", # Commented out: conflicts with torch 2.x requirement
58-
"tabpfn",
5938

6039
# Visualization and notebook integration
6140
"matplotlib>=3.9.0",
@@ -79,6 +58,8 @@ dependencies = [
7958
"black",
8059
"ruff",
8160

61+
62+
8263
]
8364

8465
[project.urls]
@@ -90,13 +71,31 @@ test = [
9071
"pytest>=7.0.0",
9172
"nbmake==1.4.6",
9273
]
74+
standard = [
75+
# Standard (non-time-series) AutoML and advanced libraries
76+
"autogluon.tabular",
77+
"tpot==0.12.2",
78+
"FLAML",
79+
"autokeras",
80+
"spacy>=3.8.0",
81+
"fastai",
82+
"tab_transformer_pytorch>=0.3.0",
83+
"tabpfn",
84+
"fitter>=1.7.1",
85+
"keras>=3.0.0",
86+
"tensorflow>=2.16.0", # Relaxed to allow resolution
87+
"torch>=2.2.0", # Relaxed to allow resolution
88+
"torchvision>=0.15.0",
89+
"lightgbm>=4.5.0",
90+
"xgboost>=2.1.1",
91+
"catboost>=1.2.7",
92+
"h2o>=3.46.0.5",
93+
"ray>=2.43.0,<2.53.0",
94+
]
9395
ts = [
9496
# Time-series specific libraries
95-
"aeon[all_extras]>=1.2.0", # Updated for compatibility with pandas>=2.2
96-
# Removed tensorflow-addons: deprecated and incompatible with Python 3.12
97+
"aeon>=1.2.0", # Core aeon toolkit
9798
"tsfresh",
98-
"tensorflow_probability",
99-
"keras-self-attention==0.51.0",
10099
"prophet==1.1.3",
101100
"pmdarima==2.0.3",
102101
"gluonts>=0.14.0",

pytest.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[pytest]
2+
markers =
3+
time_series: marks tests as time-series related
4+
slow: marks tests as slow to run
5+
addopts = -m "not time_series and not slow" --ignore=tests/test_time_series_models.py

run_ts_tests.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
# Script to run only the time series unit tests
3+
pytest tests/test_time_series_models.py -m time_series

0 commit comments

Comments
 (0)