From 87d644cd6712e13c21f3f53fad87e8fbf44c5c5c Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Mon, 27 May 2024 08:17:09 -0400 Subject: [PATCH] update requirements and lint rules --- .pylintrc | 64 +++++++++++++++++---------------------- .ruff.toml | 75 +++++++++++++++++++++++++++++++++++++++++++++ package.json | 4 +++ pyproject.toml | 79 ------------------------------------------------ requirements.txt | 11 +++---- scripts/mulan.py | 14 ++++----- 6 files changed, 119 insertions(+), 128 deletions(-) create mode 100644 .ruff.toml delete mode 100644 pyproject.toml diff --git a/.pylintrc b/.pylintrc index f9a30d336..cdbf1e841 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,79 +1,72 @@ [MAIN] analyse-fallback-blocks=no clear-cache-post-run=no -#enable-all-extensions= -#errors-only= -#exit-zero= extension-pkg-allow-list= extension-pkg-whitelist= fail-on= fail-under=10 ignore=CVS ignore-paths=/usr/lib/.*$, - ^repositories/.*$, - ^extensions/.*$, - ^extensions-builtin/.*$, - ^modules/dml/.*$, - ^modules/tcd/.*$, - ^modules/xadapters/.*$, - ^modules/hidiffusion/.*$, - ^modules/pag/.*$, - ^modules/olive_script.py, -ignore-patterns= + modules/hidiffusion, + modules/hijack, + modules/k-diffusion, + modules/ldsr, + modules/pag, + modules/rife, + modules/taesd, + modules/todo, + modules/unipc, + modules/xadapter, + modules/intel/openvino, + modules/intel/ipex, + modules/dml, + modules/control/proc, + modules/control/units, + repositories, + extensions-builtin/sd-webui-agent-scheduler, + extensions-builtin/sd-extension-chainner/nodes, + extensions-builtin/sdnext-modernui/node_modules, +ignore-patterns=.*test*.py$, + .*_model.py$, + .*_arch.py$, + .*_model_arch.py*, + .*_model_arch_v2.py$, ignored-modules= jobs=0 limit-inference-results=100 load-plugins= persistent=yes -py-version=3.10 +py-version=3.9 recursive=no source-roots= suggestion-mode=yes unsafe-load-any-extension=no -#verbose= [BASIC] argument-naming-style=snake_case -#argument-rgx= attr-naming-style=snake_case -#attr-rgx= bad-names=foo, bar, baz, toto, tutu, tata bad-names-rgxs= class-attribute-naming-style=any class-const-naming-style=UPPER_CASE -#class-const-rgx= class-naming-style=PascalCase -#class-rgx= const-naming-style=snake_case -#const-rgx= docstring-min-length=-1 function-naming-style=snake_case -#function-rgx= -# Good variable names which should always be accepted, separated by a comma. -good-names=i,j,k,e,ex,ok,p +good-names=i,j,k,e,ex,ok,p,x,y,id good-names-rgxs= include-naming-hint=no inlinevar-naming-style=any -#inlinevar-rgx= method-naming-style=snake_case -#method-rgx= module-naming-style=snake_case -#module-rgx= name-group= no-docstring-rgx=^_ property-classes=abc.abstractproperty -#typealias-rgx= -#typevar-rgx= variable-naming-style=snake_case -#variable-rgx= [CLASSES] check-protected-access-in-special-methods=no -defining-attr-methods=__init__, - __new__, - setUp, - asyncSetUp, - __post_init__ +defining-attr-methods=__init__, __new__, exclude-protected=_asdict,_fields,_replace,_source,_make,os._exit valid-classmethod-first-arg=cls valid-metaclass-classmethod-first-arg=mcs @@ -84,7 +77,7 @@ ignored-parents= max-args=99 max-attributes=99 max-bool-expr=99 -max-branches=99 +max-branches=199 max-locals=99 max-parents=99 max-public-methods=99 @@ -191,7 +184,6 @@ never-returning-functions=sys.exit,argparse.parse_error [REPORTS] evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)) msg-template= -#output-format= reports=no score=no diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 000000000..321c6396a --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,75 @@ +exclude = [ + "venv", + ".git", + ".ruff_cache", + ".vscode", + "modules/hidiffusion", + "modules/hijack", + "modules/k-diffusion", + "modules/ldsr", + "modules/pag", + "modules/rife", + "modules/taesd", + "modules/todo", + "modules/unipc", + "modules/xadapter", + "modules/intel/openvino", + "modules/intel/ipex", + "modules/dml", + "modules/control/proc", + "modules/control/units", + "repositories", + "extensions-builtin/sd-extension-chainner/nodes", + "extensions-builtin/sd-webui-agent-scheduler", + "extensions-builtin/sdnext-modernui/node_modules", +] +line-length = 250 +indent-width = 4 +target-version = "py39" + +[lint] +select = [ + "F", + "E", + "W", + "C", + "B", + "I", + "YTT", + "ASYNC", + "RUF", + "AIR", + "NPY", + "C4", + "T10", + "EXE", + "ISC", + "ICN", + "RSE", + "TCH", + "TID", + "INT", + "PLE", +] +ignore = [ + "B006", # Do not use mutable data structures for argument defaults + "I001", # Import block is un-sorted or un-formatted + "E402", # Module level import not at top of file + "E501", # Line too long + "E721", # Do not compare types, use `isinstance()` + "E731", # Do not assign a `lambda` expression, use a `def` + "RUF013", # PEP 484 prohibits implicit `Optional` +] +fixable = ["ALL"] +unfixable = [] +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +[format] +quote-style = "double" +indent-style = "space" +skip-magic-trailing-comma = false +line-ending = "auto" +docstring-code-format = false + +[lint.mccabe] +max-complexity = 99 diff --git a/package.json b/package.json index 4d19de52f..612a9f0dc 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,10 @@ "type": "git", "url": "git+https://github.com/vladmandic/automatic.git" }, + "scripts": { + "start": "python launch.py", + "lint": "ruff check; eslint javascript/ extensions-builtin/sdnext-modernui/javascript/; pylint *.py modules/ extensions-builtin/" + }, "devDependencies": { "esbuild": "^0.18.15" }, diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 15d8d047b..000000000 --- a/pyproject.toml +++ /dev/null @@ -1,79 +0,0 @@ -[tool.ruff] -target-version = "py39" -exclude = [ - "/usr/lib", - "extensions", - "extensions-builtin", - "modules/dml", - "modules/k-diffusion", - "repositories/ldm", - "repositories/taming", - "repositories/blip", - "repositories/codeformer", - "modules/control/proc/normalbae/", - "modules/control/proc/leres/", - "modules/control/units/*_model.py", - "modules/control/units/*_pipe.py", - "modules/xadapter/*.py", - "modules/hidiffusion/*.py", - "modules/tcd/*.py", - "modules/pag/pipe_*.py", -] -[tool.ruff.lint] -select = [ - "F", - "E", - "W", - "C", - "B", - "I", - "YTT", - "ASYNC", - "RUF", - "AIR", - "NPY", - "C4", - "T10", - "EXE", - "ISC", - "ICN", - "RSE", - "TCH", - "TID", - "INT", - "PLE", - # "FIX", - # "A", - # "T20", - # "S", - # "PL", -] -ignore = [ - "A003", # Class attirbute shadowing builtin - "C901", # Function is too complex - "E501", # Line too long - "E731", # Do not assign a `lambda` expression, use a `def` - "I001", # Import block is un-sorted or un-formatted - "W605", # Invalid escape sequence, messes with some docstrings - "B006", # Do not use mutable data structures for argument defaults - "B028", # No explicit stacklevel - "B905", # Without explicit scrict - "C408", # Rewrite as a literal - "E402", # Module level import not at top of file - "E721", # Do not compare types, use `isinstance()` - "E741", # Do not use variables named `l`, `O`, or `I` - "EXE001", # Shebang present - "F401", # Imported but unused - "ISC003", # Implicit string concatenation - "RUF005", # Consider concatenation - "RUF012", # Mutable class attributes - "RUF013", # Implict optional - "RUF015", # Prefer `next` - "TID252", # Relative imports from parent modules -] - -[tool.ruff.lint.flake8-bugbear] -extend-immutable-calls = ["fastapi.Depends", "fastapi.security.HTTPBasic"] - -[tool.pytest.ini_options] -base_url = "http://127.0.0.1:7860" diff --git a/requirements.txt b/requirements.txt index 801366689..b02f6ee33 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -setuptools +setuptools==69.5.1 patch-ng anyio addict @@ -34,10 +34,9 @@ pymatting orjson invisible-watermark pi-heif -setuptools==69.5.1 safetensors==0.4.3 tensordict==0.1.2 -peft==0.10.0 +peft==0.11.1 httpx==0.24.1 compel==2.0.2 torchsde==0.2.6 @@ -50,15 +49,15 @@ opencv-contrib-python-headless==4.9.0.80 diffusers==0.27.2 einops==0.4.1 gradio==3.43.2 -huggingface_hub==0.23.0 +huggingface_hub==0.23.2 numexpr==2.8.8 numpy==1.26.4 numba==0.59.1 pandas -protobuf==3.20.3 +protobuf==4.25.3 pytorch_lightning==1.9.4 tokenizers==0.19.1 -transformers==4.41.0 +transformers==4.41.1 urllib3==1.26.18 Pillow==10.3.0 timm==0.9.16 diff --git a/scripts/mulan.py b/scripts/mulan.py index 5c658f450..3b5baa570 100644 --- a/scripts/mulan.py +++ b/scripts/mulan.py @@ -3,13 +3,13 @@ # https://huggingface.co/OpenGVLab/InternVL-14B-224px """ -- [MuLan](https://github.com/mulanai/MuLan) Multi-langunage prompts - wirte your prompts in ~110 auto-detected languages! - Compatible with SD15 and SDXL - Enable in scripts -> MuLan and set encoder to `InternVL-14B-224px` encoder +- [MuLan](https://github.com/mulanai/MuLan) Multi-langunage prompts - wirte your prompts in ~110 auto-detected languages! + Compatible with SD15 and SDXL + Enable in scripts -> MuLan and set encoder to `InternVL-14B-224px` encoder (that is currently only supported encoder, but others will be added) - Note: Model will be auto-downloaded on first use: note its huge size of 27GB - Even executing it in FP16 context will require ~16GB of VRAM for text encoder alone - *Note*: Uses fixed prompt parser, so no prompt attention will be used + Note: Model will be auto-downloaded on first use: note its huge size of 27GB + Even executing it in FP16 context will require ~16GB of VRAM for text encoder alone + *Note*: Uses fixed prompt parser, so no prompt attention will be used Examples: - English: photo of a beautiful woman wearing a white bikini on a beach with a city skyline in the background @@ -19,7 +19,7 @@ Examples: - German: Foto einer schönen Frau in einem weißen Bikini an einem Strand mit einer Skyline der Stadt im Hintergrund - Arabic: صورة لامرأة جميلة ترتدي بيكيني أبيض على شاطئ مع أفق المدينة في الخلفية - Japanese: 街のスカイラインを背景にビーチで白いビキニを着た美しい女性の写真 -- Chinese: 一个美丽的女人在海滩上穿着白色比基尼的照片,背景是城市天际线 +- Chinese: 一个美丽的女人在海滩上穿着白色比基尼的照片, 背景是城市天际线 - Korean: 도시의 스카이라인을 배경으로 해변에서 흰색 비키니를 입은 아름 다운 여성의 사진 """