Skip to content

Commit 8630e5a

Browse files
author
Saurabh Badenkal
committed
Optimize get() with list accumulation, validate empty create rows, fix Copilot SDK package name
- get(): replaced per-page DataFrame concat with rows.extend() + from_records() for better performance on large paginated results - create(): detect and raise ValueError for rows with all NaN/None values (empty dicts) before sending to the API - Standardized Copilot SDK package name to 'github-copilot-sdk' everywhere
1 parent 4ea8c5a commit 8630e5a

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

examples/advanced/datascience_risk_assessment.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
pip install matplotlib # for charts / visualization
3535
pip install azure-ai-inference # Option A: Azure AI Foundry / Azure OpenAI
3636
pip install openai # Option B: OpenAI / Azure OpenAI
37-
pip install copilot-sdk # Option C: GitHub Copilot SDK (requires Copilot CLI)
37+
pip install github-copilot-sdk # Option C: GitHub Copilot SDK (requires Copilot CLI)
3838
"""
3939

4040
import sys
@@ -79,10 +79,10 @@
7979
# - Works with OpenAI API and Azure OpenAI
8080
# - pip install openai
8181
#
82-
# Option C: GitHub Copilot SDK (copilot-sdk)
82+
# Option C: GitHub Copilot SDK (github-copilot-sdk)
8383
# - Uses your existing GitHub Copilot subscription (no separate API key)
8484
# - Requires the Copilot CLI binary and async execution
85-
# - pip install copilot-sdk
85+
# - pip install github-copilot-sdk
8686
# ================================================================
8787

8888

src/PowerPlatform/Dataverse/operations/dataframe.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def get(
129129
)
130130
return pd.DataFrame([result.data])
131131

132-
frames: List[pd.DataFrame] = []
132+
rows: List[dict] = []
133133
for batch in self._client.records.get(
134134
table,
135135
select=select,
@@ -139,11 +139,11 @@ def get(
139139
expand=expand,
140140
page_size=page_size,
141141
):
142-
frames.append(pd.DataFrame([row.data for row in batch]))
142+
rows.extend(row.data for row in batch)
143143

144-
if not frames:
144+
if not rows:
145145
return pd.DataFrame()
146-
return pd.concat(frames, ignore_index=True)
146+
return pd.DataFrame.from_records(rows)
147147

148148
# ----------------------------------------------------------------- create
149149

@@ -189,6 +189,15 @@ def create(
189189
raise ValueError("records must be a non-empty DataFrame")
190190

191191
record_list = dataframe_to_records(records)
192+
193+
# Detect rows where all values were NaN/None (empty dicts after normalization)
194+
empty_rows = [records.index[i] for i, r in enumerate(record_list) if not r]
195+
if empty_rows:
196+
raise ValueError(
197+
f"Records at index(es) {empty_rows} have no non-null values. "
198+
"All rows must contain at least one field to create."
199+
)
200+
192201
ids = self._client.records.create(table, record_list)
193202

194203
if len(ids) != len(records):

0 commit comments

Comments
 (0)