File tree Expand file tree Collapse file tree 7 files changed +379
-3
lines changed
Expand file tree Collapse file tree 7 files changed +379
-3
lines changed Original file line number Diff line number Diff line change 1+ name : PredAI Tests
2+
3+ on :
4+ pull_request :
5+ branches : [ main, master, develop ]
6+ push :
7+ branches : [ main, master, develop ]
8+
9+ jobs :
10+ test :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - name : Checkout code
15+ uses : actions/checkout@v4
16+
17+ - name : Set up Python
18+ uses : actions/setup-python@v5
19+ with :
20+ python-version : ' 3.12'
21+
22+ - name : Cache pip packages
23+ uses : actions/cache@v4
24+ with :
25+ path : ~/.cache/pip
26+ key : ${{ runner.os }}-pip-${{ hashFiles('predai/requirements.txt') }}
27+ restore-keys : |
28+ ${{ runner.os }}-pip-
29+
30+ - name : Install dependencies
31+ run : |
32+ python -m pip install --upgrade pip
33+ pip install -r predai/requirements.txt
34+
35+ - name : Run unit tests
36+ run : |
37+ python -m unittest test_predai.py -v
38+
39+ - name : Test summary
40+ if : always()
41+ run : |
42+ if [ $? -eq 0 ]; then
43+ echo "✅ All tests passed successfully!"
44+ else
45+ echo "❌ Some tests failed"
46+ exit 1
47+ fi
Original file line number Diff line number Diff line change @@ -19,6 +19,10 @@ wheels/
1919* .egg-info /
2020.installed.cfg
2121* .egg
22+ .lr_find *
23+ .pytest_cache /
24+ events.out. *
25+ lightning_logs /*
2226
2327# Virtual environments
2428venv /
Original file line number Diff line number Diff line change 1- neuralprophet == 0.9.0
1+ neuralprophet
22requests
33aiohttp
44pyyaml
Original file line number Diff line number Diff line change 1313import math
1414import yaml
1515
16- # Fix for PyTorch 2.6 weights_only=True default
16+ # Fix for PyTorch 2.6+ weights_only=True default
1717# Add NeuralProphet classes to safe globals for checkpoint loading
1818try :
19+ import torch
1920 import torch .serialization
2021 from neuralprophet .configure import (
2122 ConfigSeasonality ,
2728 ConfigEvents ,
2829 ConfigCountryHolidays ,
2930 )
31+ from collections import OrderedDict
3032
3133 # Add all NeuralProphet configuration classes to safe globals
3234 torch .serialization .add_safe_globals ([
3840 ConfigLagged ,
3941 ConfigEvents ,
4042 ConfigCountryHolidays ,
43+ OrderedDict ,
4144 ])
45+
46+ # Monkey-patch torch.load to use weights_only=False by default
47+ # This is needed for PyTorch 2.6+ compatibility with PyTorch Lightning
48+ _original_torch_load = torch .load
49+ def _patched_torch_load (* args , ** kwargs ):
50+ if 'weights_only' not in kwargs :
51+ kwargs ['weights_only' ] = False
52+ return _original_torch_load (* args , ** kwargs )
53+ torch .load = _patched_torch_load
4254except (ImportError , AttributeError ):
4355 # If torch.serialization or classes are not available, continue without the fix
4456 # This allows backward compatibility with older PyTorch versions
@@ -483,4 +495,5 @@ async def main():
483495 break
484496 await asyncio .sleep (60 )
485497
486- asyncio .run (main ())
498+ if __name__ == "__main__" :
499+ asyncio .run (main ())
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # Run all PredAI unit tests
3+
4+ set -e
5+
6+ # Check if virtual environment exists
7+ if [ ! -d " venv" ]; then
8+ echo " Error: Virtual environment not found!"
9+ echo " Please run ./setup.csh first to create the environment"
10+ exit 1
11+ fi
12+
13+ # Activate virtual environment
14+ echo " Activating virtual environment..."
15+ source venv/bin/activate
16+
17+ # Run the tests
18+ echo " "
19+ echo " Running PredAI unit tests..."
20+ echo " ================================"
21+ python -m unittest test_predai.py -v
22+
23+ # Check test result
24+ if [ $? -eq 0 ]; then
25+ echo " "
26+ echo " ================================"
27+ echo " ✅ All tests passed successfully!"
28+ else
29+ echo " "
30+ echo " ================================"
31+ echo " ❌ Some tests failed"
32+ exit 1
33+ fi
Original file line number Diff line number Diff line change 1+ # Setup script for PredAI test environment
2+ # Creates a virtual environment and installs dependencies
3+
4+ echo " Creating Python virtual environment..."
5+ python3 -m venv venv
6+
7+ echo " Activating virtual environment..."
8+ source venv/bin/activate
9+
10+ echo " Installing dependencies..."
11+ python -m pip install --upgrade pip
12+ python -m pip install -r predai/requirements.txt
13+
14+ echo " "
15+ echo " Setup complete!"
16+ echo " To activate the environment manually, run:"
17+ echo " source venv/bin/activate.csh"
18+ echo " "
19+ echo " To run tests, execute:"
20+ echo " ./run_all"
21+
You can’t perform that action at this time.
0 commit comments