Skip to content

Commit 9ebd4bb

Browse files
committed
fix: add missing modules to package (session, telemetry, policy, cli)
v0.5.0 PyPI package was broken — `import venturalitica` raised ImportError because session.py, telemetry.py, and policy.py were never committed. Also replaces the old monolithic cli.py with the cli/ package (auth, dashboard, sync, transfer subcommands). Bumps version to 0.5.1.
1 parent ee10f50 commit 9ebd4bb

File tree

15 files changed

+1923
-239
lines changed

15 files changed

+1923
-239
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "venturalitica"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
description = "Frictionless Governance for AI. Enforce policies in your ML training with one line of code."
55
requires-python = ">=3.11"
66
readme = "README.md"

src/venturalitica/__init__.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.5.0"
1+
__version__ = "0.5.1"
22

33
from .api import (
44
enforce,
@@ -15,3 +15,36 @@
1515
"quickstart",
1616
"PolicyManager",
1717
]
18+
19+
20+
def _send_first_import():
21+
"""Fire a one-time sdk_first_import event (guarded by analytics.json flag)."""
22+
try:
23+
import json
24+
from pathlib import Path
25+
config_path = Path.home() / ".venturalitica" / "analytics.json"
26+
if config_path.exists():
27+
with open(config_path, "r") as f:
28+
data = json.load(f)
29+
if data.get("first_import_sent"):
30+
return
31+
32+
from .telemetry import telemetry
33+
telemetry.capture("sdk_first_import", {})
34+
35+
# Mark as sent
36+
config_path.parent.mkdir(parents=True, exist_ok=True)
37+
existing = {}
38+
if config_path.exists():
39+
try:
40+
with open(config_path, "r") as f:
41+
existing = json.load(f)
42+
except Exception:
43+
pass
44+
existing["first_import_sent"] = True
45+
with open(config_path, "w") as f:
46+
json.dump(existing, f)
47+
except Exception:
48+
pass # Never crash the import
49+
50+
_send_first_import()

src/venturalitica/cli.py

Lines changed: 0 additions & 237 deletions
This file was deleted.

src/venturalitica/cli/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Import submodules to register commands
2+
from . import (
3+
auth as auth,
4+
)
5+
from . import (
6+
dashboard as dashboard,
7+
)
8+
from . import (
9+
sync as sync,
10+
)
11+
from . import (
12+
transfer as transfer,
13+
)
14+
from .common import app
15+
16+
__all__ = ["app"]

src/venturalitica/cli/auth.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import json
2+
3+
import requests
4+
import typer
5+
6+
from ..telemetry import track_command
7+
from .common import SAAS_URL, app, console, get_config_path
8+
9+
10+
@app.command()
11+
@track_command("login")
12+
def login(system_id: str):
13+
"""
14+
Authenticates with the Venturalítica SaaS for a specific AI System.
15+
"""
16+
console.print(f"[bold green]🔐 Authenticating for system:[/bold green] {system_id}")
17+
18+
try:
19+
response = requests.post(
20+
f"{SAAS_URL}/api/cli-auth", json={"aiSystemId": system_id}
21+
)
22+
response.raise_for_status()
23+
data = response.json()
24+
25+
creds_path = get_config_path("credentials.json")
26+
with open(creds_path, "w") as f:
27+
json.dump(data, f)
28+
29+
console.print(
30+
f"[bold green]✓ Login successful for {data.get('aiSystemName')}[/bold green]"
31+
)
32+
console.print(f"Key stored in: {creds_path}")
33+
34+
except Exception as e:
35+
console.print(f"[bold red]Login failed:[/bold red] {e}")
36+
raise typer.Exit(code=1)

src/venturalitica/cli/common.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import os
2+
3+
import typer
4+
from rich.console import Console
5+
6+
app = typer.Typer()
7+
console = Console()
8+
9+
SAAS_URL = os.getenv("VENTURALITICA_SAAS_URL", "http://localhost:3000")
10+
11+
def get_config_path(filename: str) -> str:
12+
path = os.path.expanduser(f"~/.venturalitica/{filename}")
13+
dir_path = os.path.dirname(path)
14+
if not os.path.exists(dir_path):
15+
os.makedirs(dir_path, exist_ok=True)
16+
# First Run Detection
17+
if "VENTURALITICA_NO_ANALYTICS" not in os.environ:
18+
console.print(
19+
"[bold blue]ℹ Telemetry Notice[/bold blue]\n"
20+
"[dim]Venturalítica collects anonymous technical metrics to improve this tool.\n"
21+
"We NEVER collect your model data, datasets, or personal identifiers.\n"
22+
"To opt-out, set [/dim][cyan]VENTURALITICA_NO_ANALYTICS=1[/cyan][dim].\n"
23+
"Read our transparent privacy policy at: [link=https://venturalitica.ai/telemetry]https://venturalitica.ai/telemetry[/link][/dim]\n"
24+
)
25+
return path

0 commit comments

Comments
 (0)