Skip to content

Commit 01d0f22

Browse files
committed
format
1 parent 469700c commit 01d0f22

File tree

1 file changed

+18
-11
lines changed
  • packages/traceloop-sdk/traceloop/sdk/datasets

1 file changed

+18
-11
lines changed

packages/traceloop-sdk/traceloop/sdk/datasets/datasets.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import csv
2-
from typing import List, Optional, Dict, Any
32
from pathlib import Path
3+
from typing import Any, Dict, List, Optional
44

55
try:
66
import pandas as pd
@@ -10,17 +10,17 @@
1010
PANDAS_AVAILABLE = False
1111

1212

13+
from traceloop.sdk.client.http import HTTPClient
14+
from traceloop.sdk.dataset.attachment import Attachment, ExternalAttachment
15+
from traceloop.sdk.dataset.dataset import Dataset
1316
from traceloop.sdk.dataset.model import (
1417
ColumnDefinition,
15-
ValuesMap,
18+
ColumnType,
1619
CreateDatasetRequest,
1720
CreateDatasetResponse,
18-
ColumnType,
1921
DatasetMetadata,
22+
ValuesMap,
2023
)
21-
from traceloop.sdk.dataset.dataset import Dataset
22-
from traceloop.sdk.dataset.attachment import Attachment, ExternalAttachment
23-
from traceloop.sdk.client.http import HTTPClient
2424

2525

2626
class Datasets:
@@ -251,7 +251,9 @@ def _slugify(self, name: str) -> str:
251251

252252
return slug
253253

254-
def _extract_attachments(self, request: CreateDatasetRequest) -> Dict[int, Dict[str, Any]]:
254+
def _extract_attachments(
255+
self, request: CreateDatasetRequest
256+
) -> Dict[int, Dict[str, Any]]:
255257
"""
256258
Extract attachment objects from row values.
257259
@@ -285,6 +287,7 @@ def _prepare_request_for_creation(
285287

286288
# Create a deep copy of rows to avoid modifying the original
287289
import copy
290+
288291
clean_rows = []
289292
for row in request.rows:
290293
clean_row = {}
@@ -301,7 +304,7 @@ def _prepare_request_for_creation(
301304
name=request.name,
302305
description=request.description,
303306
columns=request.columns,
304-
rows=clean_rows
307+
rows=clean_rows,
305308
)
306309

307310
def _process_attachments(
@@ -316,7 +319,9 @@ def _process_attachments(
316319
"""
317320
for row_idx, row_attachments in attachments.items():
318321
if row_idx >= len(dataset.rows):
319-
print(f"Warning: Row index {row_idx} out of range, skipping attachments")
322+
print(
323+
f"Warning: Row index {row_idx} out of range, skipping attachments"
324+
)
320325
continue
321326

322327
row = dataset.rows[row_idx]
@@ -343,10 +348,12 @@ def _process_attachments(
343348
"metadata": ref.metadata,
344349
}
345350
except Exception as e:
346-
print(f"Warning: Failed to process attachment for row {row_idx}, column {col_slug}: {e}")
351+
print(
352+
f"Warning: Failed to process attachment for row {row_idx}, column {col_slug}: {e}"
353+
)
347354
# Mark as failed in row values
348355
row.values[col_slug] = {
349356
"type": "file",
350357
"status": "failed",
351-
"error": str(e)
358+
"error": str(e),
352359
}

0 commit comments

Comments
 (0)