drift-ml 0.1.10__py3-none-any.whl → 0.2.1__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.
drift/engine_launcher.py CHANGED
@@ -1,11 +1,10 @@
1
1
  """
2
2
  Download and start the drift engine binary when no backend is running.
3
- Makes pipx install drift-ml work standalone (no npm needed).
3
+ Open source no tokens, no auth. Downloads from public GitHub Releases.
4
4
  """
5
5
 
6
6
  import os
7
7
  import platform
8
- import shutil
9
8
  import subprocess
10
9
  import sys
11
10
  from pathlib import Path
@@ -16,9 +15,8 @@ try:
16
15
  except ImportError:
17
16
  requests = None
18
17
 
19
- ENGINE_TAG = "v0.1.4"
20
- GITHUB_REPO = "lakshitsachdeva/drift"
21
- GITHUB_API = f"https://api.github.com/repos/{GITHUB_REPO}/releases/tags/{ENGINE_TAG}"
18
+ GITHUB_REPO = "lakshitsachdeva/drift" # Engine binaries (v0.2.0+ also in intent2model)
19
+ ENGINE_TAG = "v0.2.0" # Pinned — direct URL, no API, no rate limits
22
20
  ENGINE_PORT = os.environ.get("DRIFT_ENGINE_PORT", "8000")
23
21
  HEALTH_URL = f"http://127.0.0.1:{ENGINE_PORT}/health"
24
22
 
@@ -60,78 +58,63 @@ def _engine_running() -> bool:
60
58
  return False
61
59
 
62
60
 
63
- def _get_asset_download_url(asset_name: str) -> str:
64
- """Resolve GitHub release asset to download URL. Prefer direct URL (no API)."""
61
+ def _get_asset_url(asset_name: str) -> str:
62
+ """Direct download URL. No API avoids rate limits."""
65
63
  base = os.environ.get("DRIFT_ENGINE_BASE_URL")
66
64
  if base:
67
65
  return f"{base.rstrip('/')}/{asset_name}"
68
66
  return f"https://github.com/{GITHUB_REPO}/releases/download/{ENGINE_TAG}/{asset_name}"
69
67
 
70
68
 
71
- def _get_asset_download_url_via_api(asset_name: str) -> str:
72
- """Fallback: get URL via GitHub API (for private repos)."""
73
- token = os.environ.get("DRIFT_GITHUB_TOKEN") or os.environ.get("GITHUB_TOKEN")
74
- headers = {
75
- "User-Agent": "Drift-Engine-Launcher/1.0",
76
- "Accept": "application/vnd.github+json",
77
- }
78
- if token:
79
- headers["Authorization"] = f"Bearer {token}"
80
- r = requests.get(GITHUB_API, headers=headers, timeout=15)
81
- if r.status_code == 404:
82
- raise RuntimeError(
83
- f"Release {ENGINE_TAG} not found. "
84
- "If the repo is private, set DRIFT_GITHUB_TOKEN with repo read access."
85
- )
86
- r.raise_for_status()
87
- data = r.json()
88
- for a in data.get("assets", []):
89
- if a.get("name") == asset_name:
90
- url = a.get("browser_download_url") or a.get("url")
91
- if url:
92
- return url
93
- raise RuntimeError(f"Asset {asset_name} not found in release {ENGINE_TAG}")
94
-
95
-
96
69
  def _download_file(url: str, dest: Path) -> None:
97
70
  dest.parent.mkdir(parents=True, exist_ok=True)
98
- token = os.environ.get("DRIFT_GITHUB_TOKEN") or os.environ.get("GITHUB_TOKEN")
99
- headers = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36"}
100
- if "api.github.com" in url:
101
- headers["Accept"] = "application/octet-stream"
102
- if token:
103
- headers["Authorization"] = f"Bearer {token}"
104
- try:
71
+ headers = {"User-Agent": "Drift/1.0"}
72
+
73
+ def try_curl():
74
+ result = subprocess.run(
75
+ ["curl", "-fsSL", "-o", str(dest), url],
76
+ capture_output=True,
77
+ timeout=120,
78
+ )
79
+ if result.returncode != 0:
80
+ raise RuntimeError("curl failed")
81
+
82
+ def try_requests():
105
83
  r = requests.get(url, headers=headers, stream=True, timeout=60)
106
84
  r.raise_for_status()
107
85
  with open(dest, "wb") as f:
108
86
  for chunk in r.iter_content(chunk_size=65536):
109
87
  f.write(chunk)
110
- except Exception:
111
- # Fallback: urllib (stdlib, no deps, works when requests has issues)
88
+
89
+ def try_urllib():
112
90
  import urllib.request
113
91
  req = urllib.request.Request(url, headers=headers)
114
92
  with urllib.request.urlopen(req, timeout=60) as resp:
115
93
  with open(dest, "wb") as f:
116
94
  f.write(resp.read())
117
95
 
96
+ for attempt in [try_curl, try_requests, try_urllib]:
97
+ try:
98
+ attempt()
99
+ return
100
+ except Exception:
101
+ continue
102
+ raise RuntimeError(f"Download failed. Try: curl -L -o {dest} {url}")
103
+
118
104
 
119
105
  def ensure_engine() -> bool:
120
- """
121
- If engine not running: download (if needed), start it, wait for health.
122
- Returns True if engine is ready, False on failure.
123
- """
106
+ """Download (if needed), start engine, wait for health."""
124
107
  if _engine_running():
125
108
  return True
126
109
 
127
110
  if not requests:
128
- print("drift: 'requests' required for engine download. pip install requests", file=sys.stderr)
111
+ print("drift: 'requests' required. pip install requests", file=sys.stderr)
129
112
  return False
130
113
 
131
114
  bin_path = _get_engine_path()
132
115
  bin_dir = _get_engine_dir()
133
116
  if not bin_path or not bin_dir:
134
- print("drift: Could not resolve engine dir (~/.drift/bin). Set HOME or USERPROFILE.", file=sys.stderr)
117
+ print("drift: Could not resolve ~/.drift/bin. Set HOME or USERPROFILE.", file=sys.stderr)
135
118
  return False
136
119
 
137
120
  bin_dir.mkdir(parents=True, exist_ok=True)
@@ -141,17 +124,13 @@ def ensure_engine() -> bool:
141
124
  ext = ".exe" if platform.system() == "Windows" else ""
142
125
  asset = f"drift-engine-{plat}-{arch}{ext}"
143
126
  print(f"drift: Downloading engine ({asset})...", file=sys.stderr)
144
- url = _get_asset_download_url(asset)
145
127
  try:
128
+ url = _get_asset_url(asset)
146
129
  _download_file(url, bin_path)
147
130
  except Exception as e:
148
- try:
149
- url = _get_asset_download_url_via_api(asset)
150
- _download_file(url, bin_path)
151
- except Exception as e2:
152
- print(f"drift: Download failed: {e2}", file=sys.stderr)
153
- print(f"drift: Try manually: curl -L -o {bin_path} {url}", file=sys.stderr)
154
- return False
131
+ print(f"drift: Download failed: {e}", file=sys.stderr)
132
+ print(f"drift: Run: mkdir -p ~/.drift/bin && curl -L -o ~/.drift/bin/{asset} <url>", file=sys.stderr)
133
+ return False
155
134
  if platform.system() != "Windows":
156
135
  bin_path.chmod(0o755)
157
136
  if platform.system() == "Darwin":
@@ -160,7 +139,13 @@ def ensure_engine() -> bool:
160
139
  except Exception:
161
140
  pass
162
141
 
163
- # Start engine
142
+ if platform.system() == "Darwin" and bin_path:
143
+ try:
144
+ bin_path.chmod(0o755)
145
+ subprocess.run(["xattr", "-dr", "com.apple.quarantine", str(bin_path)], check=False, capture_output=True)
146
+ except Exception:
147
+ pass
148
+
164
149
  env = {**os.environ, "DRIFT_ENGINE_PORT": ENGINE_PORT}
165
150
  proc = subprocess.Popen(
166
151
  [str(bin_path)],
@@ -170,10 +155,9 @@ def ensure_engine() -> bool:
170
155
  stderr=subprocess.DEVNULL,
171
156
  start_new_session=True,
172
157
  )
173
- proc.wait() # wait briefly to avoid race
158
+ proc.wait()
174
159
  del proc
175
160
 
176
- # Poll for health
177
161
  for _ in range(60):
178
162
  if _engine_running():
179
163
  return True
@@ -0,0 +1,10 @@
1
+ Metadata-Version: 2.4
2
+ Name: drift-ml
3
+ Version: 0.2.1
4
+ Summary: drift — terminal-first, chat-based AutoML. Open source. No tokens. No auth.
5
+ Project-URL: Homepage, https://github.com/lakshitsachdeva/intent2model
6
+ Project-URL: Repository, https://github.com/lakshitsachdeva/intent2model
7
+ Requires-Python: >=3.10
8
+ License-File: LICENSE
9
+ Requires-Dist: requests>=2.28.0
10
+ Dynamic: license-file
@@ -1,6 +1,6 @@
1
1
  drift/__init__.py,sha256=X0NUP5ZAZSz-rBFfjvmmS4IYWP2_CZtu187mqwpWwqk,127
2
2
  drift/__main__.py,sha256=r2mhZ3sCvDY7iEEiZoGDvUPei_CY24tfMQgs7Oal2yk,856
3
- drift/engine_launcher.py,sha256=GlqT5KU_01mPP4kMO4UF__trbjtdcRHl3lmMwjAyEco,6168
3
+ drift/engine_launcher.py,sha256=OjHNRU9jW3ToqfXuXHPpTwdaS_Axad-gNVpZZbs1W8c,5231
4
4
  drift/cli/__init__.py,sha256=OQt7M06e98e_L_60Qz-HsmSqGXKWdH53SvgETJ_BZZ0,172
5
5
  drift/cli/client.py,sha256=hGxz-J8fC_gGV9BZnpCBwkQZg4Q0_s9-Agk2PuXQ5MQ,5527
6
6
  drift/cli/repl.py,sha256=hRnx4nfP_StnXDbdRZXnnjA8aNvrdQSV-uTNsuaaO60,8262
@@ -9,8 +9,9 @@ drift/llm_adapters/__init__.py,sha256=y1UhZWlC8Ik_OKfLcOp0JZP-FKR3MBBCemWwsL6Tnk
9
9
  drift/llm_adapters/base.py,sha256=KlZUPYpvCI8pafklBWel0GHHLNtVKVwSHA92MZt3VsI,1331
10
10
  drift/llm_adapters/gemini_cli.py,sha256=Z61wY3yFiZqPrQrpJAQrBtMbBkr2qLWBkni-A4p9lZo,2163
11
11
  drift/llm_adapters/local_llm.py,sha256=Z6j6z1CXk2LMeQ5ZnY4o38PiYkHYmcIkgJGkHdU50M8,2279
12
- drift_ml-0.1.10.dist-info/METADATA,sha256=T8JG1IH8YWkfWQjzwxV30ICNP3MRZrqWgrps5sORy9o,169
13
- drift_ml-0.1.10.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
14
- drift_ml-0.1.10.dist-info/entry_points.txt,sha256=aCY7U9M8nhYj_tIfTXJmYkVmXY3ZoxF0tebDZzYswv8,46
15
- drift_ml-0.1.10.dist-info/top_level.txt,sha256=3u2KGqsciGZQ2uCoBivm55t3e8er8S4xnqkgdQ_8oeM,6
16
- drift_ml-0.1.10.dist-info/RECORD,,
12
+ drift_ml-0.2.1.dist-info/licenses/LICENSE,sha256=MdZfE1ctfpz-RISaUozKjRDuwTLqlMKcoHDzT3m43zk,1073
13
+ drift_ml-0.2.1.dist-info/METADATA,sha256=gT3VtfUdVbmlqr47_c-OG9RkGVY0mN8RPQpe5_M_Rx4,383
14
+ drift_ml-0.2.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
15
+ drift_ml-0.2.1.dist-info/entry_points.txt,sha256=aCY7U9M8nhYj_tIfTXJmYkVmXY3ZoxF0tebDZzYswv8,46
16
+ drift_ml-0.2.1.dist-info/top_level.txt,sha256=3u2KGqsciGZQ2uCoBivm55t3e8er8S4xnqkgdQ_8oeM,6
17
+ drift_ml-0.2.1.dist-info/RECORD,,
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Lakshit Sachdeva
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,6 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: drift-ml
3
- Version: 0.1.10
4
- Summary: Terminal-first AutoML CLI - chat-based ML engineer
5
- Requires-Python: >=3.10
6
- Requires-Dist: requests>=2.28.0