Edwin Salguero
commited on
Commit
Β·
a3ef409
1
Parent(s):
172f6cb
Fix OpenCV import for RL tests, mark slow RL tests, and document in README
Browse files- Add opencv-python-headless to requirements for RL compatibility
- Mark RL agent training tests as
@pytest
.mark.slow and reduce timesteps
- Update README with slow test instructions
- README.md +7 -4
- requirements.txt +1 -0
- tests/test_finrl_agent.py +5 -3
README.md
CHANGED
@@ -386,7 +386,8 @@ tests/
|
|
386 |
βββ test_strategy_agent.py
|
387 |
βββ test_execution_agent.py
|
388 |
βββ test_data_ingestion.py
|
389 |
-
|
|
|
390 |
```
|
391 |
|
392 |
### Test Categories
|
@@ -394,13 +395,15 @@ tests/
|
|
394 |
- **Integration Tests**: Test complete workflows
|
395 |
- **Performance Tests**: Test system performance and scalability
|
396 |
- **Error Handling Tests**: Test error conditions and edge cases
|
|
|
397 |
|
398 |
### Running Specific Tests
|
399 |
|
400 |
```bash
|
401 |
-
# Run
|
402 |
-
pytest
|
403 |
-
|
|
|
404 |
pytest -m slow
|
405 |
|
406 |
# Run tests with coverage
|
|
|
386 |
βββ test_strategy_agent.py
|
387 |
βββ test_execution_agent.py
|
388 |
βββ test_data_ingestion.py
|
389 |
+
βββ test_integration.py
|
390 |
+
βββ test_finrl_agent.py
|
391 |
```
|
392 |
|
393 |
### Test Categories
|
|
|
395 |
- **Integration Tests**: Test complete workflows
|
396 |
- **Performance Tests**: Test system performance and scalability
|
397 |
- **Error Handling Tests**: Test error conditions and edge cases
|
398 |
+
- **Slow RL Tests**: RL agent training tests are marked as `@pytest.mark.slow` and use minimal timesteps for speed. These are skipped by default unless explicitly run.
|
399 |
|
400 |
### Running Specific Tests
|
401 |
|
402 |
```bash
|
403 |
+
# Run all fast tests (default)
|
404 |
+
pytest
|
405 |
+
|
406 |
+
# Run slow RL tests (FinRL agent training)
|
407 |
pytest -m slow
|
408 |
|
409 |
# Run tests with coverage
|
requirements.txt
CHANGED
@@ -12,3 +12,4 @@ stable-baselines3
|
|
12 |
gymnasium
|
13 |
tensorboard
|
14 |
torch
|
|
|
|
12 |
gymnasium
|
13 |
tensorboard
|
14 |
torch
|
15 |
+
opencv-python-headless
|
tests/test_finrl_agent.py
CHANGED
@@ -228,6 +228,7 @@ class TestFinRLAgent:
|
|
228 |
macd = agent._calculate_macd(prices)
|
229 |
assert len(macd) == len(prices)
|
230 |
|
|
|
231 |
@patch('agentic_ai_system.finrl_agent.PPO')
|
232 |
def test_training_ppo(self, mock_ppo, finrl_config, sample_data):
|
233 |
"""Test PPO training"""
|
@@ -236,12 +237,13 @@ class TestFinRLAgent:
|
|
236 |
mock_ppo.return_value = mock_model
|
237 |
|
238 |
agent = FinRLAgent(finrl_config)
|
239 |
-
result = agent.train(sample_data, total_timesteps=
|
240 |
|
241 |
assert result['algorithm'] == 'PPO'
|
242 |
-
assert result['total_timesteps'] ==
|
243 |
mock_model.learn.assert_called_once()
|
244 |
|
|
|
245 |
@patch('agentic_ai_system.finrl_agent.A2C')
|
246 |
def test_training_a2c(self, mock_a2c):
|
247 |
"""Test A2C training"""
|
@@ -258,7 +260,7 @@ class TestFinRLAgent:
|
|
258 |
'volume': [1000, 1100, 1200]
|
259 |
})
|
260 |
|
261 |
-
result = agent.train(sample_data, total_timesteps=
|
262 |
|
263 |
assert result['algorithm'] == 'A2C'
|
264 |
mock_model.learn.assert_called_once()
|
|
|
228 |
macd = agent._calculate_macd(prices)
|
229 |
assert len(macd) == len(prices)
|
230 |
|
231 |
+
@pytest.mark.slow
|
232 |
@patch('agentic_ai_system.finrl_agent.PPO')
|
233 |
def test_training_ppo(self, mock_ppo, finrl_config, sample_data):
|
234 |
"""Test PPO training"""
|
|
|
237 |
mock_ppo.return_value = mock_model
|
238 |
|
239 |
agent = FinRLAgent(finrl_config)
|
240 |
+
result = agent.train(sample_data, total_timesteps=5)
|
241 |
|
242 |
assert result['algorithm'] == 'PPO'
|
243 |
+
assert result['total_timesteps'] == 5
|
244 |
mock_model.learn.assert_called_once()
|
245 |
|
246 |
+
@pytest.mark.slow
|
247 |
@patch('agentic_ai_system.finrl_agent.A2C')
|
248 |
def test_training_a2c(self, mock_a2c):
|
249 |
"""Test A2C training"""
|
|
|
260 |
'volume': [1000, 1100, 1200]
|
261 |
})
|
262 |
|
263 |
+
result = agent.train(sample_data, total_timesteps=5)
|
264 |
|
265 |
assert result['algorithm'] == 'A2C'
|
266 |
mock_model.learn.assert_called_once()
|