Skip to content

1299 - #1302

Merged
m-kovalsky merged 1 commit into
microsoft:mainfrom
m-kovalsky:m-kovalsky/1299
Jul 28, 2026
Merged

1299#1302
m-kovalsky merged 1 commit into
microsoft:mainfrom
m-kovalsky:m-kovalsky/1299

Conversation

@m-kovalsky

Copy link
Copy Markdown
Collaborator

Copilot AI review requested due to automatic review settings July 28, 2026 06:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Variable Library API wrapper to let callers overwrite an existing Variable Library’s definition (not just values/properties), addressing the gap described in issue #1299.

Changes:

  • Added update_variable_library_definition() to call the Fabric “Update Variable Library Definition” endpoint and handle Base64 payload encoding.
  • Added a small Base64-detection helper to avoid double-encoding payloads.
  • Exported the new function from sempy_labs.variable_library.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/sempy_labs/variable_library/_functions.py Implements update_variable_library_definition() and Base64 handling helpers for definition updates.
src/sempy_labs/variable_library/__init__.py Exposes update_variable_library_definition as part of the variable_library public API.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +422 to +432
def _is_b64(content: str) -> bool:
# Determines whether a definition part payload is already Base64-encoded.
import base64

try:
return (
base64.b64encode(base64.b64decode(content, validate=True)).decode("utf-8")
== content
)
except Exception:
return False
Comment on lines +742 to +756
new_parts = []
for part in parts:
payload = part.get("payload")
if isinstance(payload, (dict, list)):
payload = _encode_b64(payload)
elif isinstance(payload, str) and not _is_b64(payload):
payload = _conv_b64(payload, json_dumps=False)

new_parts.append(
{
"path": part.get("path"),
"payload": payload,
"payloadType": part.get("payloadType", "InlineBase64"),
}
)

url = f"/v1/workspaces/{workspace_id}/variableLibraries/{item_id}/updateDefinition"
if update_metadata:
url = f"{url}?updateMetadata=True"
@m-kovalsky
m-kovalsky merged commit 1465c49 into microsoft:main Jul 28, 2026
4 checks passed
@m-kovalsky
m-kovalsky deleted the m-kovalsky/1299 branch July 28, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants