wrd 0.1.41__py3-none-any.whl → 1.0.2__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.
dune/interactive_dune.py DELETED
@@ -1,272 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Interaktywny CLI dla systemu Dune - mapowanie zadań do bibliotek.
4
- """
5
-
6
- import sys
7
- import argparse
8
- from pathlib import Path
9
- from loguru import logger
10
-
11
- # Dodaj src do PYTHONPATH
12
- sys.path.insert(0, str(Path(__file__).parent / "src"))
13
-
14
- from interactive_mapper import InteractiveMapper
15
- from config_generator import ConfigGenerator
16
-
17
-
18
- def main():
19
- """Główna funkcja interaktywnego CLI."""
20
-
21
- parser = argparse.ArgumentParser(
22
- description="Dune Interactive - Mapowanie zadań do bibliotek"
23
- )
24
-
25
- parser.add_argument(
26
- "request",
27
- nargs='?',
28
- help="Żądanie w języku naturalnym"
29
- )
30
-
31
- parser.add_argument(
32
- "--discover", "-d",
33
- action="store_true",
34
- help="Odkryj interfejsy zainstalowanych bibliotek"
35
- )
36
-
37
- parser.add_argument(
38
- "--save-config", "-s",
39
- type=str,
40
- help="Zapisz wygenerowaną konfigurację do pliku"
41
- )
42
-
43
- parser.add_argument(
44
- "--auto-install", "-a",
45
- action="store_true",
46
- help="Automatycznie zainstaluj wykryte biblioteki"
47
- )
48
-
49
- args = parser.parse_args()
50
-
51
- # Konfiguruj logowanie
52
- logger.remove()
53
- logger.add(
54
- sys.stdout,
55
- format="<green>{time:HH:mm:ss}</green> | <level>{message}</level>",
56
- level="INFO"
57
- )
58
-
59
- try:
60
- if args.discover:
61
- run_discovery_mode()
62
- return
63
-
64
- # Pobierz zadanie
65
- if not args.request:
66
- request = get_interactive_request()
67
- else:
68
- request = args.request
69
-
70
- if not request:
71
- logger.error("❌ Nie podano zadania")
72
- return
73
-
74
- # Uruchom mapowanie
75
- result = run_interactive_mapping(request, args)
76
-
77
- # Zapisz konfigurację jeśli żądano
78
- if args.save_config and result:
79
- save_generated_config(result, args.save_config)
80
-
81
- except KeyboardInterrupt:
82
- print("\n👋 Do widzenia!")
83
- except Exception as e:
84
- logger.error(f"❌ Błąd: {e}")
85
- sys.exit(1)
86
-
87
-
88
- def get_interactive_request() -> str:
89
- """Pobiera zadanie w trybie interaktywnym."""
90
-
91
- print("\n" + "=" * 70)
92
- print("🏜️ DUNE - INTERAKTYWNY MAPPER BIBLIOTEK")
93
- print("=" * 70)
94
- print("Opisz zadanie, które chcesz wykonać w języku naturalnym.")
95
- print("")
96
- print("💡 Przykłady:")
97
- print(" • Pobierz emaile z IMAP i zapisz w folderach według dat")
98
- print(" • Przeanalizuj pliki CSV i wygeneruj raport z wykresami")
99
- print(" • Pobierz dane z API REST i zapisz do bazy PostgreSQL")
100
- print(" • Zmień rozmiar wszystkich zdjęć w folderze na 800x600")
101
- print(" • Wyślij emaile do listy odbiorców z załącznikami")
102
- print("=" * 70)
103
-
104
- request = input("\n📝 Twoje zadanie: ").strip()
105
- return request
106
-
107
-
108
- def run_discovery_mode():
109
- """Uruchamia tryb odkrywania bibliotek."""
110
-
111
- print("\n🔍 TRYB ODKRYWANIA BIBLIOTEK")
112
- print("=" * 40)
113
-
114
- mapper = InteractiveMapper()
115
-
116
- # Lista pakietów do sprawdzenia
117
- packages_to_check = [
118
- "requests", "pandas", "sqlalchemy", "beautifulsoup4",
119
- "selenium", "matplotlib", "numpy", "pillow", "opencv-python",
120
- "scrapy", "django", "flask", "fastapi"
121
- ]
122
-
123
- discovered = []
124
-
125
- for package in packages_to_check:
126
- print(f"🔎 Sprawdzanie {package}...")
127
- interface = mapper.discover_cli_interface(package)
128
-
129
- if interface:
130
- discovered.append((package, interface))
131
- print(f" ✅ Znaleziono interfejs")
132
- else:
133
- print(f" ❌ Brak interfejsu lub nie zainstalowany")
134
-
135
- print(f"\n📊 PODSUMOWANIE ODKRYCIA")
136
- print("=" * 40)
137
- print(f"Sprawdzono: {len(packages_to_check)} pakietów")
138
- print(f"Odkryto: {len(discovered)} interfejsów")
139
-
140
- if discovered:
141
- print(f"\n📚 Odkryte biblioteki:")
142
- for package, interface in discovered:
143
- func_count = len(interface.get("main_functions", []))
144
- print(f" • {package}: {func_count} funkcji głównych")
145
-
146
-
147
- def run_interactive_mapping(request: str, args) -> dict:
148
- """Uruchamia interaktywny proces mapowania."""
149
-
150
- mapper = InteractiveMapper()
151
-
152
- # Uruchom mapowanie
153
- result = mapper.run_interactive_mapping(request)
154
-
155
- if not result:
156
- return {}
157
-
158
- # Auto-instalacja jeśli żądano
159
- if args.auto_install and result.get("libraries"):
160
- install_detected_libraries(result["libraries"])
161
-
162
- # Wygeneruj pełną konfigurację
163
- config = generate_full_config(result)
164
- result["full_config"] = config
165
-
166
- return result
167
-
168
-
169
- def install_detected_libraries(libraries):
170
- """Automatycznie instaluje wykryte biblioteki."""
171
-
172
- print(f"\n📦 AUTO-INSTALACJA BIBLIOTEK")
173
- print("=" * 40)
174
-
175
- import subprocess
176
-
177
- for library in libraries:
178
- package = library.package
179
- print(f"📦 Instalowanie {package}...")
180
-
181
- try:
182
- subprocess.check_call([
183
- sys.executable, "-m", "pip", "install", package
184
- ], capture_output=True)
185
- print(f" ✅ {package} zainstalowany")
186
- except subprocess.CalledProcessError as e:
187
- print(f" ❌ Błąd instalacji {package}: {e}")
188
-
189
-
190
- def generate_full_config(mapping_result) -> dict:
191
- """Generuje pełną konfigurację na podstawie mapowania."""
192
-
193
- generator = ConfigGenerator()
194
-
195
- # Wygeneruj bazową konfigurację
196
- config = generator.generate_config_from_nlp(mapping_result["natural_request"])
197
-
198
- # Zaktualizuj o zebrane parametry
199
- runtime_config = mapping_result.get("runtime_config", {}).get("runtime", {})
200
- if runtime_config:
201
- config["runtime"].update(runtime_config)
202
-
203
- # Dodaj szczegóły zebranych parametrów
204
- if mapping_result.get("parameters"):
205
- config["metadata"]["collected_parameters"] = mapping_result["parameters"]
206
-
207
- # Dodaj informacje o użytych bibliotekach
208
- if mapping_result.get("libraries"):
209
- library_info = []
210
- for lib in mapping_result["libraries"]:
211
- library_info.append({
212
- "name": lib.name,
213
- "package": lib.package,
214
- "main_function": lib.main_function
215
- })
216
- config["metadata"]["mapped_libraries"] = library_info
217
-
218
- return config
219
-
220
-
221
- def save_generated_config(result, filename):
222
- """Zapisuje wygenerowaną konfigurację do pliku."""
223
-
224
- config = result.get("full_config")
225
- if not config:
226
- logger.warning("⚠️ Brak konfiguracji do zapisania")
227
- return
228
-
229
- generator = ConfigGenerator()
230
- saved_path = generator.save_config_to_file(config, filename)
231
-
232
- print(f"\n💾 Konfiguracja zapisana do: {saved_path}")
233
-
234
-
235
- def show_execution_guide(result):
236
- """Pokazuje przewodnik uruchamiania zadania."""
237
-
238
- if not result:
239
- return
240
-
241
- print(f"\n🚀 PRZEWODNIK URUCHAMIANIA")
242
- print("=" * 40)
243
-
244
- # Pokaż wymagane zmienne środowiskowe
245
- runtime_config = result.get("runtime_config", {}).get("runtime", {})
246
- required_vars = runtime_config.get("environment", {}).get("required", [])
247
-
248
- if required_vars:
249
- print(f"🔧 Wymagane zmienne środowiskowe:")
250
- for var in required_vars:
251
- print(f" export {var}=wartość")
252
- print()
253
-
254
- # Pokaż komendy instalacji
255
- packages = runtime_config.get("python_packages", {}).get("required", [])
256
- if packages:
257
- print(f"📦 Instalacja pakietów:")
258
- print(f" pip install {' '.join(packages)}")
259
- print()
260
-
261
- # Pokaż komendy uruchamiania
262
- print(f"🚀 Uruchamianie:")
263
- print(f" python enhanced_run.py")
264
-
265
- if result.get("full_config"):
266
- config_name = result["full_config"]["metadata"]["name"]
267
- print(f" # lub z konfiguracją:")
268
- print(f" python enhanced_run.py --config configs/{config_name}.yaml")
269
-
270
-
271
- if __name__ == "__main__":
272
- main()