relationalai 1.0.0a2__py3-none-any.whl → 1.0.0a4__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.
Files changed (57) hide show
  1. relationalai/config/shims.py +1 -0
  2. relationalai/semantics/__init__.py +7 -1
  3. relationalai/semantics/frontend/base.py +19 -13
  4. relationalai/semantics/frontend/core.py +30 -2
  5. relationalai/semantics/frontend/front_compiler.py +38 -11
  6. relationalai/semantics/frontend/pprint.py +1 -1
  7. relationalai/semantics/metamodel/rewriter.py +6 -2
  8. relationalai/semantics/metamodel/typer.py +70 -26
  9. relationalai/semantics/reasoners/__init__.py +11 -0
  10. relationalai/semantics/reasoners/graph/__init__.py +38 -0
  11. relationalai/semantics/reasoners/graph/core.py +9015 -0
  12. relationalai/shims/executor.py +4 -1
  13. relationalai/shims/hoister.py +9 -0
  14. relationalai/shims/mm2v0.py +47 -34
  15. relationalai/tools/cli/cli.py +138 -0
  16. relationalai/tools/cli/docs.py +394 -0
  17. {relationalai-1.0.0a2.dist-info → relationalai-1.0.0a4.dist-info}/METADATA +5 -3
  18. {relationalai-1.0.0a2.dist-info → relationalai-1.0.0a4.dist-info}/RECORD +57 -43
  19. v0/relationalai/__init__.py +69 -22
  20. v0/relationalai/clients/__init__.py +15 -2
  21. v0/relationalai/clients/client.py +4 -4
  22. v0/relationalai/clients/exec_txn_poller.py +91 -0
  23. v0/relationalai/clients/local.py +5 -5
  24. v0/relationalai/clients/resources/__init__.py +8 -0
  25. v0/relationalai/clients/{azure.py → resources/azure/azure.py} +12 -12
  26. v0/relationalai/clients/resources/snowflake/__init__.py +20 -0
  27. v0/relationalai/clients/resources/snowflake/cli_resources.py +87 -0
  28. v0/relationalai/clients/resources/snowflake/direct_access_resources.py +717 -0
  29. v0/relationalai/clients/resources/snowflake/engine_state_handlers.py +309 -0
  30. v0/relationalai/clients/resources/snowflake/error_handlers.py +199 -0
  31. v0/relationalai/clients/resources/snowflake/resources_factory.py +99 -0
  32. v0/relationalai/clients/{snowflake.py → resources/snowflake/snowflake.py} +642 -1399
  33. v0/relationalai/clients/{use_index_poller.py → resources/snowflake/use_index_poller.py} +51 -12
  34. v0/relationalai/clients/resources/snowflake/use_index_resources.py +188 -0
  35. v0/relationalai/clients/resources/snowflake/util.py +387 -0
  36. v0/relationalai/early_access/dsl/ir/executor.py +4 -4
  37. v0/relationalai/early_access/dsl/snow/api.py +2 -1
  38. v0/relationalai/errors.py +18 -0
  39. v0/relationalai/experimental/solvers.py +7 -7
  40. v0/relationalai/semantics/devtools/benchmark_lqp.py +4 -5
  41. v0/relationalai/semantics/devtools/extract_lqp.py +1 -1
  42. v0/relationalai/semantics/internal/snowflake.py +1 -1
  43. v0/relationalai/semantics/lqp/executor.py +7 -12
  44. v0/relationalai/semantics/lqp/rewrite/extract_keys.py +25 -3
  45. v0/relationalai/semantics/metamodel/util.py +6 -5
  46. v0/relationalai/semantics/reasoners/optimization/solvers_pb.py +335 -84
  47. v0/relationalai/semantics/rel/executor.py +14 -11
  48. v0/relationalai/semantics/sql/executor/snowflake.py +9 -5
  49. v0/relationalai/semantics/tests/test_snapshot_abstract.py +1 -1
  50. v0/relationalai/tools/cli.py +26 -30
  51. v0/relationalai/tools/cli_helpers.py +10 -2
  52. v0/relationalai/util/otel_configuration.py +2 -1
  53. v0/relationalai/util/otel_handler.py +1 -1
  54. {relationalai-1.0.0a2.dist-info → relationalai-1.0.0a4.dist-info}/WHEEL +0 -0
  55. {relationalai-1.0.0a2.dist-info → relationalai-1.0.0a4.dist-info}/entry_points.txt +0 -0
  56. {relationalai-1.0.0a2.dist-info → relationalai-1.0.0a4.dist-info}/top_level.txt +0 -0
  57. /v0/relationalai/clients/{cache_store.py → resources/snowflake/cache_store.py} +0 -0
@@ -0,0 +1,394 @@
1
+ """
2
+ Documentation generation and serving utilities.
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ import shutil
8
+ import subprocess
9
+ import webbrowser
10
+ from pathlib import Path
11
+ from typing import Optional
12
+
13
+ import click
14
+ from rich.console import Console
15
+
16
+ console = Console()
17
+
18
+
19
+ def find_docs_dir() -> Path:
20
+ """Find the documentation source directory."""
21
+ # Try multiple possible locations
22
+ possible_paths = [
23
+ Path("docs"), # Root level
24
+ Path(__file__).parent.parent.parent.parent / "docs", # From this file
25
+ Path.cwd() / "docs", # Current working directory
26
+ ]
27
+
28
+ for path in possible_paths:
29
+ if path.exists() and (path / "package.json").exists():
30
+ return path.resolve()
31
+
32
+ raise click.ClickException(
33
+ "Documentation source directory not found. "
34
+ "Expected 'docs/' directory with package.json"
35
+ )
36
+
37
+
38
+ def has_nodejs() -> bool:
39
+ """Check if Node.js is installed."""
40
+ try:
41
+ subprocess.run(
42
+ ["node", "--version"],
43
+ capture_output=True,
44
+ text=True,
45
+ check=True,
46
+ )
47
+ return True
48
+ except (subprocess.CalledProcessError, FileNotFoundError):
49
+ return False
50
+
51
+
52
+ def has_npm() -> bool:
53
+ """Check if npm is installed."""
54
+ try:
55
+ subprocess.run(
56
+ ["npm", "--version"],
57
+ capture_output=True,
58
+ text=True,
59
+ check=True,
60
+ )
61
+ return True
62
+ except (subprocess.CalledProcessError, FileNotFoundError):
63
+ return False
64
+
65
+
66
+ def print_generation_success(output_path: Path) -> None:
67
+ """
68
+ Print success message after documentation generation.
69
+
70
+ Args:
71
+ output_path: Path to the generated documentation output directory
72
+ """
73
+ console.print("[green]✓ Documentation generated")
74
+ console.print()
75
+ console.print("[cyan]The documentation site is ready to host![/cyan]")
76
+ console.print(f"[dim]Output location: {output_path}[/dim]")
77
+ console.print()
78
+ console.print("[yellow]You can serve it locally with:[/yellow]")
79
+ console.print(" [bold]rai docs serve[/bold]")
80
+ console.print()
81
+ console.print("[yellow]Or host the dist folder directly:[/yellow]")
82
+ console.print(
83
+ "[dim]The dist folder contains a complete static website. You can copy it to any "
84
+ "web server (Nginx, Apache, Flask, etc.), upload it to a CDN, or deploy it to "
85
+ "static hosting services like GitHub Pages, Netlify, or Vercel. All files use "
86
+ "relative paths, so it works regardless of where it's hosted.[/dim]"
87
+ )
88
+
89
+
90
+ def generate_docs(
91
+ output_dir: Optional[str] = None,
92
+ docs_dir: Optional[Path] = None,
93
+ ) -> Path:
94
+ """
95
+ Generate static documentation site.
96
+
97
+ Args:
98
+ output_dir: Optional output directory (defaults to docs/dist)
99
+ docs_dir: Optional path to docs directory
100
+
101
+ Returns:
102
+ Path to the generated output directory
103
+ """
104
+ if docs_dir is None:
105
+ docs_dir = find_docs_dir()
106
+
107
+ # Check prerequisites
108
+ if not has_nodejs():
109
+ raise click.ClickException(
110
+ "Node.js is not installed. "
111
+ "Please install Node.js from https://nodejs.org/"
112
+ )
113
+
114
+ if not has_npm():
115
+ raise click.ClickException(
116
+ "npm is not installed. "
117
+ "npm should come with Node.js installation."
118
+ )
119
+
120
+ # Check if package.json exists
121
+ package_json = docs_dir / "package.json"
122
+ if not package_json.exists():
123
+ raise click.ClickException(
124
+ f"package.json not found in {docs_dir}. "
125
+ "This doesn't appear to be a valid SolidJS project."
126
+ )
127
+
128
+ # Install dependencies if node_modules doesn't exist
129
+ node_modules = docs_dir / "node_modules"
130
+ if not node_modules.exists():
131
+ console.print("[blue]Installing dependencies...[/blue]")
132
+ try:
133
+ subprocess.run(
134
+ ["npm", "install"],
135
+ cwd=docs_dir,
136
+ check=True,
137
+ stdout=subprocess.PIPE,
138
+ stderr=subprocess.PIPE,
139
+ )
140
+ console.print("[green]✓ Dependencies installed[/green]")
141
+ except subprocess.CalledProcessError as e:
142
+ error_msg = e.stderr.decode() if e.stderr else "Unknown error"
143
+ raise click.ClickException(
144
+ f"Failed to install dependencies: {error_msg}"
145
+ )
146
+
147
+ # Build the documentation
148
+ console.print("[blue]Building documentation site...[/blue]")
149
+ try:
150
+ subprocess.run(
151
+ ["npm", "run", "build"],
152
+ cwd=docs_dir,
153
+ check=True,
154
+ capture_output=True,
155
+ text=True,
156
+ )
157
+ console.print("[green]✓ Build completed successfully[/green]")
158
+ except subprocess.CalledProcessError as e:
159
+ error_msg = e.stderr if e.stderr else e.stdout if e.stdout else "Unknown error"
160
+ console.print(f"[red]Build error output:[/red]\n{error_msg}")
161
+ raise click.ClickException(f"Build failed: {error_msg}")
162
+
163
+ # Determine output directory
164
+ build_output = docs_dir / "dist"
165
+ if not build_output.exists():
166
+ raise click.ClickException(
167
+ "Build output directory not found. "
168
+ "Build may have failed."
169
+ )
170
+
171
+ # Copy to custom output directory if specified
172
+ if output_dir:
173
+ output_path = Path(output_dir).resolve()
174
+ if output_path.exists():
175
+ console.print(f"[yellow]Output directory '{output_path}' exists. Cleaning...[/yellow]")
176
+ shutil.rmtree(output_path)
177
+ shutil.copytree(build_output, output_path)
178
+ print_generation_success(output_path)
179
+ return output_path
180
+
181
+ print_generation_success(build_output)
182
+ return build_output
183
+
184
+
185
+ def serve_docs(
186
+ build_dir: str,
187
+ host: str = "127.0.0.1",
188
+ port: int = 8000,
189
+ open_browser: bool = True,
190
+ ) -> None:
191
+ """
192
+ Serve generated documentation site.
193
+
194
+ Args:
195
+ build_dir: Directory containing built documentation
196
+ host: Host to bind to
197
+ port: Port to serve on
198
+ open_browser: Whether to open browser automatically
199
+ """
200
+ build_path = Path(build_dir).resolve()
201
+
202
+ if not build_path.exists():
203
+ raise click.ClickException(
204
+ "Build directory does not exist. "
205
+ "Run 'rai docs generate' first."
206
+ )
207
+
208
+ index_html = build_path / "index.html"
209
+ if not index_html.exists():
210
+ raise click.ClickException(
211
+ "index.html not found. "
212
+ "This doesn't appear to be a valid build directory. "
213
+ "Run 'rai docs generate' first."
214
+ )
215
+
216
+ # Import FastAPI here to avoid requiring it if not using server
217
+ try:
218
+ from fastapi import FastAPI
219
+ from fastapi.staticfiles import StaticFiles
220
+ import uvicorn
221
+ except ImportError:
222
+ raise click.ClickException(
223
+ "FastAPI and uvicorn are required for serving documentation. "
224
+ "Install with: pip install fastapi uvicorn"
225
+ )
226
+
227
+ app = FastAPI(title="RAI Documentation")
228
+ app.mount("/", StaticFiles(directory=str(build_path), html=True), name="static")
229
+
230
+ url = f"http://{host}:{port}"
231
+ console.print(f"[green]✓ Documentation server running at {url}[/green]")
232
+ console.print("[yellow]Press Ctrl+C to stop the server[/yellow]")
233
+
234
+ if open_browser:
235
+ try:
236
+ webbrowser.open(url)
237
+ except Exception:
238
+ console.print(f"[yellow]Could not open browser automatically. Visit {url}[/yellow]")
239
+
240
+ try:
241
+ uvicorn.run(app, host=host, port=port, log_level="warning")
242
+ except KeyboardInterrupt:
243
+ console.print("\n[yellow]Server stopped[/yellow]")
244
+ except OSError as e:
245
+ if "Address already in use" in str(e):
246
+ raise click.ClickException(
247
+ f"Port {port} is already in use. "
248
+ "Try a different port with --port option."
249
+ )
250
+ raise
251
+
252
+
253
+ def dev_docs(
254
+ docs_dir: Optional[Path] = None,
255
+ host: str = "127.0.0.1",
256
+ port: int = 5173,
257
+ open_browser: bool = True,
258
+ ) -> None:
259
+ """
260
+ Start development server with hot module replacement.
261
+
262
+ This runs Vite's dev server, which provides:
263
+ - Hot module replacement (HMR) - changes reflect instantly
264
+ - Fast refresh - no need to rebuild on every change
265
+ - Source maps for debugging
266
+
267
+ Args:
268
+ docs_dir: Optional path to docs directory
269
+ host: Host to bind to
270
+ port: Port to serve on (default: 5173, Vite's default)
271
+ open_browser: Whether to open browser automatically
272
+ """
273
+ if docs_dir is None:
274
+ docs_dir = find_docs_dir()
275
+
276
+ # Check prerequisites
277
+ if not has_nodejs():
278
+ raise click.ClickException(
279
+ "Node.js is not installed. "
280
+ "Please install Node.js from https://nodejs.org/"
281
+ )
282
+
283
+ if not has_npm():
284
+ raise click.ClickException(
285
+ "npm is not installed. "
286
+ "npm should come with Node.js installation."
287
+ )
288
+
289
+ # Check if package.json exists
290
+ package_json = docs_dir / "package.json"
291
+ if not package_json.exists():
292
+ raise click.ClickException(
293
+ f"package.json not found in {docs_dir}. "
294
+ "This doesn't appear to be a valid SolidJS project."
295
+ )
296
+
297
+ # Install dependencies if node_modules doesn't exist
298
+ node_modules = docs_dir / "node_modules"
299
+ if not node_modules.exists():
300
+ console.print("[blue]Installing dependencies...[/blue]")
301
+ try:
302
+ subprocess.run(
303
+ ["npm", "install"],
304
+ cwd=docs_dir,
305
+ check=True,
306
+ stdout=subprocess.PIPE,
307
+ stderr=subprocess.PIPE,
308
+ )
309
+ console.print("[green]✓ Dependencies installed[/green]")
310
+ except subprocess.CalledProcessError as e:
311
+ error_msg = e.stderr.decode() if e.stderr else "Unknown error"
312
+ raise click.ClickException(
313
+ f"Failed to install dependencies: {error_msg}"
314
+ )
315
+
316
+ # Start dev server
317
+ url = f"http://{host}:{port}"
318
+ console.print("[green]✓ Starting development server...[/green]")
319
+ console.print(f"[blue]Server will be available at {url}[/blue]")
320
+ console.print("[yellow]Press Ctrl+C to stop the server[/yellow]")
321
+ console.print(
322
+ "[dim]Note: Changes to files will automatically reload in the browser[/dim]"
323
+ )
324
+
325
+ if open_browser:
326
+ # Open browser after a short delay to let server start
327
+ import threading
328
+ import time
329
+
330
+ def open_browser_delayed():
331
+ time.sleep(1.5) # Give server time to start
332
+ try:
333
+ webbrowser.open(url)
334
+ except Exception:
335
+ console.print(f"[yellow]Could not open browser automatically. Visit {url}[/yellow]")
336
+
337
+ threading.Thread(target=open_browser_delayed, daemon=True).start()
338
+
339
+ try:
340
+ # Run npm run dev with custom host/port
341
+ # Vite accepts --host and --port flags directly
342
+ subprocess.run(
343
+ ["npm", "run", "dev", "--", "--host", host, "--port", str(port)],
344
+ cwd=docs_dir,
345
+ check=True,
346
+ )
347
+ except KeyboardInterrupt:
348
+ console.print("\n[yellow]Development server stopped[/yellow]")
349
+ except subprocess.CalledProcessError as e:
350
+ error_msg = e.stderr.decode() if e.stderr else e.stdout.decode() if e.stdout else "Unknown error"
351
+ raise click.ClickException(f"Dev server failed: {error_msg}")
352
+ except OSError as e:
353
+ if "Address already in use" in str(e):
354
+ raise click.ClickException(
355
+ f"Port {port} is already in use. "
356
+ "Try a different port with --port option."
357
+ )
358
+ raise
359
+
360
+
361
+ def cleanup_docs(docs_dir: Optional[Path] = None) -> None:
362
+ """
363
+ Clean up generated files and dependencies.
364
+
365
+ Silently removes:
366
+ - node_modules/ directory
367
+ - dist/ directory (build output)
368
+
369
+ Args:
370
+ docs_dir: Optional path to docs directory
371
+ """
372
+ if docs_dir is None:
373
+ docs_dir = find_docs_dir()
374
+
375
+ removed_items = []
376
+
377
+ # Remove node_modules
378
+ node_modules = docs_dir / "node_modules"
379
+ if node_modules.exists() and node_modules.is_dir():
380
+ try:
381
+ shutil.rmtree(node_modules)
382
+ removed_items.append("node_modules")
383
+ except Exception as e:
384
+ raise click.ClickException(f"Failed to remove node_modules: {e}")
385
+
386
+ # Remove dist
387
+ dist = docs_dir / "dist"
388
+ if dist.exists() and dist.is_dir():
389
+ try:
390
+ shutil.rmtree(dist)
391
+ removed_items.append("dist")
392
+ except Exception as e:
393
+ raise click.ClickException(f"Failed to remove dist: {e}")
394
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: relationalai
3
- Version: 1.0.0a2
3
+ Version: 1.0.0a4
4
4
  Summary: RelationalAI Library and CLI
5
5
  Author-email: RelationalAI <support@relational.ai>
6
6
  Requires-Python: >=3.10
@@ -15,10 +15,9 @@ Requires-Dist: numpy<2
15
15
  Requires-Dist: pandas
16
16
  Requires-Dist: colorama
17
17
  Requires-Dist: inquirerpy
18
- Requires-Dist: click==8.2.1
18
+ Requires-Dist: click
19
19
  Requires-Dist: gravis
20
20
  Requires-Dist: toml
21
- Requires-Dist: tomlkit
22
21
  Requires-Dist: requests
23
22
  Requires-Dist: pyarrow
24
23
  Requires-Dist: websockets
@@ -35,6 +34,9 @@ Requires-Dist: sqlglot
35
34
  Requires-Dist: pyyaml
36
35
  Requires-Dist: pydantic<2.12.0,>=2.0.0
37
36
  Requires-Dist: pydantic-settings<2.11.0,>=2.0.0
37
+ Requires-Dist: tomlkit
38
+ Requires-Dist: fastapi
39
+ Requires-Dist: uvicorn[standard]
38
40
  Provides-Extra: dev
39
41
  Requires-Dist: pytest; extra == "dev"
40
42
  Requires-Dist: pytest-cov; extra == "dev"