Fix installed demark-world CLI entry point#10
Conversation
📝 WalkthroughWalkthroughThis PR consolidates the package structure by removing the ChangesPackage namespace unification and CLI implementation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/demark_world/iopaint/schema.py (1)
9-19:⚠️ Potential issue | 🟠 MajorFix remaining stale
src.demark_worldimports in top-level scripts
src/demark_world/iopaint/schema.py’s import ofdemark_world.iopaint.constis consistent, andsrc/demark_world/iopaint/const.pyexists. However,start_server.py(lines 6-7) andexample.py(lines 2-3) still import fromsrc.demark_world.*; switch them todemark_world.*to avoid PYTHONPATH-dependent runtime resolution.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/demark_world/iopaint/schema.py` around lines 9 - 19, Update the stale top-level imports that reference the package with a "src." prefix: replace any imports like "from src.demark_world..." in start_server.py (the imports around lines 6-7) and example.py (the imports around lines 2-3) to use "from demark_world..." instead so they import modules such as demark_world.iopaint.const and demark_world.iopaint.schema (referencing symbols like ANYTEXT_NAME, INSTRUCT_PIX2PIX_NAME, KANDINSKY22_NAME, etc.) to avoid PYTHONPATH-dependent resolution.
🧹 Nitpick comments (3)
src/demark_world/cli.py (2)
103-103: 💤 Low valueAnnotate return types on new public functions/methods.
main,show_banner,process_batch, and_print_summarylack-> Nonereturn annotations. As per coding guidelines, "Always use full type annotations". Addingfrom __future__ import annotationsat the top is also recommended for this typed module.Also applies to: 170-170, 188-188, 274-274
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/demark_world/cli.py` at line 103, Add explicit return type annotations and future annotations import: add "from __future__ import annotations" at the top of the module, and annotate the public functions main, show_banner, process_batch, and _print_summary with "-> None". Update the function signatures for those symbols to include the return annotation and ensure any corresponding type hints in their definitions remain consistent with the module-level future import.
7-7: 💤 Low valueAdd a return type annotation.
validate_args_and_show_helpreturnstuple[Path, Path, argparse.Namespace]but is unannotated. As per coding guidelines, "Always use full type annotations".Proposed annotation
-def validate_args_and_show_help(): +def validate_args_and_show_help() -> tuple[Path, Path, argparse.Namespace]:🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/demark_world/cli.py` at line 7, Add an explicit return type to the function validate_args_and_show_help: change its signature to return tuple[Path, Path, argparse.Namespace] (i.e. def validate_args_and_show_help() -> tuple[Path, Path, argparse.Namespace]:). Ensure Path is available (from pathlib import Path) and argparse is imported in this module or referenced with the argparse name; if forward-reference issues occur, enable from __future__ import annotations. Keep the rest of the function logic unchanged.src/demark_world/models/model/e2fgvi_hq.py (1)
12-12: ⚡ Quick winRemove stale commented-out import.
This commented line appears to be a malformed artifact from the namespace refactor (duplicated
demark_world.modelsin the path). The correct import is already active on Line 13.🧹 Proposed fix
-# from demark_world.models.demark_world.models.model.modules.flow_comp import SPyNet from demark_world.models.model.modules.flow_comp import SPyNetAs per coding guidelines, avoid leaving stale commented-out code.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/demark_world/models/model/e2fgvi_hq.py` at line 12, Remove the stale commented-out import line referencing "demark_world.models.demark_world.models.model.modules.flow_comp import SPyNet" in the e2fgvi_hq module; keep the existing correct active import for SPyNet (the working import on the next line) and delete the malformed duplicate comment to avoid leaving outdated commented code.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/demark_world/iopaint/cli.py`:
- Around line 12-14: Update the remaining imports that reference the package
with the leading "src" so they use the installed package name "demark_world"
instead of "src.demark_world"; specifically change any occurrences like "from
src.demark_world.iopaint import ..." in start_server.py (lines around the
imports at 6-7) and example.py (lines around imports at 2-3) to "from
demark_world.iopaint import ..." (and similarly for any submodules such as
iopaint.cli, iopaint.runtime, iopaint.const, etc.) so imports match the
wheel/package layout.
In `@src/demark_world/iopaint/helper.py`:
- Around line 63-64: The f-string error message that uses _md5 and model_md5
concatenates two sentences without a space (producing "...restart
demark_world.iopaint.If you..."); update the string assembly around where the
MD5 check/log message is built (the f-strings referencing _md5 and model_md5) to
ensure a space or punctuation + space separates the sentences (e.g., add a
trailing space to the first f-string or start the second with a leading space).
Apply the same fix to the identical message block later (the similar f-strings
at the second occurrence).
In `@src/demark_world/iopaint/tests/test_load_img.py`:
- Around line 1-2: The failing imports are leftover using the old namespace
string "src.demark_world"; update any import statements that reference
"src.demark_world" (e.g., lines importing modules from that namespace) to use
the new absolute package name "demark_world" instead so imports resolve
consistently—search for occurrences of the literal "from src.demark_world" in
the codebase (including start_server.py and example.py) and replace them with
"from demark_world" keeping the rest of each import path unchanged.
---
Outside diff comments:
In `@src/demark_world/iopaint/schema.py`:
- Around line 9-19: Update the stale top-level imports that reference the
package with a "src." prefix: replace any imports like "from
src.demark_world..." in start_server.py (the imports around lines 6-7) and
example.py (the imports around lines 2-3) to use "from demark_world..." instead
so they import modules such as demark_world.iopaint.const and
demark_world.iopaint.schema (referencing symbols like ANYTEXT_NAME,
INSTRUCT_PIX2PIX_NAME, KANDINSKY22_NAME, etc.) to avoid PYTHONPATH-dependent
resolution.
---
Nitpick comments:
In `@src/demark_world/cli.py`:
- Line 103: Add explicit return type annotations and future annotations import:
add "from __future__ import annotations" at the top of the module, and annotate
the public functions main, show_banner, process_batch, and _print_summary with
"-> None". Update the function signatures for those symbols to include the
return annotation and ensure any corresponding type hints in their definitions
remain consistent with the module-level future import.
- Line 7: Add an explicit return type to the function
validate_args_and_show_help: change its signature to return tuple[Path, Path,
argparse.Namespace] (i.e. def validate_args_and_show_help() -> tuple[Path, Path,
argparse.Namespace]:). Ensure Path is available (from pathlib import Path) and
argparse is imported in this module or referenced with the argparse name; if
forward-reference issues occur, enable from __future__ import annotations. Keep
the rest of the function logic unchanged.
In `@src/demark_world/models/model/e2fgvi_hq.py`:
- Line 12: Remove the stale commented-out import line referencing
"demark_world.models.demark_world.models.model.modules.flow_comp import SPyNet"
in the e2fgvi_hq module; keep the existing correct active import for SPyNet (the
working import on the next line) and delete the malformed duplicate comment to
avoid leaving outdated commented code.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b01620ee-a7d1-42af-a915-c995f81e7c1c
⛔ Files ignored due to path filters (2)
resources/.DS_Storeis excluded by!**/.DS_Storesrc/demark_world/models/.DS_Storeis excluded by!**/.DS_Store
📒 Files selected for processing (98)
README.mdapp.pycli.pypyproject.tomlsrc/demark_world/cleaner/e2fgvi_hq_cleaner.pysrc/demark_world/cleaner/lama_cleaner.pysrc/demark_world/cli.pysrc/demark_world/core.pysrc/demark_world/iopaint/__init__.pysrc/demark_world/iopaint/api.pysrc/demark_world/iopaint/batch_processing.pysrc/demark_world/iopaint/benchmark.pysrc/demark_world/iopaint/cli.pysrc/demark_world/iopaint/download.pysrc/demark_world/iopaint/helper.pysrc/demark_world/iopaint/model/anytext/anytext_model.pysrc/demark_world/iopaint/model/anytext/anytext_pipeline.pysrc/demark_world/iopaint/model/anytext/anytext_sd15.yamlsrc/demark_world/iopaint/model/anytext/cldm/cldm.pysrc/demark_world/iopaint/model/anytext/cldm/ddim_hacked.pysrc/demark_world/iopaint/model/anytext/cldm/embedding_manager.pysrc/demark_world/iopaint/model/anytext/cldm/hack.pysrc/demark_world/iopaint/model/anytext/cldm/model.pysrc/demark_world/iopaint/model/anytext/cldm/recognizer.pysrc/demark_world/iopaint/model/anytext/ldm/models/autoencoder.pysrc/demark_world/iopaint/model/anytext/ldm/models/diffusion/ddim.pysrc/demark_world/iopaint/model/anytext/ldm/models/diffusion/ddpm.pysrc/demark_world/iopaint/model/anytext/ldm/models/diffusion/plms.pysrc/demark_world/iopaint/model/anytext/ldm/modules/attention.pysrc/demark_world/iopaint/model/anytext/ldm/modules/diffusionmodules/openaimodel.pysrc/demark_world/iopaint/model/anytext/ldm/modules/diffusionmodules/upscaling.pysrc/demark_world/iopaint/model/anytext/ldm/modules/diffusionmodules/util.pysrc/demark_world/iopaint/model/anytext/ldm/modules/encoders/modules.pysrc/demark_world/iopaint/model/base.pysrc/demark_world/iopaint/model/controlnet.pysrc/demark_world/iopaint/model/fcf.pysrc/demark_world/iopaint/model/helper/controlnet_preprocess.pysrc/demark_world/iopaint/model/instruct_pix2pix.pysrc/demark_world/iopaint/model/kandinsky.pysrc/demark_world/iopaint/model/lama.pysrc/demark_world/iopaint/model/ldm.pysrc/demark_world/iopaint/model/manga.pysrc/demark_world/iopaint/model/mat.pysrc/demark_world/iopaint/model/mi_gan.pysrc/demark_world/iopaint/model/opencv2.pysrc/demark_world/iopaint/model/paint_by_example.pysrc/demark_world/iopaint/model/power_paint/power_paint.pysrc/demark_world/iopaint/model/power_paint/power_paint_v2.pysrc/demark_world/iopaint/model/power_paint/powerpaint_tokenizer.pysrc/demark_world/iopaint/model/sd.pysrc/demark_world/iopaint/model/sdxl.pysrc/demark_world/iopaint/model/utils.pysrc/demark_world/iopaint/model/zits.pysrc/demark_world/iopaint/model_manager.pysrc/demark_world/iopaint/plugins/anime_seg.pysrc/demark_world/iopaint/plugins/base_plugin.pysrc/demark_world/iopaint/plugins/gfpgan/archs/stylegan2_clean_arch.pysrc/demark_world/iopaint/plugins/gfpgan_plugin.pysrc/demark_world/iopaint/plugins/interactive_seg.pysrc/demark_world/iopaint/plugins/realesrgan.pysrc/demark_world/iopaint/plugins/remove_bg.pysrc/demark_world/iopaint/plugins/restoreformer.pysrc/demark_world/iopaint/plugins/segment_anything/build_sam.pysrc/demark_world/iopaint/runtime.pysrc/demark_world/iopaint/schema.pysrc/demark_world/iopaint/tests/test_adjust_mask.pysrc/demark_world/iopaint/tests/test_anytext.pysrc/demark_world/iopaint/tests/test_brushnet.pysrc/demark_world/iopaint/tests/test_controlnet.pysrc/demark_world/iopaint/tests/test_instruct_pix2pix.pysrc/demark_world/iopaint/tests/test_load_img.pysrc/demark_world/iopaint/tests/test_low_mem.pysrc/demark_world/iopaint/tests/test_match_histograms.pysrc/demark_world/iopaint/tests/test_model.pysrc/demark_world/iopaint/tests/test_model_md5.pysrc/demark_world/iopaint/tests/test_model_switch.pysrc/demark_world/iopaint/tests/test_outpainting.pysrc/demark_world/iopaint/tests/test_paint_by_example.pysrc/demark_world/iopaint/tests/test_plugins.pysrc/demark_world/iopaint/tests/test_save_exif.pysrc/demark_world/iopaint/tests/test_save_quality.pysrc/demark_world/iopaint/tests/test_sd_model.pysrc/demark_world/iopaint/tests/test_sdxl.pysrc/demark_world/iopaint/tests/utils.pysrc/demark_world/iopaint/web_config.pysrc/demark_world/models/model/e2fgvi.pysrc/demark_world/models/model/e2fgvi_hq.pysrc/demark_world/models/model/modules/feat_prop.pysrc/demark_world/server/app.pysrc/demark_world/server/db.pysrc/demark_world/server/lifespan.pysrc/demark_world/server/models.pysrc/demark_world/server/router.pysrc/demark_world/server/worker.pysrc/demark_world/utils/download_utils.pysrc/demark_world/utils/watermark_utls.pysrc/demark_world/watermark_cleaner.pysrc/demark_world/watermark_detector.py
| from demark_world.iopaint.const import * | ||
| from demark_world.iopaint.runtime import check_device, dump_environment_info, setup_model_dir | ||
| from demark_world.iopaint.schema import ( |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# 1) Any remaining src.demark_world.* imports (would break under the new namespace)
rg -nP '\b(from|import)\s+src\.demark_world\b'
# 2) Confirm pyproject maps the src layout so `demark_world` is importable top-level
fd -t f 'pyproject.toml' --exec rg -nC3 'package-dir|packages|tool\.(setuptools|hatch|poetry)|where' {}Repository: linkedlist771/DeMark-World
Length of output: 874
Fix remaining src.demark_world imports so demark_world is used consistently.
start_server.py:6-7andexample.py:2-3still import fromsrc.demark_world.*, which will fail whensrcis not a Python package.pyproject.toml’s wheel config builds frompackages = ["src/demark_world"], so the installed import should bedemark_world.*; update these scripts accordingly.
🧰 Tools
🪛 Ruff (0.15.14)
[error] 12-12: from demark_world.iopaint.const import * used; unable to detect undefined names
(F403)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/demark_world/iopaint/cli.py` around lines 12 - 14, Update the remaining
imports that reference the package with the leading "src" so they use the
installed package name "demark_world" instead of "src.demark_world";
specifically change any occurrences like "from src.demark_world.iopaint import
..." in start_server.py (lines around the imports at 6-7) and example.py (lines
around imports at 2-3) to "from demark_world.iopaint import ..." (and similarly
for any submodules such as iopaint.cli, iopaint.runtime, iopaint.const, etc.) so
imports match the wheel/package layout.
| f"Model md5: {_md5}, expected md5: {model_md5}, wrong model deleted. Please restart demark_world.iopaint." | ||
| f"If you still have errors, please try download model manually first https://lama-cleaner-docs.vercel.app/install/download_model_manually.\n" |
There was a problem hiding this comment.
Missing space joins two sentences in the error message.
Implicit string concatenation produces ...restart demark_world.iopaint.If you still have errors... with no space. Same pattern at lines 87-88.
Proposed fix
- f"Model md5: {_md5}, expected md5: {model_md5}, wrong model deleted. Please restart demark_world.iopaint."
+ f"Model md5: {_md5}, expected md5: {model_md5}, wrong model deleted. Please restart demark_world.iopaint. "📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| f"Model md5: {_md5}, expected md5: {model_md5}, wrong model deleted. Please restart demark_world.iopaint." | |
| f"If you still have errors, please try download model manually first https://lama-cleaner-docs.vercel.app/install/download_model_manually.\n" | |
| f"Model md5: {_md5}, expected md5: {model_md5}, wrong model deleted. Please restart demark_world.iopaint. " | |
| f"If you still have errors, please try download model manually first https://lama-cleaner-docs.vercel.app/install/download_model_manually.\n" |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/demark_world/iopaint/helper.py` around lines 63 - 64, The f-string error
message that uses _md5 and model_md5 concatenates two sentences without a space
(producing "...restart demark_world.iopaint.If you..."); update the string
assembly around where the MD5 check/log message is built (the f-strings
referencing _md5 and model_md5) to ensure a space or punctuation + space
separates the sentences (e.g., add a trailing space to the first f-string or
start the second with a leading space). Apply the same fix to the identical
message block later (the similar f-strings at the second occurrence).
| from demark_world.iopaint.plugins.base_plugin import BasePlugin | ||
| from demark_world.iopaint.schema import Device, RemoveBGModel, RunPluginRequest |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Confirm target modules exist under the new namespace
fd -t f 'briarmbg2?.py' src/demark_world/iopaint/plugins
# Ensure no leftover old-namespace imports remain anywhere
rg -nP '\b(from|import)\s+src\.demark_world\b'Repository: linkedlist771/DeMark-World
Length of output: 414
🏁 Script executed:
#!/bin/bash
# List all remaining old-namespace `src.demark_world` imports
rg -nP '\b(from|import)\s+src\.demark_world\b' -S .
# Show the import sections for the hits we already saw
sed -n '1,80p' start_server.py
sed -n '1,120p' example.pyRepository: linkedlist771/DeMark-World
Length of output: 1717
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the lazy-import locations in remove_bg.py
nl -ba src/demark_world/iopaint/plugins/remove_bg.py | sed -n '35,80p'
# Check whether any library code still imports via `src.demark_world`
rg -nP '\b(from|import)\s+src\.demark_world\b' src/demark_world -S || true
# Confirm the target briarmbg/briarmbg2 modules exist where the new namespace expects them
ls -1 src/demark_world/iopaint/plugins/briarmbg*.pyRepository: linkedlist771/DeMark-World
Length of output: 113
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the lazy-import locations in remove_bg.py
cat -n src/demark_world/iopaint/plugins/remove_bg.py | sed -n '35,90p'
# Check whether any library code still imports via `src.demark_world`
rg -nP '\b(from|import)\s+src\.demark_world\b' src/demark_world -S || true
# Confirm the target briarmbg/briarmbg2 modules exist where the new namespace expects them
ls -1 src/demark_world/iopaint/plugins/briarmbg*.pyRepository: linkedlist771/DeMark-World
Length of output: 2597
Confirm briarmbg/briarmbg2 lazy imports + fix remaining src.demark_world imports
src/demark_world/iopaint/plugins/remove_bg.pylazily imports fromdemark_world.iopaint.plugins.briarmbg/demark_world.iopaint.plugins.briarmbg2, and bothsrc/demark_world/iopaint/plugins/briarmbg.pyandbriarmbg2.pyexist.- Remaining
from src.demark_world...imports instart_server.py(6-7) andexample.py(2-3) should be switched tofrom demark_world...to match the new namespace.
| from demark_world.iopaint.helper import load_img | ||
| from demark_world.iopaint.tests.utils import current_dir |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Find any leftover `src.demark_world` references missed by the rename.
rg -nP '\bsrc\.demark_world\b' -g '*.py' -g '*.yaml'Repository: linkedlist771/DeMark-World
Length of output: 323
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Broader scan for any remaining src.demark_world imports/usages across common text formats.
rg -nP '\bsrc\.demark_world\b' -g '*.py' -g '*.yaml' -g '*.yml' -g '*.toml' -g '*.md' -g '*.ini' -g '*.cfg' -g '*.sh' -g '*.bash' -g '*.txt' || true
# Also check for any other common "src.<pkg>" import patterns that might be part of the same rename.
rg -nP '\bsrc\.demark_world\.[A-Za-z_][A-Za-z0-9_]*\b' -g '*.py' || trueRepository: linkedlist771/DeMark-World
Length of output: 576
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Confirm there are no other occurrences anywhere in the repo (all file types).
rg -nP '\bsrc\.demark_world\b' . || trueRepository: linkedlist771/DeMark-World
Length of output: 331
Fix remaining src.demark_world imports (namespace rename incomplete).
start_server.py:6-7still importsfrom src.demark_world...example.py:2-3still importsfrom src.demark_world...
These need to be updated to the newdemark_world...absolute imports so the renamed namespace resolves consistently.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/demark_world/iopaint/tests/test_load_img.py` around lines 1 - 2, The
failing imports are leftover using the old namespace string "src.demark_world";
update any import statements that reference "src.demark_world" (e.g., lines
importing modules from that namespace) to use the new absolute package name
"demark_world" instead so imports resolve consistently—search for occurrences of
the literal "from src.demark_world" in the codebase (including start_server.py
and example.py) and replace them with "from demark_world" keeping the rest of
each import path unchanged.
Motivation
The installed CLI was broken for me because the console script pointed to a top-level
cli:mainmodule that is not included in the wheel, causingModuleNotFoundError: No module named 'cli'.Description
Moved the CLI into the packaged module at
src/demark_world/cli.pyand updated the console script to usedemark_world.cli:main.Added a small root-level
cli.pywrapper for source-checkout usage, replacedsrc.demark_world.*imports withdemark_world.*, and cleaned up linting/formatting issues.Testing
Verified the CLI help command works, confirmed all modules compile, checked the
pyproject.tomlentry point, and ran Ruff checks successfully.Summary by CodeRabbit
New Features
Refactor