Skip to content

Commit

Permalink
Add pre-commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
hameerabbasi committed Sep 4, 2023
1 parent e05a503 commit 4c7792e
Show file tree
Hide file tree
Showing 25 changed files with 144 additions and 47 deletions.
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
522dc5b4ff2a61e576aa9fb4ac3ab9274d4f26dd
15 changes: 7 additions & 8 deletions .github/workflows/on_pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ jobs:
python-version: 3.10.6
cache: pip
cache-dependency-path: requirements.txt
- name: run-ruff
- name: install-pylint
run: |
python -m pip install --upgrade pip
pip install ruff
ruff .
# - name: run-pylint
# run: |
# python -m pip install --upgrade pip
# pip install pylint
# pylint $(git ls-files '*.py')
pip install pylint
- name: pre-commit
uses: pre-commit-ci/[email protected]
if: always()
with:
msg: apply code formatting and linting auto-fixes
- name: test-startup
run: |
export COMMANDLINE_ARGS="--debug --test"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package-lock.json
venv
.history
cache
**/.DS_Store

# all models and temp files
*.log
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
url = https://github.com/KohakuBlueleaf/a1111-sd-webui-lycoris
ignore = dirty
[submodule "extensions-builtin/multidiffusion-upscaler-for-automatic1111"]
path = extensions-builtin/multidiffusion-upscaler-for-automatic1111
path = extensions-builtin/multidiffusion-upscaler-for-automatic1111
url = https://github.com/pkuliyi2015/multidiffusion-upscaler-for-automatic1111
ignore = dirty
[submodule "extensions-builtin/sd-webui-agent-scheduler"]
Expand Down
2 changes: 1 addition & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"MD033": false,
"MD036": false,
"MD041": false
}
}
66 changes: 66 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# To use:
#
# pre-commit run -a
#
# Or:
#
# pre-commit install # (runs every time you commit in git)
#
# To update this file:
#
# pre-commit autoupdate
#
# See https://github.com/pre-commit/pre-commit

ci:
autoupdate_commit_msg: "chore: update pre-commit hooks"
autofix_commit_msg: "style: pre-commit fixes"

repos:
# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
args: ["--allow-multiple-documents"]
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
exclude: |
(?x)^(
.*\.md|
.github/ISSUE_TEMPLATE/.*\.yml
)$
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.285'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
args: []

# Black, the code formatter, natively supports pre-commit
# - repo: https://github.com/psf/black
# rev: 23.7.0
# hooks:
# - id: black
# exclude: ^(docs)

# Changes tabs to spaces
# - repo: https://github.com/Lucas-C/pre-commit-hooks
# rev: v1.5.3
# hooks:
# - id: remove-tabs
# exclude: ^(docs)
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ All Individual features are not listed here, instead check [ChangeLog](CHANGELOG
Including built-in support for `torch.compile`
- Support for multiple backends!
**original** and **diffusers**
<<<<<<< HEAD
<<<<<<< HEAD
- Support for multiple diffusion models!
Stable Diffusion, SD-XL, Kandinsky, DeepFloyd IF, etc.
- Fully multiplatform with platform specific autodetection and tuning performed on install
Expand All @@ -39,6 +41,36 @@ All Individual features are not listed here, instead check [ChangeLog](CHANGELOG
- Broad compatibility with existing extensions ecosystem and new extensions manager
- Built in installer with automatic updates and dependency management
- Modernized UI (still based on Gradio) with theme support
=======
- Support for multiple diffusion models!
Stable Diffusion, SD-XL, Kandinsky, DeepFloyd IF, etc.
- Fully multiplatform with platform specific autodetection and tuning performed on install
Windows / Linux / MacOS with CPU / nVidia / AMD / IntelArc / DirectML
- Improved prompt parser
- Enhanced *Lora*/*Locon*/*Lyco* code supporting latest trends in training
- Built-in queue management
- Advanced metadata caching and handling to speed up operations
- Enterprise level logging and hardened API
- Modern localization and hints engine
- Broad compatibility with existing extensions ecosystem and new extensions manager
- Built in installer with automatic updates and dependency management
- Modernized UI (still based on Gradio) with theme support
>>>>>>> 26aee894 (Add pre-commit.)
=======
- Support for multiple diffusion models!
Stable Diffusion, SD-XL, Kandinsky, DeepFloyd IF, etc.
- Fully multiplatform with platform specific autodetection and tuning performed on install
Windows / Linux / MacOS with CPU / nVidia / AMD / Intel / DirectML
- Improved prompt parser
- Enhanced *Lora*/*Locon*/*Lyco* code supporting latest trends in training
- Built-in queue management
- Advanced metadata caching and handling to speed up operations
- Enterprise level logging and hardened API
- Modern localization and hints engine
- Broad compatibility with existing extensions ecosystem and new extensions manager
- Built in installer with automatic updates and dependency management
- Modernized UI (still based on Gradio) with theme support
>>>>>>> 75d5f19f (Exclude *.md from trailing-whitespace hook.)
## Backend support

Expand Down
2 changes: 1 addition & 1 deletion configs/alt-diffusion-inference.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ model:
cond_stage_config:
target: modules.xlmr.BertSeriesModelWithTransformation
params:
name: "XLMR-Large"
name: "XLMR-Large"
2 changes: 1 addition & 1 deletion configs/v2-inference-768-v.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ model:
target: ldm.modules.encoders.modules.FrozenOpenCLIPEmbedder
params:
freeze: True
layer: "penultimate"
layer: "penultimate"
2 changes: 1 addition & 1 deletion html/licenses.html
Original file line number Diff line number Diff line change
Expand Up @@ -687,4 +687,4 @@ <h2><a href="https://github.com/madebyollin/taesd/blob/main/LICENSE">TAESD</a></
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
</pre>
</pre>
3 changes: 1 addition & 2 deletions javascript/amethyst-nightfall.css
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ svg.feather.feather-image, .feather .feather-image { display: none }
#txt2img_subseed_strength { margin-top: 0; }
#pnginfo_html2_info { margin-top: -18px; background-color: var(--input-background-fill); padding: var(--input-padding) }
#txt2img_tools > div > button, #img2img_tools > div > button { filter: hue-rotate(180deg) saturate(0.5); }
#txt2img_tools, #img2img_tools { margin-top: -4px; margin-bottom: -4px; }
#txt2img_tools, #img2img_tools { margin-top: -4px; margin-bottom: -4px; }
#txt2img_styles_row { margin-top: -6px; }

/* custom elements overrides */
Expand Down Expand Up @@ -322,4 +322,3 @@ svg.feather.feather-image, .feather .feather-image { display: none }
--size-9: 64px;
--size-14: 64px;
}

4 changes: 2 additions & 2 deletions javascript/black-orange.css
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ svg.feather.feather-image, .feather .feather-image { display: none }
#txt2img_settings { min-width: var(--left-column); max-width: var(--left-column); background-color: #111111; padding-top: 16px; }
#pnginfo_html2_info { margin-top: -18px; background-color: var(--input-background-fill); padding: var(--input-padding) }
#txt2img_tools > div > button, #img2img_tools > div > button { filter: hue-rotate(180deg) saturate(0.5); }
#txt2img_tools, #img2img_tools { margin-top: -4px; margin-bottom: -4px; }
#txt2img_styles_row, #img2img_styles_row { margin-top: -6px; }
#txt2img_tools, #img2img_tools { margin-top: -4px; margin-bottom: -4px; }
#txt2img_styles_row { margin-top: -6px; }

/* custom elements overrides */
#steps-animation, #controlnet { border-width: 0; }
Expand Down
16 changes: 8 additions & 8 deletions javascript/panZoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function createPanZoom(domElement, options) {
dispose: dispose,
moveBy: internalMoveBy,
moveTo: moveTo,
smoothMoveTo: smoothMoveTo,
smoothMoveTo: smoothMoveTo,
centerOn: centerOn,
zoomTo: publicZoomTo,
zoomAbs: zoomAbs,
Expand Down Expand Up @@ -141,7 +141,7 @@ function createPanZoom(domElement, options) {
};

eventify(api);

var initialX = typeof options.initialX === 'number' ? options.initialX : transform.x;
var initialY = typeof options.initialY === 'number' ? options.initialY : transform.y;
var initialZoom = typeof options.initialZoom === 'number' ? options.initialZoom : transform.scale;
Expand Down Expand Up @@ -1049,7 +1049,7 @@ function autoRun() {
}

autoRun();

},{"./lib/createTextSelectionInterceptor.js":2,"./lib/domController.js":3,"./lib/kinetic.js":4,"./lib/svgController.js":5,"./lib/transform.js":6,"amator":7,"ngraph.events":9,"wheel":10}],2:[function(require,module,exports){
/**
* Disallows selecting text.
Expand Down Expand Up @@ -1087,7 +1087,7 @@ function createTextSelectionInterceptor(useFake) {

function release() {
if (!wasCaptured) return;

wasCaptured = false;
window.document.onselectstart = prevSelectStart;
if (dragObject) dragObject.ondragstart = prevDragStart;
Expand All @@ -1107,14 +1107,14 @@ module.exports = makeDomController
module.exports.canAttach = isDomElement;

function makeDomController(domElement, options) {
var elementValid = isDomElement(domElement);
var elementValid = isDomElement(domElement);
if (!elementValid) {
throw new Error('panzoom requires DOM element to be attached to the DOM tree')
}

var owner = domElement.parentElement;
domElement.scrollTop = 0;

if (!options.disableKeyboardInteraction) {
owner.setAttribute('tabindex', 0);
}
Expand All @@ -1124,7 +1124,7 @@ function makeDomController(domElement, options) {
getOwner: getOwner,
applyTransform: applyTransform,
}

return api

function getOwner() {
Expand Down Expand Up @@ -1320,7 +1320,7 @@ function makeSvgController(svgElement, options) {
applyTransform: applyTransform,
initTransform: initTransform
}

return api

function getOwner() {
Expand Down
2 changes: 1 addition & 1 deletion modules/dml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def directml_override_opts():
if item.message is not None:
shared.log.warning(item.message)
shared.log.warning(f'{key} is automatically overriden to {item.value}.')

if count > 0:
shared.log.info(f'{count} options are automatically overriden. If you want to keep them from overriding, run with --experimental argument.')

Expand Down
2 changes: 1 addition & 1 deletion modules/dml/memory_amd/driver/atiadlxx.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def get_memory_info2(self, adapterIndex: int) -> ADLMemoryInfo2:

if ADL2_Adapter_MemoryInfo2_Get(self.context, adapterIndex, C.byref(info)) != ADL_OK:
raise RuntimeError("ADL2: Failed to get MemoryInfo2")

return info

def get_dedicated_vram_usage(self, index: int) -> int:
Expand Down
2 changes: 1 addition & 1 deletion modules/dml/memory_amd/driver/atiadlxx_defines.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ADL_OK = 0
ADL_OK = 0
2 changes: 1 addition & 1 deletion modules/dml/memory_amd/driver/atiadlxx_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ class _AdapterInfo(C.Structure):
AdapterInfo = _AdapterInfo
LPAdapterInfo = C.POINTER(_AdapterInfo)

ADL_CONTEXT_HANDLE = C.c_void_p
ADL_CONTEXT_HANDLE = C.c_void_p
20 changes: 10 additions & 10 deletions modules/sd_hijack_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ def __new__(cls, orig_func, sub_func, cond_func):
orig_func = getattr(resolved_obj, func_path[-1])
setattr(resolved_obj, func_path[-1], lambda *args, **kwargs: self(*args, **kwargs))
self.__init__(orig_func, sub_func, cond_func)
return lambda *args, **kwargs: self(*args, **kwargs)
def __init__(self, orig_func, sub_func, cond_func):
self.__orig_func = orig_func
self.__sub_func = sub_func
self.__cond_func = cond_func
def __call__(self, *args, **kwargs):
if not self.__cond_func or self.__cond_func(self.__orig_func, *args, **kwargs):
return self.__sub_func(self.__orig_func, *args, **kwargs)
else:
return self.__orig_func(*args, **kwargs)
return lambda *args, **kwargs: self(*args, **kwargs)
def __init__(self, orig_func, sub_func, cond_func):
self.__orig_func = orig_func
self.__sub_func = sub_func
self.__cond_func = cond_func
def __call__(self, *args, **kwargs):
if not self.__cond_func or self.__cond_func(self.__orig_func, *args, **kwargs):
return self.__sub_func(self.__orig_func, *args, **kwargs)
else:
return self.__orig_func(*args, **kwargs)
3 changes: 1 addition & 2 deletions modules/textual_inversion/learn_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, learn_rate, max_steps, cur_step=0):
return
assert self.rates
except (ValueError, AssertionError) as e:
raise Exception('Invalid learning rate schedule. It should be a number or, for example, like "0.001:100, 0.00001:1000, 1e-5:10000" to have lr of 0.001 until step 100, 0.00001 until 1000, and 1e-5 until 10000.') from e
raise RuntimeError('Invalid learning rate schedule. It should be a number or, for example, like "0.001:100, 0.00001:1000, 1e-5:10000" to have lr of 0.001 until step 100, 0.00001 until 1000, and 1e-5 until 10000.') from e


def __iter__(self):
Expand Down Expand Up @@ -75,4 +75,3 @@ def apply(self, optimizer, step_number):

for pg in optimizer.param_groups:
pg['lr'] = self.learn_rate

2 changes: 1 addition & 1 deletion train/templates/style.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a painting, art by [name]
a painting, art by [name]
2 changes: 1 addition & 1 deletion train/templates/style_filewords.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
photo of [filewords], art by [name]
photo of [filewords], art by [name]
2 changes: 1 addition & 1 deletion train/templates/subject.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
photo of [name]
photo of [name]
2 changes: 1 addition & 1 deletion train/templates/subject_filewords.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
photo of [name], [filewords]
photo of [name], [filewords]
2 changes: 1 addition & 1 deletion train/templates/unknown.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[name]
[name]
2 changes: 1 addition & 1 deletion train/templates/unknown_filewords.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[name], [filewords]
[name], [filewords]

0 comments on commit 4c7792e

Please sign in to comment.