Fix file upload using temp files instead of relative paths #381
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Python-Apollo | |
| on: | |
| push: | |
| branches: [develop, apollo_g7] | |
| pull_request: | |
| branches: [develop] | |
| jobs: | |
| test-python-apollo: | |
| name: test-python-apollo | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Apollo | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: 17 | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Build Apollo | |
| run: ./gradlew classes | |
| - name: Start Apollo | |
| run: | | |
| ./gradlew bootRun > apollo.log 2>&1 & | |
| # Wait for health endpoint | |
| for i in $(seq 1 300); do | |
| response=$(curl -s 'http://localhost:8080/apollo/health/index' 2>/dev/null || true) | |
| if echo "$response" | grep -q '"status":"ready"'; then | |
| echo "Apollo is ready (${i}s)" | |
| break | |
| fi | |
| if [ $i -eq 300 ]; then | |
| echo "FAIL: Apollo not ready after 300 seconds" | |
| cat apollo.log | |
| exit 1 | |
| fi | |
| sleep 1 | |
| done | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Checkout python-apollo | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: galaxy-genome-annotation/python-apollo | |
| path: python-apollo | |
| ref: master | |
| - name: Install python-apollo | |
| run: | | |
| cd python-apollo | |
| pip install 'biopython<1.86' apollo pytest | |
| - name: Bootstrap test data | |
| run: | | |
| cd python-apollo | |
| export ARROW_GLOBAL_CONFIG_PATH=$(pwd)/test-data/local-apollo2-arrow.yml | |
| ./bootstrap_apollo.sh --nodocker | |
| - name: Diagnose test failures | |
| run: | | |
| cd python-apollo | |
| export ARROW_GLOBAL_CONFIG_PATH=$(pwd)/test-data/local-apollo2-arrow.yml | |
| python3 -c " | |
| import traceback, json, sys | |
| try: | |
| from apollo import ApolloInstance | |
| wa = ApolloInstance('http://localhost:8080/apollo', 'admin@local.host', 'password') | |
| print('=== Organisms ===') | |
| orgs = wa.organisms.get_organisms() | |
| for o in orgs: | |
| print(f\" {o.get('commonName')}: sequences={o.get('sequences')}\") | |
| print() | |
| print('=== Test load_gff3 ===') | |
| feature_data = wa.annotations.load_gff3('test_organism', 'test-data/mrna-top.gff') | |
| print(f'load_gff3 returned: {feature_data}') | |
| print() | |
| print('=== Remote API test ===') | |
| import tempfile, tarfile, glob, os | |
| with tempfile.NamedTemporaryFile(suffix='.tar.gz', delete=False) as archive: | |
| archive_path = archive.name | |
| with tarfile.open(archive_path, mode='w:gz') as tar: | |
| base = 'test-data/dataset_1_files/data/' | |
| for root, dirs, files in os.walk(base): | |
| for f in files: | |
| full = os.path.join(root, f) | |
| arcname = os.path.relpath(full, base) | |
| tar.add(full, arcname=arcname) | |
| with tarfile.open(archive_path, mode='r:gz') as tar: | |
| print(f' Archive has {len(tar.getmembers())} entries') | |
| for m in tar.getmembers()[:5]: | |
| print(f' {m.name}') | |
| with open(archive_path, 'rb') as f: | |
| result = wa.remote.add_organism('diag_remote_org', f) | |
| print(f' add_organism result: {json.dumps(result, indent=2, default=str)[:500]}') | |
| os.unlink(archive_path) | |
| except Exception as e: | |
| print(f'DIAGNOSTIC FAILED: {type(e).__name__}: {e}') | |
| traceback.print_exc() | |
| " 2>&1 || true | |
| echo "" | |
| echo "=== Apollo ERROR/WARN log lines ===" | |
| grep -E 'ERROR|WARN' ../apollo.log | tail -200 || true | |
| - name: Run tests | |
| run: | | |
| cd python-apollo | |
| export ARROW_GLOBAL_CONFIG_PATH=$(pwd)/test-data/local-apollo2-arrow.yml | |
| python -m pytest -v | |
| - name: Print Apollo log on failure | |
| if: failure() | |
| run: | | |
| echo "=== Last 500 lines of Apollo log ===" | |
| tail -500 apollo.log |