Skip to content

Commit 4445db1

Browse files
committed
Add backup and restore steps for root configuration files in GitHub Actions workflow
- Introduced steps to back up and restore `agents.yaml` and `tools.py` during the workflow execution, preventing interference and ensuring a clean environment for tests. - Added comprehensive execution debug step to provide detailed insights into the execution path and configuration status. - Ensured minimal changes to existing code while enhancing the debugging and testing process for configuration management.
1 parent 0db62f8 commit 4445db1

File tree

1 file changed

+133
-0
lines changed

1 file changed

+133
-0
lines changed

.github/workflows/unittest.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ jobs:
3434
echo "LOGLEVEL=DEBUG" >> $GITHUB_ENV
3535
echo "PYTHONPATH=${{ github.workspace }}/src/praisonai-agents:$PYTHONPATH" >> $GITHUB_ENV
3636
37+
- name: Backup Root Config Files
38+
run: |
39+
echo "🔄 Backing up root configuration files to prevent interference..."
40+
if [ -f "agents.yaml" ]; then
41+
mv agents.yaml agents.yaml.backup
42+
echo "✅ Moved agents.yaml to agents.yaml.backup"
43+
fi
44+
if [ -f "tools.py" ]; then
45+
mv tools.py tools.py.backup
46+
echo "✅ Moved tools.py to tools.py.backup"
47+
fi
48+
3749
- name: Debug API Key Status
3850
run: |
3951
echo "🔍 Checking API key availability..."
@@ -337,6 +349,114 @@ jobs:
337349
python -m praisonai tests/autogen-agents.yaml
338350
continue-on-error: true
339351

352+
- name: Comprehensive Execution Debug
353+
run: |
354+
echo "🔍 Comprehensive debugging of PraisonAI execution path..."
355+
python -c "
356+
import os
357+
import sys
358+
import yaml
359+
sys.path.insert(0, '.')
360+
361+
print('=' * 60)
362+
print('🔍 COMPREHENSIVE EXECUTION DEBUG')
363+
print('=' * 60)
364+
365+
# Check current working directory
366+
print(f'📁 Current working directory: {os.getcwd()}')
367+
368+
# List files in current directory
369+
print('📋 Files in current directory:')
370+
for f in os.listdir('.'):
371+
print(f' {f}')
372+
373+
print()
374+
print('📋 Files in tests/ directory:')
375+
for f in os.listdir('tests'):
376+
if f.endswith('.yaml'):
377+
print(f' tests/{f}')
378+
379+
# Check if root agents.yaml exists
380+
print()
381+
if os.path.exists('agents.yaml'):
382+
print('❌ ROOT agents.yaml EXISTS (this is the problem!)')
383+
with open('agents.yaml', 'r') as f:
384+
root_config = yaml.safe_load(f)
385+
print(f' Root framework: {root_config.get(\"framework\")}')
386+
print(f' Root roles: {list(root_config.get(\"roles\", {}).keys())}')
387+
else:
388+
print('✅ ROOT agents.yaml does NOT exist (good!)')
389+
390+
# Test the actual execution path
391+
print()
392+
print('🎯 Testing EXACT execution path:')
393+
394+
try:
395+
from praisonai import PraisonAI
396+
from praisonai.agents_generator import AgentsGenerator
397+
398+
# Test with full path
399+
test_file = 'tests/autogen-agents.yaml'
400+
print(f' Using test file: {test_file}')
401+
print(f' File exists: {os.path.exists(test_file)}')
402+
403+
# Load the test file directly
404+
with open(test_file, 'r') as f:
405+
test_config = yaml.safe_load(f)
406+
print(f' Test file framework: {test_config.get(\"framework\")}')
407+
print(f' Test file roles: {list(test_config.get(\"roles\", {}).keys())}')
408+
409+
# Create PraisonAI instance
410+
praisonai = PraisonAI(agent_file=test_file)
411+
print(f' PraisonAI.agent_file: {praisonai.agent_file}')
412+
print(f' PraisonAI.framework: {praisonai.framework}')
413+
414+
# Create AgentsGenerator
415+
agents_gen = AgentsGenerator(
416+
agent_file=test_file,
417+
framework=praisonai.framework,
418+
config_list=praisonai.config_list
419+
)
420+
print(f' AgentsGenerator.agent_file: {agents_gen.agent_file}')
421+
print(f' AgentsGenerator.framework: {agents_gen.framework}')
422+
423+
# Test what would happen in generate_crew_and_kickoff
424+
print()
425+
print('🔧 Testing generate_crew_and_kickoff logic:')
426+
427+
# Simulate the loading logic
428+
if agents_gen.agent_yaml:
429+
loaded_config = yaml.safe_load(agents_gen.agent_yaml)
430+
print(' Would load from agent_yaml')
431+
else:
432+
if agents_gen.agent_file == '/app/api:app' or agents_gen.agent_file == 'api:app':
433+
agents_gen.agent_file = 'agents.yaml'
434+
print(f' Would change agent_file to: {agents_gen.agent_file}')
435+
try:
436+
with open(agents_gen.agent_file, 'r') as f:
437+
loaded_config = yaml.safe_load(f)
438+
print(f' Successfully loaded: {agents_gen.agent_file}')
439+
except FileNotFoundError:
440+
print(f' FileNotFoundError: {agents_gen.agent_file}')
441+
loaded_config = None
442+
443+
if loaded_config:
444+
final_framework = agents_gen.framework or loaded_config.get('framework')
445+
print(f' Final framework decision: {final_framework}')
446+
print(f' Loaded roles: {list(loaded_config.get(\"roles\", {}).keys())}')
447+
448+
if 'researcher' in loaded_config.get('roles', {}):
449+
print(' ❌ FOUND Researcher role in loaded config!')
450+
else:
451+
print(' ✅ No Researcher role in loaded config')
452+
453+
except Exception as e:
454+
print(f'❌ Error during execution debug: {e}')
455+
import traceback
456+
traceback.print_exc()
457+
"
458+
continue-on-error: true
459+
340460
- name: Run Fast Tests
341461
run: |
342462
# Run the fastest, most essential tests
@@ -346,3 +466,16 @@ jobs:
346466
run: |
347467
python -m pytest tests/test.py -v --tb=short --disable-warnings
348468
continue-on-error: true
469+
470+
- name: Restore Root Config Files
471+
run: |
472+
echo "🔄 Restoring root configuration files..."
473+
if [ -f "agents.yaml.backup" ]; then
474+
mv agents.yaml.backup agents.yaml
475+
echo "✅ Restored agents.yaml"
476+
fi
477+
if [ -f "tools.py.backup" ]; then
478+
mv tools.py.backup tools.py
479+
echo "✅ Restored tools.py"
480+
fi
481+
if: always() # Always run this step, even if previous steps failed

0 commit comments

Comments
 (0)