Extensible JSONL task editing library for code and formula inputs.
Project description
logicedit
logicedit processes JSON or JSONL task records, applies controlled line edits, runs edited variants through registered tools, evaluates tool outputs, and writes successful variants back as JSONL.
Features
- Dataclass-based record models with
extra_optionsfor forward-compatible schema changes. single_editmode for independent edits from the original input.cumulative_editmode for greedy accepted edits applied on top of prior edits.- Tool registry with in-memory tools, Python-file adapters, and a built-in Z3 solver adapter.
- Explicit required tool selection via
toolandtool_type. - Configurable label comparison strategies for label-preserving and label-variation workflows.
- Minimal examples with a mock tool and mock editor.
Install
python3 -m pip install -e .[dev]
This installs the library dependencies, including z3-solver for the built-in Z3 backend.
TestPyPI Release Flow
Build and upload to TestPyPI first:
make publish-testpypi
Install the published package from TestPyPI:
make install-testpypi
If you prefer the raw commands:
python3 -m build
python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*
python3 -m pip install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/ \
logicedit
Run
python3 -m logicedit.cli \
--input /path/to/tasks.jsonl \
--output /path/to/successes.jsonl \
--tool csp_solver.py \
--tool-type csp_solver \
--edit-mode single_edit \
--number-of-edits 3 \
--label-variation \
--single-edit-ids 0,2,4
number_of_edits accepts either a positive integer or "all".
- In
single_editmode, the library evaluates independent edits from the original input and saves up to the requested maximum number of successful premise-level edits. Use--single-edit-idsorextra_options.selected_edit_idsto restrict which editable units are considered. - In
cumulative_editmode,"all"means the runner walks the editable statements from first to last, tries the available operator edits for each statement against thelabel_variationcondition, applies the first acceptable edit, and then moves to the next statement. --tooland--tool-typeare mandatory on the CLI. The library no longer defaults silently tocsp_solver.--no-label-variationis the default behavior: only save records whose tool output matches the original label.--label-variationinverts that rule: only save records whose tool output differs from the original label.
Available tool families:
csp_solver: uses the Python-file adapter. Pass a file such ascsp_solver.pyin thetoolfield and pointextra_options.tool_search_pathsat the folder containing it. The adapter can call plain functions such asrun(input_text)and also supports theCSP_Programclass shape found in the source files.z3_solver: uses the built-in vendored Z3 backend. Passz3_solveras thetoolvalue. This tool type uses Z3-specific operator edits in the# Constraintssection:AND -> OR,XOR -> OR,OR -> XOR, andNOTremoval.
The library only searches tool paths you provide or the input file directory added by the CLI.
Example Z3 run:
python3 -m logicedit.cli \
--input /path/to/z3_tasks.jsonl \
--output /path/to/z3_successes.jsonl \
--tool z3_solver \
--tool-type z3_solver \
--edit-mode cumulative_edit \
--number-of-edits all
Example Record
{
"id": "logical_deduction_0",
"tool": "csp_solver.py",
"tool_type": "csp_solver",
"input_type": "code",
"edit_mode": "single_edit",
"number_of_edits": 2,
"label_variation": false,
"expected_answer": "D",
"logic_program": "Domain:\n...\nConstraints:\nThe blue book is to the right of the yellow book. ::: blue_book > yellow_book\n...\n\nQuery:\n..."
}
Example Z3 record:
{
"id": "ar_lsat_0",
"tool": "z3_solver",
"tool_type": "z3_solver",
"input_type": "code",
"edit_mode": "single_edit",
"number_of_edits": 2,
"label_variation": true,
"expected_answer": "B",
"logic_program": "# Declarations\n...\n\n# Constraints\nrule ::: A AND B\n...\n\n# Options\nQuestion ::: ...\n..."
}
Test
python3 -m pytest
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file logicedit-0.1.6.tar.gz.
File metadata
- Download URL: logicedit-0.1.6.tar.gz
- Upload date:
- Size: 30.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70995cdf80ec7b51ad1460c0a44a35d2b8c26e0ce090df13370be25dd0b48e76
|
|
| MD5 |
5501df6c058ffbebe9dcd58a4828abb4
|
|
| BLAKE2b-256 |
66e882049d9f429ba4738da0889eb1ce96ee1edc9629f6b98c75c830182fde15
|
File details
Details for the file logicedit-0.1.6-py3-none-any.whl.
File metadata
- Download URL: logicedit-0.1.6-py3-none-any.whl
- Upload date:
- Size: 32.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e95c4032d35c8d831045e314950984188749fbcf5966c82933521dfe02810d2e
|
|
| MD5 |
286e9a4cd5ee3afa5464a2c0a82f51d5
|
|
| BLAKE2b-256 |
55b51e0523bc903223c6d47421395d1b2600aa1438ab76dda8b1b29e093dd169
|