-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'source/main' into feat/dynamic_wildcards
- Loading branch information
Showing
26 changed files
with
361 additions
and
50 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,8 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: pre-commit/[email protected] | ||
env: | ||
RUFF_OUTPUT_FORMAT: github | ||
mypy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
@@ -26,7 +28,7 @@ jobs: | |
cache: "pip" | ||
cache-dependency-path: | | ||
pyproject.toml | ||
- run: python -m pip install mypy -e .[dev,attentiongrabber,magicprompt,feelinglucky] | ||
- run: python -m pip install mypy -e .[dev,attentiongrabber,feelinglucky,yaml] | ||
- run: mypy --install-types --non-interactive src | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
|
@@ -45,7 +47,7 @@ jobs: | |
cache-dependency-path: | | ||
pyproject.toml | ||
- name: Install dependencies | ||
run: python -m pip install -e .[dev,attentiongrabber,magicprompt,feelinglucky] | ||
run: python -m pip install -e .[dev,attentiongrabber,feelinglucky,yaml] | ||
- run: pytest --cov --cov-report=term-missing --cov-report=xml . | ||
env: | ||
PYPARSINGENABLEALLWARNINGS: 1 | ||
|
@@ -67,9 +69,6 @@ jobs: | |
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
cache: "pip" | ||
cache-dependency-path: | | ||
pyproject.toml | ||
- run: python -m pip install hatch | ||
- run: hatch build -t wheel | ||
- name: Publish package distributions to PyPI | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,13 @@ | ||
repos: | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.0.290 | ||
rev: v0.1.6 | ||
hooks: | ||
- id: ruff | ||
args: | ||
- --fix | ||
- id: ruff-format | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
rev: v4.5.0 | ||
hooks: | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- repo: https://github.com/psf/black | ||
rev: 23.9.1 | ||
hooks: | ||
- id: black | ||
args: | ||
- --quiet |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from __future__ import annotations | ||
|
||
import dataclasses | ||
import logging | ||
import re | ||
|
||
from dynamicprompts.commands import Command | ||
from dynamicprompts.enums import SamplingMethod | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
WRAP_MARKER_CHARACTERS = { | ||
"\u1801", # Mongolian ellipsis | ||
"\u2026", # Horizontal ellipsis | ||
"\u22EE", # Vertical ellipsis | ||
"\u22EF", # Midline horizontal ellipsis | ||
"\u22F0", # Up right diagonal ellipsis | ||
"\u22F1", # Down right diagonal ellipsis | ||
"\uFE19", # Presentation form for vertical horizontal ellipsis | ||
} | ||
|
||
WRAP_MARKER_RE = re.compile( | ||
f"[{''.join(WRAP_MARKER_CHARACTERS)}]+" # One or more wrap marker characters | ||
"|" | ||
r"\.{3,}", # ASCII ellipsis of 3 or more dots | ||
) | ||
|
||
|
||
def split_wrapper_string(s: str) -> tuple[str, str]: | ||
""" | ||
Split a string into a prefix and suffix at the first wrap marker. | ||
""" | ||
match = WRAP_MARKER_RE.search(s) | ||
if match is None: | ||
log.warning("Found no wrap marker in string %r", s) | ||
return s, "" | ||
else: | ||
return s[: match.start()], s[match.end() :] | ||
|
||
|
||
@dataclasses.dataclass(frozen=True) | ||
class WrapCommand(Command): | ||
wrapper: Command | ||
inner: Command | ||
sampling_method: SamplingMethod | None = None |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.