waldiez 0.4.8__py3-none-any.whl → 0.4.11__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/__init__.py +1 -2
- waldiez/_version.py +1 -1
- waldiez/cli.py +90 -96
- waldiez/exporter.py +64 -9
- waldiez/exporting/agent/extras/rag/chroma_extras.py +21 -9
- waldiez/exporting/core/context.py +12 -0
- waldiez/exporting/core/extras/flow_extras.py +2 -14
- waldiez/exporting/core/types.py +21 -0
- waldiez/exporting/flow/exporter.py +4 -0
- waldiez/exporting/flow/factory.py +16 -0
- waldiez/exporting/flow/orchestrator.py +12 -0
- waldiez/exporting/flow/utils/__init__.py +2 -0
- waldiez/exporting/flow/utils/common.py +96 -2
- waldiez/exporting/flow/utils/logging.py +5 -6
- waldiez/io/mqtt.py +7 -3
- waldiez/io/structured.py +26 -2
- waldiez/models/common/method_utils.py +1 -1
- waldiez/models/tool/tool.py +2 -1
- waldiez/runner.py +402 -332
- waldiez/running/__init__.py +6 -28
- waldiez/running/base_runner.py +907 -0
- waldiez/running/environment.py +74 -0
- waldiez/running/import_runner.py +424 -0
- waldiez/running/patch_io_stream.py +208 -0
- waldiez/running/post_run.py +121 -0
- waldiez/running/pre_run.py +105 -0
- waldiez/running/protocol.py +281 -0
- waldiez/running/run_results.py +22 -0
- waldiez/running/subprocess_runner.py +100 -0
- waldiez/running/utils.py +134 -0
- waldiez/utils/__init__.py +2 -2
- waldiez/utils/version.py +49 -0
- {waldiez-0.4.8.dist-info → waldiez-0.4.11.dist-info}/METADATA +11 -11
- {waldiez-0.4.8.dist-info → waldiez-0.4.11.dist-info}/RECORD +38 -30
- waldiez/running/running.py +0 -388
- waldiez/utils/flaml_warnings.py +0 -17
- {waldiez-0.4.8.dist-info → waldiez-0.4.11.dist-info}/WHEEL +0 -0
- {waldiez-0.4.8.dist-info → waldiez-0.4.11.dist-info}/entry_points.txt +0 -0
- {waldiez-0.4.8.dist-info → waldiez-0.4.11.dist-info}/licenses/LICENSE +0 -0
- {waldiez-0.4.8.dist-info → waldiez-0.4.11.dist-info}/licenses/NOTICE.md +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
waldiez/__init__.py,sha256=
|
|
1
|
+
waldiez/__init__.py,sha256=GdbXP8mS6FUiljxvd-eH_J2gEztoHCQpD8Hq51GKUSs,943
|
|
2
2
|
waldiez/__main__.py,sha256=0dYzNrQbovRwQQvmZC6_1FDR1m71SUIOkTleO5tBnBw,203
|
|
3
|
-
waldiez/_version.py,sha256=
|
|
4
|
-
waldiez/cli.py,sha256=
|
|
5
|
-
waldiez/exporter.py,sha256=
|
|
3
|
+
waldiez/_version.py,sha256=QWIp4Z7OVTDhuUBWdL2fCZ0bU8ohzZDEUGN0OpjYUGQ,250
|
|
4
|
+
waldiez/cli.py,sha256=yVa82t0YRLzif9S8yTDrwuMdCpfHwWsLnfi8zl3MDyg,8850
|
|
5
|
+
waldiez/exporter.py,sha256=IEk8LM-tqjLxyi7R8M9wmbFXf4kZiqmiOMmsZumkgns,8347
|
|
6
6
|
waldiez/logger.py,sha256=UFdPwS2AOl2LkFQVonDSET9Dguq5jsn2mV817iTZFJc,16375
|
|
7
7
|
waldiez/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
waldiez/runner.py,sha256=
|
|
8
|
+
waldiez/runner.py,sha256=ZeT_ERfzcm7mhLGH0po5Of0ecq9fQ_0c3ECdNRgq7g0,15619
|
|
9
9
|
waldiez/exporting/__init__.py,sha256=xVOqb3gADkrTmp_BVrQ-dMPiySPUDU4xZmqYqhzL8BI,1026
|
|
10
10
|
waldiez/exporting/agent/__init__.py,sha256=GpNfVQLAvGoJP_U4WkMMIGpEB8k7vEV-FVR446s2zhY,260
|
|
11
11
|
waldiez/exporting/agent/code_execution.py,sha256=sxjulr2OmeSg0SrYz7rgpBgF_AfqpHfV86kmtGU49Yk,3795
|
|
@@ -28,7 +28,7 @@ waldiez/exporting/agent/extras/handoffs/condition.py,sha256=kURtSLS5B0WbXPARff3t
|
|
|
28
28
|
waldiez/exporting/agent/extras/handoffs/handoff.py,sha256=Xp0sYpXIoXQ6GbLrLPxylDpyNPiE2w1oXmQ-UqfnK7U,5918
|
|
29
29
|
waldiez/exporting/agent/extras/handoffs/target.py,sha256=R7KerfkL1kXkGMnoy1GXaOTH6DM6LSKXl7ohpTcInCE,6527
|
|
30
30
|
waldiez/exporting/agent/extras/rag/__init__.py,sha256=jkKSaHLfwA8Tj7QJH0MSdAphaP4HowuhQXDj7V122Ek,259
|
|
31
|
-
waldiez/exporting/agent/extras/rag/chroma_extras.py,sha256=
|
|
31
|
+
waldiez/exporting/agent/extras/rag/chroma_extras.py,sha256=vf4EuikCZPtqFEOCoB01YcD85Hi_SA37b1JO869DqSA,5555
|
|
32
32
|
waldiez/exporting/agent/extras/rag/mongo_extras.py,sha256=bn_5bfmyfdW5eQCOjcCRYPKLIJ7vZXKEiUsa4zPx7Sk,2822
|
|
33
33
|
waldiez/exporting/agent/extras/rag/pgvector_extras.py,sha256=Y08rU8Z3-oHUbh7huO1Jo_PZLlOW-NRa1Gz3-d9WXso,2961
|
|
34
34
|
waldiez/exporting/agent/extras/rag/qdrant_extras.py,sha256=hTzY7GUL8RBMFNEGefLDAxKFMSlD5Qmkzm3Ducgp9vU,3633
|
|
@@ -46,19 +46,19 @@ waldiez/exporting/chats/utils/single.py,sha256=oOlqDxRcws0Dp7ignu-7tqzMBFgshKX-0
|
|
|
46
46
|
waldiez/exporting/core/__init__.py,sha256=XwXYuiWyaPfTirac_3wVlNTBa5n0X09V752Bc4Dd0cg,3930
|
|
47
47
|
waldiez/exporting/core/constants.py,sha256=PcJQftkXX7FsDkilH_jihje_9j9SenCjUa5Hj-95akQ,492
|
|
48
48
|
waldiez/exporting/core/content.py,sha256=uxOnySvI30a2zgzkvdzkzhppZ-S1QnSxWPSJhy9wPMg,2063
|
|
49
|
-
waldiez/exporting/core/context.py,sha256=
|
|
49
|
+
waldiez/exporting/core/context.py,sha256=p6wVl_wEALOoUdJUrMCNZGbcA7myG3XLJ8HmyFqOfyQ,8375
|
|
50
50
|
waldiez/exporting/core/enums.py,sha256=CvmtPRv-4GwKpO2l0wXxxoV8Q5Oy5L5t0gnEMK8MVws,2464
|
|
51
51
|
waldiez/exporting/core/errors.py,sha256=xLfq3Z4Kg2aqlu7zYOtBd5ces7RLG-o_nF82ITFsaJg,535
|
|
52
52
|
waldiez/exporting/core/exporter.py,sha256=G-riIXeI6Ukr30mhpNNzDwbHvztZDbOhtUO5eTUYl5M,11173
|
|
53
53
|
waldiez/exporting/core/exporters.py,sha256=tlX8e-8EeLNRh49gFPDswM4EQ8nrxnXtLUn4OmmuoyM,1795
|
|
54
54
|
waldiez/exporting/core/protocols.py,sha256=xRnhET6WXc4vYbA-MoeUNRoxqt1MViSvTjwCaZLSvX4,7269
|
|
55
55
|
waldiez/exporting/core/result.py,sha256=DiN-doVKKt_FTzB4l4oNPBXbWbVDYD0nDYcNBeWC5dE,20984
|
|
56
|
-
waldiez/exporting/core/types.py,sha256=
|
|
56
|
+
waldiez/exporting/core/types.py,sha256=b4G9qZ5r6q8-ap2zAVcvL7vHpynbY5pcG8QQWXofL4g,10307
|
|
57
57
|
waldiez/exporting/core/validation.py,sha256=YlYpv4-VnBwmllznB1uijexPHaYDOrtnNwkS5QlQKF8,2728
|
|
58
58
|
waldiez/exporting/core/extras/__init__.py,sha256=I9t7fmPpcLTwe0bErsfyoLcC6VrimJ2fw52K-JuAUYU,962
|
|
59
59
|
waldiez/exporting/core/extras/base.py,sha256=ldmYmw3uCz3A-FQNoprdYiM1_45PYzm_oGtUR9OtFkI,7593
|
|
60
60
|
waldiez/exporting/core/extras/chat_extras.py,sha256=rGbkmP6uj4bteyS9RvHrEdguNYYb32SOzVeqXuv1x5s,3435
|
|
61
|
-
waldiez/exporting/core/extras/flow_extras.py,sha256=
|
|
61
|
+
waldiez/exporting/core/extras/flow_extras.py,sha256=8iktgmIMQ9mWMhGPvsFn1dKzflrQlscInE3zlA9ya3M,1661
|
|
62
62
|
waldiez/exporting/core/extras/model_extras.py,sha256=bXbfgHEr9eD2KkarowzRCuYaH0qFzv4Bd0lcwn5JjzA,2069
|
|
63
63
|
waldiez/exporting/core/extras/path_resolver.py,sha256=jongTqCMJFQ2rombuDenGwtYVEh-yrDMDgze2rOBKmQ,2140
|
|
64
64
|
waldiez/exporting/core/extras/serializer.py,sha256=mFkvTHkEF73V4CtUfxN9b6tczzCyvTHMvDIxA4PcVWY,3567
|
|
@@ -74,16 +74,16 @@ waldiez/exporting/core/utils/comment.py,sha256=0RDl48DQsOoL4V8J2334LsjMU-dHtTgUT
|
|
|
74
74
|
waldiez/exporting/core/utils/llm_config.py,sha256=NYsHimHk3c2Azjr7N4gMqjlSZO5Vw4FdFPgTxzv55iE,3959
|
|
75
75
|
waldiez/exporting/flow/__init__.py,sha256=bsKIPmNhhNb7MPnimwL2X2fe8L4tXa_dH3CCDCNJ_6g,255
|
|
76
76
|
waldiez/exporting/flow/execution_generator.py,sha256=uDlQrOh5z6SQS2ZcgBMqZ4gd0zxW0QgvlU9qOG9c4i8,6268
|
|
77
|
-
waldiez/exporting/flow/exporter.py,sha256=
|
|
78
|
-
waldiez/exporting/flow/factory.py,sha256=
|
|
77
|
+
waldiez/exporting/flow/exporter.py,sha256=8wRTCiAR4JZdxT4c22cRa6E2xFx0xs34vsZZIMZblRQ,3486
|
|
78
|
+
waldiez/exporting/flow/factory.py,sha256=GbUb8ou4pfLh2QQt17I6mFSbc3Nwuh6RY1bJqCjbHuw,3640
|
|
79
79
|
waldiez/exporting/flow/file_generator.py,sha256=7Wj2magf2J9N_jd0JzzNLuhvNBv77VhPxJX7xAZRdfE,6762
|
|
80
80
|
waldiez/exporting/flow/merger.py,sha256=F9VNFDqic4cKRAxne5kFNQT0Jn_BccVvJuOQF365ld4,12247
|
|
81
|
-
waldiez/exporting/flow/orchestrator.py,sha256=
|
|
82
|
-
waldiez/exporting/flow/utils/__init__.py,sha256=
|
|
83
|
-
waldiez/exporting/flow/utils/common.py,sha256=
|
|
81
|
+
waldiez/exporting/flow/orchestrator.py,sha256=2x2nTITgb0Q9OZLufDpTBMteu3PNFQq1qQt5KwdFq1s,15523
|
|
82
|
+
waldiez/exporting/flow/utils/__init__.py,sha256=Wh-ptZOkqt8FdRnHNfSqeJJzKS6LL9TP_VbToWnhHo4,632
|
|
83
|
+
waldiez/exporting/flow/utils/common.py,sha256=YY-4pN1zgD34d0ZHDBSZ3tteIZQyO4AUJe3bUPjNILc,7782
|
|
84
84
|
waldiez/exporting/flow/utils/importing.py,sha256=EnKeHZbD3H-xXYTZYaFJGIY6mAolVP-NNCasFHsYX9I,11119
|
|
85
85
|
waldiez/exporting/flow/utils/linting.py,sha256=N5WHCn0vANMWzl4Wzi5KA_2SwfIeVdig4_jalC5gh6I,4686
|
|
86
|
-
waldiez/exporting/flow/utils/logging.py,sha256=
|
|
86
|
+
waldiez/exporting/flow/utils/logging.py,sha256=4Nlj95TFfpHfgjYWOOKEIipYppJdFyGpVgpZszuC47A,11965
|
|
87
87
|
waldiez/exporting/models/__init__.py,sha256=xYq6kUfoeE5Jyml0PJJiviayEPFh82kxbk9C208BvbQ,279
|
|
88
88
|
waldiez/exporting/models/exporter.py,sha256=4rocKI0cTh-njbZhZdbOrRODGK-0L-xumfFgeM_ndRk,7220
|
|
89
89
|
waldiez/exporting/models/factory.py,sha256=d6DeI2aeY64zrjnmdG43bfBkfwTBBHOcS-4t0p43GqE,2053
|
|
@@ -95,9 +95,9 @@ waldiez/exporting/tools/processor.py,sha256=g9T60wucRHp91kTnc0Z3_ulg6Mn0LNhXWfL-
|
|
|
95
95
|
waldiez/exporting/tools/registration.py,sha256=Jf9QSQIDPCJoePc86zEMyxWUF-4a04qA2jQemodGmEA,3896
|
|
96
96
|
waldiez/io/__init__.py,sha256=x4-LxBgHd0ekLXyccgcgV8ERwKRENaJQxaegULkRW3g,3361
|
|
97
97
|
waldiez/io/_ws.py,sha256=uyuIfCrBK7LDXowTQ2fsbP4jvjUcIQZqPQefx2UXmp8,5652
|
|
98
|
-
waldiez/io/mqtt.py,sha256=
|
|
98
|
+
waldiez/io/mqtt.py,sha256=bLEH5vWuQXjtLxqyDYHI-WjZs7fhH5QraENuaBi8YXc,22660
|
|
99
99
|
waldiez/io/redis.py,sha256=diz0UqgcpIejBGFb9TOoT2iVzGtHWFnhg0cfEOox25Q,25523
|
|
100
|
-
waldiez/io/structured.py,sha256=
|
|
100
|
+
waldiez/io/structured.py,sha256=RiR9231ayskt0RvEyENhcHuFcfYFi08807PGXjGWJzw,14622
|
|
101
101
|
waldiez/io/utils.py,sha256=J2I0cuBMMjJadM8OjP7kiqFjoZp8hc9rXF9n5fdltEE,4488
|
|
102
102
|
waldiez/io/ws.py,sha256=aiORAYjvSA57ZqI1mXINkkHnZzqkibaICTj2bZ9Yze8,9107
|
|
103
103
|
waldiez/io/models/__init__.py,sha256=N21ET1_QEkCsJNrax8y5cDDiTrGj2rv9BfEsVvUY1m0,1240
|
|
@@ -163,7 +163,7 @@ waldiez/models/common/date_utils.py,sha256=NdVmShZjvhDVT-Y5rT8FgwQTHcDoljBJQauTs
|
|
|
163
163
|
waldiez/models/common/dict_utils.py,sha256=_Csan1HqlGFo0jVRxLQ2-2y5jzL-9qD6ggXn10nb6Vo,1958
|
|
164
164
|
waldiez/models/common/handoff.py,sha256=lJosPlt-N2RSLdbK60h77AEi9h5y6rRMMtkj-CaPp6U,12172
|
|
165
165
|
waldiez/models/common/id_generator.py,sha256=XoAzdZ0Os5ds4HFQMT_Dd53ryrmG-tB4rWKrz1D-j9A,421
|
|
166
|
-
waldiez/models/common/method_utils.py,sha256=
|
|
166
|
+
waldiez/models/common/method_utils.py,sha256=S2jCxxWdfhVIxJN3bj5Uo0HtVuYQufvc-jC88ffQ6a8,11866
|
|
167
167
|
waldiez/models/common/naming.py,sha256=w5k6q7NPsBHQTAQBwlA07D_3q2Qn6w_V0pcqxNLLyVk,3534
|
|
168
168
|
waldiez/models/common/waldiez_version.py,sha256=0IDG6cIBgBjzaVSLhthhL-K5dYt3tC2rfW_mLBQDYUc,1216
|
|
169
169
|
waldiez/models/flow/__init__.py,sha256=-EdEvNRRqcRuK1JAqV9glg31e8Ic7_Tx4QCzJUdEq40,580
|
|
@@ -178,23 +178,31 @@ waldiez/models/model/model.py,sha256=3yMlwdlagDU1jeIdij-esnZfUvlhyPiBp-rz3PWeFbE
|
|
|
178
178
|
waldiez/models/model/model_data.py,sha256=QJ-mNneo-w8Q5ZtZx6eQ4WAtS5fxSQ7BcABKtmQRQwo,6140
|
|
179
179
|
waldiez/models/tool/__init__.py,sha256=6-oOUyHO13MUj-Kqiw-A-2a0KahxRlIdMHgEOHXoTC0,456
|
|
180
180
|
waldiez/models/tool/extra_requirements.py,sha256=kNrmWxS96FhO93NV3B5Hr5wAJrjuUWbBrclpCikW4ng,988
|
|
181
|
-
waldiez/models/tool/tool.py,sha256=
|
|
181
|
+
waldiez/models/tool/tool.py,sha256=GOqtq21ZOi-go2DXmBik4hJAc_MPZ6uSo5ZrM2rgboY,9008
|
|
182
182
|
waldiez/models/tool/tool_data.py,sha256=lOtIetRM35tUvDCtjiHjddVSoqlwV4NFkz_496GLunA,1305
|
|
183
183
|
waldiez/models/tool/tool_type.py,sha256=VYcgnAlj1n6ZqXA8D0VdbRfZ-_U89CPSDuNgk822_UA,268
|
|
184
|
-
waldiez/running/__init__.py,sha256=
|
|
185
|
-
waldiez/running/
|
|
184
|
+
waldiez/running/__init__.py,sha256=4A3FHJcN4a9P8OWlKblikl89O4bzKa6JcTAPNBuwTh0,370
|
|
185
|
+
waldiez/running/base_runner.py,sha256=tp_2fFU-LFORYq0wENVFi0ZVNwm6jrZ5F1Y_oy2aSvs,29828
|
|
186
|
+
waldiez/running/environment.py,sha256=RMlX_yekAQKhexAHjWO1oAhJVRj88Qz01ZDLxfzYYWQ,5729
|
|
186
187
|
waldiez/running/gen_seq_diagram.py,sha256=wsF9b9uG0NA5iVAlW-wOtYn0w_9-bySBO9nWkUIBNUc,5943
|
|
187
|
-
waldiez/running/
|
|
188
|
-
waldiez/
|
|
188
|
+
waldiez/running/import_runner.py,sha256=fW8LdhymRvYUD3Pc0DpcDkozQHC9QQNXlUVMCl3MYj8,15687
|
|
189
|
+
waldiez/running/patch_io_stream.py,sha256=HcbS_580xSa1YD6qy6FalbuJcpMGh9Qc87MSybtGh2c,6808
|
|
190
|
+
waldiez/running/post_run.py,sha256=kD5VIjfrqeXqRqq6DhkuZcXvh7kVaiWZ_T9-KA9D0nU,3980
|
|
191
|
+
waldiez/running/pre_run.py,sha256=ASQ5uQx6lvI67kwyLVNJm6j2ZCCeCBBl40Z3t-Ra7lk,3667
|
|
192
|
+
waldiez/running/protocol.py,sha256=nAIz219Hv_0o03TNzimRzA9c0Yk7LX5csdJyJb0zRjo,8452
|
|
193
|
+
waldiez/running/run_results.py,sha256=c1fp5WTi8CEXIZpZRRH4nkJKW6RidhzIfIatjJVe9Kw,518
|
|
194
|
+
waldiez/running/subprocess_runner.py,sha256=S_B0QhH4vSRW9qyOcIy7s0jEcT3dAen4N4sPAk4tazI,2776
|
|
195
|
+
waldiez/running/utils.py,sha256=7DnuL-FNkraDhu3QUV3GEZC_dNgo3IMlptBzG9tMUKA,3002
|
|
196
|
+
waldiez/utils/__init__.py,sha256=pci9Z4pO6nEnoqCPfJBDIISYDuGH65NTRC_evZbV7ao,336
|
|
189
197
|
waldiez/utils/conflict_checker.py,sha256=bskxC2KmPrAOjjYfgQhGXgNxdU5Z10ZZmx-_c0W8I7I,1493
|
|
190
|
-
waldiez/utils/
|
|
198
|
+
waldiez/utils/version.py,sha256=qaduzoxI1qBEtDLdM5Gw0V76YgF1WABPcDC95VL8HLQ,1452
|
|
191
199
|
waldiez/utils/cli_extras/__init__.py,sha256=ZvuLaN3IGuffWMh7mladTGkJxx3kn5IepUF3jk4ZAWY,684
|
|
192
200
|
waldiez/utils/cli_extras/jupyter.py,sha256=nOQraO7Xg1G8SCP93OpIVheXieXW5ireSC9Oir-dXzA,3047
|
|
193
201
|
waldiez/utils/cli_extras/runner.py,sha256=V_aoTKZsvtPgjszvWlPamKjnOG93L2aY6sBcHnIh9XI,983
|
|
194
202
|
waldiez/utils/cli_extras/studio.py,sha256=p4CMDCYW6lxrPvHvWX2kpsE1Ix7NnKZg1Jf15weWirE,984
|
|
195
|
-
waldiez-0.4.
|
|
196
|
-
waldiez-0.4.
|
|
197
|
-
waldiez-0.4.
|
|
198
|
-
waldiez-0.4.
|
|
199
|
-
waldiez-0.4.
|
|
200
|
-
waldiez-0.4.
|
|
203
|
+
waldiez-0.4.11.dist-info/METADATA,sha256=OiHsNqVC0_0UYWvpWcsC8K5vXD3BM4OEJM6atU8XvPI,22638
|
|
204
|
+
waldiez-0.4.11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
205
|
+
waldiez-0.4.11.dist-info/entry_points.txt,sha256=9MQ8Y1rD19CU7UwjNPwoyTRpQsPs2QimjrtwTD0bD6k,44
|
|
206
|
+
waldiez-0.4.11.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
207
|
+
waldiez-0.4.11.dist-info/licenses/NOTICE.md,sha256=L7xtckFRYvYJjhjQNtFpURWCiAvEuq4ePvxJsC-XAdk,785
|
|
208
|
+
waldiez-0.4.11.dist-info/RECORD,,
|
waldiez/running/running.py
DELETED
|
@@ -1,388 +0,0 @@
|
|
|
1
|
-
# SPDX-License-Identifier: Apache-2.0.
|
|
2
|
-
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
-
"""Utilities for running code."""
|
|
4
|
-
|
|
5
|
-
import asyncio
|
|
6
|
-
import datetime
|
|
7
|
-
import io
|
|
8
|
-
import os
|
|
9
|
-
import re
|
|
10
|
-
import shutil
|
|
11
|
-
import subprocess
|
|
12
|
-
import sys
|
|
13
|
-
import tempfile
|
|
14
|
-
from contextlib import asynccontextmanager, contextmanager
|
|
15
|
-
from pathlib import Path
|
|
16
|
-
from typing import (
|
|
17
|
-
Any,
|
|
18
|
-
AsyncIterator,
|
|
19
|
-
Callable,
|
|
20
|
-
Iterator,
|
|
21
|
-
Optional,
|
|
22
|
-
Set,
|
|
23
|
-
Union,
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
from .environment import in_virtualenv, is_root
|
|
27
|
-
from .gen_seq_diagram import generate_sequence_diagram
|
|
28
|
-
|
|
29
|
-
# pylint: disable=import-outside-toplevel
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
@contextmanager
|
|
33
|
-
def chdir(to: Union[str, Path]) -> Iterator[None]:
|
|
34
|
-
"""Change the current working directory in a context.
|
|
35
|
-
|
|
36
|
-
Parameters
|
|
37
|
-
----------
|
|
38
|
-
to : Union[str, Path]
|
|
39
|
-
The directory to change to.
|
|
40
|
-
|
|
41
|
-
Yields
|
|
42
|
-
------
|
|
43
|
-
Iterator[None]
|
|
44
|
-
The context manager.
|
|
45
|
-
"""
|
|
46
|
-
old_cwd = str(os.getcwd())
|
|
47
|
-
os.chdir(to)
|
|
48
|
-
try:
|
|
49
|
-
yield
|
|
50
|
-
finally:
|
|
51
|
-
os.chdir(old_cwd)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
@asynccontextmanager
|
|
55
|
-
async def a_chdir(to: Union[str, Path]) -> AsyncIterator[None]:
|
|
56
|
-
"""Asynchronously change the current working directory in a context.
|
|
57
|
-
|
|
58
|
-
Parameters
|
|
59
|
-
----------
|
|
60
|
-
to : Union[str, Path]
|
|
61
|
-
The directory to change to.
|
|
62
|
-
|
|
63
|
-
Yields
|
|
64
|
-
------
|
|
65
|
-
AsyncIterator[None]
|
|
66
|
-
The async context manager.
|
|
67
|
-
"""
|
|
68
|
-
old_cwd = str(os.getcwd())
|
|
69
|
-
os.chdir(to)
|
|
70
|
-
try:
|
|
71
|
-
yield
|
|
72
|
-
finally:
|
|
73
|
-
os.chdir(old_cwd)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
def strip_ansi(text: str) -> str:
|
|
77
|
-
"""Remove ANSI escape sequences from text.
|
|
78
|
-
|
|
79
|
-
Parameters
|
|
80
|
-
----------
|
|
81
|
-
text : str
|
|
82
|
-
The text to strip.
|
|
83
|
-
|
|
84
|
-
Returns
|
|
85
|
-
-------
|
|
86
|
-
str
|
|
87
|
-
The text without ANSI escape sequences.
|
|
88
|
-
"""
|
|
89
|
-
ansi_pattern = re.compile(r"\x1b\[[0-9;]*m|\x1b\[.*?[@-~]")
|
|
90
|
-
return ansi_pattern.sub("", text)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
def before_run(
|
|
94
|
-
output_path: Optional[Union[str, Path]],
|
|
95
|
-
uploads_root: Optional[Union[str, Path]],
|
|
96
|
-
) -> str:
|
|
97
|
-
"""Actions to perform before running the flow.
|
|
98
|
-
|
|
99
|
-
Parameters
|
|
100
|
-
----------
|
|
101
|
-
output_path : Optional[Union[str, Path]]
|
|
102
|
-
The output path.
|
|
103
|
-
uploads_root : Optional[Union[str, Path]]
|
|
104
|
-
The runtime uploads root.
|
|
105
|
-
|
|
106
|
-
Returns
|
|
107
|
-
-------
|
|
108
|
-
str
|
|
109
|
-
The file name.
|
|
110
|
-
"""
|
|
111
|
-
if not uploads_root:
|
|
112
|
-
uploads_root = Path(tempfile.mkdtemp())
|
|
113
|
-
else:
|
|
114
|
-
uploads_root = Path(uploads_root)
|
|
115
|
-
if not uploads_root.exists():
|
|
116
|
-
uploads_root.mkdir(parents=True)
|
|
117
|
-
file_name = "waldiez_flow.py" if not output_path else Path(output_path).name
|
|
118
|
-
if file_name.endswith((".json", ".waldiez")):
|
|
119
|
-
file_name = file_name.replace(".json", ".py").replace(".waldiez", ".py")
|
|
120
|
-
if not file_name.endswith(".py"):
|
|
121
|
-
file_name += ".py"
|
|
122
|
-
return file_name
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
def install_requirements(
|
|
126
|
-
extra_requirements: Set[str], printer: Callable[..., None]
|
|
127
|
-
) -> None:
|
|
128
|
-
"""Install the requirements.
|
|
129
|
-
|
|
130
|
-
Parameters
|
|
131
|
-
----------
|
|
132
|
-
extra_requirements : Set[str]
|
|
133
|
-
The extra requirements.
|
|
134
|
-
printer : Callable[..., None]
|
|
135
|
-
The printer function.
|
|
136
|
-
"""
|
|
137
|
-
requirements_string = ", ".join(extra_requirements)
|
|
138
|
-
printer(f"Installing requirements: {requirements_string}")
|
|
139
|
-
pip_install = [sys.executable, "-m", "pip", "install"]
|
|
140
|
-
break_system_packages = ""
|
|
141
|
-
if not in_virtualenv(): # it should
|
|
142
|
-
# if not, let's try to install as user
|
|
143
|
-
# not sure if --break-system-packages is safe,
|
|
144
|
-
# but it might fail if we don't
|
|
145
|
-
break_system_packages = os.environ.get("PIP_BREAK_SYSTEM_PACKAGES", "")
|
|
146
|
-
os.environ["PIP_BREAK_SYSTEM_PACKAGES"] = "1"
|
|
147
|
-
if not is_root():
|
|
148
|
-
pip_install.append("--user")
|
|
149
|
-
pip_install.extend(extra_requirements)
|
|
150
|
-
# pylint: disable=too-many-try-statements
|
|
151
|
-
try:
|
|
152
|
-
with subprocess.Popen(
|
|
153
|
-
pip_install,
|
|
154
|
-
stdout=subprocess.PIPE,
|
|
155
|
-
stderr=subprocess.PIPE,
|
|
156
|
-
) as proc:
|
|
157
|
-
if proc.stdout:
|
|
158
|
-
for line in io.TextIOWrapper(proc.stdout, encoding="utf-8"):
|
|
159
|
-
printer(strip_ansi(line.strip()))
|
|
160
|
-
if proc.stderr:
|
|
161
|
-
for line in io.TextIOWrapper(proc.stderr, encoding="utf-8"):
|
|
162
|
-
printer(strip_ansi(line.strip()))
|
|
163
|
-
finally:
|
|
164
|
-
if not in_virtualenv():
|
|
165
|
-
# restore the old env var
|
|
166
|
-
if break_system_packages:
|
|
167
|
-
os.environ["PIP_BREAK_SYSTEM_PACKAGES"] = break_system_packages
|
|
168
|
-
else:
|
|
169
|
-
del os.environ["PIP_BREAK_SYSTEM_PACKAGES"]
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
async def a_install_requirements(
|
|
173
|
-
extra_requirements: Set[str], printer: Callable[..., None]
|
|
174
|
-
) -> None:
|
|
175
|
-
"""Install the requirements asynchronously.
|
|
176
|
-
|
|
177
|
-
Parameters
|
|
178
|
-
----------
|
|
179
|
-
extra_requirements : Set[str]
|
|
180
|
-
The extra requirements.
|
|
181
|
-
printer : Callable[..., None]
|
|
182
|
-
The printer function.
|
|
183
|
-
"""
|
|
184
|
-
requirements_string = ", ".join(extra_requirements)
|
|
185
|
-
printer(f"Installing requirements: {requirements_string}")
|
|
186
|
-
pip_install = [sys.executable, "-m", "pip", "install"]
|
|
187
|
-
break_system_packages = ""
|
|
188
|
-
if not in_virtualenv():
|
|
189
|
-
break_system_packages = os.environ.get("PIP_BREAK_SYSTEM_PACKAGES", "")
|
|
190
|
-
os.environ["PIP_BREAK_SYSTEM_PACKAGES"] = "1"
|
|
191
|
-
if not is_root():
|
|
192
|
-
pip_install.extend(["--user"])
|
|
193
|
-
pip_install.extend(extra_requirements)
|
|
194
|
-
# pylint: disable=too-many-try-statements
|
|
195
|
-
try:
|
|
196
|
-
proc = await asyncio.create_subprocess_exec(
|
|
197
|
-
*pip_install,
|
|
198
|
-
stdout=asyncio.subprocess.PIPE,
|
|
199
|
-
stderr=asyncio.subprocess.PIPE,
|
|
200
|
-
)
|
|
201
|
-
if proc.stdout:
|
|
202
|
-
async for line in proc.stdout:
|
|
203
|
-
printer(strip_ansi(line.decode().strip()))
|
|
204
|
-
if proc.stderr:
|
|
205
|
-
async for line in proc.stderr:
|
|
206
|
-
printer(strip_ansi(line.decode().strip()))
|
|
207
|
-
finally:
|
|
208
|
-
if not in_virtualenv():
|
|
209
|
-
if break_system_packages:
|
|
210
|
-
os.environ["PIP_BREAK_SYSTEM_PACKAGES"] = break_system_packages
|
|
211
|
-
else:
|
|
212
|
-
del os.environ["PIP_BREAK_SYSTEM_PACKAGES"]
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
def after_run(
|
|
216
|
-
temp_dir: Path,
|
|
217
|
-
output_path: Optional[Union[str, Path]],
|
|
218
|
-
printer: Callable[..., None],
|
|
219
|
-
flow_name: str,
|
|
220
|
-
skip_mmd: bool = False,
|
|
221
|
-
) -> None:
|
|
222
|
-
"""Actions to perform after running the flow.
|
|
223
|
-
|
|
224
|
-
Parameters
|
|
225
|
-
----------
|
|
226
|
-
temp_dir : Path
|
|
227
|
-
The temporary directory.
|
|
228
|
-
output_path : Optional[Union[str, Path]]
|
|
229
|
-
The output path.
|
|
230
|
-
printer : Callable[..., None]
|
|
231
|
-
The printer function.
|
|
232
|
-
flow_name : str
|
|
233
|
-
The flow name.
|
|
234
|
-
skip_mmd : bool, optional
|
|
235
|
-
Whether to skip the mermaid sequence diagram generation,
|
|
236
|
-
by default, False
|
|
237
|
-
"""
|
|
238
|
-
if isinstance(output_path, str):
|
|
239
|
-
output_path = Path(output_path)
|
|
240
|
-
output_dir = output_path.parent if output_path else Path.cwd()
|
|
241
|
-
if skip_mmd is False:
|
|
242
|
-
events_csv_path = temp_dir / "logs" / "events.csv"
|
|
243
|
-
if events_csv_path.exists():
|
|
244
|
-
printer("Generating mermaid sequence diagram...")
|
|
245
|
-
mmd_path = temp_dir / f"{flow_name}.mmd"
|
|
246
|
-
generate_sequence_diagram(events_csv_path, mmd_path)
|
|
247
|
-
if mmd_path.exists():
|
|
248
|
-
shutil.copyfile(mmd_path, output_dir / f"{flow_name}.mmd")
|
|
249
|
-
if output_path:
|
|
250
|
-
destination_dir = output_path.parent
|
|
251
|
-
destination_dir = (
|
|
252
|
-
destination_dir
|
|
253
|
-
/ "waldiez_out"
|
|
254
|
-
/ datetime.datetime.now().strftime("%Y%m%d%H%M%S")
|
|
255
|
-
)
|
|
256
|
-
destination_dir.mkdir(parents=True, exist_ok=True)
|
|
257
|
-
# copy the contents of the temp dir to the destination dir
|
|
258
|
-
printer(f"Copying the results to {destination_dir}")
|
|
259
|
-
copy_results(
|
|
260
|
-
temp_dir=temp_dir,
|
|
261
|
-
output_path=output_path,
|
|
262
|
-
output_dir=output_dir,
|
|
263
|
-
destination_dir=destination_dir,
|
|
264
|
-
)
|
|
265
|
-
shutil.rmtree(temp_dir)
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
def copy_results(
|
|
269
|
-
temp_dir: Path,
|
|
270
|
-
output_path: Path,
|
|
271
|
-
output_dir: Path,
|
|
272
|
-
destination_dir: Path,
|
|
273
|
-
) -> None:
|
|
274
|
-
"""Copy the results to the output directory.
|
|
275
|
-
|
|
276
|
-
Parameters
|
|
277
|
-
----------
|
|
278
|
-
temp_dir : Path
|
|
279
|
-
The temporary directory.
|
|
280
|
-
output_path : Path
|
|
281
|
-
The output path.
|
|
282
|
-
output_dir : Path
|
|
283
|
-
The output directory.
|
|
284
|
-
destination_dir : Path
|
|
285
|
-
The destination directory.
|
|
286
|
-
"""
|
|
287
|
-
temp_dir.mkdir(parents=True, exist_ok=True)
|
|
288
|
-
for item in temp_dir.iterdir():
|
|
289
|
-
# skip cache files
|
|
290
|
-
if (
|
|
291
|
-
item.name.startswith("__pycache__")
|
|
292
|
-
or item.name.endswith(".pyc")
|
|
293
|
-
or item.name.endswith(".pyo")
|
|
294
|
-
or item.name.endswith(".pyd")
|
|
295
|
-
or item.name == ".cache"
|
|
296
|
-
):
|
|
297
|
-
continue
|
|
298
|
-
if item.is_file():
|
|
299
|
-
# let's also copy the "tree of thoughts" image
|
|
300
|
-
# to the output directory
|
|
301
|
-
if item.name.endswith("tree_of_thoughts.png") or item.name.endswith(
|
|
302
|
-
"reasoning_tree.json"
|
|
303
|
-
):
|
|
304
|
-
shutil.copy(item, output_dir / item.name)
|
|
305
|
-
shutil.copy(item, destination_dir)
|
|
306
|
-
else:
|
|
307
|
-
shutil.copytree(item, destination_dir / item.name)
|
|
308
|
-
if output_path.is_file():
|
|
309
|
-
if output_path.suffix == ".waldiez":
|
|
310
|
-
output_path = output_path.with_suffix(".py")
|
|
311
|
-
if output_path.suffix == ".py":
|
|
312
|
-
src = temp_dir / output_path.name
|
|
313
|
-
if src.exists():
|
|
314
|
-
dst = destination_dir / output_path.name
|
|
315
|
-
if dst.exists():
|
|
316
|
-
dst.unlink()
|
|
317
|
-
shutil.copyfile(src, output_dir / output_path.name)
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
def get_printer() -> Callable[..., None]:
|
|
321
|
-
"""Get the printer function.
|
|
322
|
-
|
|
323
|
-
Returns
|
|
324
|
-
-------
|
|
325
|
-
Callable[..., None]
|
|
326
|
-
The printer function.
|
|
327
|
-
"""
|
|
328
|
-
from autogen.io import IOStream # type: ignore
|
|
329
|
-
|
|
330
|
-
# noinspection PyUnboundLocalVariable
|
|
331
|
-
printer = IOStream.get_default().print
|
|
332
|
-
|
|
333
|
-
def safe_printer(*args: Any, **kwargs: Any) -> None:
|
|
334
|
-
try:
|
|
335
|
-
printer(*args, **kwargs)
|
|
336
|
-
except UnicodeEncodeError:
|
|
337
|
-
try:
|
|
338
|
-
# Use the helper to get safely encoded message
|
|
339
|
-
safe_msg, flush = get_what_to_print(*args, **kwargs)
|
|
340
|
-
# Try printing the safe message
|
|
341
|
-
# (without end since it's already included)
|
|
342
|
-
printer(safe_msg, end="", flush=flush)
|
|
343
|
-
except UnicodeEncodeError:
|
|
344
|
-
# pylint: disable=too-many-try-statements
|
|
345
|
-
try:
|
|
346
|
-
# If that still fails, write directly to buffer
|
|
347
|
-
msg, flush = get_what_to_print(*args, **kwargs)
|
|
348
|
-
safe_msg_bytes = msg.encode("utf-8", errors="replace")
|
|
349
|
-
sys.stdout.buffer.write(safe_msg_bytes)
|
|
350
|
-
if flush:
|
|
351
|
-
sys.stdout.buffer.flush()
|
|
352
|
-
except Exception: # pylint: disable=broad-exception-caught
|
|
353
|
-
error_msg = (
|
|
354
|
-
b"Could not print message due to encoding issues.\n"
|
|
355
|
-
)
|
|
356
|
-
sys.stderr.buffer.write(error_msg)
|
|
357
|
-
sys.stderr.buffer.flush()
|
|
358
|
-
|
|
359
|
-
return safe_printer
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
def get_what_to_print(*args: object, **kwargs: object) -> tuple[str, bool]:
|
|
363
|
-
"""Get what to print.
|
|
364
|
-
|
|
365
|
-
Parameters
|
|
366
|
-
----------
|
|
367
|
-
args : object
|
|
368
|
-
The print arguments.
|
|
369
|
-
kwargs : object
|
|
370
|
-
The keyword arguments.
|
|
371
|
-
|
|
372
|
-
Returns
|
|
373
|
-
-------
|
|
374
|
-
tuple[str, bool]
|
|
375
|
-
The message and whether to flush.
|
|
376
|
-
"""
|
|
377
|
-
sep = kwargs.get("sep", " ")
|
|
378
|
-
if not isinstance(sep, str):
|
|
379
|
-
sep = " "
|
|
380
|
-
end = kwargs.get("end", "\n")
|
|
381
|
-
if not isinstance(end, str):
|
|
382
|
-
end = "\n"
|
|
383
|
-
flush = kwargs.get("flush", False)
|
|
384
|
-
if not isinstance(flush, bool):
|
|
385
|
-
flush = False
|
|
386
|
-
msg = sep.join(str(arg) for arg in args) + end
|
|
387
|
-
utf8_msg = msg.encode("utf-8", errors="replace").decode("utf-8")
|
|
388
|
-
return utf8_msg, flush
|
waldiez/utils/flaml_warnings.py
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# SPDX-License-Identifier: Apache-2.0.
|
|
2
|
-
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
-
"""Try to suppress the warning about flaml.automl not being available."""
|
|
4
|
-
|
|
5
|
-
import logging
|
|
6
|
-
|
|
7
|
-
__waldiez_checked_flaml_warnings = False # pylint: disable=invalid-name
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def check_flaml_warnings() -> None: # pragma: no cover
|
|
11
|
-
"""Check for flaml warnings once."""
|
|
12
|
-
# pylint: disable=global-statement
|
|
13
|
-
global __waldiez_checked_flaml_warnings
|
|
14
|
-
if __waldiez_checked_flaml_warnings is False:
|
|
15
|
-
flam_logger = logging.getLogger("flaml")
|
|
16
|
-
flam_logger.setLevel(logging.ERROR)
|
|
17
|
-
__waldiez_checked_flaml_warnings = True
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|