Merge master into leap-mutation-fix, resolving conflicts · QData/TextAttack@c48c25a · GitHub
Skip to content

Commit c48c25a

Browse files
qiyanjunclaude
andcommitted
Merge master into leap-mutation-fix, resolving conflicts
master had drifted significantly (RemoteModelWrapper, DifferentialEvolution search method, a large docs restructure, bad-characters recipe, and more) since this branch was cut. Conflicts and resolutions: - CHANGELOG.md: both sides added entries under [Unreleased]; kept master's intro line and merged both Added sections, keeping our Changed/Fixed sections. - docs/api/search_methods.rst, textattack/attack_args.py, textattack/search_methods/__init__.py: both sides added independent entries (ParticleSwarmOptimizationLEAP vs. DifferentialEvolution, "leap" vs. "bad-characters" recipe keys); kept both. - textattack/search_methods/particle_swarm_optimization.py: auto-merged cleanly -- master's only change there was formatting already identical to what our branch had applied, so our hook-based refactor applied with no real conflict. Diffed against origin/master to confirm. Also installed the newly-required `Levenshtein` dependency (for master's new MaximizeLevenshtein goal function) to verify imports and tests still pass post-merge. Verified: tests/test_attack_recipes.py passes, `textattack list search-methods` shows both `pso` and the new `differential-evolution`, and a `textattack attack --recipe leap` smoke run behaves consistently with pre-merge runs on the same example. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2 parents 4bfe4c6 + ae70466 commit c48c25a

126 files changed

Lines changed: 5526 additions & 335 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 8 additions & 15 deletions
Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
# For most projects, this workflow file will not need changing; you simply need
2-
# to commit it to your repository.
3-
#
4-
# You may wish to alter this file to override the set of languages analyzed,
5-
# or to provide custom queries or build logic.
6-
#
7-
# ******** NOTE ********
8-
# We have attempted to detect the languages in your repository. Please check
9-
# the `language` matrix defined below to confirm you have the correct set of
10-
# supported CodeQL languages.
11-
#
121
name: "CodeQL"
132

143
on:
154
push:
165
branches: [ master, master* ]
176
pull_request:
18-
# The branches below must be a subset of the branches above
197
branches: [ master ]
208
schedule:
219
- cron: '24 1 * * 0'
@@ -29,39 +17,18 @@ jobs:
2917
fail-fast: false
3018
matrix:
3119
language: [ 'python' ]
32-
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
33-
# Learn more:
34-
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
3520

3621
steps:
3722
- name: Checkout repository
38-
uses: actions/checkout@v2
23+
uses: actions/checkout@v4
3924

40-
# Initializes the CodeQL tools for scanning.
4125
- name: Initialize CodeQL
42-
uses: github/codeql-action/init@v1
26+
uses: github/codeql-action/init@v3
4327
with:
4428
languages: ${{ matrix.language }}
45-
# If you wish to specify custom queries, you can do so here or in a config file.
46-
# By default, queries listed here will override any specified in a config file.
47-
# Prefix the list here with "+" to use these queries and those in the config file.
48-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
4929

50-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
51-
# If this step fails, then you should remove it and run the build manually (see below)
5230
- name: Autobuild
53-
uses: github/codeql-action/autobuild@v1
54-
55-
# ℹ️ Command-line programs to run using the OS shell.
56-
# 📚 https://git.io/JvXDl
57-
58-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
59-
# and modify them (or add more) to build your code if your project
60-
# uses a compiled language
61-
62-
#- run: |
63-
# make bootstrap
64-
# make release
31+
uses: github/codeql-action/autobuild@v3
6532

6633
- name: Perform CodeQL Analysis
67-
uses: github/codeql-action/analyze@v1
34+
uses: github/codeql-action/analyze@v3

‎.github/workflows/make-docs.yml‎

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3-
41
name: Build documentation with Sphinx
52

63
on:
@@ -10,29 +7,23 @@ on:
107
branches: [ master ]
118

129
jobs:
13-
build:
14-
10+
docs:
1511
runs-on: ubuntu-latest
16-
strategy:
17-
matrix:
18-
python-version: [3.8]
1912

2013
steps:
21-
- uses: actions/checkout@v2
22-
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v2
14+
- uses: actions/checkout@v4
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
2417
with:
25-
python-version: ${{ matrix.python-version }}
18+
python-version: "3.11"
2619
- name: Install dependencies
2720
run: |
28-
sudo sed -i 's/azure\.//' /etc/apt/sources.list # workaround for flaky pandoc install
29-
sudo apt-get update # from here https://github.com/actions/virtual-environments/issues/675
30-
sudo apt-get install pandoc -o Acquire::Retries=3 # install pandoc
31-
python -m pip install --upgrade pip setuptools wheel # update python
32-
pip install ipython --upgrade # needed for Github for whatever reason
33-
python setup.py install_egg_info # Workaround https://github.com/pypa/pip/issues/4537
34-
pip install -e .[dev]
35-
pip install jupyter 'ipykernel<5.0.0' 'ipython<7.0.0' # ipykernel workaround: github.com/jupyter/notebook/issues/4050
21+
sudo apt-get update
22+
sudo apt-get install pandoc -o Acquire::Retries=3
23+
python -m pip install --upgrade pip setuptools wheel
24+
python setup.py install_egg_info
25+
pip install -e .[docs]
26+
pip install jupyter ipykernel
3627
- name: Build docs with Sphinx and check for errors
3728
run: |
3829
sphinx-build -b html docs docs/_build/html

‎.github/workflows/publish-to-pypi.yml‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflows will upload a Python Package using Twine when a release is created
2-
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3-
41
name: Upload Python Package to PyPI
52

63
on:
@@ -9,19 +6,17 @@ on:
96

107
jobs:
118
deploy:
12-
139
runs-on: ubuntu-latest
1410

1511
steps:
16-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v4
1713
- name: Set up Python
18-
uses: actions/setup-python@v2
14+
uses: actions/setup-python@v5
1915
with:
20-
python-version: '3.x'
16+
python-version: "3.11"
2117
- name: Install dependencies
2218
run: |
23-
python -m pip install --upgrade pip setuptools wheel
24-
pip install setuptools wheel twine
19+
python -m pip install --upgrade pip setuptools wheel twine
2520
- name: Build and publish
2621
env:
2722
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}

‎.github/workflows/run-pytest.yml‎

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3-
41
name: Test with PyTest
52

63
on:
@@ -10,48 +7,34 @@ on:
107
branches: [ master ]
118

129
jobs:
13-
build:
14-
10+
test:
1511
runs-on: ubuntu-latest
1612
strategy:
1713
matrix:
18-
python-version: [3.8, 3.9]
14+
python-version: ["3.10", "3.11"]
1915

2016
steps:
21-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v4
2218
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v2
19+
uses: actions/setup-python@v5
2420
with:
2521
python-version: ${{ matrix.python-version }}
2622
- name: Install dependencies
2723
run: |
2824
python -m pip install --upgrade pip setuptools wheel
29-
pip install pytest pytest-xdist # Testing packages
30-
pip uninstall textattack --yes # Remove TA if it's already installed
31-
python setup.py install_egg_info # Workaround https://github.com/pypa/pip/issues/4537
32-
pip install -e .[dev]
25+
pip install pytest pytest-xdist
26+
pip uninstall textattack --yes
27+
python setup.py install_egg_info
28+
pip install -e .[test]
3329
pip freeze
30+
- name: Download NLTK data
31+
run: |
32+
python -c "import nltk; nltk.download('punkt_tab'); nltk.download('averaged_perceptron_tagger'); nltk.download('stopwords'); nltk.download('omw-1.4'); nltk.download('wordnet')"
3433
- name: Free disk space
3534
run: |
36-
sudo apt-get remove mysql-client libmysqlclient-dev -y >/dev/null 2>&1
37-
sudo apt-get remove php* -y >/dev/null 2>&1
38-
sudo apt-get autoremove -y >/dev/null 2>&1
39-
sudo apt-get autoclean -y >/dev/null 2>&1
4035
sudo rm -rf /usr/local/lib/android >/dev/null 2>&1
41-
docker rmi $(docker image ls -aq) >/dev/null 2>&1
36+
sudo rm -rf /usr/share/dotnet >/dev/null 2>&1
4237
df -h
43-
- name: Increase swap space
44-
run: |
45-
swapon --show
46-
export SWAP_FILE=$(swapon --show=NAME | tail -n 1)
47-
sudo swapoff $SWAP_FILE
48-
sudo dd if=/dev/zero of=$SWAP_FILE bs=1M count=8k oflag=append conv=notrunc # Increase by 8GB
49-
sudo chmod 0600 $SWAP_FILE
50-
sudo mkswap $SWAP_FILE
51-
sudo swapon $SWAP_FILE
52-
swapon --show
5338
- name: Test with pytest
5439
run: |
55-
echo "skipping tests!"
56-
# pytest tests -v
57-
40+
pytest tests -v

‎CHANGELOG.md‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
This file was started alongside the `leap` attack recipe addition below;
6-
it does not attempt to reconstruct history prior to that point. Format
7-
loosely follows [Keep a Changelog](https://keepachangelog.com/).
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
86

97
## [Unreleased]
108

119
### Added
1210

11+
- `RemoteModelWrapper` (`textattack.models.wrappers.RemoteModelWrapper`): query a model served behind a remote HTTP API instead of running it locally. Request/response handling is adaptable to different endpoint schemas via `request_fn`/`response_fn`.
1312
- New attack recipe `leap` (`LEAP2023`, see `textattack/attack_recipes/leap_2023.py`)
1413
implementing LEAP: Efficient and Automated Test Method for NLP Software
1514
([arXiv:2308.11284](https://arxiv.org/abs/2308.11284)). LEAP is a

‎CLAUDE.md‎

Lines changed: 101 additions & 0 deletions

0 commit comments

Comments
 (0)