lcode-cli 0.49.0__tar.gz → 0.49.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/CHANGELOG.md +18 -1
  2. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/PKG-INFO +1 -1
  3. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/modes.md +8 -1
  4. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/quickstart.md +1 -1
  5. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/__init__.py +1 -1
  6. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/hardware.py +49 -0
  7. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/media.py +71 -12
  8. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/repl.py +2 -0
  9. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/residency.py +33 -0
  10. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/conftest.py +3 -0
  11. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_comfy.py +4 -2
  12. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_film.py +4 -1
  13. lcode_cli-0.49.1/tests/test_gpu_handover.py +156 -0
  14. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/.editorconfig +0 -0
  15. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/.github/CODEOWNERS +0 -0
  16. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
  17. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  18. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
  19. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/.github/ISSUE_TEMPLATE/model_request.yml +0 -0
  20. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  21. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/.github/dependabot.yml +0 -0
  22. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/.github/workflows/ci.yml +0 -0
  23. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/.github/workflows/docs.yml +0 -0
  24. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/.github/workflows/release.yml +0 -0
  25. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/.gitignore +0 -0
  26. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/.pre-commit-config.yaml +0 -0
  27. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/AGENTS.md +0 -0
  28. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/CODE_OF_CONDUCT.md +0 -0
  29. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/CONTRIBUTING.md +0 -0
  30. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/LICENSE +0 -0
  31. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/README.md +0 -0
  32. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/SECURITY.md +0 -0
  33. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/action.yml +0 -0
  34. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/agents.md +0 -0
  35. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/assets/demo.svg +0 -0
  36. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/assets/extra.css +0 -0
  37. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/assets/film-fox-and-kitten.jpg +0 -0
  38. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/automation.md +0 -0
  39. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/bench.md +0 -0
  40. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/changelog.md +0 -0
  41. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/commands.md +0 -0
  42. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/configuration.md +0 -0
  43. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/contributing.md +0 -0
  44. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/editors.md +0 -0
  45. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/git.md +0 -0
  46. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/hooks.md +0 -0
  47. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/how-it-works.md +0 -0
  48. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/index.md +0 -0
  49. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/installation.md +0 -0
  50. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/lsp.md +0 -0
  51. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/mcp.md +0 -0
  52. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/memory.md +0 -0
  53. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/models.md +0 -0
  54. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/sandbox.md +0 -0
  55. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/search.md +0 -0
  56. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/servers.md +0 -0
  57. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/troubleshooting.md +0 -0
  58. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/docs/usage.md +0 -0
  59. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/examples/README.md +0 -0
  60. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/examples/api/fix_tests.py +0 -0
  61. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/examples/commands/review.md +0 -0
  62. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/examples/skills/commit-message/SKILL.md +0 -0
  63. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/examples/skills/commit-message/scripts/staged.sh +0 -0
  64. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/install.sh +0 -0
  65. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/mkdocs.yml +0 -0
  66. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/overrides/main.html +0 -0
  67. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/pyproject.toml +0 -0
  68. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/scripts/make_logos.py +0 -0
  69. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/scripts/record_demo.py +0 -0
  70. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/scripts/social-preview.html +0 -0
  71. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/__main__.py +0 -0
  72. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/acp.py +0 -0
  73. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/action.py +0 -0
  74. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/agent.py +0 -0
  75. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/api.py +0 -0
  76. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/assistant.py +0 -0
  77. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/backends.py +0 -0
  78. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/bench.py +0 -0
  79. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/bench_backend.py +0 -0
  80. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/bench_runtime.py +0 -0
  81. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/catalog.py +0 -0
  82. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/checkpoints.py +0 -0
  83. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/checks.py +0 -0
  84. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/cli.py +0 -0
  85. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/clipboard.py +0 -0
  86. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/cloud.py +0 -0
  87. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/codesearch.py +0 -0
  88. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/comfy.py +0 -0
  89. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/config.py +0 -0
  90. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/context.py +0 -0
  91. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/edits.py +0 -0
  92. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/escalate.py +0 -0
  93. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/extensions.py +0 -0
  94. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/film.py +0 -0
  95. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/frontmatter.py +0 -0
  96. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/gitflow.py +0 -0
  97. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/hooks.py +0 -0
  98. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/imageopts.py +0 -0
  99. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/jobs.py +0 -0
  100. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/limits.py +0 -0
  101. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/lsp.py +0 -0
  102. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/matching.py +0 -0
  103. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/mcp/__init__.py +0 -0
  104. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/mcp/auth.py +0 -0
  105. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/mcp/catalog.py +0 -0
  106. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/mcp/catalog.toml +0 -0
  107. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/mcp/client.py +0 -0
  108. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/mcp/commands.py +0 -0
  109. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/mcp/config.py +0 -0
  110. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/mcp/http.py +0 -0
  111. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/mcp/manager.py +0 -0
  112. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/mcp/protocol.py +0 -0
  113. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/mcp/server.py +0 -0
  114. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/mcp/stdio.py +0 -0
  115. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/media.toml +0 -0
  116. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/media_catalog.py +0 -0
  117. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/media_cloud.py +0 -0
  118. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/memory.py +0 -0
  119. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/models.toml +0 -0
  120. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/modes.py +0 -0
  121. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/notify.py +0 -0
  122. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/ollama.py +0 -0
  123. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/permissions.py +0 -0
  124. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/planning.py +0 -0
  125. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/preview.py +0 -0
  126. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/render.py +0 -0
  127. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/repeats.py +0 -0
  128. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/repomap.py +0 -0
  129. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/review.py +0 -0
  130. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/sandbox.py +0 -0
  131. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/screenshots.py +0 -0
  132. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/secretscan.py +0 -0
  133. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/servers/__init__.py +0 -0
  134. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/servers/encord.py +0 -0
  135. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/servers/valohai.py +0 -0
  136. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/servers/xai.py +0 -0
  137. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/sessions.py +0 -0
  138. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/steer.py +0 -0
  139. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/subagents.py +0 -0
  140. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/tools.py +0 -0
  141. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/unreachable.py +0 -0
  142. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/update.py +0 -0
  143. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/vision.py +0 -0
  144. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/web.py +0 -0
  145. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/workflows/__init__.py +0 -0
  146. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/workflows/flux2-klein-4b-t2i.json +0 -0
  147. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/workflows/remove-background.json +0 -0
  148. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/workflows/smooth-film.json +0 -0
  149. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/workflows/sound-stable-audio.json +0 -0
  150. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/workflows/upscale-esrgan.json +0 -0
  151. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/workflows/upscale-video-esrgan.json +0 -0
  152. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/workflows/wan21-fun-camera.json +0 -0
  153. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/workflows/wan21-vace.json +0 -0
  154. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/workflows/wan22-fun-inp-5b.json +0 -0
  155. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/workflows/wan22-ti2v-5b.json +0 -0
  156. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/src/lcode/workflows/z-image-turbo-t2i.json +0 -0
  157. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/comfy_standin.py +0 -0
  158. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/fake_lsp_server.py +0 -0
  159. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/fake_mcp_server.py +0 -0
  160. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_acp.py +0 -0
  161. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_action.py +0 -0
  162. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_agent.py +0 -0
  163. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_api.py +0 -0
  164. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_assistant.py +0 -0
  165. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_backends.py +0 -0
  166. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_bench.py +0 -0
  167. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_catalog.py +0 -0
  168. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_checkpoints.py +0 -0
  169. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_checks.py +0 -0
  170. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_cli.py +0 -0
  171. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_clipboard.py +0 -0
  172. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_cloud.py +0 -0
  173. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_codesearch.py +0 -0
  174. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_config.py +0 -0
  175. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_context.py +0 -0
  176. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_context_picker.py +0 -0
  177. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_escalate.py +0 -0
  178. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_extensions.py +0 -0
  179. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_gitflow.py +0 -0
  180. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_hooks.py +0 -0
  181. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_image_edit.py +0 -0
  182. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_image_generate.py +0 -0
  183. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_jobs.py +0 -0
  184. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_look.py +0 -0
  185. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_lsp.py +0 -0
  186. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_matching.py +0 -0
  187. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_mcp.py +0 -0
  188. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_media_catalog.py +0 -0
  189. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_media_cloud.py +0 -0
  190. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_memory.py +0 -0
  191. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_model_picker.py +0 -0
  192. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_modes.py +0 -0
  193. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_permissions.py +0 -0
  194. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_plan_mode.py +0 -0
  195. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_repeats.py +0 -0
  196. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_repomap.py +0 -0
  197. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_residency.py +0 -0
  198. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_review.py +0 -0
  199. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_robustness.py +0 -0
  200. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_sandbox.py +0 -0
  201. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_screenshots.py +0 -0
  202. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_secretscan.py +0 -0
  203. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_servers.py +0 -0
  204. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_sessions.py +0 -0
  205. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_steer.py +0 -0
  206. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_stuck.py +0 -0
  207. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_subagents.py +0 -0
  208. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_tools.py +0 -0
  209. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_update.py +0 -0
  210. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_video.py +0 -0
  211. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_vision.py +0 -0
  212. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_web.py +0 -0
  213. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/tests/test_xai.py +0 -0
  214. {lcode_cli-0.49.0 → lcode_cli-0.49.1}/uv.lock +0 -0
@@ -6,6 +6,22 @@ All notable changes to lcode are documented here. The format follows
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.49.1] - 2026-10-26
10
+
11
+ ### Fixed
12
+
13
+ - **Image and video jobs no longer run out of GPU memory right after switching modes.** Switching
14
+ to video mode in the first half minute after lcode starts unloaded the coding model while it was
15
+ still loading; the load then finished and kept the GPU (10.8 GB of 12 here), and the next job
16
+ sent to ComfyUI ran out of memory. A load that ends outside code mode now unloads itself, a job
17
+ waits for a load still going, and unloading waits until Ollama has really freed the memory.
18
+ - **Running out of GPU memory says what holds it** (`Other programs hold GPU memory: obs
19
+ (1.6 GB)…`) instead of ComfyUI's whole error, and lcode starts its ComfyUI afresh: after running
20
+ out of memory ComfyUI crashed on the next job. A crash now says it was one, with the log's path,
21
+ instead of "ComfyUI closed the websocket".
22
+ - **A nearly full disk stops a job before it starts** (under 1 GB free), and ComfyUI's "No space
23
+ left on device" is said plainly: a film used to stop at shot 6 on it.
24
+
9
25
  ## [0.49.0] - 2026-10-24
10
26
 
11
27
  ### Added
@@ -1049,7 +1065,8 @@ First public release.
1049
1065
  - `AGENTS.md` project instructions and `/init` to generate them.
1050
1066
  - One-line installer for Linux and macOS.
1051
1067
 
1052
- [Unreleased]: https://github.com/nasser1941/lcode/compare/v0.49.0...HEAD
1068
+ [Unreleased]: https://github.com/nasser1941/lcode/compare/v0.49.1...HEAD
1069
+ [0.49.1]: https://github.com/nasser1941/lcode/compare/v0.49.0...v0.49.1
1053
1070
  [0.49.0]: https://github.com/nasser1941/lcode/compare/v0.48.0...v0.49.0
1054
1071
  [0.48.0]: https://github.com/nasser1941/lcode/compare/v0.47.0...v0.48.0
1055
1072
  [0.47.0]: https://github.com/nasser1941/lcode/compare/v0.46.0...v0.47.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: lcode-cli
3
- Version: 0.49.0
3
+ Version: 0.49.1
4
4
  Summary: A local-first terminal coding agent powered by open-weight models on your own GPU or Mac, via Ollama.
5
5
  Project-URL: Homepage, https://nasser1941.github.io/lcode/
6
6
  Project-URL: Documentation, https://nasser1941.github.io/lcode/
@@ -437,9 +437,16 @@ the [prompt assistant](#the-prompt-assistant) loads only while it writes. Image
437
437
  need the GPU to themselves:
438
438
 
439
439
  - **Into image or video mode:** lcode unloads its coding model from Ollama, and checks again
440
- before each image.
440
+ before each image. It waits until the memory is really free (Ollama lets go of it a moment after
441
+ it answers). If the coding model was still loading when you switched, as it is in the first half
442
+ minute after lcode starts, the job waits for that load to end and unloads it.
441
443
  - **Back to code mode:** lcode stops the ComfyUI it started, or asks yours to free its memory,
442
444
  then loads the coding model again in the background.
445
+ - **Other programs on the GPU** leave less room. When a job runs out of GPU memory, lcode names
446
+ what holds it (`obs (1.6 GB)`, `render.py (2.0 GB)`) and starts its ComfyUI afresh for the next request:
447
+ after running out of memory, ComfyUI can crash on the next job. If it crashes anyway, lcode says
448
+ so and points to its log (`comfyui.log` in lcode's state folder).
449
+ - **A nearly full disk** (under 1 GB free) stops a job before it starts, rather than at its end.
443
450
 
444
451
  The permission mode (`ask`, `plan`, `auto-edit`, `yolo`) is a different setting: `/permissions`
445
452
  sets it, and Shift+Tab cycles it as before.
@@ -12,7 +12,7 @@ lcode
12
12
 
13
13
  ```text
14
14
  ╭──────────────────────────────────────────────╮
15
- │ lcode v0.49.0 — local coding agent │
15
+ │ lcode v0.49.1 — local coding agent │
16
16
  │ │
17
17
  │ model lcode-qwen3.6-35b │
18
18
  │ context 256K tokens │
@@ -3,7 +3,7 @@
3
3
  From a program: `from lcode import Session` (see lcode.api).
4
4
  """
5
5
 
6
- __version__ = "0.49.0"
6
+ __version__ = "0.49.1"
7
7
 
8
8
  API = ("Session", "Result", "Options", "SetupError")
9
9
 
@@ -5,6 +5,7 @@ from __future__ import annotations
5
5
  import platform
6
6
  import subprocess
7
7
  from dataclasses import dataclass
8
+ from pathlib import Path
8
9
 
9
10
  GIB = 1024**3
10
11
 
@@ -46,6 +47,54 @@ def _run(cmd: list[str]) -> str:
46
47
  return ""
47
48
 
48
49
 
50
+ def gpu_used_gib() -> float | None:
51
+ """GPU memory in use on the NVIDIA GPUs, in GiB; None without nvidia-smi."""
52
+ out = _run(["nvidia-smi", "--query-gpu=memory.used", "--format=csv,noheader,nounits"])
53
+ try:
54
+ return sum(float(v) for v in out.split()) / 1024 if out else None
55
+ except ValueError:
56
+ return None
57
+
58
+
59
+ def gpu_users() -> list[tuple[str, float]]:
60
+ """The programs holding NVIDIA GPU memory, largest first: (a short name, GiB). Empty without nvidia-smi."""
61
+ out = _run(["nvidia-smi", "--query-compute-apps=pid,process_name,used_memory", "--format=csv,noheader,nounits"])
62
+ users: dict[str, float] = {}
63
+ for line in out.splitlines():
64
+ parts = [p.strip() for p in line.split(",")]
65
+ if len(parts) != 3:
66
+ continue
67
+ try:
68
+ gib = float(parts[2]) / 1024
69
+ except ValueError:
70
+ continue
71
+ name = program_name(parts[0], parts[1])
72
+ users[name] = users.get(name, 0.0) + gib
73
+ return sorted(users.items(), key=lambda item: -item[1])
74
+
75
+
76
+ def program_name(pid: str, process: str) -> str:
77
+ """A GPU program's short name, from its command line (/proc) or else nvidia-smi's process name."""
78
+ try:
79
+ argv = [a.decode(errors="replace") for a in Path(f"/proc/{pid}/cmdline").read_bytes().split(b"\0") if a]
80
+ except OSError:
81
+ argv = []
82
+ return name_from(argv or [process], process)
83
+
84
+
85
+ def name_from(argv: list[str], process: str = "") -> str:
86
+ """'render.py' for `python3 render.py`, 'ComfyUI' for its main.py, 'Ollama', else the program."""
87
+ program = Path(argv[0]).name if argv else process
88
+ if program.startswith("python") and len(argv) > 1:
89
+ script = next((a for a in argv[1:] if not a.startswith("-")), argv[1])
90
+ if Path(script).name == "main.py" and "comfyui" in " ".join(argv[:2]).lower():
91
+ return "ComfyUI"
92
+ return Path(script).name
93
+ if program in ("llama-server", "ollama") or "/ollama/" in (argv[0] if argv else ""):
94
+ return "Ollama"
95
+ return program or process
96
+
97
+
49
98
  def _linux_ram_gib() -> float:
50
99
  try:
51
100
  with open("/proc/meminfo") as f:
@@ -23,13 +23,18 @@ from typing import TYPE_CHECKING
23
23
  import requests
24
24
  from rich.text import Text
25
25
 
26
- from lcode import assistant, comfy, edits, imageopts, media_cloud, preview
26
+ from lcode import assistant, comfy, edits, hardware, imageopts, media_cloud, preview, residency
27
27
  from lcode import media_catalog as catalog
28
28
 
29
29
  if TYPE_CHECKING:
30
30
  from lcode.agent import Agent
31
31
 
32
32
  SOON: dict[str, str] = {}
33
+ LOAD_WAIT = 180 # seconds to wait for the coding model to finish loading before a job (it then unloads itself)
34
+ MIN_FREE_GB = 1.0 # disk space a job needs, where its results are saved
35
+ # how PyTorch and ComfyUI say the GPU is full
36
+ OUT_OF_MEMORY = ("out of memory", "outofmemory", "vram grow failed", "would exceed allowed memory",
37
+ "cudaerrormemoryallocation", "alloc_failed") # fmt: skip
33
38
  IGNORED = "# lcode's images and videos: not part of the project unless you add them\n*\n"
34
39
 
35
40
 
@@ -135,20 +140,24 @@ def stop_engine(agent: Agent) -> bool:
135
140
 
136
141
 
137
142
  def free_gpu(agent: Agent) -> None:
138
- """Unload lcode's coding model if Ollama still has it: the image or video model needs the GPU."""
143
+ """Unload lcode's coding model if Ollama still has it, and wait until its GPU memory is free: the image or video
144
+ model needs the GPU, and a job sent while Ollama is still letting go of it runs out of memory."""
139
145
  if getattr(agent.ollama, "kind", "ollama") != "ollama":
140
146
  return
147
+ if agent.load_state == "loading": # started in code mode: the load gives the GPU back when it's done
148
+ with agent.console.status(f"Waiting for {agent.settings.model} to finish loading, to unload it…"):
149
+ deadline = time.monotonic() + LOAD_WAIT
150
+ while agent.load_state == "loading" and time.monotonic() < deadline:
151
+ time.sleep(0.2)
141
152
  try:
142
- loaded = {name for m in agent.ollama.running() for name in (m.get("name"), m.get("model"))}
153
+ if not residency.placement(agent.ollama, agent.settings.model):
154
+ return
155
+ with agent.console.status(f"Unloading {agent.settings.model} to free the GPU…"):
156
+ freed = residency.release(agent.ollama, agent.settings.model)
143
157
  except Exception:
144
158
  return
145
- model = agent.settings.model
146
- if loaded & {model, f"{model}:latest"}:
147
- try:
148
- agent.ollama.unload(model)
149
- agent.say(f"Unloaded {model} to free the GPU.")
150
- except Exception:
151
- pass
159
+ if freed:
160
+ agent.say(f"Unloaded {agent.settings.model} to free the GPU.")
152
161
 
153
162
 
154
163
  # ----------------------------------------------------------------------------- where the files go
@@ -926,8 +935,9 @@ def describe_job(model, workflow, prompt, text, seed, values, options, files) ->
926
935
 
927
936
  def run_plan(agent: Agent, server: comfy.Server, plan: Plan, cancelled, label: str) -> Made:
928
937
  """Queue the plan, follow it, save what it made, number it, show it."""
929
- free_gpu(agent)
930
938
  out = folder(agent)
939
+ check_disk(agent, out)
940
+ free_gpu(agent)
931
941
  stem = plan.stem or f"{time.strftime('%Y%m%d-%H%M%S')}-{comfy.slug(plan.prompt)}"
932
942
  hint = "Esc or Ctrl+C cancels" if agent.interactive else ""
933
943
  line = Line(f"{plan.model.name} ({label})" if label else plan.model.name, hint)
@@ -958,7 +968,7 @@ def run_plan(agent: Agent, server: comfy.Server, plan: Plan, cancelled, label: s
958
968
  except comfy.ComfyError as e:
959
969
  if job["id"]:
960
970
  comfy.forget(job["id"])
961
- raise MediaError(str(e)) from e
971
+ raise MediaError(explain(agent, str(e))) from e
962
972
  try:
963
973
  saved = comfy.save(server, outputs, out, stem, {**plan.meta, "comfyui_prompt_id": prompt_id})
964
974
  except (comfy.ComfyError, OSError) as e:
@@ -981,6 +991,55 @@ def run_plan(agent: Agent, server: comfy.Server, plan: Plan, cancelled, label: s
981
991
  return made
982
992
 
983
993
 
994
+ def check_disk(agent: Agent, out: Path) -> None:
995
+ """Refuse a job when the disk it saves to is nearly full: ComfyUI fails at the end of it otherwise."""
996
+ places = [out]
997
+ install = comfy.find_install(agent.settings.comfyui_path) if agent.comfy_process is not None else None
998
+ if install is not None:
999
+ places.append(install.path) # ComfyUI writes there first
1000
+ for place in places:
1001
+ try:
1002
+ free = shutil.disk_usage(place).free / 1e9
1003
+ except OSError:
1004
+ continue
1005
+ if free < MIN_FREE_GB:
1006
+ raise MediaError(
1007
+ f"The disk is nearly full ({free:.1f} GB free at {place}): images and videos need room. Free some "
1008
+ "space, then try again."
1009
+ )
1010
+
1011
+
1012
+ def explain(agent: Agent, error: str) -> str:
1013
+ """ComfyUI's error, said so it can be acted on: running out of GPU memory or disk space, or a crash."""
1014
+ low = error.lower()
1015
+ if any(words in low for words in OUT_OF_MEMORY):
1016
+ step = error.split(" failed:", 1)[0] if " failed:" in error else "a step"
1017
+ others = [(name, gib) for name, gib in hardware.gpu_users() if name != "ComfyUI" and gib >= 0.1]
1018
+ held = ", ".join(f"{name} ({gib:.1f} GB)" for name, gib in others)
1019
+ message = f"The GPU ran out of memory ({step})."
1020
+ if held:
1021
+ message += f" Other programs hold GPU memory: {held}. Close what you can, or try"
1022
+ else:
1023
+ message += " Try"
1024
+ message += " --quality fast or a smaller model (/models)."
1025
+ if stop_engine(agent): # after running out of memory ComfyUI can crash on its next job: start it afresh
1026
+ message += " lcode restarts ComfyUI with your next request."
1027
+ else:
1028
+ message += " Restart your ComfyUI if it keeps failing."
1029
+ return message
1030
+ if "no space left on device" in low:
1031
+ return "ComfyUI couldn't save what it made: the disk is full. Free some space, then try again."
1032
+ if "closed the websocket" in low or "connection" in low:
1033
+ proc = agent.comfy_process
1034
+ if proc is not None and proc.poll() is not None:
1035
+ agent.comfy_process = None
1036
+ return (
1037
+ f"ComfyUI stopped while it worked (it crashed; its log: {comfy.log_path()}). lcode starts it again "
1038
+ "with your next request."
1039
+ )
1040
+ return error
1041
+
1042
+
984
1043
  # ----------------------------------------------------------------------------- results: numbered, shown, opened
985
1044
 
986
1045
 
@@ -1737,6 +1737,8 @@ def preload(agent: Agent, session: PromptSession | None = None) -> None:
1737
1737
  refresh()
1738
1738
  try:
1739
1739
  agent.ollama.load(agent.settings.model, agent.options(), agent.settings.keep_alive)
1740
+ if agent.settings.mode != "code": # switched to image or video mode while it loaded: give the GPU back
1741
+ residency.release(agent.ollama, agent.settings.model)
1740
1742
  except OllamaError:
1741
1743
  pass
1742
1744
  finally:
@@ -19,6 +19,7 @@ from lcode.cloud import is_cloud
19
19
  from lcode.ollama import OllamaError
20
20
 
21
21
  GB = 1e9
22
+ RELEASE_WAIT = 15.0 # seconds to wait for Ollama to give an unloaded model's GPU memory back
22
23
  SPLIT_WARNING = 0.95 # a dense model with less than this on the GPU runs much slower
23
24
  SHORTFALL = 0.25 # this much less on the GPU than expected: something else is using GPU memory
24
25
 
@@ -69,6 +70,38 @@ def loaded(ollama, model: str | None = None) -> list[Placement]:
69
70
  return found
70
71
 
71
72
 
73
+ def release(ollama, model: str, wait: float | None = None) -> bool:
74
+ """Unload a model and wait until its GPU memory is free again; whether it was loaded.
75
+
76
+ Ollama answers the unload at once and frees the memory a moment later: a program that starts on the GPU in
77
+ that moment finds it still full. So this waits until Ollama no longer lists the model and, on NVIDIA GPUs, until
78
+ most of what it held shows as free.
79
+ """
80
+ from lcode import hardware
81
+
82
+ held = loaded(ollama, model)
83
+ if not held:
84
+ return False
85
+ before = hardware.gpu_used_gib()
86
+ ollama.unload(model)
87
+ deadline = time.monotonic() + (RELEASE_WAIT if wait is None else wait)
88
+ while loaded(ollama, model) and time.monotonic() < deadline:
89
+ time.sleep(0.2)
90
+ if before is not None: # NVIDIA: until most of it is free, or the memory stops going down for a second
91
+ target = before - 0.75 * sum(p.vram for p in held) / 2**30
92
+ last, steady = before, time.monotonic()
93
+ while time.monotonic() < deadline:
94
+ used = hardware.gpu_used_gib()
95
+ if used is None or used <= target:
96
+ break
97
+ if abs(used - last) > 0.1:
98
+ last, steady = used, time.monotonic()
99
+ elif time.monotonic() - steady >= 1.0 and used < before - 0.1:
100
+ break
101
+ time.sleep(0.2)
102
+ return True
103
+
104
+
72
105
  def placement(ollama, model: str) -> Placement | None:
73
106
  found = loaded(ollama, model)
74
107
  return found[0] if found else None
@@ -79,6 +79,9 @@ def isolated_state(tmp_path_factory, monkeypatch):
79
79
  monkeypatch.setattr("lcode.config.STATE_DIR", tmp_path_factory.mktemp("lcode-state"))
80
80
  monkeypatch.setattr("lcode.comfy.CANDIDATES", ())
81
81
  monkeypatch.setattr("lcode.comfy.cli_workspace", lambda: None)
82
+ monkeypatch.setattr("lcode.hardware.gpu_used_gib", lambda: None) # never this machine's GPU
83
+ monkeypatch.setattr("lcode.hardware.gpu_users", lambda: [])
84
+ monkeypatch.setattr("lcode.residency.RELEASE_WAIT", 0.0) # FakeOllama keeps listing what it unloaded
82
85
 
83
86
  def no_launch(*args, **kwargs):
84
87
  raise AssertionError("a test tried to start a real ComfyUI")
@@ -116,8 +116,10 @@ def test_esc_cancels_the_job_in_comfyui_too(image_agent, standin):
116
116
 
117
117
 
118
118
  def test_a_failed_job_says_which_node_and_why(image_agent, standin):
119
- standin.fail = "CUDA out of memory. Tried to allocate 2.00 GiB"
120
- with pytest.raises(media.MediaError, match="SamplerCustomAdvanced failed: CUDA out of memory"):
119
+ standin.fail = "mat1 and mat2 shapes cannot be multiplied (77x768 and 2048x3072)"
120
+ with pytest.raises(
121
+ media.MediaError, match=r"SamplerCustomAdvanced failed: mat1 and mat2 shapes cannot be multiplied"
122
+ ):
121
123
  media.generate_image(image_agent, "a fox")
122
124
  assert comfy._read_jobs() == {}
123
125
 
@@ -50,8 +50,11 @@ def agent(make_agent, standin, monkeypatch):
50
50
  agent.interactive = False
51
51
  monkeypatch.setattr(agent.ollama, "installed_names", lambda: {"qwen3.5:4b"})
52
52
  joined = []
53
+ real_run = subprocess.run
53
54
 
54
- def ffmpeg(command, **kwargs):
55
+ def ffmpeg(command, **kwargs): # subprocess.run for everyone: only ffmpeg is stubbed
56
+ if not str(command[0]).endswith("ffmpeg"):
57
+ return real_run(command, **kwargs)
55
58
  joined.append(command)
56
59
  film.Path(command[-1]).write_bytes(b"\x00\x00\x00\x18ftypmp42 a film")
57
60
  return subprocess.CompletedProcess(command, 0, "", "")
@@ -0,0 +1,156 @@
1
+ """Handing the GPU from the coding model to ComfyUI: unloading waits until the memory is free, a load still going when
2
+ you leave code mode gives the GPU back, and running out of GPU memory or disk, or a crash, is said plainly."""
3
+
4
+ import threading
5
+ import time
6
+ from collections import namedtuple
7
+
8
+ import pytest
9
+
10
+ from comfy_standin import StandIn
11
+ from lcode import comfy, hardware, media, residency
12
+ from lcode.repl import preload
13
+
14
+ MODEL = "lcode-qwen3.6-35b"
15
+
16
+
17
+ class Ollama:
18
+ """Ollama as far as unloading goes: it stops listing a model a few polls after the unload."""
19
+
20
+ kind = "ollama"
21
+
22
+ def __init__(self, polls_until_gone=3):
23
+ self.loaded = [{"name": f"{MODEL}:latest", "size": 11e9, "size_vram": 10.5 * 2**30}]
24
+ self.unloaded, self.polls_until_gone, self.polls = [], polls_until_gone, 0
25
+
26
+ def running(self):
27
+ if self.unloaded:
28
+ self.polls += 1
29
+ if self.polls >= self.polls_until_gone:
30
+ self.loaded = []
31
+ return self.loaded
32
+
33
+ def unload(self, model):
34
+ self.unloaded.append(model)
35
+
36
+
37
+ def gpu_readings(monkeypatch, values):
38
+ """nvidia-smi's memory in use, one value per call (the last one repeats)."""
39
+ readings = list(values)
40
+ calls = []
41
+
42
+ def used():
43
+ calls.append(readings[0] if len(readings) == 1 else readings.pop(0))
44
+ return calls[-1]
45
+
46
+ monkeypatch.setattr(hardware, "gpu_used_gib", used)
47
+ return calls
48
+
49
+
50
+ def test_unloading_waits_until_the_memory_is_free(monkeypatch):
51
+ calls = gpu_readings(monkeypatch, [11.0, 11.0, 11.0, 10.9, 0.6])
52
+ ollama = Ollama()
53
+ assert residency.release(ollama, MODEL, wait=5) is True
54
+ assert ollama.unloaded == [MODEL] and ollama.loaded == [] and calls[-1] == 0.6
55
+ assert residency.release(Ollama(), "another-model", wait=5) is False # not loaded: nothing to do
56
+
57
+
58
+ def test_unloading_stops_waiting_when_the_memory_stops_going_down(monkeypatch):
59
+ gpu_readings(monkeypatch, [11.0, 6.0]) # another program keeps part of it: no point waiting the whole time
60
+ started = time.monotonic()
61
+ assert residency.release(Ollama(polls_until_gone=1), MODEL, wait=10) is True
62
+ assert 0.9 < time.monotonic() - started < 4
63
+
64
+
65
+ def test_a_job_waits_for_the_coding_model_still_loading(make_agent, monkeypatch):
66
+ agent = make_agent()
67
+ agent.ollama.loaded = []
68
+ agent.load_state = "loading"
69
+ threading.Timer(0.4, lambda: setattr(agent, "load_state", "")).start()
70
+ started = time.monotonic()
71
+ media.free_gpu(agent)
72
+ assert time.monotonic() - started >= 0.35
73
+
74
+
75
+ def test_a_load_that_ends_after_leaving_code_mode_gives_the_gpu_back(make_agent):
76
+ agent = make_agent()
77
+ agent.ollama.loaded = []
78
+ go = threading.Event()
79
+
80
+ def slow_load(model, options, keep_alive): # the 35B at 256K takes half a minute
81
+ go.wait(5)
82
+ agent.ollama.loaded = [{"name": f"{model}:latest", "size": 11e9, "size_vram": 11e9}]
83
+
84
+ agent.ollama.load = slow_load
85
+ preload(agent)
86
+ assert agent.load_state == "loading"
87
+ agent.settings.mode = "video" # /mode video before it's loaded
88
+ go.set()
89
+ deadline = time.monotonic() + 5
90
+ while agent.load_state and time.monotonic() < deadline:
91
+ time.sleep(0.05)
92
+ assert agent.ollama.unloaded == [MODEL]
93
+
94
+
95
+ class Process:
96
+ """A ComfyUI lcode started: running, or ended with `code`."""
97
+
98
+ def __init__(self, code=None):
99
+ self.code, self.pid = code, 0
100
+
101
+ def poll(self):
102
+ return self.code
103
+
104
+
105
+ @pytest.fixture
106
+ def agent(make_agent):
107
+ with StandIn() as server:
108
+ agent = make_agent(comfyui_url=server.url)
109
+ agent.settings.mode = "image"
110
+ agent.interactive = False
111
+ agent.standin = server
112
+ yield agent
113
+
114
+
115
+ def test_running_out_of_gpu_memory_says_what_holds_it(agent, monkeypatch):
116
+ stopped = []
117
+ monkeypatch.setattr(comfy, "stop", stopped.append)
118
+ agent.comfy_process = Process()
119
+ monkeypatch.setattr(hardware, "gpu_users", lambda: [("Ollama", 10.5), ("render.py", 1.6), ("ComfyUI", 0.03)])
120
+ agent.standin.fail = "Allocation on device 0 would exceed allowed memory. (out of memory)"
121
+ with pytest.raises(media.MediaError) as e:
122
+ media.generate_image(agent, "a fox")
123
+ assert str(e.value) == (
124
+ "The GPU ran out of memory (SamplerCustomAdvanced). Other programs hold GPU memory: Ollama (10.5 GB), "
125
+ "render.py (1.6 GB). Close what you can, or try --quality fast or a smaller model (/models). "
126
+ "lcode restarts ComfyUI with your next request."
127
+ )
128
+ assert stopped and agent.comfy_process is None # started afresh next time: it can crash after running out
129
+
130
+
131
+ def test_a_crash_and_a_full_disk_are_said_plainly(agent, monkeypatch):
132
+ agent.comfy_process = Process(code=-6) # aborted
133
+ message = media.explain(agent, "ComfyUI closed the websocket")
134
+ assert message.startswith("ComfyUI stopped while it worked (it crashed; its log: ")
135
+ assert message.endswith("lcode starts it again with your next request.") and agent.comfy_process is None
136
+ assert media.explain(agent, "SaveImage failed: [Errno 28] No space left on device").startswith(
137
+ "ComfyUI couldn't save what it made: the disk is full."
138
+ )
139
+ assert media.explain(agent, "KSampler failed: bad input") == "KSampler failed: bad input"
140
+ vram = media.explain(agent, "CLIPTextEncode failed: VRAM grow failed: 777912320 bytes") # ComfyUI 0.38's words
141
+ assert vram.startswith("The GPU ran out of memory (CLIPTextEncode).")
142
+ Usage = namedtuple("Usage", "total used free")
143
+ monkeypatch.setattr(media.shutil, "disk_usage", lambda path: Usage(500e9, 499.7e9, 0.3e9))
144
+ with pytest.raises(media.MediaError, match=r"The disk is nearly full \(0\.3 GB free at "):
145
+ media.generate_image(agent, "a fox")
146
+ assert agent.standin.prompts == [] # refused before ComfyUI got it
147
+
148
+
149
+ def test_programs_on_the_gpu_have_short_names():
150
+ comfy_python = "/home/u/comfy/ComfyUI/.venv/bin/python"
151
+ assert hardware.name_from([comfy_python, "main.py", "--port", "8188"]) == "ComfyUI"
152
+ assert hardware.name_from([comfy_python, "/tmp/hog.py", "11"]) == "hog.py" # ComfyUI's Python, another script
153
+ assert hardware.name_from(["python3", "-u", "render.py"]) == "render.py"
154
+ assert hardware.name_from(["/usr/lib/ollama/llama-server", "--model", "x"]) == "Ollama"
155
+ assert hardware.name_from(["/usr/bin/ffmpeg", "-i", "a.mp4"]) == "ffmpeg"
156
+ assert hardware.program_name("999999999", "/usr/bin/python3") == "python3" # gone: nvidia-smi's name
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes