discovery-engine-api 0.1.47__py3-none-any.whl → 0.1.57__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.
discovery/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """Discovery Engine Python SDK."""
2
2
 
3
- __version__ = "0.1.47"
3
+ __version__ = "0.1.57"
4
4
 
5
5
  from discovery.client import Engine
6
6
  from discovery.types import (
discovery/client.py CHANGED
@@ -36,6 +36,9 @@ class Engine:
36
36
  # This points to the Modal-deployed FastAPI API
37
37
  _DEFAULT_BASE_URL = "https://leap-labs-production--discovery-api.modal.run"
38
38
 
39
+ # Dashboard URL for web UI and /api/* endpoints
40
+ _DEFAULT_DASHBOARD_URL = "https://disco.leap-labs.com"
41
+
39
42
  def __init__(self, api_key: str):
40
43
  """
41
44
  Initialize the Discovery Engine.
@@ -49,8 +52,13 @@ class Engine:
49
52
  # Use DISCOVERY_API_URL env var if set (for testing/custom deployments),
50
53
  # otherwise use the production default
51
54
  self.base_url = os.getenv("DISCOVERY_API_URL", self._DEFAULT_BASE_URL).rstrip("/")
55
+ # Dashboard URL for /api/* endpoints and web UI links
56
+ self.dashboard_url = os.getenv(
57
+ "DISCOVERY_DASHBOARD_URL", self._DEFAULT_DASHBOARD_URL
58
+ ).rstrip("/")
52
59
  self._organization_id: Optional[str] = None
53
60
  self._client: Optional[httpx.AsyncClient] = None
61
+ self._dashboard_client: Optional[httpx.AsyncClient] = None
54
62
  self._org_fetched = False
55
63
 
56
64
  async def _ensure_organization_id(self) -> str:
@@ -119,11 +127,25 @@ class Engine:
119
127
 
120
128
  return client
121
129
 
130
+ async def _get_dashboard_client(self) -> httpx.AsyncClient:
131
+ """Get or create the HTTP client for dashboard API calls."""
132
+ if self._dashboard_client is None:
133
+ headers = {"Authorization": f"Bearer {self.api_key}"}
134
+ self._dashboard_client = httpx.AsyncClient(
135
+ base_url=self.dashboard_url,
136
+ headers=headers,
137
+ timeout=60.0,
138
+ )
139
+ return self._dashboard_client
140
+
122
141
  async def close(self):
123
- """Close the HTTP client."""
142
+ """Close the HTTP clients."""
124
143
  if self._client:
125
144
  await self._client.aclose()
126
145
  self._client = None
146
+ if self._dashboard_client:
147
+ await self._dashboard_client.aclose()
148
+ self._dashboard_client = None
127
149
 
128
150
  async def __aenter__(self):
129
151
  """Async context manager entry."""
@@ -365,10 +387,11 @@ class Engine:
365
387
  Returns:
366
388
  EngineResult with complete analysis data
367
389
  """
368
- client = await self._get_client_with_org()
390
+ # Use dashboard client for /api/* endpoints (hosted on Next.js dashboard, not Modal API)
391
+ dashboard_client = await self._get_dashboard_client()
369
392
 
370
393
  # Call dashboard API for results
371
- response = await client.get(f"/api/runs/{run_id}/results")
394
+ response = await dashboard_client.get(f"/api/runs/{run_id}/results")
372
395
  response.raise_for_status()
373
396
 
374
397
  data = response.json()
@@ -501,8 +524,6 @@ class Engine:
501
524
  Returns:
502
525
  EngineResult with run_id and (if wait=True) complete results
503
526
  """
504
- client = await self._get_client_with_org()
505
-
506
527
  # Prepare file for upload
507
528
  if pd is not None and isinstance(file, pd.DataFrame):
508
529
  # Convert DataFrame to CSV in memory
@@ -556,8 +577,10 @@ class Engine:
556
577
  print(
557
578
  f"🚀 Uploading file and creating run (depth: {depth_iterations}, target: {target_column})..."
558
579
  )
580
+ # Use dashboard client for /api/* endpoints (hosted on Next.js dashboard, not Modal API)
581
+ dashboard_client = await self._get_dashboard_client()
559
582
  # httpx automatically handles multipart/form-data when both files and data are provided
560
- response = await client.post("/api/reports/create", files=files, data=data)
583
+ response = await dashboard_client.post("/api/reports/create", files=files, data=data)
561
584
  response.raise_for_status()
562
585
 
563
586
  result_data = response.json()
@@ -574,8 +597,8 @@ class Engine:
574
597
  print(f"ℹ️ Duplicate report found (run_id: {run_id})")
575
598
 
576
599
  # Construct dashboard URL for the processing page
577
- dashboard_url = f"{self.base_url}/reports/new/{run_id}/processing"
578
- print(f"🔗 View progress: {dashboard_url}")
600
+ progress_url = f"{self.dashboard_url}/reports/new/{run_id}/processing"
601
+ print(f"🔗 View progress: {progress_url}")
579
602
 
580
603
  # If wait is True, fetch the full results for the existing report
581
604
  if wait:
@@ -592,8 +615,8 @@ class Engine:
592
615
  print(f"✓ Run created: {run_id}")
593
616
 
594
617
  # Construct dashboard URL for the processing page
595
- dashboard_url = f"{self.base_url}/reports/new/{run_id}/processing"
596
- print(f"🔗 View progress: {dashboard_url}")
618
+ progress_url = f"{self.dashboard_url}/reports/new/{run_id}/processing"
619
+ print(f"🔗 View progress: {progress_url}")
597
620
 
598
621
  if wait:
599
622
  # Wait for completion and return full results
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: discovery-engine-api
3
- Version: 0.1.47
3
+ Version: 0.1.57
4
4
  Summary: Python SDK for the Discovery Engine API
5
5
  Project-URL: Homepage, https://github.com/leap-laboratories/discovery
6
6
  Project-URL: Documentation, https://github.com/leap-laboratories/discovery
@@ -0,0 +1,6 @@
1
+ discovery/__init__.py,sha256=SaMyN0LNagF7B8YbpxeoiimRgWaRRgWseBlhvY2jkCE,586
2
+ discovery/client.py,sha256=4qRYvnf7oU0HUC5M15S8fKbQjyw4C_qQ7g4ExJEeRwo,32174
3
+ discovery/types.py,sha256=4Z3gKdxWnOpymEjBGCzAeUGjwRT2A0aCpmuwctbE4w0,6008
4
+ discovery_engine_api-0.1.57.dist-info/METADATA,sha256=maCzXl4-4CVOupFobK6Ubx3XzdnH12EUXbv7eg7kLlw,12675
5
+ discovery_engine_api-0.1.57.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
6
+ discovery_engine_api-0.1.57.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- discovery/__init__.py,sha256=fkx9RJUVloq7PZZKXI1CDnw93YDMn5FfuIyHuzzrrzo,586
2
- discovery/client.py,sha256=sv1AoRzipSlgx1H6GRab4EfT8DlOm5xzKKNeTdkQiO8,30976
3
- discovery/types.py,sha256=4Z3gKdxWnOpymEjBGCzAeUGjwRT2A0aCpmuwctbE4w0,6008
4
- discovery_engine_api-0.1.47.dist-info/METADATA,sha256=jHGgVtlj1Fc9Fhl84yh2NMpMLrLR7_fGJ96oAoyK9OE,12675
5
- discovery_engine_api-0.1.47.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
6
- discovery_engine_api-0.1.47.dist-info/RECORD,,