duckrun 0.2.9.dev2__py3-none-any.whl → 0.2.9.dev4__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.
duckrun/__init__.py CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  from duckrun.core import Duckrun
4
4
 
5
- __version__ = "0.1.0"
5
+ __version__ = "0.2.9.dev4"
6
6
 
7
7
  # Expose unified connect method at module level
8
8
  connect = Duckrun.connect
duckrun/core.py CHANGED
@@ -727,8 +727,8 @@ class Duckrun:
727
727
 
728
728
  # Call the deployment function (DirectLake only)
729
729
  return deploy_semantic_model(
730
- workspace_name=self.workspace,
731
- lakehouse_name=self.lakehouse_name,
730
+ workspace_name_or_id=self.workspace,
731
+ lakehouse_name_or_id=self.lakehouse_name,
732
732
  schema_name=self.schema,
733
733
  dataset_name=dataset_name,
734
734
  bim_url=bim_url,
duckrun/semantic_model.py CHANGED
@@ -129,9 +129,12 @@ def check_dataset_exists(dataset_name, workspace_id, client):
129
129
  return False
130
130
 
131
131
 
132
- def refresh_dataset(dataset_name, workspace_id, client):
132
+ def refresh_dataset(dataset_name, workspace_id, client, dataset_id=None):
133
133
  """Refresh a dataset and monitor progress"""
134
- dataset_id = get_dataset_id(dataset_name, workspace_id, client)
134
+
135
+ # If dataset_id not provided, look it up by name
136
+ if not dataset_id:
137
+ dataset_id = get_dataset_id(dataset_name, workspace_id, client)
135
138
 
136
139
  payload = {
137
140
  "type": "full",
@@ -246,7 +249,7 @@ def update_bim_for_directlake(bim_content, workspace_id, lakehouse_id, schema_na
246
249
 
247
250
 
248
251
  def create_dataset_from_bim(dataset_name, bim_content, workspace_id, client):
249
- """Create semantic model from BIM using Fabric REST API"""
252
+ """Create semantic model from BIM using Fabric REST API and return the dataset ID"""
250
253
  # Convert to base64
251
254
  bim_json = json.dumps(bim_content, indent=2)
252
255
  bim_base64 = base64.b64encode(bim_json.encode('utf-8')).decode('utf-8')
@@ -280,7 +283,7 @@ def create_dataset_from_bim(dataset_name, bim_content, workspace_id, client):
280
283
 
281
284
  print(f"✓ Semantic model created")
282
285
 
283
- # Handle long-running operation
286
+ # Handle long-running operation and return the dataset ID
284
287
  if response.status_code == 202:
285
288
  operation_id = response.headers.get('x-ms-operation-id')
286
289
  print(f" Waiting for operation to complete...")
@@ -288,17 +291,38 @@ def create_dataset_from_bim(dataset_name, bim_content, workspace_id, client):
288
291
  max_attempts = 30
289
292
  for attempt in range(max_attempts):
290
293
  time.sleep(2)
294
+
295
+ # Get operation result (not just status)
296
+ result_response = client.get(f"/v1/operations/{operation_id}/result")
297
+
298
+ # Check if operation is complete by getting the status
291
299
  status_response = client.get(f"/v1/operations/{operation_id}")
292
300
  status = status_response.json().get('status')
293
301
 
294
302
  if status == 'Succeeded':
295
303
  print(f"✓ Operation completed")
296
- break
304
+ # Return the created dataset ID from the result
305
+ result_data = result_response.json()
306
+ dataset_id = result_data.get('id')
307
+ if dataset_id:
308
+ return dataset_id
309
+ else:
310
+ # Fallback: search for the dataset by name
311
+ return get_dataset_id(dataset_name, workspace_id, client)
297
312
  elif status == 'Failed':
298
313
  error = status_response.json().get('error', {})
299
314
  raise Exception(f"Operation failed: {error.get('message')}")
300
315
  elif attempt == max_attempts - 1:
301
316
  raise Exception(f"Operation timed out")
317
+
318
+ # For non-async responses (status 200/201)
319
+ result_data = response.json()
320
+ dataset_id = result_data.get('id')
321
+ if dataset_id:
322
+ return dataset_id
323
+ else:
324
+ # Fallback: search for the dataset by name
325
+ return get_dataset_id(dataset_name, workspace_id, client)
302
326
 
303
327
 
304
328
  def deploy_semantic_model(workspace_name_or_id, lakehouse_name_or_id, schema_name, dataset_name,
@@ -365,17 +389,18 @@ def deploy_semantic_model(workspace_name_or_id, lakehouse_name_or_id, schema_nam
365
389
  modified_bim['name'] = dataset_name
366
390
  modified_bim['id'] = dataset_name
367
391
 
368
- # Step 5: Deploy
392
+ # Step 5: Deploy and get the dataset ID
369
393
  print("\n[Step 5/6] Deploying semantic model...")
370
- create_dataset_from_bim(dataset_name, modified_bim, workspace_id, client)
394
+ dataset_id = create_dataset_from_bim(dataset_name, modified_bim, workspace_id, client)
395
+ print(f" Dataset ID: {dataset_id}")
371
396
 
372
397
  if wait_seconds > 0:
373
- print(f" Waiting {wait_seconds} seconds for permissions...")
398
+ print(f" Waiting {wait_seconds} seconds before refresh...")
374
399
  time.sleep(wait_seconds)
375
400
 
376
- # Step 6: Refresh
401
+ # Step 6: Refresh using the dataset ID returned from creation
377
402
  print("\n[Step 6/6] Refreshing semantic model...")
378
- refresh_dataset(dataset_name, workspace_id, client)
403
+ refresh_dataset(dataset_name, workspace_id, client, dataset_id=dataset_id)
379
404
 
380
405
  print("\n" + "=" * 70)
381
406
  print("🎉 Deployment Completed!")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: duckrun
3
- Version: 0.2.9.dev2
3
+ Version: 0.2.9.dev4
4
4
  Summary: Lakehouse task runner powered by DuckDB for Microsoft Fabric
5
5
  Author: mim
6
6
  License: MIT
@@ -0,0 +1,14 @@
1
+ duckrun/__init__.py,sha256=VJAx606MLj6SVHu3nVePEO0BBp0WxCBtgk_U1olMU7g,235
2
+ duckrun/auth.py,sha256=qPaLQ7InlV9leA9r6E6VEeYavFFoBi0zSN8m_l1aoQs,9545
3
+ duckrun/core.py,sha256=CrWMgA1QHvVF2AAlTlBlQ7VfKsuakcqZa4VuX2WJmik,39279
4
+ duckrun/files.py,sha256=Fvdjg3DyHJzIVzKo8M_j-eGz4zU61lOB38Y_onbQJkI,10137
5
+ duckrun/lakehouse.py,sha256=j--Z3zo8AOWt1GF9VzRosmmTAy6ey2D0LVubti58twU,14109
6
+ duckrun/runner.py,sha256=yrDxfy1RVkb8iK9GKGmIFZHzCvcO_0GVQlbng7Vw_iM,14171
7
+ duckrun/semantic_model.py,sha256=4_VgsXAHaWhqxI2kOSB2UtRLa6CoBYFEXt418j5xce0,16739
8
+ duckrun/stats.py,sha256=CXfb2DWF3PgOckelJooU0y-BAsNT9NFDfDYEmo0mUQQ,10473
9
+ duckrun/writer.py,sha256=svUuPCYOhrz299NgnpTKhARKjfej0PxnoND2iPDSypk,8098
10
+ duckrun-0.2.9.dev4.dist-info/licenses/LICENSE,sha256=-DeQQwdbCbkB4507ZF3QbocysB-EIjDtaLexvqRkGZc,1083
11
+ duckrun-0.2.9.dev4.dist-info/METADATA,sha256=iBsF-oRskhqicNpd3i5NJq0XZxTepDERJ3i_LVV0rZ4,19277
12
+ duckrun-0.2.9.dev4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
+ duckrun-0.2.9.dev4.dist-info/top_level.txt,sha256=BknMEwebbUHrVAp3SC92ps8MPhK7XSYsaogTvi_DmEU,8
14
+ duckrun-0.2.9.dev4.dist-info/RECORD,,
@@ -1,14 +0,0 @@
1
- duckrun/__init__.py,sha256=XA85pL2vK1AkmBic8e7WxeqNvcd6SjFX4zsQpImDO6E,230
2
- duckrun/auth.py,sha256=qPaLQ7InlV9leA9r6E6VEeYavFFoBi0zSN8m_l1aoQs,9545
3
- duckrun/core.py,sha256=ulKRnxTH8MfGtcKAAORBs-_vd-_jIyWmwv9Bims0TsQ,39267
4
- duckrun/files.py,sha256=Fvdjg3DyHJzIVzKo8M_j-eGz4zU61lOB38Y_onbQJkI,10137
5
- duckrun/lakehouse.py,sha256=j--Z3zo8AOWt1GF9VzRosmmTAy6ey2D0LVubti58twU,14109
6
- duckrun/runner.py,sha256=yrDxfy1RVkb8iK9GKGmIFZHzCvcO_0GVQlbng7Vw_iM,14171
7
- duckrun/semantic_model.py,sha256=y_E1VlpqSx9DHOGi--4ZccaODErthzty5CVN4TI-mQ0,15509
8
- duckrun/stats.py,sha256=CXfb2DWF3PgOckelJooU0y-BAsNT9NFDfDYEmo0mUQQ,10473
9
- duckrun/writer.py,sha256=svUuPCYOhrz299NgnpTKhARKjfej0PxnoND2iPDSypk,8098
10
- duckrun-0.2.9.dev2.dist-info/licenses/LICENSE,sha256=-DeQQwdbCbkB4507ZF3QbocysB-EIjDtaLexvqRkGZc,1083
11
- duckrun-0.2.9.dev2.dist-info/METADATA,sha256=4vDjuMN2L2Uiv6CLIP7UyaKss6-jjNE7ZUxJC5SLnT8,19277
12
- duckrun-0.2.9.dev2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
- duckrun-0.2.9.dev2.dist-info/top_level.txt,sha256=BknMEwebbUHrVAp3SC92ps8MPhK7XSYsaogTvi_DmEU,8
14
- duckrun-0.2.9.dev2.dist-info/RECORD,,