Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a manual GH action we can use to run make-appmaps with. #4

Merged
merged 78 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
9389723
Add basic GH action starting point
petecheslock Jun 3, 2024
cd64a65
Grab bits from the solve.yml
petecheslock Jun 3, 2024
866487e
Rename
petecheslock Jun 3, 2024
546f7e0
Put in correct directory
petecheslock Jun 3, 2024
0493d85
Added submodule
petecheslock Jun 3, 2024
522f989
Cache the conda env and the appmap-js submodule build
petecheslock Jun 3, 2024
f778014
fix: add --show-instances
apotterri Jun 3, 2024
9414a58
just assume its on the path and execute
petecheslock Jun 3, 2024
ea04f50
Fix caching for conda env
petecheslock Jun 3, 2024
531e612
Use python 3.9
petecheslock Jun 3, 2024
a6d1756
Don't need to rebuild if the cache hit on the submodules is true
petecheslock Jun 3, 2024
7fd6fd8
Setup python 3.9
petecheslock Jun 3, 2024
fe2dfc6
Update cache details
petecheslock Jun 3, 2024
8cbb9f1
fix yaml
petecheslock Jun 3, 2024
7ede9d7
Set the ID for the submodule cache hit
petecheslock Jun 3, 2024
0ef4344
Enable debugging
petecheslock Jun 3, 2024
5856edc
Fix environment variable for cache
petecheslock Jun 3, 2024
b111bae
Basic test to see if enviornment is working
petecheslock Jun 3, 2024
fbb978b
Use the repository project filter
petecheslock Jun 3, 2024
cbab0f0
Debug
petecheslock Jun 3, 2024
bfa0926
Dont need to auto activate
petecheslock Jun 3, 2024
bb1c5f5
Start debugging after job runs
petecheslock Jun 3, 2024
db99e28
Try again
petecheslock Jun 3, 2024
a5bba4a
Use diff upterm session action
petecheslock Jun 3, 2024
cfc4611
cache pip also
petecheslock Jun 3, 2024
09f76f3
Use pyvista and update the asset archive
petecheslock Jun 3, 2024
bc9647c
Make maps with matplotlib
petecheslock Jun 3, 2024
c19fc87
Hard code for now
petecheslock Jun 3, 2024
2c42cdf
Display params false by default
petecheslock Jun 3, 2024
f8abd23
Remove option to see if more deps are found
petecheslock Jun 3, 2024
321df55
Limit max events.
petecheslock Jun 3, 2024
72697d7
Use full path to the submodule
petecheslock Jun 3, 2024
c94d116
Use appmap binary
petecheslock Jun 3, 2024
71b99aa
Get the linux version from a pinned release
petecheslock Jun 3, 2024
5a5adca
No longer need submodule for this
petecheslock Jun 3, 2024
4d76708
Give the worker more temp build space
petecheslock Jun 3, 2024
cad6144
Clear cache
petecheslock Jun 3, 2024
0c16ce2
Adjust storage location
petecheslock Jun 4, 2024
4720508
Adjust temp directory location
petecheslock Jun 4, 2024
ace5f9c
fix: tee test output to file and stdout
apotterri Jun 4, 2024
7dd51a2
fix: fix the pytest install command
apotterri Jun 4, 2024
26c711d
fix: upload everything in appmaps and appmap_logs
apotterri Jun 4, 2024
34eda1d
fix: set the name of the artifact
apotterri Jun 4, 2024
b2ef56f
Debug
petecheslock Jun 4, 2024
85959aa
Use diff mount point for temp dir
petecheslock Jun 4, 2024
c2dca56
Investigate
petecheslock Jun 4, 2024
d013bb9
Use larger runner
petecheslock Jun 4, 2024
9cdf60b
Clear cache with new runner
petecheslock Jun 4, 2024
c457556
Use diff python version
petecheslock Jun 4, 2024
872d20c
Check if conda is set
petecheslock Jun 4, 2024
68afae0
Try to remove variables
petecheslock Jun 4, 2024
82430bc
Re source the shell
petecheslock Jun 4, 2024
5075887
Add more cache dirs
petecheslock Jun 4, 2024
3087475
Re-enable debugging to see what's happening
petecheslock Jun 4, 2024
0cd59fe
Disable appmap, see how long it takes
petecheslock Jun 4, 2024
52f7635
Re enable appmap and reduce max events
petecheslock Jun 4, 2024
e3afdfc
Disable debug session
petecheslock Jun 4, 2024
026f7c8
Forget about caching conda for now
petecheslock Jun 4, 2024
e5247a6
Use input filters for workflow dispatch and set a debug session if a
petecheslock Jun 4, 2024
9e51022
Save everything in the appmaps dir (compressed archives)
petecheslock Jun 4, 2024
c0e6dd4
Put back empty gitmodules
petecheslock Jun 4, 2024
2631827
fix: split the tests into groups
apotterri Jun 4, 2024
ea42bba
Merge branch 'test-output_20240604' into feat/add-gh-action
petecheslock Jun 4, 2024
bf795ec
Create a cloned version of the workflow for testing
petecheslock Jun 4, 2024
8270bf2
fix: be more verbose when running tests
apotterri Jun 4, 2024
6509b96
Merge branch 'test-output_20240604' into feat/add-gh-action
petecheslock Jun 4, 2024
e392a26
Remove this line
petecheslock Jun 4, 2024
6662f9e
Some manual adjustments to test artifact uploads
petecheslock Jun 4, 2024
a77ab62
Test archiving artifacts in the directory
petecheslock Jun 4, 2024
0bea090
Store the artifact left behind with the same name so we can find it
petecheslock Jun 4, 2024
496faf3
Update way of getting file name for upload
petecheslock Jun 4, 2024
7d4fd7b
Remove test action - pull in updates
petecheslock Jun 4, 2024
2fcdda4
Merge branch 'main' into feat/add-gh-action
petecheslock Jun 5, 2024
d007f48
Put this back for a test after merging in mainline
petecheslock Jun 5, 2024
f7704e0
Fix the CLI flags
petecheslock Jun 5, 2024
42b7b8e
Remove the test job for release
petecheslock Jun 5, 2024
ef1a1eb
Use APPMAP_MAX_TIME
petecheslock Jun 5, 2024
b19615a
Use the full swe-bench data set for GH action
petecheslock Jun 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/workflows/make-appmaps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Make AppMaps

on:
workflow_dispatch:
inputs:
projectFilter:
description: 'Project or instance to filter for'
required: true
appmapMaxEvents:
description: 'Max Events per AppMap'
required: true
default: '25000'
appmapMaxTime:
description: 'Max time per appmap creation'
required: true
default: '30'

permissions:
contents: write
actions: write

jobs:
run:
runs-on: SWE-Bench_Larger
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install AppMap tools
uses: getappmap/install-action@v1
with:
install-appmap-library: false
tools-url: https://github.com/getappmap/appmap-js/releases/download/%40appland%2Fappmap-v3.147.0/appmap-linux-x64

- name: Set up Python
uses: actions/setup-python@v5
with:
cache: 'pip'

- name: Set up Conda
uses: conda-incubator/setup-miniconda@v3
with:
python-version: 3.9

- name: Make dirs
run: |
mkdir -p appmaps appmap_logs /tmp/swe-appmaps

- name: Create conda env
run: |
conda init bash
conda env create -f environment.yml

- name: Make Appmaps
run: |
source /home/runner/.bashrc
conda activate swe-bench
conda info
APPMAP_MAX_TIME=${{ github.event.inputs.appmapMaxTime }} APPMAP_MAX_EVENTS=${{ github.event.inputs.appmapMaxEvents }} ./appmap/make_appmaps-github-actions.sh --filter ${{ github.event.inputs.projectFilter }}

- name: Get Artifact Name
id: get-artifact-name
run: |
file=$(ls appmaps/ | head -n 1)
echo "file_name=$file" >> $GITHUB_ENV
echo "::set-output name=file_name::$file"

- name: Upload AppMaps
uses: actions/upload-artifact@v4
with:
name: ${{ steps.get-artifact-name.outputs.file_name }}
path: ./appmaps/${{ steps.get-artifact-name.outputs.file_name }}

- name: Upload SWE Bench Logs
uses: actions/upload-artifact@v4
with:
name: appmap-logs.zip
path: ./appmap_logs/

# If the build fails leave a terminal open for 5 minutes
# we can investigate if needed
- name: Setup upterm session
uses: owenthereal/action-upterm@v1
if: ${{ failure() }}
with:
wait-timeout-minutes: 5
19 changes: 19 additions & 0 deletions appmap/make_appmaps-github-actions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# find project root directory
PROJECT_ROOT=$(git rev-parse --show-toplevel)
# add it to python path
export PYTHONPATH=$PROJECT_ROOT:$PYTHONPATH

INSTANCES="princeton-nlp/SWE-bench"

python $PROJECT_ROOT/appmap/make_appmaps.py \
--instances_path "$INSTANCES" \
--log_dir "appmap_logs" \
--appmap_archive_dir appmaps \
--temp_dir "/tmp/swe-appmaps" \
--num_workers 1 \
--verbose \
--path_conda $(conda info --base) \
--appmap_bin /usr/local/bin/appmap \
"$@"
36 changes: 31 additions & 5 deletions appmap/make_appmaps.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import argparse, glob, itertools, os, tarfile, subprocess

import argparse
import faulthandler
import glob
import itertools
import json
import os
import signal
import subprocess
import sys
import tarfile
from multiprocessing import Pool, cpu_count
from swebench.harness.constants import MAP_REPO_TO_TEST_FRAMEWORK
from swebench.harness.context_manager import (
TaskEnvContextManager,
TestbedContextManager,
)
from swebench.harness.utils import split_instances, DotDict
from swebench.harness.utils import DotDict, split_instances
from swebench.metrics.getters import get_eval_refs

faulthandler.register(signal.SIGUSR1)

SKIP_INSTANCES = {"pytest-dev/pytest": ["6387", "7956", "3805"]}

Expand Down Expand Up @@ -80,12 +89,15 @@ def make_appmaps(data: dict):
tcm.run_install_task(task_instance)
tcm.log.write("Installing appmap")
tcm.exec(["bash", "-c", f"{tcm.cmd_activate} && pip install appmap"])
tcm.log.write("Installing pytest-test-groups")
tcm.exec(["bash", "-c", f"{tcm.cmd_activate} && pip install pytest-test-groups"])
task_instance["test_cmd"] = MAP_REPO_TO_TEST_FRAMEWORK[
task_instance["repo"]
] # run all tests
tcm.log.write("Running tests with appmap")
task_instance["test_cmd"] = f"appmap-python {task_instance['test_cmd']}"
tcm.run_tests_task(task_instance)
for i in range(1,100):
test_cmd = f"APPMAP_DISPLAY_PARAMS=false PYTHONUNBUFFERED=1 appmap-python {task_instance['test_cmd']} --test-group-count 100 --test-group {i}"
tcm.run_tests_task(task_instance, test_cmd)
tcm.log.write("Uninstalling appmap")
tcm.exec(["bash", "-c", f"{tcm.cmd_activate} && pip uninstall -y appmap"])
# count .appmap.json files in testbed/tmp/appmap (recursively)
Expand Down Expand Up @@ -166,6 +178,14 @@ def main(args):
for task_instance in task_instances
if args.filter in task_instance["instance_id"]
]
if (args.show_instances):
def filter_keys(dicts):
keys_to_keep=["instance_id", "version", "environment_setup_commit"]
return [{k: v for k, v in d.items() if k in keys_to_keep} for d in dicts]

json.dump(filter_keys(task_instances), indent=2, fp=sys.stdout)
sys.exit(0)


# group by repo-version
rv_groups = itertools.groupby(task_instances, lambda x: (x["repo"], x["version"]))
Expand Down Expand Up @@ -267,6 +287,12 @@ def main(args):
action="store_true",
help="(Optional) Keep temporary directories after running",
)
parser.add_argument(
"--show-instances",
action="store_true",
help="Only show instance info",
)

args = parser.parse_args()
appmap_bin = os.path.expanduser(args.appmap_bin)
validate_args(args)
Expand Down
5 changes: 3 additions & 2 deletions swebench/harness/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
MAP_VERSION_TO_INSTALL_PYTEST["8.0"]["pip_packages"] = [
"iniconfig==2.0.0", "packaging==23.1", "pluggy==1.3.0",
"exceptiongroup==1.1.3", "tomli==2.0.1"]
MAP_VERSION_TO_INSTALL_PYTEST["8.0"]["install"] = "pip install -e .[testing]"

MAP_VERSION_TO_INSTALL_MATPLOTLIB = {
k: {
Expand Down Expand Up @@ -571,7 +572,7 @@
MAP_REPO_TO_INSTALL = {}

# Constants - Task Instance Test Frameworks
TEST_PYTEST = "pytest --no-header -rA --tb=no -p no:cacheprovider"
TEST_PYTEST = "pytest --no-header -rA --tb=no -p no:cacheprovider -v"
MAP_REPO_TO_TEST_FRAMEWORK = {
"astropy/astropy": TEST_PYTEST,
"django/django": "./tests/runtests.py --verbosity 2",
Expand All @@ -585,7 +586,7 @@
"pydicom/pydicom": TEST_PYTEST,
"pylint-dev/astroid": TEST_PYTEST,
"pylint-dev/pylint": TEST_PYTEST,
"pytest-dev/pytest": "pytest -rA",
"pytest-dev/pytest": "pytest -vrA",
"pyvista/pyvista": TEST_PYTEST,
"scikit-learn/scikit-learn": TEST_PYTEST,
"sphinx-doc/sphinx": "tox -epy39 -v --",
Expand Down
Loading