Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions datalab_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,22 +882,23 @@ async def delete_workflow(self, workflow_id: int) -> Dict[str, Any]:
async def execute_workflow(
self,
workflow_id: int,
input_config: InputConfig,
input_config: Optional[InputConfig] = None,
) -> WorkflowExecution:
"""
Trigger a workflow execution

Args:
workflow_id: ID of the workflow to execute
input_config: Input configuration for the workflow
input_config: Optional input configuration for the workflow.
If omitted, the workflow uses its default/stored input.

Returns:
WorkflowExecution object with initial status (typically "processing")
Use get_execution_status() to check completion status
"""
execution_data = {
"input_config": input_config.to_dict(),
}
execution_data = {}
if input_config is not None:
execution_data["input_config"] = input_config.to_dict()

response = await self._make_request(
"POST",
Expand All @@ -915,12 +916,13 @@ async def execute_workflow(
id=execution_id,
workflow_id=workflow_id,
status=response.get("status", "processing"),
input_config=input_config.to_dict(),
input_config=input_config.to_dict() if input_config is not None else {},
success=response.get("success", True),
steps=response.get("results"),
error=response.get("error"),
created=response.get("created"),
updated=response.get("updated"),
external_workflow_id=response.get("external_workflow_id"),
)

async def get_execution_status(
Expand Down Expand Up @@ -988,6 +990,7 @@ async def get_execution_status(
error=error,
created=response.get("created"),
updated=response.get("updated"),
external_workflow_id=response.get("external_workflow_id"),
)

# If complete or failed, return immediately
Expand Down
12 changes: 11 additions & 1 deletion datalab_sdk/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class ConvertOptions(ProcessingOptions):
output_format: str = "markdown" # markdown, json, html, chunks (comma-separated for multiple)
mode: str = "fast" # fast, balanced, accurate
keep_spreadsheet_formatting: bool = False
keep_pageheader_in_output: bool = False # keep page headers in output
keep_pagefooter_in_output: bool = False # keep page footers in output
webhook_url: Optional[str] = None
# Comma-separated list of extra features: 'track_changes', 'chart_understanding',
# 'table_row_bboxes', 'extract_links', 'infographic', 'new_block_types'
Expand All @@ -59,14 +61,20 @@ def to_form_data(self) -> Dict[str, Any]:
# Start with parent's form data
form_data = super().to_form_data()

# Remove keep_spreadsheet_formatting from top-level (it goes in additional_config)
# Remove these from top-level (they go in additional_config)
form_data.pop("keep_spreadsheet_formatting", None)
form_data.pop("keep_pageheader_in_output", None)
form_data.pop("keep_pagefooter_in_output", None)

additional_config_dict = {}
if self.additional_config:
additional_config_dict.update(self.additional_config)
if self.keep_spreadsheet_formatting:
additional_config_dict["keep_spreadsheet_formatting"] = True
if self.keep_pageheader_in_output:
additional_config_dict["keep_pageheader_in_output"] = True
if self.keep_pagefooter_in_output:
additional_config_dict["keep_pagefooter_in_output"] = True

if additional_config_dict:
form_data["additional_config"] = (None, json.dumps(additional_config_dict))
Expand Down Expand Up @@ -324,6 +332,7 @@ class WorkflowExecution:
error: Optional[str] = None
created: Optional[str] = None
updated: Optional[str] = None
external_workflow_id: Optional[str] = None # Temporal workflow ID

def save_output(self, output_path: Union[str, Path]) -> None:
"""Save the execution steps to a JSON file"""
Expand All @@ -339,6 +348,7 @@ def save_output(self, output_path: Union[str, Path]) -> None:
"error": self.error,
"created": self.created,
"updated": self.updated,
"external_workflow_id": self.external_workflow_id,
}

with open(output_path.with_suffix(".json"), "w", encoding="utf-8") as f:
Expand Down
18 changes: 16 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.