Skip to content

chore: perf of flamepy. #312

chore: perf of flamepy.

chore: perf of flamepy. #312

Workflow file for this run

name: Flame CI
on: [push, pull_request]
env:
CLICOLOR_FORCE: 1
INSTALL_PREFIX: /opt/flame-test
FLAME_ENDPOINT: http://127.0.0.1:8080
jobs:
ci:
name: BareMetal Python Test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
rust: [stable]
os: [ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
- name: Install Python and uv
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.local/bin" >> $GITHUB_PATH
# Install uv to /usr/bin for flmrun service
sudo cp $HOME/.local/bin/uv /usr/bin/uv
sudo chmod +x /usr/bin/uv
echo "✓ Installed uv to /usr/bin/uv for flmrun"
- name: Install system dependencies
run: |
sudo apt-get update && sudo apt-get install -y protobuf-compiler
- name: Build Flame
run: |
cargo build --release
- name: Verify systemd availability
run: |
echo "=== Checking systemd ==="
systemctl --version
echo ""
echo "=== Systemd status ==="
systemctl status || echo "systemd status command returned non-zero"
echo ""
echo "=== Check if systemd is running as init ==="
ps -p 1 -o comm=
echo ""
echo "=== Current user ==="
whoami
echo ""
echo "=== Sudo privileges ==="
sudo -v && echo "✓ Sudo available"
- name: Install dufs for HTTP package storage
run: |
echo "=== Installing dufs ==="
cargo install dufs
echo "✓ Installed dufs"
- name: Install Flame with flmadm and systemd
run: |
sudo ./target/release/flmadm install --all --src-dir . --skip-build --prefix $INSTALL_PREFIX --enable
echo "$INSTALL_PREFIX/bin" >> $GITHUB_PATH
- name: Setup local configuration and packages directory
run: |
echo "=== Copy local configuration ==="
mkdir -p ~/.flame
cp ci/flame-local.yaml ~/.flame/flame.yaml
echo "✓ Copied flame-local.yaml to ~/.flame/flame.yaml"
echo "=== Create packages directory ==="
sudo mkdir -p /opt/flame/packages
sudo chmod 0777 /opt/flame/packages
echo "✓ Created /opt/flame/packages with 0777 permissions"
- name: Start HTTP package storage server
run: |
echo "=== Starting dufs package storage server ==="
nohup dufs /opt/flame/packages -p 5050 -A > /tmp/dufs.log 2>&1 &
echo $! > /tmp/dufs.pid
sleep 2
if ps -p $(cat /tmp/dufs.pid) > /dev/null; then
echo "✓ Package storage server started (PID: $(cat /tmp/dufs.pid))"
curl -s http://127.0.0.1:5050/ > /dev/null && echo "✓ Package storage server is accessible"
else
echo "✗ Package storage server failed to start"
cat /tmp/dufs.log
exit 1
fi
- name: Install Python SDK for test client
run: |
echo "=== Installing flamepy for test client (not required for flmrun service) ==="
pip3 install --user ./sdk/python
echo "✓ flamepy installed for test client"
echo ""
echo "Note: flmrun service uses 'uv run --with' to access flamepy from $INSTALL_PREFIX/sdk/python"
- name: Check service status
run: |
# Wait for services to be ready
sleep 5
# Check service status
sudo systemctl status flame-session-manager || (echo "Session manager not running" && sudo journalctl -u flame-session-manager -n 50 && exit 1)
sudo systemctl status flame-executor-manager || (echo "Executor manager not running" && sudo journalctl -u flame-executor-manager -n 50 && exit 1)
echo "✓ Services are running via systemd"
- name: Verify Python SDK installation (for test client)
run: |
echo "=== Verify flamepy installation for test client ==="
pip3 show flamepy
echo ""
echo "=== Test import ==="
python3 -c "import flamepy; print('✓ flamepy imported successfully from:', flamepy.__file__)"
echo ""
echo "=== Verify SDK copied to installation directory ==="
ls -la $INSTALL_PREFIX/sdk/python/
- name: Install Python dependencies
run: |
# Install test dependencies
pip3 install grpcio grpcio-tools pytest pytest-timeout black isort
- name: Verify Flame cluster is ready
run: |
echo "=== Check flmctl connectivity ==="
flmctl list -a || echo "Warning: Could not list applications"
echo ""
echo "=== Verify HTTP storage is accessible ==="
curl -s http://127.0.0.1:5050/ && echo "✓ HTTP storage is accessible" || echo "Warning: HTTP storage not accessible"
- name: Run test_runner
timeout-minutes: 10
run: |
# Add e2e src to PYTHONPATH (flamepy is already system-installed)
export PYTHONPATH="$(pwd)/e2e/src:$PYTHONPATH"
cd e2e
pytest -vv --durations=0 tests/test_runner.py
- name: Show service logs on failure
if: failure() || cancelled()
run: |
echo "=== Package Storage Logs ==="
cat /tmp/dufs.log || echo "No dufs log file found"
echo ""
echo "=== Session Manager Logs (systemd) ==="
sudo journalctl -u flame-session-manager -n 200 || echo "No systemd logs found"
echo ""
echo "=== Session Manager Logs (file) ==="
sudo cat $INSTALL_PREFIX/logs/fsm.log || echo "No FSM log file found"
echo ""
echo "=== Executor Manager Logs (systemd) ==="
sudo journalctl -u flame-executor-manager -n 200 || echo "No systemd logs found"
echo ""
echo "=== Executor Manager Logs (file) ==="
sudo cat $INSTALL_PREFIX/logs/fem.log || echo "No FEM log file found"
echo ""
echo "=== Active processes ==="
ps aux | grep -E "(flame|dufs|python)" || true
echo ""
echo "=== Network connections ==="
netstat -tlnp 2>/dev/null || ss -tlnp || true
- name: Stop Flame services
if: always()
run: |
# Stop services via systemd
sudo systemctl stop flame-executor-manager || true
sudo systemctl stop flame-session-manager || true
- name: Cleanup
if: always()
run: |
# Stop package storage server
if [ -f /tmp/dufs.pid ]; then
kill $(cat /tmp/dufs.pid) || true
rm -f /tmp/dufs.pid
fi
sudo ./target/release/flmadm uninstall --prefix $INSTALL_PREFIX --no-backup --force || true