-
Notifications
You must be signed in to change notification settings - Fork 118
Open
Labels
enhancementNew feature or requestNew feature or request
Description
What is the feature?
The Gap:
When using deploy_with_config, the FabricWorkspace object is instantiated internally within the function scope.
- On Success: The function returns
None, swallowing theresponsesdictionary (whenenable_response_collectionis active). - On Failure: The function raises an exception immediately. Because the
FabricWorkspaceobject is local to the function scope, it is destroyed when the stack unwinds. The caller has no way to accessworkspace.responsesto determine which items succeeded before the crash.
This makes deploy_with_config unsuitable for production pipelines where reporting partial success (e.g., "Notebooks deployed, but Pipelines failed") is required.
The Ideal Solution:
Modify deploy_with_config in src/fabric_cicd/publish.py to wrap the operations in a try...except block.
- Happy Path: Return
workspace.responses. - Failure Path: Catch the exception, attach the
workspace.responsesdictionary to the Exception instance (e.g., as a.partial_resultsattribute), and re-raise the exception.
Proposed Implementation Logic:
# src/fabric_cicd/publish.py
def deploy_with_config(...):
# ... setup workspace ...
try:
# Execute deployment operations
if not publish_settings.get("skip", False):
publish_all_items(workspace, ...)
if not unpublish_settings.get("skip", False):
unpublish_all_orphan_items(workspace, ...)
except Exception as e:
# Attach partial responses to the exception object before re-raising
# This preserves the data that would otherwise be lost when 'workspace' goes out of scope
if hasattr(workspace, 'responses') and workspace.responses:
# Dynamically attach attribute to exception instance
e.partial_results = workspace.responses
raise e
# Happy path return
return getattr(workspace, 'responses', None)Additional context
Example Usage if implemented:
from fabric_cicd import deploy_with_config, append_feature_flag
append_feature_flag("enable_response_collection")
# ... enable other flags ...
try:
results = deploy_with_config(config_file_path="config.yml", environment="PROD")
print("Deployment Success!")
# Process results (e.g. log new Item IDs)
if results:
print(results)
except Exception as e:
print("Deployment Failed!")
# Feature allows accessing partial data attached to the exception
if hasattr(e, 'partial_results'):
print("Items that succeeded before crash:")
for item_type, items in e.partial_results.items():
print(f"- {item_type}: {list(items.keys())}")
raise e # Fail the pipelineMetadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request