waldiez 0.5.3__py3-none-any.whl → 0.5.5__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.

Files changed (76) hide show
  1. waldiez/_version.py +1 -1
  2. waldiez/cli.py +3 -27
  3. waldiez/exporter.py +0 -13
  4. waldiez/exporting/agent/exporter.py +38 -0
  5. waldiez/exporting/agent/extras/__init__.py +2 -0
  6. waldiez/exporting/agent/extras/doc_agent_extras.py +366 -0
  7. waldiez/exporting/agent/extras/group_member_extras.py +3 -2
  8. waldiez/exporting/agent/processor.py +113 -15
  9. waldiez/exporting/chats/processor.py +2 -21
  10. waldiez/exporting/chats/utils/common.py +66 -1
  11. waldiez/exporting/chats/utils/group.py +6 -3
  12. waldiez/exporting/chats/utils/nested.py +1 -1
  13. waldiez/exporting/chats/utils/sequential.py +25 -9
  14. waldiez/exporting/chats/utils/single.py +8 -6
  15. waldiez/exporting/core/context.py +0 -12
  16. waldiez/exporting/core/extras/agent_extras/standard_extras.py +3 -1
  17. waldiez/exporting/core/extras/base.py +20 -17
  18. waldiez/exporting/core/extras/path_resolver.py +39 -41
  19. waldiez/exporting/core/extras/serializer.py +16 -1
  20. waldiez/exporting/core/protocols.py +17 -0
  21. waldiez/exporting/core/types.py +6 -9
  22. waldiez/exporting/flow/execution_generator.py +56 -21
  23. waldiez/exporting/flow/exporter.py +1 -4
  24. waldiez/exporting/flow/factory.py +0 -9
  25. waldiez/exporting/flow/file_generator.py +6 -0
  26. waldiez/exporting/flow/orchestrator.py +27 -21
  27. waldiez/exporting/flow/utils/__init__.py +0 -2
  28. waldiez/exporting/flow/utils/common.py +15 -96
  29. waldiez/exporting/flow/utils/importing.py +4 -0
  30. waldiez/io/mqtt.py +33 -14
  31. waldiez/io/redis.py +18 -13
  32. waldiez/io/structured.py +9 -4
  33. waldiez/io/utils.py +32 -0
  34. waldiez/io/ws.py +8 -2
  35. waldiez/models/__init__.py +6 -0
  36. waldiez/models/agents/__init__.py +8 -0
  37. waldiez/models/agents/agent/agent.py +136 -38
  38. waldiez/models/agents/agent/agent_type.py +3 -2
  39. waldiez/models/agents/agents.py +10 -0
  40. waldiez/models/agents/doc_agent/__init__.py +13 -0
  41. waldiez/models/agents/doc_agent/doc_agent.py +126 -0
  42. waldiez/models/agents/doc_agent/doc_agent_data.py +149 -0
  43. waldiez/models/agents/doc_agent/rag_query_engine.py +127 -0
  44. waldiez/models/flow/flow.py +13 -2
  45. waldiez/models/model/__init__.py +2 -2
  46. waldiez/models/model/_aws.py +75 -0
  47. waldiez/models/model/_llm.py +516 -0
  48. waldiez/models/model/_price.py +30 -0
  49. waldiez/models/model/model.py +45 -2
  50. waldiez/models/model/model_data.py +2 -83
  51. waldiez/models/tool/predefined/_duckduckgo.py +123 -0
  52. waldiez/models/tool/predefined/_google.py +31 -9
  53. waldiez/models/tool/predefined/_perplexity.py +161 -0
  54. waldiez/models/tool/predefined/_searxng.py +152 -0
  55. waldiez/models/tool/predefined/_tavily.py +46 -9
  56. waldiez/models/tool/predefined/_wikipedia.py +26 -6
  57. waldiez/models/tool/predefined/_youtube.py +36 -8
  58. waldiez/models/tool/predefined/registry.py +6 -0
  59. waldiez/models/waldiez.py +12 -0
  60. waldiez/runner.py +177 -408
  61. waldiez/running/__init__.py +2 -4
  62. waldiez/running/base_runner.py +100 -112
  63. waldiez/running/environment.py +29 -4
  64. waldiez/running/post_run.py +0 -1
  65. waldiez/running/protocol.py +36 -48
  66. waldiez/running/run_results.py +5 -5
  67. waldiez/running/standard_runner.py +429 -0
  68. waldiez/running/timeline_processor.py +0 -82
  69. {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/METADATA +59 -62
  70. {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/RECORD +74 -64
  71. waldiez/running/import_runner.py +0 -437
  72. waldiez/running/subprocess_runner.py +0 -104
  73. {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/WHEEL +0 -0
  74. {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/entry_points.txt +0 -0
  75. {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/licenses/LICENSE +0 -0
  76. {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/licenses/NOTICE.md +0 -0
@@ -3,11 +3,9 @@
3
3
  """Running related functions."""
4
4
 
5
5
  from .base_runner import WaldiezBaseRunner
6
- from .import_runner import WaldiezImportRunner
7
- from .subprocess_runner import WaldiezSubprocessRunner
6
+ from .standard_runner import WaldiezStandardRunner
8
7
 
9
8
  __all__ = [
10
9
  "WaldiezBaseRunner",
11
- "WaldiezImportRunner",
12
- "WaldiezSubprocessRunner",
10
+ "WaldiezStandardRunner",
13
11
  ]
@@ -12,7 +12,15 @@ import tempfile
12
12
  import threading
13
13
  from pathlib import Path
14
14
  from types import TracebackType
15
- from typing import TYPE_CHECKING, Type, Union
15
+ from typing import (
16
+ TYPE_CHECKING,
17
+ Any,
18
+ Callable,
19
+ Coroutine,
20
+ Optional,
21
+ Type,
22
+ Union,
23
+ )
16
24
 
17
25
  from anyio.from_thread import start_blocking_portal
18
26
  from typing_extensions import Self
@@ -34,7 +42,11 @@ from .utils import (
34
42
  )
35
43
 
36
44
  if TYPE_CHECKING:
37
- from autogen import ChatResult # type: ignore[import-untyped]
45
+ from autogen.events import BaseEvent # type: ignore[import-untyped]
46
+ from autogen.io.run_response import ( # type: ignore[import-untyped]
47
+ AsyncRunResponseProtocol,
48
+ RunResponseProtocol,
49
+ )
38
50
 
39
51
 
40
52
  class WaldiezBaseRunner(WaldiezRunnerProtocol):
@@ -53,9 +65,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
53
65
  - _a_stop: Async actions to perform when stopping the flow.
54
66
  """
55
67
 
56
- _threaded: bool
57
68
  _structured_io: bool
58
- _isolated: bool
59
69
  _output_path: str | Path | None
60
70
  _uploads_root: str | Path | None
61
71
  _skip_patch_io: bool
@@ -67,29 +77,30 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
67
77
  output_path: str | Path | None,
68
78
  uploads_root: str | Path | None,
69
79
  structured_io: bool,
70
- isolated: bool,
71
- threaded: bool,
72
80
  skip_patch_io: bool = False,
73
81
  ) -> None:
74
82
  """Initialize the Waldiez manager."""
75
83
  self._waldiez = waldiez
76
84
  WaldiezBaseRunner._running = False
77
85
  WaldiezBaseRunner._structured_io = structured_io
78
- WaldiezBaseRunner._isolated = isolated
79
86
  WaldiezBaseRunner._output_path = output_path
80
87
  WaldiezBaseRunner._uploads_root = uploads_root
81
- WaldiezBaseRunner._threaded = threaded
82
88
  WaldiezBaseRunner._skip_patch_io = skip_patch_io
83
89
  self._called_install_requirements = False
84
90
  self._exporter = WaldiezExporter(waldiez)
85
91
  self._stop_requested = threading.Event()
86
92
  self._logger = get_logger()
93
+ self._print: Callable[..., None] = print
94
+ self._send: Callable[["BaseEvent"], None] = self._print
95
+ self._input: (
96
+ Callable[..., str] | Callable[..., Coroutine[Any, Any, str]]
97
+ ) = input
87
98
  self._last_results: Union[
88
- "ChatResult",
89
- list["ChatResult"],
90
- dict[int, "ChatResult"],
99
+ list["RunResponseProtocol"], list["AsyncRunResponseProtocol"]
91
100
  ] = []
92
101
  self._last_exception: Exception | None = None
102
+ self._execution_complete_event = threading.Event()
103
+ self._execution_thread: Optional[threading.Thread] = None
93
104
 
94
105
  def is_running(self) -> bool:
95
106
  """Check if the workflow is currently running.
@@ -101,9 +112,64 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
101
112
  """
102
113
  return WaldiezBaseRunner._running
103
114
 
104
- # ===================================================================
105
- # PRIVATE METHODS TO OVERRIDE IN SUBCLASSES
106
- # ===================================================================
115
+ def wait_for_completion(self, timeout: Optional[float] = None) -> bool:
116
+ """Wait for non-blocking execution to complete.
117
+
118
+ This is a base implementation that subclasses can override if needed.
119
+
120
+ Parameters
121
+ ----------
122
+ timeout: float | None
123
+ The maximum time to wait for completion, in seconds.
124
+ If None, wait indefinitely.
125
+
126
+ Returns
127
+ -------
128
+ bool
129
+ True if the workflow completed successfully, False if it timed out.
130
+ """
131
+ # Default implementation - subclasses can override
132
+ if not self.is_running():
133
+ return True
134
+
135
+ if self._execution_thread and self._execution_thread.is_alive():
136
+ self._execution_thread.join(timeout)
137
+ return not self._execution_thread.is_alive()
138
+
139
+ return self._execution_complete_event.wait(timeout or 0)
140
+
141
+ def get_execution_stats(self) -> dict[str, Any]:
142
+ """Get basic execution statistics.
143
+
144
+ Returns
145
+ -------
146
+ dict[str, Any]
147
+ A dictionary containing execution statistics.
148
+ - is_running: Whether the runner is currently running.
149
+ - has_thread: Whether there is an execution thread.
150
+ - thread_alive: Whether the execution thread is alive.
151
+ - has_error: Whether there was an error during execution.
152
+ """
153
+ return {
154
+ "is_running": self.is_running(),
155
+ "has_thread": self._execution_thread is not None,
156
+ "thread_alive": (
157
+ self._execution_thread.is_alive()
158
+ if self._execution_thread
159
+ else False
160
+ ),
161
+ "has_error": self._last_exception is not None,
162
+ }
163
+
164
+ # Helper for subclasses
165
+ def _signal_completion(self) -> None:
166
+ """Signal that execution has completed."""
167
+ self._execution_complete_event.set()
168
+
169
+ def _reset_completion_state(self) -> None:
170
+ """Reset completion state for new execution."""
171
+ self._execution_complete_event.clear()
172
+
107
173
  def _before_run(
108
174
  self,
109
175
  output_file: Path,
@@ -118,10 +184,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
118
184
  path=file_name,
119
185
  force=True,
120
186
  uploads_root=uploads_root,
121
- # if not isolated, we use structured IO in a context manager
122
- structured_io=WaldiezBaseRunner._structured_io
123
- and WaldiezBaseRunner._isolated,
124
- skip_patch_io=WaldiezBaseRunner._skip_patch_io,
187
+ structured_io=WaldiezBaseRunner._structured_io,
125
188
  )
126
189
  return temp_dir
127
190
 
@@ -149,11 +212,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
149
212
  uploads_root: Path | None,
150
213
  skip_mmd: bool,
151
214
  skip_timeline: bool,
152
- ) -> Union[
153
- "ChatResult",
154
- list["ChatResult"],
155
- dict[int, "ChatResult"],
156
- ]: # pyright: ignore
215
+ ) -> Union[list["RunResponseProtocol"], list["AsyncRunResponseProtocol"]]:
157
216
  """Run the Waldiez flow."""
158
217
  raise NotImplementedError(
159
218
  "The _run method must be implemented in the subclass."
@@ -166,11 +225,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
166
225
  uploads_root: Path | None,
167
226
  skip_mmd: bool,
168
227
  skip_timeline: bool,
169
- ) -> Union[
170
- "ChatResult",
171
- list["ChatResult"],
172
- dict[int, "ChatResult"],
173
- ]: # pyright: ignore
228
+ ) -> Union[list["AsyncRunResponseProtocol"], list["RunResponseProtocol"]]:
174
229
  """Run the Waldiez flow asynchronously."""
175
230
  raise NotImplementedError(
176
231
  "The _a_run method must be implemented in the subclass."
@@ -219,9 +274,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
219
274
  def _after_run(
220
275
  self,
221
276
  results: Union[
222
- "ChatResult",
223
- list["ChatResult"],
224
- dict[int, "ChatResult"],
277
+ list["RunResponseProtocol"], list["AsyncRunResponseProtocol"]
225
278
  ],
226
279
  output_file: Path,
227
280
  uploads_root: Path | None,
@@ -248,9 +301,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
248
301
  async def _a_after_run(
249
302
  self,
250
303
  results: Union[
251
- "ChatResult",
252
- list["ChatResult"],
253
- dict[int, "ChatResult"],
304
+ list["RunResponseProtocol"], list["AsyncRunResponseProtocol"]
254
305
  ],
255
306
  output_file: Path,
256
307
  uploads_root: Path | None,
@@ -391,15 +442,9 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
391
442
  output_path: str | Path | None = None,
392
443
  uploads_root: str | Path | None = None,
393
444
  structured_io: bool | None = None,
394
- threaded: bool | None = None,
395
- skip_patch_io: bool | None = None,
396
445
  skip_mmd: bool = False,
397
446
  skip_timeline: bool = False,
398
- ) -> Union[
399
- "ChatResult",
400
- list["ChatResult"],
401
- dict[int, "ChatResult"],
402
- ]: # pyright: ignore
447
+ ) -> Union[list["RunResponseProtocol"], list["AsyncRunResponseProtocol"]]:
403
448
  """Run the Waldiez flow in blocking mode.
404
449
 
405
450
  Parameters
@@ -411,10 +456,6 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
411
456
  structured_io : bool
412
457
  Whether to use structured IO instead of the default 'input/print',
413
458
  by default False.
414
- threaded : bool | None
415
- Whether to run the flow in a threaded environment, by default None.
416
- skip_patch_io : bool | None
417
- Whether to skip patching the IO streams, by default None.
418
459
  skip_mmd : bool
419
460
  Whether to skip generating the mermaid diagram, by default False.
420
461
  skip_timeline : bool
@@ -422,22 +463,17 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
422
463
 
423
464
  Returns
424
465
  -------
425
- Union[ChatResult, list[ChatResult], dict[int, ChatResult]]
426
- The result of the run, which can be a single ChatResult,
427
- a list of ChatResults,
428
- or a dictionary mapping indices to ChatResults.
466
+ Union[list["RunResponseProtocol"], list["AsyncRunResponseProtocol"]]
467
+ The result of the run, which can be a list of RunResponseProtocol
468
+ or a list of AsyncRunResponseProtocol.
429
469
 
430
470
  Raises
431
471
  ------
432
472
  RuntimeError
433
473
  If the runner is already running.
434
474
  """
435
- if skip_patch_io is not None:
436
- WaldiezBaseRunner._skip_patch_io = skip_patch_io
437
475
  if structured_io is not None:
438
476
  WaldiezBaseRunner._structured_io = structured_io
439
- if threaded is not None:
440
- WaldiezBaseRunner._threaded = threaded
441
477
  if self.is_running():
442
478
  raise RuntimeError("Workflow already running")
443
479
  if self.waldiez.is_async:
@@ -447,7 +483,6 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
447
483
  output_path,
448
484
  uploads_root,
449
485
  structured_io,
450
- skip_patch_io,
451
486
  skip_mmd,
452
487
  )
453
488
  output_file, uploads_root_path = self._prepare_paths(
@@ -462,9 +497,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
462
497
  refresh_environment()
463
498
  WaldiezBaseRunner._running = True
464
499
  results: Union[
465
- "ChatResult",
466
- list["ChatResult"],
467
- dict[int, "ChatResult"],
500
+ list["RunResponseProtocol"], list["AsyncRunResponseProtocol"]
468
501
  ] = []
469
502
  old_env_vars = set_env_vars(self.waldiez.get_flow_env_vars())
470
503
  try:
@@ -488,6 +521,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
488
521
  skip_mmd=skip_mmd,
489
522
  skip_timeline=skip_timeline,
490
523
  )
524
+ self._print("<Waldiez> - Done running the flow.")
491
525
  if sys.path[0] == str(temp_dir):
492
526
  sys.path.pop(0)
493
527
  return results
@@ -497,14 +531,9 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
497
531
  output_path: str | Path | None = None,
498
532
  uploads_root: str | Path | None = None,
499
533
  structured_io: bool | None = None,
500
- skip_patch_io: bool | None = None,
501
534
  skip_mmd: bool = False,
502
535
  skip_timeline: bool = False,
503
- ) -> Union[
504
- "ChatResult",
505
- list["ChatResult"],
506
- dict[int, "ChatResult"],
507
- ]: # pyright: ignore
536
+ ) -> Union[list["RunResponseProtocol"], list["AsyncRunResponseProtocol"]]:
508
537
  """Run the Waldiez flow asynchronously.
509
538
 
510
539
  Parameters
@@ -516,8 +545,6 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
516
545
  structured_io : bool
517
546
  Whether to use structured IO instead of the default 'input/print',
518
547
  by default False.
519
- skip_patch_io : bool | None
520
- Whether to skip patching I/O, by default None.
521
548
  skip_mmd : bool
522
549
  Whether to skip generating the mermaid diagram, by default False.
523
550
  skip_timeline : bool
@@ -525,18 +552,15 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
525
552
 
526
553
  Returns
527
554
  -------
528
- Union[ChatResult, list[ChatResult], dict[int, ChatResult]]
529
- The result of the run, which can be a single ChatResult,
530
- a list of ChatResults,
531
- or a dictionary mapping indices to ChatResults.
555
+ Union[list["RunResponseProtocol"], list["AsyncRunResponseProtocol"]]
556
+ The result of the run, which can be a list of RunResponseProtocol
557
+ or a list of AsyncRunResponseProtocol.
532
558
 
533
559
  Raises
534
560
  ------
535
561
  RuntimeError
536
562
  If the runner is already running.
537
563
  """
538
- if skip_patch_io is not None:
539
- WaldiezBaseRunner._skip_patch_io = skip_patch_io
540
564
  if structured_io is not None:
541
565
  WaldiezBaseRunner._structured_io = structured_io
542
566
  if self.is_running():
@@ -553,10 +577,9 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
553
577
  refresh_environment()
554
578
  WaldiezBaseRunner._running = True
555
579
  results: Union[
556
- "ChatResult",
557
- list["ChatResult"],
558
- dict[int, "ChatResult"],
580
+ list["RunResponseProtocol"], list["AsyncRunResponseProtocol"]
559
581
  ] = []
582
+ old_env_vars = set_env_vars(self.waldiez.get_flow_env_vars())
560
583
  try:
561
584
  async with a_chdir(to=temp_dir):
562
585
  sys.path.insert(0, str(temp_dir))
@@ -569,6 +592,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
569
592
  )
570
593
  finally:
571
594
  WaldiezBaseRunner._running = False
595
+ reset_env_vars(old_env_vars)
572
596
  await self._a_after_run(
573
597
  results=results,
574
598
  output_file=output_file,
@@ -586,7 +610,6 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
586
610
  output_path: str | Path | None,
587
611
  uploads_root: str | Path | None,
588
612
  structured_io: bool | None = None,
589
- skip_patch_io: bool | None = None,
590
613
  skip_mmd: bool = False,
591
614
  skip_timeline: bool = False,
592
615
  ) -> None:
@@ -600,8 +623,6 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
600
623
  The runtime uploads root.
601
624
  structured_io : bool | None
602
625
  Whether to use structured IO instead of the default 'input/print'.
603
- skip_patch_io : bool | None
604
- Whether to skip patching I/O, by default None.
605
626
  skip_mmd : bool
606
627
  Whether to skip generating the mermaid diagram, by default False.
607
628
  skip_timeline : bool
@@ -612,8 +633,6 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
612
633
  RuntimeError
613
634
  If the runner is already running.
614
635
  """
615
- if skip_patch_io is not None:
616
- WaldiezBaseRunner._skip_patch_io = skip_patch_io
617
636
  if structured_io is not None:
618
637
  WaldiezBaseRunner._structured_io = structured_io
619
638
  if self.is_running():
@@ -642,7 +661,6 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
642
661
  output_path: str | Path | None,
643
662
  uploads_root: str | Path | None,
644
663
  structured_io: bool | None = None,
645
- skip_patch_io: bool | None = None,
646
664
  skip_mmd: bool = False,
647
665
  skip_timeline: bool = False,
648
666
  ) -> None:
@@ -656,8 +674,6 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
656
674
  The runtime uploads root.
657
675
  structured_io : bool | None = None
658
676
  Whether to use structured IO instead of the default 'input/print'.
659
- skip_patch_io : bool | None = None
660
- Whether to skip patching I/O, by default None.
661
677
  skip_mmd : bool = False
662
678
  Whether to skip generating the mermaid diagram, by default False.
663
679
  skip_timeline : bool = False
@@ -668,8 +684,6 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
668
684
  RuntimeError
669
685
  If the runner is already running.
670
686
  """
671
- if skip_patch_io is not None:
672
- WaldiezBaseRunner._skip_patch_io = skip_patch_io
673
687
  if structured_io is not None:
674
688
  WaldiezBaseRunner._structured_io = structured_io
675
689
  if self.is_running():
@@ -696,9 +710,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
696
710
  def after_run(
697
711
  self,
698
712
  results: Union[
699
- "ChatResult",
700
- list["ChatResult"],
701
- dict[int, "ChatResult"],
713
+ list["RunResponseProtocol"], list["AsyncRunResponseProtocol"]
702
714
  ],
703
715
  output_file: Path,
704
716
  uploads_root: Path | None,
@@ -735,9 +747,7 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
735
747
  async def a_after_run(
736
748
  self,
737
749
  results: Union[
738
- "ChatResult",
739
- list["ChatResult"],
740
- dict[int, "ChatResult"],
750
+ list["RunResponseProtocol"], list["AsyncRunResponseProtocol"]
741
751
  ],
742
752
  output_file: Path,
743
753
  uploads_root: Path | None,
@@ -813,21 +823,11 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
813
823
  """Get the logger for the runner."""
814
824
  return self._logger
815
825
 
816
- @property
817
- def threaded(self) -> bool:
818
- """Check if the runner is running in a threaded environment."""
819
- return WaldiezBaseRunner._threaded
820
-
821
826
  @property
822
827
  def structured_io(self) -> bool:
823
828
  """Check if the runner is using structured IO."""
824
829
  return WaldiezBaseRunner._structured_io
825
830
 
826
- @property
827
- def isolated(self) -> bool:
828
- """Check if the runner is running in an isolated environment."""
829
- return WaldiezBaseRunner._isolated
830
-
831
831
  @property
832
832
  def output_path(self) -> str | Path | None:
833
833
  """Get the output path for the runner."""
@@ -854,9 +854,6 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
854
854
  output_path: str | Path | None = None,
855
855
  uploads_root: str | Path | None = None,
856
856
  structured_io: bool = False,
857
- isolated: bool = False,
858
- threaded: bool = False,
859
- skip_patch_io: bool = True,
860
857
  ) -> "WaldiezBaseRunner":
861
858
  """Load a waldiez flow from a file and create a runner.
862
859
 
@@ -879,12 +876,6 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
879
876
  structured_io : bool, optional
880
877
  Whether to use structured IO instead of the default 'input/print',
881
878
  by default False.
882
- isolated : bool, optional
883
- Whether to run the flow in an isolated environment, default False.
884
- threaded : bool, optional
885
- Whether to run the flow in a threaded environment, default False.
886
- skip_patch_io : bool, optional
887
- Whether to skip patching IO, by default True.
888
879
 
889
880
  Returns
890
881
  -------
@@ -903,9 +894,6 @@ class WaldiezBaseRunner(WaldiezRunnerProtocol):
903
894
  output_path=output_path,
904
895
  uploads_root=uploads_root,
905
896
  structured_io=structured_io,
906
- isolated=isolated,
907
- threaded=threaded,
908
- skip_patch_io=skip_patch_io,
909
897
  )
910
898
 
911
899
  def __enter__(self) -> Self:
@@ -1,6 +1,8 @@
1
1
  # SPDX-License-Identifier: Apache-2.0.
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
- # pylint: disable=import-outside-toplevel,reimported
3
+ # pylint: disable=import-outside-toplevel,reimported,line-too-long
4
+ # flake8: noqa: E501, F401
5
+ # pyright: reportUnusedImport=false
4
6
  """Environment related utilities."""
5
7
 
6
8
  import importlib
@@ -54,12 +56,14 @@ def refresh_environment() -> None:
54
56
  # default code execution with docker
55
57
  # temp (until we handle/detect docker setup)
56
58
  os.environ["AUTOGEN_USE_DOCKER"] = "0"
59
+ os.environ["ANONYMIZED_TELEMETRY"] = "False"
57
60
  try_handle_the_np_thing()
58
61
  reload_autogen()
62
+ reload_chroma_if_needed()
59
63
 
60
64
 
61
65
  # pylint: disable=too-complex,too-many-try-statements,unused-import
62
- def reload_autogen() -> None: # noqa: C901
66
+ def reload_autogen() -> None: # noqa: C901 # pragma: no cover
63
67
  """Reload the autogen package.
64
68
 
65
69
  Try to avoid "please install package x" errors
@@ -106,7 +110,7 @@ def reload_autogen() -> None: # noqa: C901
106
110
 
107
111
  if "autogen" in sys.modules:
108
112
  del sys.modules["autogen"]
109
-
113
+ site.main() # Rebuild the site module cache
110
114
  # Re-import autogen
111
115
  # pylint: disable=unused-import
112
116
  import autogen # pyright: ignore
@@ -149,6 +153,27 @@ def reload_autogen() -> None: # noqa: C901
149
153
  raise e
150
154
 
151
155
 
156
+ def reload_chroma_if_needed() -> None: # pragma: no cover
157
+ """Reload the chroma package if it is installed."""
158
+ cheomadb_modules = [
159
+ name
160
+ for name in sys.modules
161
+ if name.startswith("chromadb.") or name == "chromadb"
162
+ ]
163
+ if not cheomadb_modules:
164
+ return
165
+
166
+ for mod_name in sorted(cheomadb_modules, key=len, reverse=True):
167
+ # Remove chromadb modules in reverse dependency order
168
+ if mod_name in sys.modules:
169
+ del sys.modules[mod_name]
170
+ try:
171
+ import chromadb # type: ignore[unused-ignore, import-not-found, import-untyped]
172
+ except ImportError:
173
+ # If chromadb is not installed, we can ignore this
174
+ return
175
+
176
+
152
177
  def try_handle_the_np_thing() -> None:
153
178
  """Try to handle the numpy deprecation warning."""
154
179
  # we might get:
@@ -160,7 +185,7 @@ def try_handle_the_np_thing() -> None:
160
185
  os.environ["NPY_PROMOTION_STATE"] = "weak"
161
186
  import numpy as np
162
187
 
163
- if not hasattr(np, "_no_pep50_warning"):
188
+ if not hasattr(np, "_no_pep50_warning"): # pragma: no branch
164
189
  import contextlib
165
190
 
166
191
  @contextlib.contextmanager
@@ -99,7 +99,6 @@ def _make_timeline_json(
99
99
  """Make the timeline JSON file."""
100
100
  events_csv_path = temp_dir / "logs" / "events.csv"
101
101
  if events_csv_path.exists():
102
- print("Processing timeline...")
103
102
  log_files = TimelineProcessor.get_files(temp_dir / "logs")
104
103
  if any(log_files.values()):
105
104
  output_file = temp_dir / "timeline.json"