diff --git a/TODO.md b/TODO.md index 5ca4347b0..b2910e114 100644 --- a/TODO.md +++ b/TODO.md @@ -76,6 +76,27 @@ TODO: *Prioritize*! - [Wan2.2-Animate-14B](https://huggingface.co/Wan-AI/Wan2.2-Animate-14B) - [WAN2GP](https://github.com/deepbeepmeep/Wan2GP) +## Futureproofing + +Anything marked with **(!!!)** means a change *will* eventually be required. + +### General + +- Review/improve type-hinting and type checking + - A little easier to work with due to syntax changes in Python 3.10 + +### Asyncio + +- **(!!!)** Policy system is deprecated and will be removed in **Python 3.16** + - [Python 3.14 removals - asyncio](https://docs.python.org/3.14/whatsnew/3.14.html#id10) + - https://docs.python.org/3.14/library/asyncio-policy.html + - Affected files: + - [`webui.py`](webui.py) + - [`cli/sdapi.py`](cli/sdapi.py) + - Migration: + - [asyncio.run](https://docs.python.org/3.14/library/asyncio-runner.html#asyncio.run) + - [asyncio.Runner](https://docs.python.org/3.14/library/asyncio-runner.html#asyncio.Runner) + ## Code TODO > npm run todo diff --git a/modules/intel/ipex/__init__.py b/modules/intel/ipex/__init__.py index 393c32164..726e5e742 100644 --- a/modules/intel/ipex/__init__.py +++ b/modules/intel/ipex/__init__.py @@ -50,8 +50,8 @@ def ipex_init(): # pylint: disable=too-many-statements torch.Tensor.is_cuda = torch.Tensor.is_xpu torch.nn.Module.cuda = torch.nn.Module.xpu torch.cuda.Optional = torch.xpu.Optional - torch.cuda.__cached__ = torch.xpu.__cached__ - torch.cuda.__loader__ = torch.xpu.__loader__ + torch.cuda.__cached__ = getattr(torch.xpu, "__cached__", None) + torch.cuda.__loader__ = getattr(torch.xpu, "__loader__", None) torch.cuda.streams = torch.xpu.streams torch.cuda.Any = torch.xpu.Any torch.cuda.__doc__ = torch.xpu.__doc__ @@ -62,7 +62,7 @@ def ipex_init(): # pylint: disable=too-many-statements torch.cuda.torch = torch.xpu.torch torch.cuda.Union = torch.xpu.Union torch.cuda.__annotations__ = torch.xpu.__annotations__ - torch.cuda.__package__ = torch.xpu.__package__ + torch.cuda.__package__ = getattr(torch.xpu, "__package__", None) torch.cuda.__builtins__ = torch.xpu.__builtins__ torch.cuda._lazy_init = torch.xpu._lazy_init torch.cuda.StreamContext = torch.xpu.StreamContext diff --git a/modules/ui_extensions.py b/modules/ui_extensions.py index 640c0d622..f1240a64c 100644 --- a/modules/ui_extensions.py +++ b/modules/ui_extensions.py @@ -191,11 +191,10 @@ def install_extension(extension_to_install, search_text, sort_column): def uninstall_extension(extension_path, search_text, sort_column): - def errorRemoveReadonly(func, path, exc): + def excRemoveReadonly(func, path, exc: Exception): import stat - excvalue = exc[1] - shared.log.debug(f'Exception during cleanup: {func} {path} {excvalue.strerror}') - if func in (os.rmdir, os.remove, os.unlink) and excvalue.errno == errno.EACCES: + shared.log.debug(f'Exception during cleanup: {func} {path} {type(exc).__name__}') + if func in (os.rmdir, os.remove, os.unlink) and isinstance(exc, PermissionError): shared.log.debug(f'Retrying cleanup: {path}') os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) func(path) @@ -204,7 +203,7 @@ def uninstall_extension(extension_path, search_text, sort_column): if len(found) > 0 and os.path.isdir(extension_path): found = found[0] try: - shutil.rmtree(found.path, ignore_errors=False, onerror=errorRemoveReadonly) # pylint: disable=deprecated-argument + shutil.rmtree(found.path, ignore_errors=False, onexc=excRemoveReadonly) # extensions.extensions = [extension for extension in extensions.extensions if os.path.abspath(found.path) != os.path.abspath(extension_path)] except Exception as e: shared.log.warning(f'Extension uninstall failed: {found.path} {e}')