Skip to content

Commit 7a45c64

Browse files
scp7Stephen Parkinsongemini-code-assist[bot]
authored
Introduce EXPERIMENTAL_DF flag to gate cloud features (#531)
* Add EXPERIMENTAL_DF flag around cloud features * Remove duplicate comment * Update deepfabric/auth.py Resolve blank lines Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Update deepfabric/evaluation/reporters/cloud_reporter.py Simplify if/else block to boolean expression Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Lint checked --------- Co-authored-by: Stephen Parkinson <scp@Stephens-MacBook-Pro.local> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 0811e54 commit 7a45c64

4 files changed

Lines changed: 36 additions & 3 deletions

File tree

deepfabric/auth.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
import httpx
1111

1212
from .tui import get_tui
13+
from .utils import get_bool_env
1314

1415
DEFAULT_API_URL = os.getenv("DEEPFABRIC_API_URL", "https://api.deepfabric.dev")
16+
1517
CONFIG_DIR = Path.home() / ".deepfabric"
1618
CONFIG_FILE = CONFIG_DIR / "config.json"
1719

@@ -75,8 +77,14 @@ def prompt_cloud_signup(api_url: str = DEFAULT_API_URL) -> bool:
7577
Returns:
7678
True if user successfully authenticated, False otherwise
7779
"""
80+
if not get_bool_env("EXPERIMENTAL_DF"):
81+
return False
82+
7883
tui = get_tui()
7984

85+
86+
87+
8088
tui.console.print("")
8189
tui.info("DeepFabric Cloud can save and track your evaluations")
8290
tui.info(" - Compare models across runs")

deepfabric/cli.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from .topic_model import TopicModel
2424
from .tui import configure_tui, get_tui
2525
from .update_checker import check_for_updates
26+
from .utils import get_bool_env
2627
from .validation import show_validation_success, validate_path_requirements
2728

2829
OverrideValue = str | int | float | bool | None
@@ -1097,7 +1098,11 @@ def evaluate(
10971098

10981099

10991100
# Register the auth command group
1100-
cli.add_command(auth_group)
1101+
# EXPERIMENTAL: Only enable cloud features if explicitly opted in
1102+
if get_bool_env("EXPERIMENTAL_DF"):
1103+
cli.add_command(auth_group)
1104+
1105+
11011106

11021107

11031108
@cli.command("import-tools")

deepfabric/evaluation/reporters/cloud_reporter.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from rich.console import Console
1515

16+
from ...utils import get_bool_env
1617
from .base import BaseReporter
1718

1819
if TYPE_CHECKING:
@@ -67,11 +68,15 @@ def __init__(self, config: dict | None = None):
6768
# Get project ID from config
6869
self.project_id = config.get("project_id") if config else None
6970

70-
# Enable cloud reporting if authenticated
71-
self.enabled = (
71+
# Enable cloud reporting if authenticated AND experimental flag is set
72+
is_experimental = get_bool_env("EXPERIMENTAL_DF")
73+
self.enabled = is_experimental and (
7274
config.get("enabled", bool(self.auth_token)) if config else bool(self.auth_token)
7375
)
7476

77+
78+
79+
7580
# Generate unique run ID for this evaluation
7681
self.run_id = None # Will be set when creating run
7782
self.evaluation_run_id = None # Backend run ID

deepfabric/utils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import ast
22
import asyncio
33
import json
4+
import os
45
import re
56

67
VALIDATION_ERROR_INDICATORS = [
@@ -147,4 +148,18 @@ def read_topic_tree_from_jsonl(file_path: str) -> list[dict]:
147148
with open(file_path) as file:
148149
for line in file:
149150
topic_tree.append(json.loads(line.strip()))
151+
150152
return topic_tree
153+
154+
155+
def get_bool_env(key: str, default: bool = False) -> bool:
156+
"""Get a boolean environment variable.
157+
158+
Supports: '1', 'true', 'yes', 'on' (case-insensitive) as True.
159+
Everything else is False unless default is True and key is missing.
160+
"""
161+
val = os.getenv(key)
162+
if val is None:
163+
return default
164+
return val.lower() in ("1", "true", "yes", "on")
165+

0 commit comments

Comments
 (0)