Merged
Conversation
…bui-ranbooruX - Reduced scripts/ranbooru.py by 27% (from 7,343 lines down to 5,356 lines) - Extracted booru scrapers into ranboorux/boorus/ package (__init__, gelbooru, simple) - Extracted AdetailerOrchestrator into ranboorux/integrations/adetailer_orchestration.py - Implemented AdetailerState enum with 5 explicit lifecycle states - Modularized ui() into 4 UI section builder methods - Eliminated 10 duplicated tag sets, dead code, and thin wrapper functions - Merged prompting.py into tag_pipeline.py and io_lists.py into user_store.py - Renamed host_state.py -> mutation_scope.py and requesting.py -> http_client.py - Added FilterContext dataclass and CatalogResolver Protocol - Expanded test suite to 179 passing tests (+6 test cases for tag pipeline edge cases) - Unified README.md with upstream origin/main changes & refreshed .gitignore
…o ControlNet handoff, & add Anima ControlNet LLLite support Summary of changes since published 'refactor' branch (origin/refactor): 1. **Forge Neo Native ControlNet Integration**: - Replaced legacy external_code API calls and flat-index `p.script_args` hacks in `scripts/ranbooru.py` with Forge Neo's native ControlNet script runner integration. - Dynamically locates `ControlNetForForgeOfficial` via `p.scripts.alwayson_scripts` and populates Unit 0's control image slot using the script's exact `args_from` / `args_to` slice. - Added safeguard setting `p.resize_mode = 1` (ResizeMode.INNER_FIT) to prevent `AttributeError` cascades during initial pass rendering. - Documented in README that ControlNet handoff is designed and tested strictly for Forge Neo. 2. **Booru API HTTP Resilience**: - Added automatic retry loop with exponential backoff (3 attempts: 1s, 2s, 4s delay) to `_fetch_data()` in `ranboorux/boorus/__init__.py`. - Retries on HTTP 5xx server errors and network connection drops, failing immediately on 4xx client errors. 3. **ADetailer & ADetailer Neo Runtime Execution Fix**: - Resolved false-negative detection in manual ADetailer postprocessing runs by inspecting `pp.image` prior to `pp.images[0]` in `ranboorux/integrations/adetailer_runtime.py`. - Support for both standard ADetailer and ADetailer Neo script discovery at gather and removal stages. 4. **Anima Model, ControlNet LLLite & Sampler Tuning Controls**: - Native auto-detection of Anima (2B DiT) models by checkpoint filename or class signature. - Basic Img2Img support for Anima models fully operational (flow-matching scheduler tuning, resolution defaults, and prompt quality prefixes). - Documented ControlNet LLLite support (`anima-lllite-lineart-1`, `anima-lllite-depth-1`, `anima-lllite-inpainting-v2`) for Anima models, clarifying that Anima Edit (Cosmos-Reference) is not supported. - Removed all references or disclaimers suggesting Anima ControlNet support is "being worked on" or "untested". - Added `Auto-tune Img2Img parameters for Anima` (`anima_tune_img2img`) UI toggle allowing users to choose between automatic flow-matching parameter overrides vs. manual WebUI sampler settings. 5. **GitHub CI & Repository Maintenance**: - Configured `fetch-depth: 0` and global `safe.directory "*"` in `.github/workflows/ci.yml` to resolve exit code 128 git errors in GitHub Actions runners. - Updated `tools/repo_guard.py` git runner to handle git errors gracefully. - Removed accidental `adetailer/` submodule directory from git tracking and added `adetailer/` to `.gitignore`. - Configured git repository user to `soficis` (`soficis@users.noreply.github.com`). - 100% clean check across automated test suite (`pytest`: 187 passed), `ruff`, `black`, and `mypy` (18 source files). 6. **README Structure & Layout Overhaul**: - Announced exclusive targeting of Forge Neo and full support for ADetailer Neo. - Moved `LoRAnado` section near the bottom of `README.md` (above `Credits`) to make it less prominent. - Merged "Why this fork?" and "Key features" into a unified "Features & Exclusive Fork Capabilities" section. - Documented ControlNet environment overrides (`SD_FORGE_CONTROLNET_PATH` and `RANBOORUX_CN_PATH`). - Added detailed sections for ControlNet Unit 0 handoff, Anima settings customization, and Anima sampler tuning.
… env overrides Summary of changes: - **Image Assets**: Replaced `pics/image.png` with `pics/image.jpg` and embedded `pics/filters.jpg` under the Tag Filters section. - **Workflow Guide**: Merged and updated Quick Start, Tag Catalog, and Two-Pass Img2Img + ADetailer / ADetailer Neo pipeline into a unified workflow guide. - **Collapsible Overrides**: Converted Environment Configuration Overrides into an expandable HTML dropdown (`<details><summary>`). - **Developer Documentation**: Added a cross-platform Developer & Verification guide with execution instructions for Windows (PowerShell/CMD) and Linux/macOS.
Owner
Author
|
@copilot resolve the merge conflicts in this pull request |
There was a problem hiding this comment.
Pull request overview
This PR completes a large refactor that moves RanbooruX from a monolithic script toward a modular ranboorux/ core, adds Forge Neo–specific integrations (ADetailer Neo, ControlNet Unit 0 handoff, Anima model detection/tuning), and introduces CI + local tooling to enforce quality and release hygiene.
Changes:
- Added a typed core package (
ranboorux/) covering run options, HTTP hardening, user storage, booru clients, and integration runtimes (ControlNet, Img2Img lifecycle, ADetailer runtime). - Expanded automated tests to lock UI argument contract ordering, lifecycle invariants, integration behavior, and release hygiene.
- Introduced developer/release tooling (
tools/*.py) plus GitHub Actions CI for tests + formatting + linting + type checks.
Reviewed changes
Copilot reviewed 46 out of 51 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/verify.py | Adds a local “run the full verification suite” script (tests + ruff/black/mypy). |
| tools/repo_guard.py | Adds a guard tool to detect forbidden modified paths by mode. |
| tools/inspect_ui.py | Adds a UI contract extractor tool for Script.ui() positional return order. |
| tools/build_release.py | Adds an allowlist-based release zip builder with archive hygiene checks. |
| tests/test_wrappers.py | Updates wrapper tests to match refactored tag pipeline locations. |
| tests/test_user_store.py | Adds unit coverage for new user storage helpers (credentials, lists, logs, prefs). |
| tests/test_ui_contract.py | Locks the UI contract length/order via RunComponents + UI_ARGUMENT_FIELDS. |
| tests/test_tag_pipeline.py | Adds comprehensive unit tests for tag parsing/dedup/filtering/synonyms. |
| tests/test_tag_catalog.py | Adjusts catalog behavior expectations and adds config-loading coverage. |
| tests/test_run_options.py | Adds tests that freeze UI argument field order and mapping into RunOptions. |
| tests/test_requesting.py | Adds extensive HTTP client hardening tests (redaction, SSRF defenses, bounds). |
| tests/test_repo_guard.py | Adds tests for repo guard behavior with/without git metadata. |
| tests/test_release_hygiene.py | Adds tests for allowlist staging and archive hygiene rejection rules. |
| tests/test_prompt_and_parsing.py | Updates tests to use ranboorux modules instead of monolithic wrappers. |
| tests/test_modules.py | Updates import smoke tests to new module structure (tag_pipeline, user_store). |
| tests/test_loranado.py | Adds tests for LoRA normalization/selection/formatting helpers. |
| tests/test_lifecycle_contract.py | Adds lifecycle tests ensuring guards/state cleanup across runs/errors. |
| tests/test_img2img_lifecycle.py | Adds tests for processed-result replacement helpers. |
| tests/test_host_state.py | Adds tests for mutation scope restoration and temp-path ownership cleanup. |
| tests/test_helpers.py | Adds snapshot helper tests for detecting host state leakage. |
| tests/test_controlnet.py | Expands tests around ControlNet import failure redaction/diagnostics. |
| tests/test_anima_detect.py | Adds tests for Anima model detection and tuning toggles. |
| tests/test_adetailer.py | Expands ADetailer integration tests around isolation/guards/manual execution. |
| tests/test_adetailer_runtime.py | Adds unit tests for the refactored ADetailer runtime utilities. |
| tests/host_snapshot.py | Introduces helper for capturing host processing state for leak detection. |
| tests/conftest.py | Extends stubs/mocks for requests + adapters to support new HTTP client behaviors. |
| README.md | Updates docs to Forge Neo exclusivity and describes new features/tooling/workflows. |
| ranboorux/user_store.py | Adds user-data storage utilities (atomic write, credential/prefs handling, logs). |
| ranboorux/run_options.py | Adds frozen UI argument schema and mapping helpers (RunOptions, RunComponents). |
| ranboorux/prompting.py | Removes legacy prompting module (superseded by tag_pipeline). |
| ranboorux/mutation_scope.py | Adds mutation scope utilities for safe host state patching/restoration. |
| ranboorux/loranado.py | Adds LoRA selection utilities with deterministic RNG support. |
| ranboorux/io_lists.py | Removes legacy list file helpers (superseded by user_store). |
| ranboorux/integrations/img2img_lifecycle.py | Adds helpers for consistent processed-object result replacement. |
| ranboorux/integrations/controlnet.py | Refactors ControlNet external_code loading with better redaction/logging. |
| ranboorux/integrations/adetailer_runtime.py | Adds reusable runtime utilities for ADetailer discovery/isolation/guards. |
| ranboorux/image_ops.py | Tightens typing for image resize helper signature/return type. |
| ranboorux/http_client.py | Adds hardened HTTP client (SSRF protections, redaction, bounded streaming, caching rules). |
| ranboorux/boorus/simple.py | Adds config-driven simple booru subclasses. |
| ranboorux/boorus/gelbooru.py | Adds Gelbooru + Gelbooru-compatible implementations with retry/diagnostics. |
| ranboorux/boorus/init.py | Adds shared Booru base class with fetch + standardization logic. |
| ranboorux/anima_detect.py | Adds Anima model detection utilities. |
| pyproject.toml | Updates mypy config (e.g., follow_imports=skip). |
| .gitignore | Updates ignore patterns for tooling/user data. |
| .github/workflows/ci.yml | Adds CI workflow running tests on 3.10–3.12 plus ruff/black/mypy checks. |
Comments suppressed due to low confidence (2)
ranboorux/boorus/simple.py:240
base_api_urlalready contains?limit=..., butget_posts()appends?page=...which results in an invalid query string (two?). This should be&page=....
page = random.randint(1, max_pages)
query_url = f"{self.base_api_url}?page={page}{tags_query}"
fetched_data = self._fetch_data(query_url)
tools/inspect_ui.py:231
- The contract text written to
docs/handoff/UI_ARGUMENT_CONTRACT.mdstill claims there are 62 positional arguments, butScript.ui()andUI_ARGUMENT_FIELDSdefine 64. The generated docs should reflect the correct frozen contract size.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR merges the
refactorbranch intomain, completing a major architectural overhaul of RanbooruX. The extension is now exclusively targeted at Forge Neo and introduces native support for ADetailer Neo, Anima (2B DiT) models, ControlNet Unit 0 handoff, and the Danbooru Tag Catalog system, backed by a modularranboorux/core and automated CI testing.🌟 Key Features & Improvements
1. 🚀 Forge Neo & ADetailer Neo Exclusivity
ranboorux/integrations/adetailer_runtime.py,adetailer_orchestration.py) to auto-detect both standard ADetailer and ADetailer Neo scripts at gather and removal stages.2. 🌀 Anima (2B DiT) Model Support & ControlNet LLLite
ranboorux/anima_detect.py) for Anima models by filename tokens or architecture metadata._→ spaces) for Qwen3.anima-lllite-lineart-1,anima-lllite-depth-1,anima-lllite-inpainting-v2).Auto-tune Img2Img parameters for Anima(anima_tune_img2img) UI toggle allowing manual WebUI sampler overrides when unchecked.3. 🎯 Forge Neo ControlNet Unit 0 Integration
external_codeAPI calls and flat-index hacks with native Forge Neo script runner integration (p.scripts.alwayson_scripts->ControlNetForForgeOfficialslice).p.resize_mode = 1(ResizeMode.INNER_FIT) safeguard to eliminate initial-pass rendering errors.4. 🏷️ Danbooru Tag Catalog System
data/catalogs/danbooru_tags.csv) supporting alias normalization, category-aware filtering, custom CSV import, and hair/eye color preservation.5. 🌐 HTTP Resilience & Gelbooru CDN Fixes
_fetch_data()to recover from transient HTTP 5xx errors and connection drops.6. 🏗️ Modular Package & Quality Tooling
scripts/ranbooru.pyinto a clean, typedranboorux/package.pytest), strict type checking (mypy), linting (ruff), and code formatting (black)..github/workflows/ci.yml) withfetch-depth: 0andsafe.directory "*"to ensure clean automated builds.SD_FORGE_CONTROLNET_PATHandRANBOORUX_CN_PATHenv variable overrides for custom ControlNet installations (documented in README).✅ Verification & Testing
python -m pytest tests/ -q).ruff,black, andmypy(18 source files).