From 13b9d6ffe24b41e486742bfd864a22c7ed3ab429 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Wed, 5 Apr 2023 14:36:57 -0400 Subject: [PATCH] update extensions --- cli/random/extensions.js | 129 ++++++++++++++++++++ extensions-builtin/sd-extension-system-info | 2 +- launch.py | 2 +- modules/lycoris | 2 +- wiki | 2 +- 5 files changed, 133 insertions(+), 4 deletions(-) create mode 100644 cli/random/extensions.js diff --git a/cli/random/extensions.js b/cli/random/extensions.js new file mode 100644 index 000000000..929c3f9d5 --- /dev/null +++ b/cli/random/extensions.js @@ -0,0 +1,129 @@ +const URL = 'https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui-extensions/master/index.json'; +const console = require('console'); + +const headers = { + 'content-type': 'application/json', + 'accept': 'application/vnd.github.v3+json', + 'user-agent': 'nodejs/fetch', +}; + +let logger = new console.Console({ + stdout: process.stdout, + stderr: process.stderr, + ignoreErrors: true, + inspectOptions: { + showHidden: false, + depth: 5, + colors: true, + showProxy: true, + maxArrayLength: 1024, + maxStringLength: 10240, + breakLength: process.stdout.columns, + compact: 64, + sorted: false, + getters: false, + } +}); + +const log = (...args) => logger.log(...args); + +const http = async (url) => { + try { + const res = await fetch(url, { method: 'GET', headers }) + if (res.status !== 200) { + const limit = parseInt(res.headers.get('x-ratelimit-remaining') || '0'); + if (limit === 0) log(`ratelimit: ${url}`, new Date(1000 * parseInt(res.headers.get('x-ratelimit-reset')))); + else log(`error: ${res.status} ${res.statusText} ${url}`) + return {}; + } + const text = await res.text(); + const json = JSON.parse(text); + return json; + } catch (e) { + log(`exception: ${e} ${url}`) + return {}; + } +}; + +const head = async (url) => { + let json = {}; + const res = await fetch(url, { method: 'GET', headers }) + if (res.status !== 200) return {}; + for (const h of res.headers) json[h[0]] = h[1]; + return json; +}; + +async function getDetails(extension) { + return new Promise(async (resolve) => { + let name = extension.url.replace('https://github.com/', ''); + if (name.endsWith('.git')) name = name.replace('.git', ''); + const ext = { + name: extension.name, + url: extension.url, + description: extension.description.substring(0, 64), + tags: extension.tags, + added: new Date(extension.added), + } + if (ext.tags.includes('localization')) resolve(ext); // don't fetch details for localization tags + else { + const r = await http(`https://api.github.com/repos/${name}`); + if (!r.full_name) resolve(ext); + else { + ext.created = new Date(r.created_at); + ext.updated = new Date(r.pushed_at); + ext.name = r.full_name; + ext.description = (r.description || extension.description).substring(0, 96); + ext.size = r.size; + ext.stars = r.stargazers_count; + ext.issues = r.open_issues_count; + const h = await head(`https://api.github.com/repos/${r.full_name}/commits?per_page=1`); // get headers + const commits = parseInt(h.link?.match(/\d+/g).pop() || '0'); // extract total commit count from pagination data + ext.commits = commits; + // const c = await http(`https://api.github.com/repos/${r.full_name}/traffic/clones?per=week`); // not allowed for non-owners + // const clones = c.clones?.map((c) => c.count).reduce((avg, value, _, { length }) => avg + value / length, 0) || 0; + // ext.clones: Math.round(clones), + resolve(ext); + } + } + }) +} + +async function main() { + // const repos = await githubRepositories(); + if (process.env.GITHUB_TOKEN) { + log('using github token'); + headers['authorization'] = `token ${process.env.GITHUB_TOKEN}`; + } else { + log('no github token set so low rate limiting will apply'); + } + log(`fetching extensions index: ${URL}`) + const index = await http(URL); + const extensions = index?.extensions || []; + log(`analyzing extensions: ${extensions.length}`) + + const promises = []; + for (const e of extensions) { + ext = getDetails(e); + promises.push(ext); + } + let details = await Promise.all(promises); + + const word = process.argv[2] + if (word) { + if (details[0][word]) { + log('sorting by field:', word); + details.sort((a, b) => b[word] - a[word]); + } else if (Object.keys(index?.tags || {}).includes(word)) { + log('filtering by tag:', word); + details = details.filter((a) => a.tags.includes(word)); + } else { + log('filtering by keyword:', word); + details = details.filter((a) => (a.name.includes(word) || a.description.includes(word))); + } + } + details.length = Math.min(parseInt(process.argv[3] || 100000), details.length); + log('extensions:'); + for (const ext of details) log(ext); +} + +main(); diff --git a/extensions-builtin/sd-extension-system-info b/extensions-builtin/sd-extension-system-info index 025840d98..b4bac45a9 160000 --- a/extensions-builtin/sd-extension-system-info +++ b/extensions-builtin/sd-extension-system-info @@ -1 +1 @@ -Subproject commit 025840d981e43418fc5305d5bbb81f359e5538dc +Subproject commit b4bac45a9bf38008651a070518f3b5aa871c6e99 diff --git a/launch.py b/launch.py index aa799b71a..0420c468c 100644 --- a/launch.py +++ b/launch.py @@ -216,7 +216,7 @@ def prepare_environment(): torch_command = os.environ.get('TORCH_COMMAND', "pip install torch torchaudio torchvision --extra-index-url https://download.pytorch.org/whl/cu118") requirements_file = os.environ.get('REQS_FILE', "requirements_versions.txt") - xformers_package = os.environ.get('XFORMERS_PACKAGE', 'xformers==0.0.17') + xformers_package = os.environ.get('XFORMERS_PACKAGE', 'xformers==0.0.18') gfpgan_package = os.environ.get('GFPGAN_PACKAGE', "git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379") clip_package = os.environ.get('CLIP_PACKAGE', "git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1") openclip_package = os.environ.get('OPENCLIP_PACKAGE', "git+https://github.com/mlfoundations/open_clip.git@bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b") diff --git a/modules/lycoris b/modules/lycoris index a7bfc2ab8..ec1b758ab 160000 --- a/modules/lycoris +++ b/modules/lycoris @@ -1 +1 @@ -Subproject commit a7bfc2ab83956680ef6c9ced34d08cbc251fce66 +Subproject commit ec1b758ab416e9d2f3590d5dd961b9ec27a0dc60 diff --git a/wiki b/wiki index 61feae068..faecb8a98 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 61feae068dd102d86a5dd92329ae10df9a314ef6 +Subproject commit faecb8a98cbe7d26928a6e517729a90a06eb32f3