@@ -464,13 +464,13 @@ def _end_tests(test_suite: _LangSmithTestSuite):
464
464
test_suite .client .update_dataset_tag (
465
465
dataset_id = dataset_id ,
466
466
as_of = dataset_version ,
467
- tag = f' git:commit:{ git_info [" commit" ] } ' ,
467
+ tag = f" git:commit:{ git_info [' commit' ] } " ,
468
468
)
469
469
if dataset_version and git_info ["branch" ] is not None :
470
470
test_suite .client .update_dataset_tag (
471
471
dataset_id = dataset_id ,
472
472
as_of = dataset_version ,
473
- tag = f' git:branch:{ git_info [" branch" ] } ' ,
473
+ tag = f" git:branch:{ git_info [' branch' ] } " ,
474
474
)
475
475
476
476
@@ -560,7 +560,9 @@ def submit_result(
560
560
self ._executor .submit (self ._submit_result , run_id , score )
561
561
562
562
def _submit_result (self , run_id : uuid .UUID , score : Optional [int ]) -> None :
563
- self .client .create_feedback (run_id , key = "pass" , score = score )
563
+ # trace_id will always be run_id here because the feedback is on the root
564
+ # test run
565
+ self .client .create_feedback (run_id , key = "pass" , score = score , trace_id = run_id )
564
566
565
567
def sync_example (
566
568
self ,
@@ -635,7 +637,9 @@ def _submit_feedback(
635
637
)
636
638
637
639
def _create_feedback (self , run_id : ID_TYPE , feedback : dict , ** kwargs : Any ) -> None :
638
- self .client .create_feedback (run_id , ** feedback , ** kwargs )
640
+ # trace_id will always be run_id here because the feedback is on the root
641
+ # test run
642
+ self .client .create_feedback (run_id , ** feedback , ** kwargs , trace_id = run_id )
639
643
640
644
def shutdown (self ):
641
645
self ._executor .shutdown ()
@@ -914,10 +918,11 @@ def _test():
914
918
"reference_example_id" : str (test_case .example_id ),
915
919
},
916
920
}
917
- with rh .tracing_context (
918
- ** {** current_context , "metadata" : metadata }
919
- ), ls_utils .with_optional_cache (
920
- cache_path , ignore_hosts = [test_case .test_suite .client .api_url ]
921
+ with (
922
+ rh .tracing_context (** {** current_context , "metadata" : metadata }),
923
+ ls_utils .with_optional_cache (
924
+ cache_path , ignore_hosts = [test_case .test_suite .client .api_url ]
925
+ ),
921
926
):
922
927
_test ()
923
928
@@ -982,10 +987,11 @@ async def _test():
982
987
"reference_example_id" : str (test_case .example_id ),
983
988
},
984
989
}
985
- with rh .tracing_context (
986
- ** {** current_context , "metadata" : metadata }
987
- ), ls_utils .with_optional_cache (
988
- cache_path , ignore_hosts = [test_case .test_suite .client .api_url ]
990
+ with (
991
+ rh .tracing_context (** {** current_context , "metadata" : metadata }),
992
+ ls_utils .with_optional_cache (
993
+ cache_path , ignore_hosts = [test_case .test_suite .client .api_url ]
994
+ ),
989
995
):
990
996
await _test ()
991
997
@@ -1020,9 +1026,7 @@ def test_foo() -> None:
1020
1026
assert foo(x, y) == 2
1021
1027
"""
1022
1028
if ls_utils .test_tracking_is_disabled ():
1023
- logger .info (
1024
- "LANGSMITH_TEST_TRACKING is set to 'false'." " Skipping log_inputs."
1025
- )
1029
+ logger .info ("LANGSMITH_TEST_TRACKING is set to 'false'. Skipping log_inputs." )
1026
1030
return
1027
1031
run_tree = rh .get_current_run_tree ()
1028
1032
test_case = _TEST_CASE .get ()
@@ -1064,9 +1068,7 @@ def test_foo() -> None:
1064
1068
assert result == 2
1065
1069
"""
1066
1070
if ls_utils .test_tracking_is_disabled ():
1067
- logger .info (
1068
- "LANGSMITH_TEST_TRACKING is set to 'false'." " Skipping log_outputs."
1069
- )
1071
+ logger .info ("LANGSMITH_TEST_TRACKING is set to 'false'. Skipping log_outputs." )
1070
1072
return
1071
1073
run_tree = rh .get_current_run_tree ()
1072
1074
test_case = _TEST_CASE .get ()
@@ -1110,8 +1112,7 @@ def test_foo() -> None:
1110
1112
"""
1111
1113
if ls_utils .test_tracking_is_disabled ():
1112
1114
logger .info (
1113
- "LANGSMITH_TEST_TRACKING is set to 'false'."
1114
- " Skipping log_reference_outputs."
1115
+ "LANGSMITH_TEST_TRACKING is set to 'false'. Skipping log_reference_outputs."
1115
1116
)
1116
1117
return
1117
1118
test_case = _TEST_CASE .get ()
@@ -1164,9 +1165,7 @@ def test_foo() -> None:
1164
1165
assert result == expected
1165
1166
"""
1166
1167
if ls_utils .test_tracking_is_disabled ():
1167
- logger .info (
1168
- "LANGSMITH_TEST_TRACKING is set to 'false'." " Skipping log_feedback."
1169
- )
1168
+ logger .info ("LANGSMITH_TEST_TRACKING is set to 'false'. Skipping log_feedback." )
1170
1169
return
1171
1170
if feedback and any ((key , score , value )):
1172
1171
msg = "Must specify one of 'feedback' and ('key', 'score', 'value'), not both."
@@ -1270,9 +1269,7 @@ def test_openai_says_hello():
1270
1269
assert "hello" in response.choices[0].message.content.lower()
1271
1270
""" # noqa: E501
1272
1271
if ls_utils .test_tracking_is_disabled ():
1273
- logger .info (
1274
- "LANGSMITH_TEST_TRACKING is set to 'false'." " Skipping log_feedback."
1275
- )
1272
+ logger .info ("LANGSMITH_TEST_TRACKING is set to 'false'. Skipping log_feedback." )
1276
1273
yield None
1277
1274
return
1278
1275
parent_run = rh .get_current_run_tree ()
0 commit comments