Skip to content

Commit 464a64f

Browse files
committed
rename current version to latest version and use urlencode
1 parent 1013ec3 commit 464a64f

File tree

4 files changed

+81
-79
lines changed

4 files changed

+81
-79
lines changed

ddtrace/llmobs/_experiment.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class Dataset:
107107
_id: str
108108
_records: List[DatasetRecord]
109109
_version: int
110-
_current_version: int
110+
_latest_version: int
111111
_dne_client: "LLMObsExperimentsClient"
112112
_new_records_by_record_id: Dict[str, DatasetRecordRaw]
113113
_updated_record_ids_to_new_fields: Dict[str, UpdatableDatasetRecord]
@@ -122,15 +122,15 @@ def __init__(
122122
dataset_id: str,
123123
records: List[DatasetRecord],
124124
description: str,
125-
current_version: int,
125+
latest_version: int,
126126
version: int,
127127
_dne_client: "LLMObsExperimentsClient",
128128
) -> None:
129129
self.name = name
130130
self.project = project
131131
self.description = description
132132
self._id = dataset_id
133-
self._current_version = current_version
133+
self._latest_version = latest_version
134134
self._version = version
135135
self._dne_client = _dne_client
136136
self._records = records
@@ -171,10 +171,10 @@ def push(self) -> None:
171171
record["record_id"] = record_id # type: ignore
172172

173173
# FIXME: we don't get version numbers in responses to deletion requests
174-
self._current_version = new_version if new_version != -1 else self._current_version + 1
174+
self._latest_version = new_version if new_version != -1 else self._latest_version + 1
175175
# no matter what the version was before the push, pushing will result in the dataset being on the current
176176
# version tracked by the backend
177-
self._version = self._current_version
177+
self._version = self._latest_version
178178
self._new_records_by_record_id = {}
179179
self._deleted_record_ids = []
180180
self._updated_record_ids_to_new_fields = {}
@@ -232,8 +232,8 @@ def url(self) -> str:
232232
return f"{_get_base_url()}/llm/datasets/{self._id}"
233233

234234
@property
235-
def current_version(self) -> int:
236-
return self._current_version
235+
def latest_version(self) -> int:
236+
return self._latest_version
237237

238238
@property
239239
def version(self) -> int:
@@ -448,7 +448,7 @@ def _run_task(self, jobs: int, raise_errors: bool = False, sample_size: Optional
448448
dataset_id=self._dataset._id,
449449
records=subset_records,
450450
description=self._dataset.description,
451-
current_version=self._dataset._current_version,
451+
latest_version=self._dataset._latest_version,
452452
version=self._dataset._version,
453453
_dne_client=self._dataset._dne_client,
454454
)

ddtrace/llmobs/_writer.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import os
55
import tempfile
6+
import urllib
67
from typing import Any
78
from typing import Dict
89
from typing import List
@@ -400,7 +401,16 @@ def dataset_create(
400401
if dataset_id is None or dataset_id == "":
401402
raise ValueError(f"unexpected dataset state, invalid ID (is None: {dataset_id is None})")
402403
curr_version = response_data["data"]["attributes"]["current_version"]
403-
return Dataset(dataset_name, project, dataset_id, [], description, curr_version, curr_version, _dne_client=self)
404+
return Dataset(
405+
name=dataset_name,
406+
project=project,
407+
dataset_id=dataset_id,
408+
records=[],
409+
description=description,
410+
latest_version=curr_version,
411+
version=curr_version,
412+
_dne_client=self,
413+
)
404414

405415
@staticmethod
406416
def _get_record_json(record: Union[UpdatableDatasetRecord, DatasetRecordRaw], is_update: bool) -> JSONType:
@@ -484,8 +494,10 @@ def dataset_get_with_records(
484494
dataset_id = data[0]["id"]
485495

486496
list_base_path = f"/api/unstable/llm-obs/v1/datasets/{dataset_id}/records"
497+
498+
url_options = {}
487499
if version:
488-
list_base_path = f"{list_base_path}?filter[version]={version}"
500+
url_options["filter[version]"] = version
489501

490502
has_next_page = True
491503
class_records: List[DatasetRecord] = []
@@ -514,17 +526,18 @@ def dataset_get_with_records(
514526
has_next_page = False
515527
if next_cursor:
516528
has_next_page = True
517-
list_path = f"{list_base_path}{'&' if version else '?'}page[cursor]={next_cursor}"
529+
url_options["page[cursor]"] = next_cursor
530+
list_path = f"{list_base_path}?{urllib.parse.urlencode(url_options, safe='[]')}"
518531
logger.debug("next list records request path %s", list_path)
519532
page_num += 1
520533
return Dataset(
521-
dataset_name,
522-
project,
523-
dataset_id,
524-
class_records,
525-
dataset_description,
526-
curr_version,
527-
version or curr_version,
534+
name=dataset_name,
535+
project=project,
536+
dataset_id=dataset_id,
537+
records=class_records,
538+
description=dataset_description,
539+
latest_version=curr_version,
540+
version=version or curr_version,
528541
_dne_client=self,
529542
)
530543

setup.cfg

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
1+
[bdist_wheel]
2+
universal=1
3+
14
[codespell]
25
skip = *.json,*.h,*.cpp,*.c,.riot,.tox,.mypy_cache,.git,*ddtrace/vendor,tests/contrib/openai/cassettes/*,tests/contrib/langchain/cassettes/*,ddtrace/appsec/_iast/_taint_tracking/_vendor/*
36
exclude-file = .codespellignorelines
47
ignore-words-list = asend,dne,fo,medias,ment,nin,ot,setttings,statics,ba,spawnve,doas
58

6-
# DEV: We use `conftest.py` as a local pytest plugin to configure hooks for collection
7-
[tool:pytest]
8-
# --cov-report is intentionally empty else pytest-cov will default to generating a report
9-
addopts =
10-
--cov=ddtrace/
11-
--cov=tests/
12-
--cov-append
13-
--cov-report=
14-
--durations=10
15-
--junitxml=test-results/junit.xml
16-
# DEV: The default is `test_*\.py` which will miss `test.py` files
17-
python_files = test*\.py
18-
asyncio_mode = auto
19-
209
[flake8]
2110
max-line-length = 120

0 commit comments

Comments
 (0)