1299 - #1302
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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" |
whiskyboy
approved these changes
Jul 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#1299