waldiez 0.5.2__py3-none-any.whl → 0.5.3__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.
Potentially problematic release.
This version of waldiez might be problematic. Click here for more details.
- waldiez/_version.py +1 -1
- waldiez/cli.py +2 -0
- waldiez/models/chat/chat_message.py +1 -1
- waldiez/runner.py +35 -2
- waldiez/running/base_runner.py +38 -8
- waldiez/running/environment.py +32 -13
- waldiez/running/import_runner.py +13 -0
- waldiez/running/post_run.py +71 -14
- waldiez/running/pre_run.py +42 -0
- waldiez/running/protocol.py +6 -0
- waldiez/running/subprocess_runner.py +4 -0
- waldiez/running/timeline_processor.py +1248 -0
- waldiez/utils/version.py +12 -1
- {waldiez-0.5.2.dist-info → waldiez-0.5.3.dist-info}/METADATA +33 -32
- {waldiez-0.5.2.dist-info → waldiez-0.5.3.dist-info}/RECORD +19 -18
- {waldiez-0.5.2.dist-info → waldiez-0.5.3.dist-info}/WHEEL +0 -0
- {waldiez-0.5.2.dist-info → waldiez-0.5.3.dist-info}/entry_points.txt +0 -0
- {waldiez-0.5.2.dist-info → waldiez-0.5.3.dist-info}/licenses/LICENSE +0 -0
- {waldiez-0.5.2.dist-info → waldiez-0.5.3.dist-info}/licenses/NOTICE.md +0 -0
waldiez/_version.py
CHANGED
waldiez/cli.py
CHANGED
|
@@ -139,6 +139,7 @@ def run(
|
|
|
139
139
|
structured,
|
|
140
140
|
not patch_io, # skip_patch_io
|
|
141
141
|
False, # skip_mmd
|
|
142
|
+
False, # skip_timeline
|
|
142
143
|
)
|
|
143
144
|
else:
|
|
144
145
|
runner.run(
|
|
@@ -148,6 +149,7 @@ def run(
|
|
|
148
149
|
threaded=threaded,
|
|
149
150
|
skip_patch_io=not patch_io,
|
|
150
151
|
skip_mmd=False,
|
|
152
|
+
skip_timeline=False,
|
|
151
153
|
)
|
|
152
154
|
|
|
153
155
|
|
|
@@ -159,7 +159,7 @@ class WaldiezChatMessage(WaldiezBase):
|
|
|
159
159
|
)
|
|
160
160
|
content = self.content
|
|
161
161
|
if self.type == "rag_message_generator":
|
|
162
|
-
if self.use_carryover:
|
|
162
|
+
if not self.use_carryover:
|
|
163
163
|
content = get_last_carryover_method_content(
|
|
164
164
|
text_content=self.content or "",
|
|
165
165
|
)
|
waldiez/runner.py
CHANGED
|
@@ -222,6 +222,7 @@ class WaldiezRunner(WaldiezBaseRunner):
|
|
|
222
222
|
output_file: Path,
|
|
223
223
|
uploads_root: Path | None,
|
|
224
224
|
skip_mmd: bool = False,
|
|
225
|
+
skip_timeline: bool = False,
|
|
225
226
|
) -> Union[
|
|
226
227
|
"ChatResult",
|
|
227
228
|
list["ChatResult"],
|
|
@@ -239,6 +240,8 @@ class WaldiezRunner(WaldiezBaseRunner):
|
|
|
239
240
|
The runtime uploads root.
|
|
240
241
|
skip_mmd : bool
|
|
241
242
|
Whether to skip generating the mermaid diagram.
|
|
243
|
+
skip_timeline : bool
|
|
244
|
+
Whether to skip generating the timeline JSON.
|
|
242
245
|
|
|
243
246
|
Returns
|
|
244
247
|
-------
|
|
@@ -252,6 +255,7 @@ class WaldiezRunner(WaldiezBaseRunner):
|
|
|
252
255
|
output_file=output_file,
|
|
253
256
|
uploads_root=uploads_root,
|
|
254
257
|
skip_mmd=skip_mmd,
|
|
258
|
+
skip_timeline=skip_timeline,
|
|
255
259
|
)
|
|
256
260
|
|
|
257
261
|
async def _a_run(
|
|
@@ -260,6 +264,7 @@ class WaldiezRunner(WaldiezBaseRunner):
|
|
|
260
264
|
output_file: Path,
|
|
261
265
|
uploads_root: Path | None,
|
|
262
266
|
skip_mmd: bool,
|
|
267
|
+
skip_timeline: bool,
|
|
263
268
|
) -> Union[
|
|
264
269
|
"ChatResult",
|
|
265
270
|
list["ChatResult"],
|
|
@@ -277,6 +282,8 @@ class WaldiezRunner(WaldiezBaseRunner):
|
|
|
277
282
|
The runtime uploads root.
|
|
278
283
|
skip_mmd : bool
|
|
279
284
|
Whether to skip generating the mermaid diagram.
|
|
285
|
+
skip_timeline : bool
|
|
286
|
+
Whether to skip generating the timeline JSON.
|
|
280
287
|
|
|
281
288
|
Returns
|
|
282
289
|
-------
|
|
@@ -290,6 +297,7 @@ class WaldiezRunner(WaldiezBaseRunner):
|
|
|
290
297
|
output_file=output_file,
|
|
291
298
|
uploads_root=uploads_root,
|
|
292
299
|
skip_mmd=skip_mmd,
|
|
300
|
+
skip_timeline=skip_timeline,
|
|
293
301
|
)
|
|
294
302
|
|
|
295
303
|
def _after_run(
|
|
@@ -303,6 +311,7 @@ class WaldiezRunner(WaldiezBaseRunner):
|
|
|
303
311
|
uploads_root: Path | None,
|
|
304
312
|
temp_dir: Path,
|
|
305
313
|
skip_mmd: bool,
|
|
314
|
+
skip_timeline: bool,
|
|
306
315
|
) -> None:
|
|
307
316
|
"""Actions to perform after running the flow.
|
|
308
317
|
|
|
@@ -322,13 +331,16 @@ class WaldiezRunner(WaldiezBaseRunner):
|
|
|
322
331
|
The path to the temporary directory created for the run.
|
|
323
332
|
skip_mmd : bool
|
|
324
333
|
Whether to skip generating the mermaid diagram.
|
|
334
|
+
skip_timeline : bool
|
|
335
|
+
Whether to skip generating the timeline JSON.
|
|
325
336
|
"""
|
|
326
337
|
self._implementation._after_run(
|
|
327
338
|
results,
|
|
328
339
|
output_file,
|
|
329
340
|
uploads_root,
|
|
330
341
|
temp_dir,
|
|
331
|
-
skip_mmd,
|
|
342
|
+
skip_mmd=skip_mmd,
|
|
343
|
+
skip_timeline=skip_timeline,
|
|
332
344
|
)
|
|
333
345
|
|
|
334
346
|
async def _a_after_run(
|
|
@@ -342,6 +354,7 @@ class WaldiezRunner(WaldiezBaseRunner):
|
|
|
342
354
|
uploads_root: Path | None,
|
|
343
355
|
temp_dir: Path,
|
|
344
356
|
skip_mmd: bool,
|
|
357
|
+
skip_timeline: bool,
|
|
345
358
|
) -> None:
|
|
346
359
|
"""Asynchronously perform actions after running the flow.
|
|
347
360
|
|
|
@@ -357,13 +370,16 @@ class WaldiezRunner(WaldiezBaseRunner):
|
|
|
357
370
|
The path to the temporary directory created for the run.
|
|
358
371
|
skip_mmd : bool
|
|
359
372
|
Whether to skip generating the mermaid diagram.
|
|
373
|
+
skip_timeline : bool
|
|
374
|
+
Whether to skip generating the timeline JSON.
|
|
360
375
|
"""
|
|
361
376
|
await self._implementation._a_after_run(
|
|
362
377
|
results,
|
|
363
378
|
output_file,
|
|
364
379
|
uploads_root,
|
|
365
380
|
temp_dir,
|
|
366
|
-
skip_mmd,
|
|
381
|
+
skip_mmd=skip_mmd,
|
|
382
|
+
skip_timeline=skip_timeline,
|
|
367
383
|
)
|
|
368
384
|
|
|
369
385
|
def start(
|
|
@@ -373,6 +389,7 @@ class WaldiezRunner(WaldiezBaseRunner):
|
|
|
373
389
|
structured_io: bool | None = None,
|
|
374
390
|
skip_patch_io: bool | None = None,
|
|
375
391
|
skip_mmd: bool = False,
|
|
392
|
+
skip_timeline: bool = False,
|
|
376
393
|
) -> None:
|
|
377
394
|
"""Start the flow.
|
|
378
395
|
|
|
@@ -390,12 +407,16 @@ class WaldiezRunner(WaldiezBaseRunner):
|
|
|
390
407
|
If None, it will use the value from the context.
|
|
391
408
|
skip_mmd : bool = False
|
|
392
409
|
Whether to skip generating the mermaid diagram.
|
|
410
|
+
skip_timeline : bool = False
|
|
411
|
+
Whether to skip generating the timeline JSON.
|
|
393
412
|
"""
|
|
394
413
|
self._implementation.start(
|
|
395
414
|
output_path=output_path,
|
|
396
415
|
uploads_root=uploads_root,
|
|
397
416
|
structured_io=structured_io,
|
|
398
417
|
skip_patch_io=skip_patch_io,
|
|
418
|
+
skip_mmd=skip_mmd,
|
|
419
|
+
skip_timeline=skip_timeline,
|
|
399
420
|
)
|
|
400
421
|
|
|
401
422
|
def _start(
|
|
@@ -404,6 +425,7 @@ class WaldiezRunner(WaldiezBaseRunner):
|
|
|
404
425
|
output_file: Path,
|
|
405
426
|
uploads_root: Path | None,
|
|
406
427
|
skip_mmd: bool,
|
|
428
|
+
skip_timeline: bool,
|
|
407
429
|
) -> None:
|
|
408
430
|
"""Start the flow.
|
|
409
431
|
|
|
@@ -415,12 +437,15 @@ class WaldiezRunner(WaldiezBaseRunner):
|
|
|
415
437
|
The runtime uploads root.
|
|
416
438
|
skip_mmd : bool
|
|
417
439
|
Whether to skip generating the mermaid diagram.
|
|
440
|
+
skip_timeline : bool
|
|
441
|
+
Whether to skip generating the timeline JSON.
|
|
418
442
|
"""
|
|
419
443
|
self._implementation._start(
|
|
420
444
|
temp_dir=temp_dir,
|
|
421
445
|
output_file=output_file,
|
|
422
446
|
uploads_root=uploads_root,
|
|
423
447
|
skip_mmd=skip_mmd,
|
|
448
|
+
skip_timeline=skip_timeline,
|
|
424
449
|
)
|
|
425
450
|
|
|
426
451
|
async def a_start(
|
|
@@ -430,6 +455,7 @@ class WaldiezRunner(WaldiezBaseRunner):
|
|
|
430
455
|
structured_io: bool | None = None,
|
|
431
456
|
skip_patch_io: bool | None = None,
|
|
432
457
|
skip_mmd: bool = False,
|
|
458
|
+
skip_timeline: bool = False,
|
|
433
459
|
) -> None:
|
|
434
460
|
"""Asynchronously start the flow.
|
|
435
461
|
|
|
@@ -445,6 +471,8 @@ class WaldiezRunner(WaldiezBaseRunner):
|
|
|
445
471
|
Whether to skip patching I/O, by default None.
|
|
446
472
|
skip_mmd : bool = False
|
|
447
473
|
Whether to skip generating the mermaid diagram, by default False.
|
|
474
|
+
skip_timeline : bool = False
|
|
475
|
+
Whether to skip generating the timeline JSON, by default False.
|
|
448
476
|
"""
|
|
449
477
|
await self._implementation.a_start(
|
|
450
478
|
output_path=output_path,
|
|
@@ -452,6 +480,7 @@ class WaldiezRunner(WaldiezBaseRunner):
|
|
|
452
480
|
structured_io=structured_io,
|
|
453
481
|
skip_patch_io=skip_patch_io,
|
|
454
482
|
skip_mmd=skip_mmd,
|
|
483
|
+
skip_timeline=skip_timeline,
|
|
455
484
|
)
|
|
456
485
|
|
|
457
486
|
async def _a_start(
|
|
@@ -460,6 +489,7 @@ class WaldiezRunner(WaldiezBaseRunner):
|
|
|
460
489
|
output_file: Path,
|
|
461
490
|
uploads_root: Path | None,
|
|
462
491
|
skip_mmd: bool,
|
|
492
|
+
skip_timeline: bool = False,
|
|
463
493
|
) -> None:
|
|
464
494
|
"""Asynchronously start the flow.
|
|
465
495
|
|
|
@@ -473,12 +503,15 @@ class WaldiezRunner(WaldiezBaseRunner):
|
|
|
473
503
|
The runtime uploads root.
|
|
474
504
|
skip_mmd : bool
|
|
475
505
|
Whether to skip generating the mermaid diagram.
|
|
506
|
+
skip_timeline : bool, optional
|
|
507
|
+
Whether to skip generating the timeline JSON, by default False.
|
|
476
508
|
"""
|
|
477
509
|
await self._implementation._a_start(
|
|
478
510
|
temp_dir=temp_dir,
|
|
479
511
|
output_file=output_file,
|
|
480
512
|
uploads_root=uploads_root,
|
|
481
513
|
skip_mmd=skip_mmd,
|
|
514
|
+
skip_timeline=skip_timeline,
|
|
482
515
|
)
|
|
483
516
|
|
|
484
517
|
def _stop(self) -> None:
|
waldiez/running/base_runner.py
CHANGED
|
@@ -20,7 +20,6 @@ from typing_extensions import Self
|
|
|
20
20
|
from waldiez.exporter import WaldiezExporter
|
|
21
21
|
from waldiez.logger import WaldiezLogger, get_logger
|
|
22
22
|
from waldiez.models import Waldiez
|
|
23
|
-
from waldiez.utils import get_waldiez_version
|
|
24
23
|
|
|
25
24
|
from .environment import refresh_environment, reset_env_vars, set_env_vars
|
|
26
25
|
from .post_run import after_run
|
|
@@ -149,6 +148,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
149
148
|
output_file: Path,
|
|
150
149
|
uploads_root: Path | None,
|
|
151
150
|
skip_mmd: bool,
|
|
151
|
+
skip_timeline: bool,
|
|
152
152
|
) -> Union[
|
|
153
153
|
"ChatResult",
|
|
154
154
|
list["ChatResult"],
|
|
@@ -165,6 +165,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
165
165
|
output_file: Path,
|
|
166
166
|
uploads_root: Path | None,
|
|
167
167
|
skip_mmd: bool,
|
|
168
|
+
skip_timeline: bool,
|
|
168
169
|
) -> Union[
|
|
169
170
|
"ChatResult",
|
|
170
171
|
list["ChatResult"],
|
|
@@ -181,6 +182,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
181
182
|
output_file: Path,
|
|
182
183
|
uploads_root: Path | None,
|
|
183
184
|
skip_mmd: bool,
|
|
185
|
+
skip_timeline: bool,
|
|
184
186
|
) -> None:
|
|
185
187
|
"""Start running the Waldiez flow in a non-blocking way."""
|
|
186
188
|
raise NotImplementedError(
|
|
@@ -193,6 +195,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
193
195
|
output_file: Path,
|
|
194
196
|
uploads_root: Path | None,
|
|
195
197
|
skip_mmd: bool,
|
|
198
|
+
skip_timeline: bool,
|
|
196
199
|
) -> None:
|
|
197
200
|
"""Start running the Waldiez flow in a non-blocking way asynchronously.
|
|
198
201
|
|
|
@@ -224,6 +227,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
224
227
|
uploads_root: Path | None,
|
|
225
228
|
temp_dir: Path,
|
|
226
229
|
skip_mmd: bool,
|
|
230
|
+
skip_timeline: bool,
|
|
227
231
|
) -> None:
|
|
228
232
|
"""Run after the flow execution."""
|
|
229
233
|
# Save results
|
|
@@ -237,6 +241,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
237
241
|
flow_name=self.waldiez.name,
|
|
238
242
|
uploads_root=uploads_root,
|
|
239
243
|
skip_mmd=skip_mmd,
|
|
244
|
+
skip_timeline=skip_timeline,
|
|
240
245
|
)
|
|
241
246
|
self.log.info("Cleanup completed")
|
|
242
247
|
|
|
@@ -251,6 +256,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
251
256
|
uploads_root: Path | None,
|
|
252
257
|
temp_dir: Path,
|
|
253
258
|
skip_mmd: bool,
|
|
259
|
+
skip_timeline: bool,
|
|
254
260
|
) -> None:
|
|
255
261
|
"""Run after the flow execution asynchronously."""
|
|
256
262
|
self._after_run(
|
|
@@ -259,6 +265,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
259
265
|
uploads_root=uploads_root,
|
|
260
266
|
temp_dir=temp_dir,
|
|
261
267
|
skip_mmd=skip_mmd,
|
|
268
|
+
skip_timeline=skip_timeline,
|
|
262
269
|
)
|
|
263
270
|
|
|
264
271
|
def _stop(self) -> None:
|
|
@@ -309,9 +316,6 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
309
316
|
for req in self.waldiez.requirements
|
|
310
317
|
if req not in sys.modules and "waldiez" not in req
|
|
311
318
|
}
|
|
312
|
-
waldiez_version = get_waldiez_version()
|
|
313
|
-
if "waldiez" not in sys.modules:
|
|
314
|
-
extra_requirements.add(f"waldiez=={waldiez_version}")
|
|
315
319
|
return extra_requirements
|
|
316
320
|
|
|
317
321
|
def install_requirements(self) -> None:
|
|
@@ -390,6 +394,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
390
394
|
threaded: bool | None = None,
|
|
391
395
|
skip_patch_io: bool | None = None,
|
|
392
396
|
skip_mmd: bool = False,
|
|
397
|
+
skip_timeline: bool = False,
|
|
393
398
|
) -> Union[
|
|
394
399
|
"ChatResult",
|
|
395
400
|
list["ChatResult"],
|
|
@@ -408,10 +413,12 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
408
413
|
by default False.
|
|
409
414
|
threaded : bool | None
|
|
410
415
|
Whether to run the flow in a threaded environment, by default None.
|
|
411
|
-
skip_mmd : bool
|
|
412
|
-
Whether to skip generating the mermaid diagram, by default False.
|
|
413
416
|
skip_patch_io : bool | None
|
|
414
417
|
Whether to skip patching the IO streams, by default None.
|
|
418
|
+
skip_mmd : bool
|
|
419
|
+
Whether to skip generating the mermaid diagram, by default False.
|
|
420
|
+
skip_timeline : bool
|
|
421
|
+
Whether to skip generating the timeline JSON.
|
|
415
422
|
|
|
416
423
|
Returns
|
|
417
424
|
-------
|
|
@@ -468,6 +475,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
468
475
|
output_file=output_file,
|
|
469
476
|
uploads_root=uploads_root_path,
|
|
470
477
|
skip_mmd=skip_mmd,
|
|
478
|
+
skip_timeline=skip_timeline,
|
|
471
479
|
)
|
|
472
480
|
finally:
|
|
473
481
|
WaldiezBaseRunner._running = False
|
|
@@ -478,6 +486,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
478
486
|
uploads_root=uploads_root_path,
|
|
479
487
|
temp_dir=temp_dir,
|
|
480
488
|
skip_mmd=skip_mmd,
|
|
489
|
+
skip_timeline=skip_timeline,
|
|
481
490
|
)
|
|
482
491
|
if sys.path[0] == str(temp_dir):
|
|
483
492
|
sys.path.pop(0)
|
|
@@ -490,6 +499,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
490
499
|
structured_io: bool | None = None,
|
|
491
500
|
skip_patch_io: bool | None = None,
|
|
492
501
|
skip_mmd: bool = False,
|
|
502
|
+
skip_timeline: bool = False,
|
|
493
503
|
) -> Union[
|
|
494
504
|
"ChatResult",
|
|
495
505
|
list["ChatResult"],
|
|
@@ -510,6 +520,8 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
510
520
|
Whether to skip patching I/O, by default None.
|
|
511
521
|
skip_mmd : bool
|
|
512
522
|
Whether to skip generating the mermaid diagram, by default False.
|
|
523
|
+
skip_timeline : bool
|
|
524
|
+
Whether to skip generating the timeline JSON, by default False.
|
|
513
525
|
|
|
514
526
|
Returns
|
|
515
527
|
-------
|
|
@@ -553,6 +565,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
553
565
|
output_file=output_file,
|
|
554
566
|
uploads_root=uploads_root_path,
|
|
555
567
|
skip_mmd=skip_mmd,
|
|
568
|
+
skip_timeline=skip_timeline,
|
|
556
569
|
)
|
|
557
570
|
finally:
|
|
558
571
|
WaldiezBaseRunner._running = False
|
|
@@ -562,6 +575,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
562
575
|
uploads_root=uploads_root_path,
|
|
563
576
|
temp_dir=temp_dir,
|
|
564
577
|
skip_mmd=skip_mmd,
|
|
578
|
+
skip_timeline=skip_timeline,
|
|
565
579
|
)
|
|
566
580
|
if sys.path[0] == str(temp_dir):
|
|
567
581
|
sys.path.pop(0)
|
|
@@ -574,6 +588,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
574
588
|
structured_io: bool | None = None,
|
|
575
589
|
skip_patch_io: bool | None = None,
|
|
576
590
|
skip_mmd: bool = False,
|
|
591
|
+
skip_timeline: bool = False,
|
|
577
592
|
) -> None:
|
|
578
593
|
"""Start running the Waldiez flow in a non-blocking way.
|
|
579
594
|
|
|
@@ -589,6 +604,8 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
589
604
|
Whether to skip patching I/O, by default None.
|
|
590
605
|
skip_mmd : bool
|
|
591
606
|
Whether to skip generating the mermaid diagram, by default False.
|
|
607
|
+
skip_timeline : bool
|
|
608
|
+
Whether to skip generating the timeline JSON, by default False.
|
|
592
609
|
|
|
593
610
|
Raises
|
|
594
611
|
------
|
|
@@ -617,6 +634,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
617
634
|
output_file=output_file,
|
|
618
635
|
uploads_root=uploads_root_path,
|
|
619
636
|
skip_mmd=skip_mmd,
|
|
637
|
+
skip_timeline=skip_timeline,
|
|
620
638
|
)
|
|
621
639
|
|
|
622
640
|
async def a_start(
|
|
@@ -626,6 +644,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
626
644
|
structured_io: bool | None = None,
|
|
627
645
|
skip_patch_io: bool | None = None,
|
|
628
646
|
skip_mmd: bool = False,
|
|
647
|
+
skip_timeline: bool = False,
|
|
629
648
|
) -> None:
|
|
630
649
|
"""Asynchronously start running the Waldiez flow in a non-blocking way.
|
|
631
650
|
|
|
@@ -639,8 +658,10 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
639
658
|
Whether to use structured IO instead of the default 'input/print'.
|
|
640
659
|
skip_patch_io : bool | None = None
|
|
641
660
|
Whether to skip patching I/O, by default None.
|
|
642
|
-
skip_mmd : bool
|
|
643
|
-
Whether to skip generating the mermaid diagram, by default
|
|
661
|
+
skip_mmd : bool = False
|
|
662
|
+
Whether to skip generating the mermaid diagram, by default False.
|
|
663
|
+
skip_timeline : bool = False
|
|
664
|
+
Whether to skip generating the timeline JSON, by default False.
|
|
644
665
|
|
|
645
666
|
Raises
|
|
646
667
|
------
|
|
@@ -669,6 +690,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
669
690
|
output_file=output_file,
|
|
670
691
|
uploads_root=uploads_root_path,
|
|
671
692
|
skip_mmd=skip_mmd,
|
|
693
|
+
skip_timeline=skip_timeline,
|
|
672
694
|
)
|
|
673
695
|
|
|
674
696
|
def after_run(
|
|
@@ -682,6 +704,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
682
704
|
uploads_root: Path | None,
|
|
683
705
|
temp_dir: Path,
|
|
684
706
|
skip_mmd: bool,
|
|
707
|
+
skip_timeline: bool,
|
|
685
708
|
) -> None:
|
|
686
709
|
"""Actions to perform after running the flow.
|
|
687
710
|
|
|
@@ -697,6 +720,8 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
697
720
|
The path to the temporary directory used during the run.
|
|
698
721
|
skip_mmd : bool
|
|
699
722
|
Whether to skip generating the mermaid diagram.
|
|
723
|
+
skip_timeline : bool
|
|
724
|
+
Whether to skip generating the timeline JSON.
|
|
700
725
|
"""
|
|
701
726
|
self._after_run(
|
|
702
727
|
results=results,
|
|
@@ -704,6 +729,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
704
729
|
uploads_root=uploads_root,
|
|
705
730
|
temp_dir=temp_dir,
|
|
706
731
|
skip_mmd=skip_mmd,
|
|
732
|
+
skip_timeline=skip_timeline,
|
|
707
733
|
)
|
|
708
734
|
|
|
709
735
|
async def a_after_run(
|
|
@@ -717,6 +743,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
717
743
|
uploads_root: Path | None,
|
|
718
744
|
temp_dir: Path,
|
|
719
745
|
skip_mmd: bool,
|
|
746
|
+
skip_timeline: bool,
|
|
720
747
|
) -> None:
|
|
721
748
|
"""Asynchronously perform actions after running the flow.
|
|
722
749
|
|
|
@@ -732,6 +759,8 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
732
759
|
The path to the temporary directory used during the run.
|
|
733
760
|
skip_mmd : bool
|
|
734
761
|
Whether to skip generating the mermaid diagram.
|
|
762
|
+
skip_timeline : bool
|
|
763
|
+
|
|
735
764
|
"""
|
|
736
765
|
await self._a_after_run(
|
|
737
766
|
results=results,
|
|
@@ -739,6 +768,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
|
|
|
739
768
|
uploads_root=uploads_root,
|
|
740
769
|
temp_dir=temp_dir,
|
|
741
770
|
skip_mmd=skip_mmd,
|
|
771
|
+
skip_timeline=skip_timeline,
|
|
742
772
|
)
|
|
743
773
|
|
|
744
774
|
def stop(self) -> None:
|
waldiez/running/environment.py
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
# pylint: disable=import-outside-toplevel,reimported
|
|
4
4
|
"""Environment related utilities."""
|
|
5
5
|
|
|
6
|
+
import importlib
|
|
6
7
|
import os
|
|
7
8
|
import site
|
|
8
9
|
import sys
|
|
@@ -86,20 +87,19 @@ def reload_autogen() -> None: # noqa: C901
|
|
|
86
87
|
default_io_stream = IOStream.get_default()
|
|
87
88
|
except (ImportError, AttributeError):
|
|
88
89
|
pass
|
|
89
|
-
|
|
90
|
+
autogen_modules = sorted(
|
|
91
|
+
[
|
|
92
|
+
name
|
|
93
|
+
for name in sys.modules
|
|
94
|
+
if name.startswith("autogen.")
|
|
95
|
+
and not name.startswith("autogen.io")
|
|
96
|
+
and not name.startswith("autogen.tools")
|
|
97
|
+
],
|
|
98
|
+
key=len,
|
|
99
|
+
reverse=True, # Longer names (deeper modules) first
|
|
100
|
+
)
|
|
90
101
|
try:
|
|
91
102
|
# Remove autogen modules in reverse dependency order
|
|
92
|
-
autogen_modules = sorted(
|
|
93
|
-
[
|
|
94
|
-
name
|
|
95
|
-
for name in sys.modules
|
|
96
|
-
if name.startswith("autogen.")
|
|
97
|
-
and not name.startswith("autogen.io")
|
|
98
|
-
and not name.startswith("autogen.tools")
|
|
99
|
-
],
|
|
100
|
-
key=len,
|
|
101
|
-
reverse=True, # Longer names (deeper modules) first
|
|
102
|
-
)
|
|
103
103
|
for mod_name in autogen_modules:
|
|
104
104
|
if mod_name in sys.modules:
|
|
105
105
|
del sys.modules[mod_name]
|
|
@@ -111,6 +111,14 @@ def reload_autogen() -> None: # noqa: C901
|
|
|
111
111
|
# pylint: disable=unused-import
|
|
112
112
|
import autogen # pyright: ignore
|
|
113
113
|
|
|
114
|
+
for mod_name in sorted(autogen_modules, key=len, reverse=False):
|
|
115
|
+
# Re-import each module
|
|
116
|
+
try:
|
|
117
|
+
importlib.import_module(mod_name)
|
|
118
|
+
except ImportError as e:
|
|
119
|
+
# If a module fails to import, we can log it or handle it
|
|
120
|
+
print(f"Failed to re-import {mod_name}: {e}", file=sys.stderr)
|
|
121
|
+
|
|
114
122
|
# Restore IOStream state if we had it
|
|
115
123
|
if default_io_stream is not None:
|
|
116
124
|
try:
|
|
@@ -125,7 +133,18 @@ def reload_autogen() -> None: # noqa: C901
|
|
|
125
133
|
# If reload fails, at least try to re-import autogen
|
|
126
134
|
try:
|
|
127
135
|
import autogen # type: ignore # noqa: F401
|
|
128
|
-
|
|
136
|
+
|
|
137
|
+
for mod_name in sorted(autogen_modules, key=len, reverse=False):
|
|
138
|
+
# Re-import each module
|
|
139
|
+
try:
|
|
140
|
+
importlib.import_module(mod_name)
|
|
141
|
+
except ImportError as err:
|
|
142
|
+
# If a module fails to import, we can log it or handle it
|
|
143
|
+
print(
|
|
144
|
+
f"Failed to re-import {mod_name}: {err}",
|
|
145
|
+
file=sys.stderr,
|
|
146
|
+
)
|
|
147
|
+
except Exception: # pylint: disable=broad-exception-caught
|
|
129
148
|
pass
|
|
130
149
|
raise e
|
|
131
150
|
|
waldiez/running/import_runner.py
CHANGED
|
@@ -63,6 +63,7 @@ class WaldiezImportRunner(WaldiezBaseRunner):
|
|
|
63
63
|
output_file: Path,
|
|
64
64
|
uploads_root: Path | None,
|
|
65
65
|
skip_mmd: bool,
|
|
66
|
+
skip_timeline: bool,
|
|
66
67
|
) -> Union["ChatResult", list["ChatResult"], dict[int, "ChatResult"]]:
|
|
67
68
|
"""Run the Waldiez workflow."""
|
|
68
69
|
if self.threaded:
|
|
@@ -71,6 +72,7 @@ class WaldiezImportRunner(WaldiezBaseRunner):
|
|
|
71
72
|
output_file=output_file,
|
|
72
73
|
uploads_root=uploads_root,
|
|
73
74
|
skip_mmd=skip_mmd,
|
|
75
|
+
skip_timeline=skip_timeline,
|
|
74
76
|
)
|
|
75
77
|
|
|
76
78
|
return self._run_not_threaded(
|
|
@@ -78,14 +80,17 @@ class WaldiezImportRunner(WaldiezBaseRunner):
|
|
|
78
80
|
output_file=output_file,
|
|
79
81
|
uploads_root=uploads_root,
|
|
80
82
|
skip_mmd=skip_mmd,
|
|
83
|
+
skip_timeline=skip_timeline,
|
|
81
84
|
)
|
|
82
85
|
|
|
86
|
+
# pylint: disable=too-many-locals
|
|
83
87
|
def _run_not_threaded(
|
|
84
88
|
self,
|
|
85
89
|
temp_dir: Path,
|
|
86
90
|
output_file: Path,
|
|
87
91
|
uploads_root: Path | None,
|
|
88
92
|
skip_mmd: bool,
|
|
93
|
+
skip_timeline: bool,
|
|
89
94
|
) -> Union[
|
|
90
95
|
"ChatResult",
|
|
91
96
|
list["ChatResult"],
|
|
@@ -149,6 +154,7 @@ class WaldiezImportRunner(WaldiezBaseRunner):
|
|
|
149
154
|
output_file: Path,
|
|
150
155
|
uploads_root: Path | None,
|
|
151
156
|
skip_mmd: bool,
|
|
157
|
+
skip_timeline: bool,
|
|
152
158
|
) -> Union[
|
|
153
159
|
"ChatResult",
|
|
154
160
|
list["ChatResult"],
|
|
@@ -246,6 +252,7 @@ class WaldiezImportRunner(WaldiezBaseRunner):
|
|
|
246
252
|
output_file: Path,
|
|
247
253
|
uploads_root: Path | None,
|
|
248
254
|
skip_mmd: bool,
|
|
255
|
+
skip_timeline: bool,
|
|
249
256
|
) -> Union[
|
|
250
257
|
"ChatResult",
|
|
251
258
|
list["ChatResult"],
|
|
@@ -336,6 +343,7 @@ class WaldiezImportRunner(WaldiezBaseRunner):
|
|
|
336
343
|
uploads_root: Path | None,
|
|
337
344
|
temp_dir: Path,
|
|
338
345
|
skip_mmd: bool,
|
|
346
|
+
skip_timeline: bool,
|
|
339
347
|
) -> None:
|
|
340
348
|
super()._after_run(
|
|
341
349
|
results=results,
|
|
@@ -343,6 +351,7 @@ class WaldiezImportRunner(WaldiezBaseRunner):
|
|
|
343
351
|
uploads_root=uploads_root,
|
|
344
352
|
temp_dir=temp_dir,
|
|
345
353
|
skip_mmd=skip_mmd,
|
|
354
|
+
skip_timeline=skip_timeline,
|
|
346
355
|
)
|
|
347
356
|
|
|
348
357
|
# Clean up module reference
|
|
@@ -354,6 +363,7 @@ class WaldiezImportRunner(WaldiezBaseRunner):
|
|
|
354
363
|
output_file: Path,
|
|
355
364
|
uploads_root: Path | None,
|
|
356
365
|
skip_mmd: bool = False,
|
|
366
|
+
skip_timeline: bool = False,
|
|
357
367
|
) -> None:
|
|
358
368
|
"""Start the Waldiez workflow."""
|
|
359
369
|
|
|
@@ -366,6 +376,7 @@ class WaldiezImportRunner(WaldiezBaseRunner):
|
|
|
366
376
|
output_file=output_file,
|
|
367
377
|
uploads_root=uploads_root,
|
|
368
378
|
skip_mmd=skip_mmd,
|
|
379
|
+
skip_timeline=skip_timeline,
|
|
369
380
|
)
|
|
370
381
|
except Exception as e: # pylint: disable=broad-exception-caught
|
|
371
382
|
self._last_exception = e
|
|
@@ -383,6 +394,7 @@ class WaldiezImportRunner(WaldiezBaseRunner):
|
|
|
383
394
|
output_file: Path,
|
|
384
395
|
uploads_root: Path | None,
|
|
385
396
|
skip_mmd: bool = False,
|
|
397
|
+
skip_timeline: bool = False,
|
|
386
398
|
) -> None:
|
|
387
399
|
"""Start the Waldiez workflow asynchronously."""
|
|
388
400
|
|
|
@@ -394,6 +406,7 @@ class WaldiezImportRunner(WaldiezBaseRunner):
|
|
|
394
406
|
output_file=output_file,
|
|
395
407
|
uploads_root=uploads_root,
|
|
396
408
|
skip_mmd=skip_mmd,
|
|
409
|
+
skip_timeline=skip_timeline,
|
|
397
410
|
)
|
|
398
411
|
except Exception as e: # pylint: disable=broad-exception-caught
|
|
399
412
|
self._last_exception = e
|