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_worker.py
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Worker process management for REPL.
|
|
3
|
+
|
|
4
|
+
Handles starting, stopping, and communicating with the worker process
|
|
5
|
+
that keeps models loaded in GPU memory.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import multiprocessing
|
|
9
|
+
import queue as queue_module
|
|
10
|
+
import logging
|
|
11
|
+
from typing import Optional
|
|
12
|
+
from .worker import worker_main
|
|
13
|
+
|
|
14
|
+
logger = logging.getLogger("dw")
|
|
15
|
+
|
|
16
|
+
# REPL constants
|
|
17
|
+
WORKER_SHUTDOWN_TIMEOUT_SECONDS = 10
|
|
18
|
+
WORKER_TERMINATE_TIMEOUT_SECONDS = 5
|
|
19
|
+
|
|
20
|
+
# How often get_result checks worker liveness while waiting for a message
|
|
21
|
+
WORKER_LIVENESS_POLL_SECONDS = 1.0
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class WorkerManager:
|
|
25
|
+
"""Manages the worker process lifecycle and communication."""
|
|
26
|
+
|
|
27
|
+
def __init__(self):
|
|
28
|
+
"""Initialize worker manager with no active worker."""
|
|
29
|
+
self.worker_process: Optional[multiprocessing.Process] = None
|
|
30
|
+
self.command_queue: Optional[multiprocessing.Queue] = None
|
|
31
|
+
self.result_queue: Optional[multiprocessing.Queue] = None
|
|
32
|
+
self.worker_active = False
|
|
33
|
+
|
|
34
|
+
def ensure_worker(self, log_level: str = "INFO"):
|
|
35
|
+
"""Start worker process if not running.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
log_level: Logging level for the worker process
|
|
39
|
+
"""
|
|
40
|
+
if self.worker_process is None or not self.worker_process.is_alive():
|
|
41
|
+
logger.info("Starting worker process...")
|
|
42
|
+
self.command_queue = multiprocessing.Queue()
|
|
43
|
+
self.result_queue = multiprocessing.Queue()
|
|
44
|
+
|
|
45
|
+
self.worker_process = multiprocessing.Process(
|
|
46
|
+
target=worker_main,
|
|
47
|
+
args=(self.command_queue, self.result_queue, log_level),
|
|
48
|
+
)
|
|
49
|
+
self.worker_process.start()
|
|
50
|
+
self.worker_active = True
|
|
51
|
+
logger.info("Worker process started")
|
|
52
|
+
|
|
53
|
+
def shutdown_worker(self):
|
|
54
|
+
"""Gracefully shutdown worker process."""
|
|
55
|
+
if self.worker_process and self.worker_process.is_alive():
|
|
56
|
+
logger.info("Shutting down worker process...")
|
|
57
|
+
try:
|
|
58
|
+
if self.command_queue:
|
|
59
|
+
self.command_queue.put({"type": "shutdown"})
|
|
60
|
+
self.worker_process.join(timeout=WORKER_SHUTDOWN_TIMEOUT_SECONDS)
|
|
61
|
+
|
|
62
|
+
if self.worker_process.is_alive():
|
|
63
|
+
logger.warning("Worker did not shutdown gracefully, terminating...")
|
|
64
|
+
self.worker_process.terminate()
|
|
65
|
+
self.worker_process.join(timeout=WORKER_TERMINATE_TIMEOUT_SECONDS)
|
|
66
|
+
|
|
67
|
+
if self.worker_process.is_alive():
|
|
68
|
+
logger.error("Worker did not terminate, killing...")
|
|
69
|
+
self.worker_process.kill()
|
|
70
|
+
|
|
71
|
+
except Exception as e:
|
|
72
|
+
logger.error(f"Error shutting down worker: {e}")
|
|
73
|
+
finally:
|
|
74
|
+
self.worker_active = False
|
|
75
|
+
self.worker_process = None
|
|
76
|
+
self.command_queue = None
|
|
77
|
+
self.result_queue = None
|
|
78
|
+
|
|
79
|
+
def send_command(self, command: dict):
|
|
80
|
+
"""Send a command to the worker process.
|
|
81
|
+
|
|
82
|
+
Args:
|
|
83
|
+
command: Dictionary containing command type and parameters
|
|
84
|
+
"""
|
|
85
|
+
if not self.worker_active or not self.command_queue:
|
|
86
|
+
raise RuntimeError("Worker process is not active")
|
|
87
|
+
self.command_queue.put(command)
|
|
88
|
+
|
|
89
|
+
def get_result(self, timeout: Optional[float] = None):
|
|
90
|
+
"""Get a result from the worker process.
|
|
91
|
+
|
|
92
|
+
With no timeout this waits as long as the worker is alive - a video
|
|
93
|
+
generation or a cold model download takes however long it takes, and
|
|
94
|
+
progress events keep the caller informed in the meantime. The wait
|
|
95
|
+
polls so a worker that dies mid-run raises instead of blocking forever.
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
timeout: Optional timeout in seconds; None waits indefinitely
|
|
99
|
+
while the worker process is alive
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
Result dictionary from worker
|
|
103
|
+
|
|
104
|
+
Raises:
|
|
105
|
+
RuntimeError: If worker is not active or dies while waiting
|
|
106
|
+
queue.Empty: If an explicit timeout elapses
|
|
107
|
+
"""
|
|
108
|
+
if not self.worker_active or not self.result_queue:
|
|
109
|
+
raise RuntimeError("Worker process is not active")
|
|
110
|
+
|
|
111
|
+
if timeout is not None:
|
|
112
|
+
return self.result_queue.get(timeout=timeout)
|
|
113
|
+
|
|
114
|
+
while True:
|
|
115
|
+
try:
|
|
116
|
+
return self.result_queue.get(timeout=WORKER_LIVENESS_POLL_SECONDS)
|
|
117
|
+
except queue_module.Empty:
|
|
118
|
+
if self.worker_process is None or not self.worker_process.is_alive():
|
|
119
|
+
raise RuntimeError("Worker process died while waiting for results")
|
|
120
|
+
|
|
121
|
+
def cancel(self):
|
|
122
|
+
"""Ask the worker to cancel the workflow it is running."""
|
|
123
|
+
self.send_command({"type": "cancel"})
|
|
124
|
+
|
|
125
|
+
def mark_crashed(self):
|
|
126
|
+
"""Record that the worker process died on its own - no shutdown
|
|
127
|
+
handshake to attempt, just clear the tracking state."""
|
|
128
|
+
self.worker_active = False
|
|
129
|
+
self.worker_process = None
|