Skip to content

Commit

Permalink
mv timing
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw committed Sep 24, 2024
1 parent da3affd commit bd499ea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/langsmith/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,10 +1153,15 @@ def _run_transform(
run_create: dict = run.dict() # type: ignore
else:
run_create = cast(dict, run)
if not update and not run_create.get("start_time"):
# Should not hit here if you're using run_trees or other higher-order
# abstractions
run_create["start_time"] = datetime.datetime.now(datetime.timezone.utc)
if "id" not in run_create:
run_create["id"] = uuid.uuid4()
elif isinstance(run_create["id"], str):
run_create["id"] = uuid.UUID(run_create["id"])

if "inputs" in run_create and run_create["inputs"] is not None:
if copy:
run_create["inputs"] = ls_utils.deepish_copy(run_create["inputs"])
Expand All @@ -1165,8 +1170,6 @@ def _run_transform(
if copy:
run_create["outputs"] = ls_utils.deepish_copy(run_create["outputs"])
run_create["outputs"] = self._hide_run_outputs(run_create["outputs"])
if not update and not run_create.get("start_time"):
run_create["start_time"] = datetime.datetime.now(datetime.timezone.utc)

# Only retain LLM & Prompt manifests
if "serialized" in run_create:
Expand Down
2 changes: 2 additions & 0 deletions python/langsmith/run_trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class Config:
@root_validator(pre=True)
def infer_defaults(cls, values: dict) -> dict:
"""Assign name to the run."""
if not values.get("start_time"):
values["start_time"] = datetime.now(timezone.utc)
if values.get("name") is None and values.get("serialized") is not None:
if "name" in values["serialized"]:
values["name"] = values["serialized"]["name"]
Expand Down
1 change: 1 addition & 0 deletions python/tests/unit_tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,7 @@ def test_batch_ingest_run_retry_on_429(mock_raise_for_status):
"id": str(uuid.uuid4()),
"trace_id": str(uuid.uuid4()),
"dotted_order": str(uuid.uuid4()),
"start_time": datetime.now(tz=timezone.utc),
}
],
)
Expand Down

0 comments on commit bd499ea

Please sign in to comment.