Skip to main content

Upgrade

Version Management

Ubuntu Upgrade Process bash



# Check current version
source /opt/autogen/autogen-env/bin/activate
python -c "import autogen; print(autogen.__version__)"
# Backup current installation
/opt/autogen/backup.sh
# Stop service
sudo systemctl stop autogen
# Upgrade AutoGen
pip install --upgrade pyautogen
# Test new version
python -c "import autogen; print('New version:', autogen.__version__)"
# Start service
sudo systemctl start autogen
# Verify functionality
/opt/autogen/health_check.sh

RHEL8 Upgrade Process

The process is similar to Ubuntu, with additional SELinux considerations:

bash



# Stop service
sudo systemctl stop autogen
# Backup current installation
/opt/autogen/backup.sh
# Upgrade with SELinux context preservation
pip install --upgrade pyautogen
# Restore SELinux contexts
sudo restorecon -R /opt/autogen/
# Start service
sudo systemctl start autogen

Migration Procedures

Configuration Migration

bash



# Create migration script
vim /opt/autogen/migrate.sh
chmod +x /opt/autogen/migrate.sh

bash


#!/bin/bash
# AutoGen Migration Script
OLD_VERSION=$1
NEW_VERSION=$2
if [ -z "$OLD_VERSION" ] || [ -z "$NEW_VERSION" ]; then
echo "Usage: $0 <old_version> <new_version>"
exit 1
fi
echo "Migrating from $OLD_VERSION to $NEW_VERSION"
# Backup configuration
cp /etc/autogen/config.env /etc/autogen/config.env.backup
# Update configuration based on version changes
case $NEW_VERSION in
"0.2.*")
echo "Applying 0.2.x configuration updates"
# Add new configuration parameters
echo "# New parameters for v0.2.x" >> /etc/autogen/config.env
echo "ENABLE_TEACHING=true" >> /etc/autogen/config.env
;;
"0.3.*")
echo "Applying 0.3.x configuration updates"
# Update existing parameters
sed -i 's/CODE_EXECUTION_CONFIG_USE_DOCKER=false/CODE_EXECUTION_CONFIG_USE_DOCKER=true/' /etc/autogen/config.env
;;
esac
echo "Migration completed"

Rollback Procedures

Automated Rollback Script

bash


# /opt/autogen/rollback.sh
#!/bin/bash
BACKUP_FILE=$1
if [ -z "$BACKUP_FILE" ]; then
echo "Usage: $0 <backup_file>"
echo "Available backups:"
ls -la /backup/autogen/
exit 1
fi
echo "Rolling back to $BACKUP_FILE"
# Stop current service
sudo systemctl stop autogen
# Backup current state (just in case)
/opt/autogen/backup.sh
# Restore from backup
cd /
sudo tar -xzf "/backup/autogen/$BACKUP_FILE"
# Restore permissions
sudo chown -R autogen:autogen /opt/autogen
sudo chown -R autogen:autogen /etc/autogen
# Start service
sudo systemctl start autogen
# Verify rollback
/opt/autogen/health_check.sh
echo "Rollback completed"

Testing Post-Upgrade

Automated Testing Script

python


# /opt/autogen/test_upgrade.py
import autogen
import os
import sys
from llm_config import llm_config
def test_basic_functionality():
"""Test basic AutoGen functionality"""
try:
# Test agent creation
assistant = autogen.AssistantAgent(
name="test_assistant",
llm_config=llm_config,
system_message="You are a test assistant."
)
user_proxy = autogen.UserProxyAgent(
name="test_user",
human_input_mode="NEVER",
code_execution_config=False
)
print("✓ Agent creation successful")
return True
except Exception as e:
print(f"✗ Agent creation failed: {e}")
return False
def test_api_connectivity():
"""Test API connectivity"""
try:
# Simple API test
response = assistant.generate_reply([{"role": "user", "content": "Hello"}])
print("✓ API connectivity successful")
return True
except Exception as e:
print(f"✗ API connectivity failed: {e}")
return False
if __name__ == "__main__":
print("=== AutoGen Upgrade Testing ===")
tests = [
test_basic_functionality,
test_api_connectivity
]
passed = 0
total = len(tests)
for test in tests:
if test():
passed += 1
print(f"\nTests passed: {passed}/{total}")
if passed == total:
print("All tests passed! Upgrade successful.")
sys.exit(0)
else:
print("Some tests failed. Consider rollback.")
sys.exit(1)