From 4415e2274441b63c9e68fe43e7cc26f8f774612b Mon Sep 17 00:00:00 2001 From: newtextdoc1111 Date: Thu, 29 May 2025 17:51:50 +0900 Subject: [PATCH 1/3] fix: Log CSV file status in ComfyUI console and browser network tab --- modules/api.py | 14 ++++++++++---- web/js/data.js | 19 ++++++++++--------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/modules/api.py b/modules/api.py index d1cf78f..313cfbf 100644 --- a/modules/api.py +++ b/modules/api.py @@ -103,17 +103,23 @@ async def get_csv_list(_request): response = { DANBOORU_PREFIX: { 'base_tags': csv_file_status[DANBOORU_PREFIX]['base_tags'], - 'extra_tags': len(csv_file_status[DANBOORU_PREFIX]['extra_tags']), + 'extra_tags': csv_file_status[DANBOORU_PREFIX]['extra_tags'], 'base_cooccurrence': csv_file_status[DANBOORU_PREFIX]['base_cooccurrence'], - 'extra_cooccurrence': len(csv_file_status[DANBOORU_PREFIX]['extra_cooccurrence']), + 'extra_cooccurrence': csv_file_status[DANBOORU_PREFIX]['extra_cooccurrence'], }, E621_PREFIX: { 'base_tags': csv_file_status[E621_PREFIX]['base_tags'], - 'extra_tags': len(csv_file_status[E621_PREFIX]['extra_tags']), + 'extra_tags': csv_file_status[E621_PREFIX]['extra_tags'], 'base_cooccurrence': csv_file_status[E621_PREFIX]['base_cooccurrence'], - 'extra_cooccurrence': len(csv_file_status[E621_PREFIX]['extra_cooccurrence']), + 'extra_cooccurrence': csv_file_status[E621_PREFIX]['extra_cooccurrence'], } } + + # Print csv file status to the console for debugging + print(f"""[Autocomplete-Plus] CSV file status: + * Danbooru -> base: {response[DANBOORU_PREFIX]['base_tags']}, extra: {", ".join(response[DANBOORU_PREFIX]['extra_tags'])} + * E621 -> base: {response[E621_PREFIX]['base_tags']}, extra: {", ".join(response[E621_PREFIX]['extra_tags'])}""") + return web.json_response(response) @server.PromptServer.instance.routes.get('/autocomplete-plus/csv/{source}/{suffix}/base') diff --git a/web/js/data.js b/web/js/data.js index 6e85c8f..0f57bfb 100644 --- a/web/js/data.js +++ b/web/js/data.js @@ -340,8 +340,8 @@ export async function initializeData(csvListData, source) { return; } - const extraTagsCount = csvListData[source].extra_tags || 0; - const extraCooccurrenceCount = csvListData[source].extra_cooccurrence || 0; + const extraTagsFileList = csvListData[source].extra_tags || []; + const extraCooccurrenceFileList = csvListData[source].extra_cooccurrence || []; const tagsUrl = `/autocomplete-plus/csv/${source}/tags`; const cooccurrenceUrl = `/autocomplete-plus/csv/${source}/tags_cooccurrence`; @@ -349,7 +349,7 @@ export async function initializeData(csvListData, source) { // Factory for loading tags for the current sourte const siteTagsLoaderFactory = async () => { let promiseChain = Promise.resolve(); - for (let i = 0; i < extraTagsCount; i++) { + for (let i = 0; i < extraTagsFileList.length; i++) { promiseChain = promiseChain.then(() => loadTags(`${tagsUrl}/extra/${i}`, source)); } if (csvListData[source].base_tags) { @@ -362,7 +362,7 @@ export async function initializeData(csvListData, source) { // Factory for loading cooccurrence data for the current sourte const siteCooccurrenceLoaderFactory = async () => { let promiseChain = Promise.resolve(); - for (let i = 0; i < extraCooccurrenceCount; i++) { + for (let i = 0; i < extraCooccurrenceFileList.length; i++) { promiseChain = promiseChain.then(() => loadCooccurrence(`${cooccurrenceUrl}/extra/${i}`, source)); } if (csvListData[source].base_cooccurrence) { @@ -377,14 +377,15 @@ export async function initializeData(csvListData, source) { await Promise.all([ Promise.all(tagsLoadPromiseFactories.map(factory => factory())).then(() => { const endTime = performance.now(); - console.log(`[Autocomplete-Plus] "${source}" Tags loading complete in ${(endTime - startTime).toFixed(2)}ms`); + if (csvListData[source].base_tags) { + console.log(`[Autocomplete-Plus] "${source}" Tags loading complete in ${(endTime - startTime).toFixed(2)}ms`); + } }), Promise.all(cooccurrenceLoadPromiseFactories.map(factory => factory())).then(() => { const endTime = performance.now(); - // The original log for extraCooccurrenceCount was potentially misleading as it showed - // the count for the last processed sourte. Removed for clarity. - // If a total count is needed, it should be calculated across all sites. - console.log(`[Autocomplete-Plus] "${source}" Co-occurrence loading complete in ${(endTime - startTime).toFixed(2)}ms.`); + if (csvListData[source].base_cooccurrence) { + console.log(`[Autocomplete-Plus] "${source}" Co-occurrence loading complete in ${(endTime - startTime).toFixed(2)}ms.`); + } }) ]); From 47635d5aeae2073a311fe06094d39b05986e9883 Mon Sep 17 00:00:00 2001 From: newtextdoc1111 Date: Thu, 29 May 2025 17:52:09 +0900 Subject: [PATCH 2/3] docs: Update user CSV instructions with naming conventions and console log details --- README.md | 16 +++++++++++++++- docs/README_jp.md | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e622273..5e3297f 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,12 @@ Also, displaying related tags is not supported. ### User CSV -Users can also use their own CSV files. For example, frequently used meta tags can be added to the autocomplete suggestions by placing a file named `danbooru_tags_meta.csv` in the `data` folder. +Users can also use their own CSV files. CSV files should be placed in the `data` folder according to the following naming convention: + +- **CSV for Autocomplete**: `_tags*.csv` +- **CSV for Related Tags**: `_tags_cooccurrence*.csv` + +For example, you can add frequently used meta tags to the autocomplete suggestions by placing a file named `danbooru_tags_meta.csv` in the `data` folder. A header row is not required. A browser reload is necessary to apply the changes. **Example of meta tags:** @@ -106,6 +111,15 @@ low_quality,5,9999999, worst_quality,5,9999999, ``` +When the browser is reloaded, you can check the list of loaded CSV files in the ComfyUI console log. If a file is not included in the log output, please verify that the file name follows the naming convention. + +**Example of ComfyUI console log output:** +``` +[Autocomplete-Plus] CSV file status: + * Danbooru -> base: True, extra: danbooru_tags_meta.csv // If displayed here, meta tags can be autocompleted + * E621 -> base: False, extra: +``` + >[!NOTE] > If there are multiple user CSV files, they are loaded in alphabetical order. If the same tag exists in multiple files, the one loaded first is retained. The basic CSV is loaded last. diff --git a/docs/README_jp.md b/docs/README_jp.md index a9962c9..c0d4c5b 100644 --- a/docs/README_jp.md +++ b/docs/README_jp.md @@ -90,7 +90,12 @@ ### ユーザーCSV -ユーザーが自身で用意した CSV を使用することも可能です。例として、よく使うメタタグを `danbooru_tags_meta.csv` の名前で `data` フォルダーに配置することでオートコンプリート候補に追加できます。 +ユーザーが自身で用意した CSV を使用することも可能です。 CSV ファイルは以下の命名規則に従って `data` フォルダーに配置してください。 + +- **オートコンプリート用 CSV**: _tags*.csv +- **関連タグ用 CSV**: _tags_cooccurrence*.csv + +例として、よく使うメタタグを `danbooru_tags_meta.csv` の名前で `data` フォルダーに配置することでオートコンプリート候補に追加できます。 ヘッダー行はなくても構いません。反映にはブラウザのリロードが必要です。 **メタタグの例** @@ -104,6 +109,15 @@ low_quality,5,9999999, worst_quality,5,9999999, ``` +ブラウザリロード時、ロードされる CSV ファイル一覧をComfyUIのコンソールのログで確認出来ます。ログ出力に含まれていない場合はファイル名が命名規則に沿っているか確認してください。 + +**ComfyUIコンソールログ出力の例:** +``` +[Autocomplete-Plus] CSV file status: + * Danbooru -> base: True, extra: danbooru_tags_meta.csv // ここに表示されていればメタタグを入力補完できます + * E621 -> base: False, extra: +``` + >[!NOTE] > ユーザー CSV が複数ある場合アルファベット順に読み込まれます。同じタグが複数のファイルに存在する場合は先に読み込まれた方が保持されます。基本 CSV は最後にロードされます。 From 7a73a5b1b3d26e169c538419ab4637a3f78e3565 Mon Sep 17 00:00:00 2001 From: newtextdoc1111 Date: Thu, 29 May 2025 17:59:07 +0900 Subject: [PATCH 3/3] fix: Bump version to 1.0.2 in pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d6d3373..b40afec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-autocomplete-plus" description = "Autocomplete and Related Tag display for ComfyUI" -version = "1.0.1" +version = "1.0.2" license = {file = "LICENSE"} dependencies = ["",]