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
2 changes: 1 addition & 1 deletion datalab_sdk/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ def create_workflow(
# Create workflow
client = DatalabClient(api_key=api_key, base_url=base_url)
workflow = client.create_workflow(
name=name, team_id=team_id, steps=workflow_steps
name=name, steps=workflow_steps
)

click.echo("Workflow created successfully!")
Expand Down
23 changes: 16 additions & 7 deletions datalab_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,7 @@ async def _download_step_results(self, steps_data: dict) -> dict:
async def _upload_single_file(
self,
file_path: Union[str, Path],
processing_location: Optional[str] = None,
) -> UploadedFileMetadata:
"""
Internal method to upload a single file to Datalab storage
Expand Down Expand Up @@ -1399,13 +1400,17 @@ async def _upload_single_file(
mime_type = MIMETYPE_MAP.get(extension, "application/octet-stream")

# Step 1: Request presigned upload URL
upload_request: Dict[str, Any] = {
"filename": file_path.name,
"content_type": mime_type,
}
if processing_location is not None:
upload_request["processing_location"] = processing_location

response = await self._make_request(
"POST",
"/api/v1/files/upload",
json={
"filename": file_path.name,
"content_type": mime_type,
},
json=upload_request,
)

file_id = response["file_id"]
Expand Down Expand Up @@ -1448,6 +1453,7 @@ async def _upload_single_file(
async def upload_files(
self,
file_paths: Union[str, Path, list[Union[str, Path]]],
processing_location: Optional[str] = None,
) -> Union[UploadedFileMetadata, list[UploadedFileMetadata]]:
"""
Upload one or more files to Datalab storage
Expand All @@ -1461,6 +1467,7 @@ async def upload_files(

Args:
file_paths: Single file path or list of file paths to upload
processing_location: Optional data residency region (e.g. "us", "eu")

Returns:
If single file: UploadedFileMetadata object
Expand All @@ -1475,10 +1482,10 @@ async def upload_files(
"""
# Handle single file path
if isinstance(file_paths, (str, Path)):
return await self._upload_single_file(file_paths)
return await self._upload_single_file(file_paths, processing_location=processing_location)

# Handle list of file paths
tasks = [self._upload_single_file(file_path) for file_path in file_paths]
tasks = [self._upload_single_file(file_path, processing_location=processing_location) for file_path in file_paths]
return await asyncio.gather(*tasks)

async def list_files(
Expand Down Expand Up @@ -2543,6 +2550,7 @@ def get_execution_status(
def upload_files(
self,
file_paths: Union[str, Path, list[Union[str, Path]]],
processing_location: Optional[str] = None,
) -> Union[UploadedFileMetadata, list[UploadedFileMetadata]]:
"""
Upload one or more files to Datalab storage (sync version)
Expand All @@ -2556,6 +2564,7 @@ def upload_files(

Args:
file_paths: Single file path or list of file paths to upload
processing_location: Optional data residency region (e.g. "us", "eu")

Returns:
If single file: UploadedFileMetadata object
Expand All @@ -2568,7 +2577,7 @@ def upload_files(
# Upload multiple files
metadatas = client.upload_files(["doc1.pdf", "doc2.pdf"])
"""
return self._run_async(self._async_client.upload_files(file_paths=file_paths))
return self._run_async(self._async_client.upload_files(file_paths=file_paths, processing_location=processing_location))

def list_files(
self,
Expand Down
7 changes: 6 additions & 1 deletion datalab_sdk/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ConvertOptions(ProcessingOptions):
include_markdown_in_chunks: bool = False # include markdown field in chunks/JSON output
token_efficient_markdown: bool = False # optimize markdown for LLM token usage
eval_rubric_id: Optional[int] = None # run evaluation rubric after conversion
word_bboxes: bool = False # predict per-word bounding boxes with confidence scores

def to_form_data(self) -> Dict[str, Any]:
"""Convert to form data format for API requests"""
Expand Down Expand Up @@ -83,7 +84,8 @@ class ExtractOptions(ProcessingOptions):
schema_id: Optional[str] = None # ID of a saved extraction schema (e.g. sch_k8Hx9mP2nQ4v). Mutually exclusive with page_schema.
schema_version: Optional[int] = None # Version of the schema. Only valid with schema_id.
checkpoint_id: Optional[str] = None # From previous /convert with save_checkpoint=true
mode: str = "fast" # fast, balanced, accurate
mode: str = "fast" # Parse mode: fast, balanced, accurate
extraction_mode: Optional[str] = None # Extraction mode: "turbo" (fastest, image-only), "fast", or "balanced". Defaults to "balanced".
output_format: str = "markdown" # markdown, json, html, chunks
save_checkpoint: bool = False
webhook_url: Optional[str] = None
Expand All @@ -94,6 +96,9 @@ def to_form_data(self) -> Dict[str, Any]:
# When using schema_id, suppress the empty default page_schema
if self.schema_id and not self.page_schema:
form_data.pop("page_schema", None)
# Only send extraction_mode if explicitly set
if self.extraction_mode is None:
form_data.pop("extraction_mode", None)
return form_data


Expand Down
2 changes: 1 addition & 1 deletion uv.lock

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

Loading