Skip to content

Commit 48e4ca9

Browse files
committed
fresh url options after list records call
1 parent 13c0407 commit 48e4ca9

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

ddtrace/llmobs/_writer.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import json
44
import os
55
import tempfile
6-
import urllib
76
from typing import Any
87
from typing import Dict
98
from typing import List
@@ -12,6 +11,7 @@
1211
from typing import TypedDict
1312
from typing import Union
1413
from typing import cast
14+
import urllib
1515
from urllib.parse import quote
1616
from urllib.parse import urlparse
1717

@@ -495,15 +495,16 @@ def dataset_get_with_records(
495495

496496
list_base_path = f"/api/unstable/llm-obs/v1/datasets/{dataset_id}/records"
497497

498-
url_options = {}
499-
if version:
500-
url_options["filter[version]"] = version
501-
502498
has_next_page = True
503499
class_records: List[DatasetRecord] = []
504-
list_path = f"{list_base_path}?{urllib.parse.urlencode(url_options, safe='[]')}"
505500
page_num = 0
501+
url_options = {}
506502
while has_next_page:
503+
if version:
504+
url_options["filter[version]"] = version
505+
506+
list_path = f"{list_base_path}?{urllib.parse.urlencode(url_options, safe='[]')}"
507+
logger.debug("list records page %d, request path=%s", page_num, list_path)
507508
resp = self.request("GET", list_path, timeout=self.LIST_RECORDS_TIMEOUT)
508509
if resp.status != 200:
509510
raise ValueError(
@@ -523,12 +524,12 @@ def dataset_get_with_records(
523524
}
524525
)
525526
next_cursor = records_data.get("meta", {}).get("after")
527+
528+
url_options = {}
526529
has_next_page = False
527530
if next_cursor:
528531
has_next_page = True
529532
url_options["page[cursor]"] = next_cursor
530-
list_path = f"{list_base_path}?{urllib.parse.urlencode(url_options, safe='[]')}"
531-
logger.debug("next list records request path %s", list_path)
532533
page_num += 1
533534
return Dataset(
534535
name=dataset_name,

0 commit comments

Comments
 (0)