diffusers-workflow 0.4.0a3__py3-none-any.whl
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.
- diffusers_workflow-0.4.0a3.dist-info/METADATA +310 -0
- diffusers_workflow-0.4.0a3.dist-info/RECORD +171 -0
- diffusers_workflow-0.4.0a3.dist-info/WHEEL +5 -0
- diffusers_workflow-0.4.0a3.dist-info/entry_points.txt +6 -0
- diffusers_workflow-0.4.0a3.dist-info/licenses/LICENSE +201 -0
- diffusers_workflow-0.4.0a3.dist-info/top_level.txt +1 -0
- dw/__init__.py +353 -0
- dw/arguments.py +906 -0
- dw/cache_blocks.json +16 -0
- dw/cache_blocks.py +145 -0
- dw/community_pipelines/pipeline_flux_rf_inversion.py +1184 -0
- dw/events.py +78 -0
- dw/hub_cache.py +289 -0
- dw/introspection.py +458 -0
- dw/log_setup.py +45 -0
- dw/pipeline_processors/chain.py +750 -0
- dw/pipeline_processors/config_objects.py +235 -0
- dw/pipeline_processors/pipeline.py +1687 -0
- dw/pipeline_processors/remote.py +18 -0
- dw/previous_results.py +259 -0
- dw/prompt_weighting.py +378 -0
- dw/repl.py +298 -0
- dw/repl_commands.py +808 -0
- dw/repl_worker.py +129 -0
- dw/result.py +850 -0
- dw/run.py +92 -0
- dw/schema.py +24 -0
- dw/security.py +379 -0
- dw/serve.py +70 -0
- dw/server/__init__.py +2 -0
- dw/server/app.py +588 -0
- dw/server/jobs.py +547 -0
- dw/server/ui/assets/abap-08VXUWAP.js +1 -0
- dw/server/ui/assets/apex-BWPQTe0t.js +1 -0
- dw/server/ui/assets/azcli-Bc_sGQ0U.js +1 -0
- dw/server/ui/assets/bat-i0X4ZdIN.js +1 -0
- dw/server/ui/assets/bicep-B5-_aFwp.js +2 -0
- dw/server/ui/assets/cameligo-DMUM7wLl.js +1 -0
- dw/server/ui/assets/clojure-Cm7r79vr.js +1 -0
- dw/server/ui/assets/codicon-Brq4_Ui5.ttf +0 -0
- dw/server/ui/assets/coffee-Ba7i2nA0.js +1 -0
- dw/server/ui/assets/cpp-C7h46wYY.js +1 -0
- dw/server/ui/assets/csharp-BKxtCVv1.js +1 -0
- dw/server/ui/assets/csp-bTuwJoIa.js +1 -0
- dw/server/ui/assets/css-DIMkf-bt.js +3 -0
- dw/server/ui/assets/css.worker-B3ciXF_0.js +93 -0
- dw/server/ui/assets/cssMode-CEh6hWi2.js +1 -0
- dw/server/ui/assets/cypher-CVaqCwHa.js +1 -0
- dw/server/ui/assets/dart-onAF5SnQ.js +1 -0
- dw/server/ui/assets/dockerfile-DZFCIeNp.js +1 -0
- dw/server/ui/assets/ecl-D05T4iGw.js +1 -0
- dw/server/ui/assets/editor-jjEx9u7D.css +1 -0
- dw/server/ui/assets/editor.api-CExg3_mM.js +847 -0
- dw/server/ui/assets/editor.worker-q-txB4vs.js +30 -0
- dw/server/ui/assets/elixir-6RTg0lbw.js +1 -0
- dw/server/ui/assets/flow9-C5_-GSwl.js +1 -0
- dw/server/ui/assets/freemarker2-DH6orYh2.js +3 -0
- dw/server/ui/assets/fsharp-C8Ef5oNN.js +1 -0
- dw/server/ui/assets/go-C-y9NEjX.js +1 -0
- dw/server/ui/assets/graphql-fmXr3nnJ.js +1 -0
- dw/server/ui/assets/handlebars-CbrMVW4Q.js +1 -0
- dw/server/ui/assets/hcl-CpzslTdj.js +1 -0
- dw/server/ui/assets/html-YDNPZw2M.js +1 -0
- dw/server/ui/assets/html.worker-C93Ht9o9.js +506 -0
- dw/server/ui/assets/htmlMode-B_zSGWO2.js +1 -0
- dw/server/ui/assets/index-B7-VcYS-.css +1 -0
- dw/server/ui/assets/index-D_EiPU3b.js +13 -0
- dw/server/ui/assets/ini-sBoK_t0W.js +1 -0
- dw/server/ui/assets/java-BEtHBSE6.js +1 -0
- dw/server/ui/assets/javascript-dYuBvioq.js +1 -0
- dw/server/ui/assets/json.worker-B2V3pomh.js +62 -0
- dw/server/ui/assets/jsonMode-CUqLM39V.js +7 -0
- dw/server/ui/assets/julia-Bri6UV-V.js +1 -0
- dw/server/ui/assets/kotlin-BOotOW0E.js +1 -0
- dw/server/ui/assets/less-B9JPFI3C.js +2 -0
- dw/server/ui/assets/lexon-CfSJPG6W.js +1 -0
- dw/server/ui/assets/liquid-D6vxBzMv.js +1 -0
- dw/server/ui/assets/lspLanguageFeatures-1WJ2palX.js +4 -0
- dw/server/ui/assets/lua-CsQS60Ue.js +1 -0
- dw/server/ui/assets/m3-D-oSqn_W.js +1 -0
- dw/server/ui/assets/markdown-Cimd5fb3.js +1 -0
- dw/server/ui/assets/mdx-SHQb6vmD.js +1 -0
- dw/server/ui/assets/mips-CIPQ_RoX.js +1 -0
- dw/server/ui/assets/monaco--ixms01u.css +1 -0
- dw/server/ui/assets/monaco-CP-s5rcP.js +56 -0
- dw/server/ui/assets/msdax-DauUninz.js +1 -0
- dw/server/ui/assets/mysql-SOo6toE5.js +1 -0
- dw/server/ui/assets/objective-c-FvmIjYaQ.js +1 -0
- dw/server/ui/assets/pascal-DrH0SRf2.js +1 -0
- dw/server/ui/assets/pascaligo-D-ptJ9y-.js +1 -0
- dw/server/ui/assets/perl-oz_6vUea.js +1 -0
- dw/server/ui/assets/pgsql-DTj74zXo.js +1 -0
- dw/server/ui/assets/php-nr791fC2.js +1 -0
- dw/server/ui/assets/pla-CopQ2nXW.js +1 -0
- dw/server/ui/assets/postiats-43DmfD33.js +1 -0
- dw/server/ui/assets/powerquery-D3hlyOfw.js +1 -0
- dw/server/ui/assets/powershell-DmHpPYUd.js +1 -0
- dw/server/ui/assets/protobuf-C531GsRP.js +2 -0
- dw/server/ui/assets/pug-Z5eAx3Zn.js +1 -0
- dw/server/ui/assets/python-x0_EGHq9.js +1 -0
- dw/server/ui/assets/qsharp-DkqhCAOL.js +1 -0
- dw/server/ui/assets/r-BwWrilGY.js +1 -0
- dw/server/ui/assets/razor-BZC4LQDP.js +1 -0
- dw/server/ui/assets/redis-ClamHrr6.js +1 -0
- dw/server/ui/assets/redshift-DT7zqm-g.js +1 -0
- dw/server/ui/assets/restructuredtext-BYgofb2h.js +1 -0
- dw/server/ui/assets/ruby-DezsRK8O.js +1 -0
- dw/server/ui/assets/rust-DdL9SqIa.js +1 -0
- dw/server/ui/assets/sb-CcwsVR0C.js +1 -0
- dw/server/ui/assets/scala-DHpiXF5c.js +1 -0
- dw/server/ui/assets/scheme-BeGwcela.js +1 -0
- dw/server/ui/assets/scss-gp-XZpBa.js +3 -0
- dw/server/ui/assets/shell-CC2rA5mh.js +1 -0
- dw/server/ui/assets/solidity-BEEn4gHE.js +1 -0
- dw/server/ui/assets/sophia-CRfGWb83.js +1 -0
- dw/server/ui/assets/sparql-D_Lu-MrJ.js +1 -0
- dw/server/ui/assets/sql-NEE52Syq.js +1 -0
- dw/server/ui/assets/st-DbInun42.js +1 -0
- dw/server/ui/assets/swift-Bxkupp3x.js +1 -0
- dw/server/ui/assets/systemverilog-Bz4Y3fRF.js +1 -0
- dw/server/ui/assets/tcl-DISqw1ZD.js +1 -0
- dw/server/ui/assets/ts.worker-D7T1-Ig5.js +67738 -0
- dw/server/ui/assets/tsMode-BTfA6SbD.js +11 -0
- dw/server/ui/assets/twig-De2hgUGE.js +1 -0
- dw/server/ui/assets/typescript-CWA4MsNk.js +1 -0
- dw/server/ui/assets/typespec-B8J7ngcE.js +1 -0
- dw/server/ui/assets/vb-DV3o63ZY.js +1 -0
- dw/server/ui/assets/wgsl-DpFanUEy.js +298 -0
- dw/server/ui/assets/workers-CWU0uvj5.js +1 -0
- dw/server/ui/assets/xml-KmfTm3rg.js +1 -0
- dw/server/ui/assets/yaml-nFO_dDS6.js +1 -0
- dw/server/ui/index.html +17 -0
- dw/settings.py +77 -0
- dw/step.py +132 -0
- dw/tasks/audio_utils.py +266 -0
- dw/tasks/background_remover.py +43 -0
- dw/tasks/borders.py +113 -0
- dw/tasks/concat_videos.py +80 -0
- dw/tasks/depth_estimator.py +54 -0
- dw/tasks/diffusion_upscale.py +109 -0
- dw/tasks/format_messages.py +24 -0
- dw/tasks/gather.py +139 -0
- dw/tasks/image_to_text.py +43 -0
- dw/tasks/image_utils.py +661 -0
- dw/tasks/interpolate_frames.py +227 -0
- dw/tasks/model_cache.py +39 -0
- dw/tasks/pair_audio.py +58 -0
- dw/tasks/qr_code.py +19 -0
- dw/tasks/restore_faces.py +175 -0
- dw/tasks/rife_model.py +192 -0
- dw/tasks/segment.py +121 -0
- dw/tasks/task.py +474 -0
- dw/tasks/tensor_image.py +57 -0
- dw/tasks/text_generation.py +168 -0
- dw/tasks/text_sections.py +80 -0
- dw/tasks/upscale.py +203 -0
- dw/tasks/video_utils.py +154 -0
- dw/tasks/zoe_depth.py +71 -0
- dw/teacache.py +376 -0
- dw/teacache_models.json +99 -0
- dw/test.py +29 -0
- dw/type_helpers.py +68 -0
- dw/validate.py +43 -0
- dw/variables.py +153 -0
- dw/worker.py +517 -0
- dw/workflow.py +553 -0
- dw/workflow_schema.json +1157 -0
- dw/workflows/augment_prompt.json +65 -0
- dw/workflows/describe_image.json +58 -0
- dw/workflows/h3_context_ir.json +57 -0
- dw/workflows/test.json +31 -0
dw/repl.py
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Interactive REPL for Diffusers Workflow.
|
|
3
|
+
|
|
4
|
+
Main entry point for the REPL interface. Delegates command handling
|
|
5
|
+
to specialized command classes and worker management to WorkerManager.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import cmd
|
|
9
|
+
import sys
|
|
10
|
+
import argparse
|
|
11
|
+
import difflib
|
|
12
|
+
import logging
|
|
13
|
+
import os
|
|
14
|
+
import multiprocessing
|
|
15
|
+
from . import startup
|
|
16
|
+
from .repl_worker import WorkerManager
|
|
17
|
+
from .repl_commands import (
|
|
18
|
+
ConfigCommands,
|
|
19
|
+
ArgCommands,
|
|
20
|
+
MemoryCommands,
|
|
21
|
+
WorkflowCommands,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
# CRITICAL: Set multiprocessing start method to 'spawn' for CUDA compatibility
|
|
25
|
+
# Must be done before any multiprocessing operations
|
|
26
|
+
if multiprocessing.get_start_method(allow_none=True) != "spawn":
|
|
27
|
+
try:
|
|
28
|
+
multiprocessing.set_start_method("spawn", force=True)
|
|
29
|
+
except RuntimeError:
|
|
30
|
+
# Already set, ignore
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
logger = logging.getLogger("dw")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class DiffusersWorkflowREPL(cmd.Cmd):
|
|
37
|
+
"""Interactive command line interface for Diffusers Workflow"""
|
|
38
|
+
|
|
39
|
+
intro = (
|
|
40
|
+
"Welcome to the Diffusers Workflow REPL.\n"
|
|
41
|
+
" 'workflow list' shows available workflows, 'help' gets you oriented.\n"
|
|
42
|
+
)
|
|
43
|
+
prompt = "dw> "
|
|
44
|
+
use_rawinput = True # Ensure we're using raw_input for command reading
|
|
45
|
+
|
|
46
|
+
def __init__(self):
|
|
47
|
+
# Initialize cmd.Cmd first, before setting up our globals
|
|
48
|
+
cmd.Cmd.__init__(self)
|
|
49
|
+
# Initialize globals dictionary with default values
|
|
50
|
+
self.globals = {
|
|
51
|
+
"output_dir": "./outputs", # Default output directory
|
|
52
|
+
"log_level": "INFO", # Default log level
|
|
53
|
+
"workflow_dir": "./examples", # Default workflow directory
|
|
54
|
+
}
|
|
55
|
+
self.current_workflow = None
|
|
56
|
+
self.workflow_args = {} # Store workflow arguments
|
|
57
|
+
|
|
58
|
+
# Initialize worker manager
|
|
59
|
+
self.worker_manager = WorkerManager()
|
|
60
|
+
|
|
61
|
+
# Initialize command handlers
|
|
62
|
+
self.config_commands = ConfigCommands(self)
|
|
63
|
+
self.arg_commands = ArgCommands(self)
|
|
64
|
+
self.memory_commands = MemoryCommands(self)
|
|
65
|
+
self.workflow_commands = WorkflowCommands(self)
|
|
66
|
+
|
|
67
|
+
def preloop(self):
|
|
68
|
+
"""Hook method executed once when cmdloop() is called."""
|
|
69
|
+
try:
|
|
70
|
+
import readline
|
|
71
|
+
|
|
72
|
+
history_file = os.path.expanduser("~/.dw_history")
|
|
73
|
+
readline.read_history_file(history_file)
|
|
74
|
+
except (ImportError, FileNotFoundError):
|
|
75
|
+
pass
|
|
76
|
+
|
|
77
|
+
def postloop(self):
|
|
78
|
+
"""Hook method executed once when cmdloop() is about to return."""
|
|
79
|
+
try:
|
|
80
|
+
import readline
|
|
81
|
+
|
|
82
|
+
history_file = os.path.expanduser("~/.dw_history")
|
|
83
|
+
readline.write_history_file(history_file)
|
|
84
|
+
except (ImportError, FileNotFoundError):
|
|
85
|
+
pass
|
|
86
|
+
|
|
87
|
+
def emptyline(self):
|
|
88
|
+
"""Override emptyline to do nothing instead of repeating last command."""
|
|
89
|
+
pass
|
|
90
|
+
|
|
91
|
+
# Group commands whose detailed help lives in the group handler - 'help
|
|
92
|
+
# workflow' and 'workflow ?' must tell the same story
|
|
93
|
+
COMMAND_GROUPS = ("workflow", "arg", "memory", "config")
|
|
94
|
+
|
|
95
|
+
def do_help(self, arg):
|
|
96
|
+
"""List available commands with "help" or detailed help with "help cmd"."""
|
|
97
|
+
if not arg:
|
|
98
|
+
print("\nDiffusers Workflow REPL")
|
|
99
|
+
print("=" * 60)
|
|
100
|
+
print("\nTypical session:")
|
|
101
|
+
print(" workflow list See available workflows")
|
|
102
|
+
print(" workflow load FluxDev Load one (validated immediately)")
|
|
103
|
+
print(" arg show See its variables and defaults")
|
|
104
|
+
print(' arg set prompt="a cat" Override a variable')
|
|
105
|
+
print(" workflow run Run it")
|
|
106
|
+
print(" workflow run steps=30 Set arguments and run in one line")
|
|
107
|
+
print("\nModels stay loaded in a worker process between runs, so the")
|
|
108
|
+
print("second run of a workflow skips straight to inference.")
|
|
109
|
+
print("\nCommand groups ('help <group>' or '<group> ?' for details):")
|
|
110
|
+
print(" workflow - list, load, reload, status, run, restart")
|
|
111
|
+
print(" arg - show, set, clear")
|
|
112
|
+
print(" memory - show, clear")
|
|
113
|
+
print(" config - show, set")
|
|
114
|
+
print("\nShortcuts:")
|
|
115
|
+
print(" run [<name>=<value> ...] same as 'workflow run'")
|
|
116
|
+
print(" load <name> same as 'workflow load'")
|
|
117
|
+
print(" set <name>=<value> same as 'arg set'")
|
|
118
|
+
print(" <TAB> completes commands, workflow names,")
|
|
119
|
+
print(" and argument names")
|
|
120
|
+
print("\nWhile a workflow runs:")
|
|
121
|
+
print(" Progress prints per step and per denoise step. Ctrl+C cancels")
|
|
122
|
+
print(" the run (models stay cached); a second Ctrl+C stops the worker.")
|
|
123
|
+
print("\n'exit' or 'quit' leaves the REPL.")
|
|
124
|
+
print()
|
|
125
|
+
elif arg.strip() in self.COMMAND_GROUPS:
|
|
126
|
+
# Route to the group's own help so there is one source of truth
|
|
127
|
+
getattr(self, f"do_{arg.strip()}")("?")
|
|
128
|
+
else:
|
|
129
|
+
super().do_help(arg)
|
|
130
|
+
|
|
131
|
+
def do_exit(self, arg):
|
|
132
|
+
"""Exit the REPL"""
|
|
133
|
+
self.worker_manager.shutdown_worker()
|
|
134
|
+
print("Goodbye!")
|
|
135
|
+
return True
|
|
136
|
+
|
|
137
|
+
def do_quit(self, arg):
|
|
138
|
+
"""Exit the REPL (alias for exit)"""
|
|
139
|
+
return self.do_exit(arg)
|
|
140
|
+
|
|
141
|
+
# ========================================================================
|
|
142
|
+
# Command delegation to specialized handlers
|
|
143
|
+
# ========================================================================
|
|
144
|
+
|
|
145
|
+
def do_config(self, arg):
|
|
146
|
+
"""Configure global settings."""
|
|
147
|
+
self.config_commands.do_config(arg)
|
|
148
|
+
|
|
149
|
+
def do_arg(self, arg):
|
|
150
|
+
"""Manage workflow arguments."""
|
|
151
|
+
self.arg_commands.do_arg(arg)
|
|
152
|
+
|
|
153
|
+
def do_memory(self, arg):
|
|
154
|
+
"""Manage GPU memory."""
|
|
155
|
+
self.memory_commands.do_memory(arg)
|
|
156
|
+
|
|
157
|
+
def do_workflow(self, arg):
|
|
158
|
+
"""Manage workflows. 'workflow ?' lists subcommands."""
|
|
159
|
+
self.workflow_commands.do_workflow(arg)
|
|
160
|
+
|
|
161
|
+
# ========================================================================
|
|
162
|
+
# Shortcuts for the hot loop: run / load / set
|
|
163
|
+
# ========================================================================
|
|
164
|
+
|
|
165
|
+
def do_run(self, arg):
|
|
166
|
+
"""Run the loaded workflow. Shortcut for 'workflow run [<name>=<value> ...]'."""
|
|
167
|
+
self.workflow_commands.do_workflow(f"run {arg}".strip())
|
|
168
|
+
|
|
169
|
+
def do_load(self, arg):
|
|
170
|
+
"""Load a workflow. Shortcut for 'workflow load <name>'."""
|
|
171
|
+
self.workflow_commands.do_workflow(f"load {arg}".strip())
|
|
172
|
+
|
|
173
|
+
def do_set(self, arg):
|
|
174
|
+
"""Set a workflow argument. Shortcut for 'arg set <name>=<value>'."""
|
|
175
|
+
self.arg_commands.do_arg(f"set {arg}".strip())
|
|
176
|
+
|
|
177
|
+
# ========================================================================
|
|
178
|
+
# Tab completion
|
|
179
|
+
# ========================================================================
|
|
180
|
+
|
|
181
|
+
WORKFLOW_SUBCOMMANDS = ("list", "load", "reload", "status", "run", "restart")
|
|
182
|
+
ARG_SUBCOMMANDS = ("show", "set", "clear")
|
|
183
|
+
MEMORY_SUBCOMMANDS = ("show", "clear")
|
|
184
|
+
CONFIG_SUBCOMMANDS = ("show", "set")
|
|
185
|
+
CONFIG_KEYS = ("output_dir", "log_level", "workflow_dir")
|
|
186
|
+
|
|
187
|
+
@staticmethod
|
|
188
|
+
def _matches(candidates, text):
|
|
189
|
+
return [candidate for candidate in candidates if candidate.startswith(text)]
|
|
190
|
+
|
|
191
|
+
def _variable_candidates(self):
|
|
192
|
+
"""The loaded workflow's variable names, ready for name=value entry."""
|
|
193
|
+
if not self.current_workflow:
|
|
194
|
+
return []
|
|
195
|
+
return [f"{name}=" for name in self.current_workflow.variables]
|
|
196
|
+
|
|
197
|
+
def complete_workflow(self, text, line, begidx, endidx):
|
|
198
|
+
words = line.split()
|
|
199
|
+
# Completing the subcommand itself
|
|
200
|
+
if len(words) == 1 or (len(words) == 2 and not line.endswith(" ")):
|
|
201
|
+
return self._matches(self.WORKFLOW_SUBCOMMANDS, text)
|
|
202
|
+
if words[1] == "load":
|
|
203
|
+
return self._matches(self.workflow_commands.workflow_names(), text)
|
|
204
|
+
if words[1] == "run":
|
|
205
|
+
return self._matches(self._variable_candidates(), text)
|
|
206
|
+
return []
|
|
207
|
+
|
|
208
|
+
def complete_arg(self, text, line, begidx, endidx):
|
|
209
|
+
words = line.split()
|
|
210
|
+
if len(words) == 1 or (len(words) == 2 and not line.endswith(" ")):
|
|
211
|
+
return self._matches(self.ARG_SUBCOMMANDS, text)
|
|
212
|
+
if words[1] == "set":
|
|
213
|
+
return self._matches(self._variable_candidates(), text)
|
|
214
|
+
if words[1] == "clear":
|
|
215
|
+
return self._matches(list(self.workflow_args), text)
|
|
216
|
+
return []
|
|
217
|
+
|
|
218
|
+
def complete_memory(self, text, line, begidx, endidx):
|
|
219
|
+
return self._matches(self.MEMORY_SUBCOMMANDS, text)
|
|
220
|
+
|
|
221
|
+
def complete_config(self, text, line, begidx, endidx):
|
|
222
|
+
words = line.split()
|
|
223
|
+
if len(words) == 1 or (len(words) == 2 and not line.endswith(" ")):
|
|
224
|
+
return self._matches(self.CONFIG_SUBCOMMANDS, text)
|
|
225
|
+
if words[1] == "set":
|
|
226
|
+
return self._matches([f"{key}=" for key in self.CONFIG_KEYS], text)
|
|
227
|
+
return []
|
|
228
|
+
|
|
229
|
+
def complete_load(self, text, line, begidx, endidx):
|
|
230
|
+
return self._matches(self.workflow_commands.workflow_names(), text)
|
|
231
|
+
|
|
232
|
+
def complete_run(self, text, line, begidx, endidx):
|
|
233
|
+
return self._matches(self._variable_candidates(), text)
|
|
234
|
+
|
|
235
|
+
def complete_set(self, text, line, begidx, endidx):
|
|
236
|
+
return self._matches(self._variable_candidates(), text)
|
|
237
|
+
|
|
238
|
+
def default(self, line):
|
|
239
|
+
"""Handle unknown commands"""
|
|
240
|
+
print(f"Unknown command: {line}")
|
|
241
|
+
command = line.split()[0] if line.split() else ""
|
|
242
|
+
known = [name[3:] for name in dir(self) if name.startswith("do_")]
|
|
243
|
+
suggestions = difflib.get_close_matches(command, known, n=3, cutoff=0.6)
|
|
244
|
+
if suggestions:
|
|
245
|
+
print(f"Did you mean: {', '.join(suggestions)}?")
|
|
246
|
+
print("Type 'help' or '?' for a list of commands")
|
|
247
|
+
|
|
248
|
+
# ========================================================================
|
|
249
|
+
# Helper methods
|
|
250
|
+
# ========================================================================
|
|
251
|
+
|
|
252
|
+
def _print_memory_info(self, info):
|
|
253
|
+
"""Print formatted memory information"""
|
|
254
|
+
if not info.get("gpu_available"):
|
|
255
|
+
print("GPU not available")
|
|
256
|
+
return
|
|
257
|
+
|
|
258
|
+
print(f"\nGPU Memory Status:")
|
|
259
|
+
print(f" Device: {info.get('gpu_device_name', 'Unknown')}")
|
|
260
|
+
print(f" Allocated: {info.get('gpu_memory_allocated_mb', 0):.1f} MB")
|
|
261
|
+
print(f" Reserved: {info.get('gpu_memory_reserved_mb', 0):.1f} MB")
|
|
262
|
+
|
|
263
|
+
if "gpu_memory_free_mb" in info:
|
|
264
|
+
print(f" Free: {info.get('gpu_memory_free_mb', 0):.1f} MB")
|
|
265
|
+
print(f" Total: {info.get('gpu_memory_total_mb', 0):.1f} MB")
|
|
266
|
+
|
|
267
|
+
print(f" Runs in this session: {info.get('run_count', 0)}")
|
|
268
|
+
print()
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
def main():
|
|
272
|
+
"""Start the REPL interface"""
|
|
273
|
+
parser = argparse.ArgumentParser(description="Start Diffusers Workflow REPL.")
|
|
274
|
+
parser.add_argument(
|
|
275
|
+
"-l",
|
|
276
|
+
"--log_level",
|
|
277
|
+
type=str,
|
|
278
|
+
default="INFO",
|
|
279
|
+
help="Set the logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)",
|
|
280
|
+
)
|
|
281
|
+
args = parser.parse_args()
|
|
282
|
+
|
|
283
|
+
# Initialize logging
|
|
284
|
+
startup(args.log_level)
|
|
285
|
+
|
|
286
|
+
try:
|
|
287
|
+
repl = DiffusersWorkflowREPL()
|
|
288
|
+
repl.cmdloop()
|
|
289
|
+
except KeyboardInterrupt:
|
|
290
|
+
print("\nGoodbye!")
|
|
291
|
+
sys.exit(0)
|
|
292
|
+
except Exception as e:
|
|
293
|
+
logger.error(f"Error in REPL: {str(e)}", exc_info=True)
|
|
294
|
+
sys.exit(1)
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
if __name__ == "__main__":
|
|
298
|
+
main()
|