|
| 1 | +# Ariadne - WALA Python/ML Analysis Framework |
| 2 | + |
| 3 | +Ariadne is a static analysis framework for Python and Machine Learning code built on IBM WALA. It provides Python call graph analysis, ML-specific analysis, and Language Server Protocol (LSP) support for editor integration. |
| 4 | + |
| 5 | +**ALWAYS reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.** |
| 6 | + |
| 7 | +## Working Effectively |
| 8 | + |
| 9 | +### Bootstrap and Build |
| 10 | +Execute these commands in order for a complete setup: |
| 11 | + |
| 12 | +```bash |
| 13 | +# 1. Initialize git submodules (3 minutes - NEVER CANCEL) |
| 14 | +git submodule update --init --recursive |
| 15 | + |
| 16 | +# 2. Install Python dependencies (30 seconds) |
| 17 | +pip install -r requirements.txt |
| 18 | + |
| 19 | +# 3. Set Java environment (required: Java 25 for compilation) |
| 20 | +export JAVA_HOME=/usr/lib/jvm/temurin-25-jdk-amd64 |
| 21 | +export PATH=$JAVA_HOME/bin:$PATH |
| 22 | + |
| 23 | +# 4. Build Jython3 (26 seconds - NEVER CANCEL) |
| 24 | +cd jython3 |
| 25 | +ant |
| 26 | +cd dist |
| 27 | +mvn install:install-file \ |
| 28 | +-Dfile=./jython-dev.jar \ |
| 29 | +-DgroupId="org.python" \ |
| 30 | +-DartifactId="jython3" \ |
| 31 | +-Dversion="0.0.1-SNAPSHOT" \ |
| 32 | +-Dpackaging="jar" \ |
| 33 | +-DgeneratePom=true -B |
| 34 | +cd ../.. |
| 35 | + |
| 36 | +# 5. Build WALA from source (5+ minutes - NEVER CANCEL, set timeout to 600+ seconds) |
| 37 | +cd WALA |
| 38 | +./gradlew build publishToMavenLocal -x test -x javadoc -x lintMarkdown |
| 39 | +cd .. |
| 40 | + |
| 41 | +# 6. Build IDE/LSP component (17 seconds - NEVER CANCEL) |
| 42 | +cd IDE/com.ibm.wala.cast.lsp |
| 43 | +mvn install -B -q -DskipTests |
| 44 | +cd ../.. |
| 45 | + |
| 46 | +# 7. Build main project (40 seconds - NEVER CANCEL, set timeout to 120+ seconds) |
| 47 | +mvn install -B -DskipTests |
| 48 | +``` |
| 49 | + |
| 50 | +### CRITICAL Build Notes |
| 51 | +- **NEVER CANCEL** any build command. Set timeouts to 600+ seconds minimum for WALA builds, 120+ seconds for Maven builds. |
| 52 | +- **WALA Dependency**: The project requires WALA 1.6.13-SNAPSHOT built from the Git submodule. Do NOT use Maven Central versions. |
| 53 | +- **Java Version**: Use Java 25 for the project. This is required for both WALA compilation and the ML project. |
| 54 | +- **Test Failures**: Tests may fail due to dependencies. Always use `-DskipTests` for reliable builds. |
| 55 | + |
| 56 | +## Validation and Testing |
| 57 | + |
| 58 | +### Format and Lint Checks |
| 59 | +```bash |
| 60 | +# Java code formatting check (19 seconds - NEVER CANCEL, set timeout to 60+ seconds) |
| 61 | +mvn spotless:check -B |
| 62 | + |
| 63 | +# Python code formatting check (3 seconds) |
| 64 | +black --fast --check . |
| 65 | + |
| 66 | +# Apply formatting fixes |
| 67 | +mvn spotless:apply -B |
| 68 | +black . |
| 69 | +``` |
| 70 | + |
| 71 | +### Running Tests |
| 72 | +```bash |
| 73 | +# Compile only (42 seconds - NEVER CANCEL, set timeout to 120+ seconds) |
| 74 | +mvn compile -B |
| 75 | + |
| 76 | +# Limited tests (some will fail due to WALA dependencies) |
| 77 | +mvn test -B -Dtest="TestCalls" |
| 78 | + |
| 79 | +# Skip all tests for reliable CI build |
| 80 | +mvn install -B -DskipTests |
| 81 | +``` |
| 82 | + |
| 83 | +### Ariadne CLI Tool |
| 84 | +```bash |
| 85 | +# Build creates shaded JAR for CLI usage |
| 86 | +java -cp ml/com.ibm.wala.cast.python.ml/target/com.ibm.wala.cast.python.ml-0.0.1-SNAPSHOT-shaded.jar \ |
| 87 | +com.ibm.wala.cast.python.ml.driver.Ariadne --help |
| 88 | + |
| 89 | +# Note: Full functionality requires complete WALA build dependencies |
| 90 | +``` |
| 91 | + |
| 92 | +## Manual Validation Requirements |
| 93 | +After making changes, always run through this validation sequence: |
| 94 | + |
| 95 | +1. **Build Validation**: Run full build sequence above and verify no compilation errors |
| 96 | +2. **Format Validation**: Run both spotless and black checks to ensure code style compliance |
| 97 | +3. **CLI Testing**: Verify Ariadne CLI shows help output correctly |
| 98 | +4. **Import Testing**: Test basic Java compilation to verify dependencies resolve |
| 99 | + |
| 100 | +## Timing Expectations |
| 101 | + |
| 102 | +| Step | Time | Timeout | Critical Notes | |
| 103 | +|------|------|---------|----------------| |
| 104 | +| Git submodules | 3 minutes | 300+ seconds | One-time setup, NEVER CANCEL | |
| 105 | +| Jython3 build | 26 seconds | 120+ seconds | NEVER CANCEL | |
| 106 | +| Jython3 install | 6 seconds | 60+ seconds | Maven install step | |
| 107 | +| WALA build | 5+ minutes | 600+ seconds | NEVER CANCEL, requires Java 25 | |
| 108 | +| IDE build | 17 seconds | 60+ seconds | NEVER CANCEL | |
| 109 | +| Main build | 40 seconds | 120+ seconds | NEVER CANCEL | |
| 110 | +| Spotless check | 19 seconds | 60+ seconds | NEVER CANCEL | |
| 111 | +| Black check | 3 seconds | 30+ seconds | Fast Python format check | |
| 112 | + |
| 113 | +**Total clean build time: ~2.5 hours (including submodules) or ~6 minutes (if submodules exist)** |
| 114 | + |
| 115 | +## Repository Structure |
| 116 | + |
| 117 | +### Key Components |
| 118 | +- **core/**: Python analysis core (`com.ibm.wala.cast.python`) |
| 119 | +- **ml/**: ML-specific analysis (`com.ibm.wala.cast.python.ml`) |
| 120 | +- **jython/**: Jython-based Python parsing |
| 121 | +- **jep/**: JEP (Java Embedded Python) integration |
| 122 | +- **IDE/**: Language Server Protocol implementation |
| 123 | +- **WALA/**: WALA static analysis framework (git submodule) |
| 124 | +- **jython3/**: Jython 3 implementation (git submodule) |
| 125 | + |
| 126 | +### Important Files |
| 127 | +- `pom.xml`: Root Maven project configuration |
| 128 | +- `requirements.txt`: Python dependencies (ast2json, jep, black) |
| 129 | +- `CONTRIBUTING.md`: Detailed build instructions |
| 130 | +- `.github/workflows/continuous-integration.yml`: CI pipeline configuration |
| 131 | + |
| 132 | +## Common Tasks |
| 133 | + |
| 134 | +### Building for Development |
| 135 | +```bash |
| 136 | +# Quick compile check |
| 137 | +mvn compile -B |
| 138 | + |
| 139 | +# Full build with format checks |
| 140 | +mvn spotless:apply -B && black . && mvn install -B -DskipTests |
| 141 | +``` |
| 142 | + |
| 143 | +### CI Pipeline Preparation |
| 144 | +The project's CI pipeline expects this sequence: |
| 145 | +1. Git submodules initialized |
| 146 | +2. Python dependencies installed |
| 147 | +3. Jython3 built and installed |
| 148 | +4. WALA built from source (requires Java 25) |
| 149 | +5. IDE component built |
| 150 | +6. Main project built with tests |
| 151 | + |
| 152 | +Always run `mvn spotless:apply -B` and `black .` before committing to avoid CI failures. |
| 153 | + |
| 154 | +## Troubleshooting |
| 155 | + |
| 156 | +### Common Issues |
| 157 | +- **Java version errors**: Ensure Java 25 is set in JAVA_HOME and PATH |
| 158 | +- **WALA build failures**: Ensure you have Java 25 and sufficient memory (Gradle may require more RAM) |
| 159 | +- **Test failures**: Expected due to dependencies, use `-DskipTests` |
| 160 | +- **Formatting failures**: Run `mvn spotless:apply -B` and `black .` to auto-fix |
| 161 | +- **Submodule issues**: Re-run `git submodule update --init --recursive` |
| 162 | +- **Gradle errors**: WALA build requires proper toolchain setup and network access |
| 163 | + |
| 164 | +### Network Dependencies |
| 165 | +- Maven Central for Java dependencies |
| 166 | +- Python Package Index for Python dependencies |
| 167 | +- GitHub for git submodules (WALA, IDE, jython3) |
| 168 | + |
| 169 | +## Project Context |
| 170 | +This is a research framework for static analysis of Python code with focus on Machine Learning applications. The main deliverable is the Ariadne tool which can be used as: |
| 171 | +- Command-line linter for Python/ML code |
| 172 | +- Language Server Protocol server for editor integration |
| 173 | +- Analysis framework for research applications |
| 174 | + |
| 175 | +The codebase integrates multiple technologies (Java, Python, Jython) and requires careful dependency management between WALA, Jython, and the ML-specific components. |
0 commit comments