|
27 | 27 | from nat.test.utils import run_workflow |
28 | 28 |
|
29 | 29 | if typing.TYPE_CHECKING: |
| 30 | + import galileo.log_streams |
| 31 | + import galileo.projects |
30 | 32 | import langsmith.client |
31 | 33 |
|
32 | 34 |
|
@@ -136,26 +138,46 @@ async def test_langsmith_full_workflow(config_dir: Path, |
136 | 138 |
|
137 | 139 | await run_workflow(config=config, question=question, expected_answer=expected_answer) |
138 | 140 |
|
139 | | - done = False |
140 | 141 | runlist = [] |
141 | 142 | deadline = time.time() + 10 |
142 | | - while not done and time.time() < deadline: |
| 143 | + while len(runlist) == 0 and time.time() < deadline: |
143 | 144 | # Wait for traces to be ingested |
144 | 145 | await asyncio.sleep(0.5) |
145 | 146 | runs = langsmith_client.list_runs(project_name=langsmith_project_name, is_root=True) |
146 | 147 | runlist = [run for run in runs] |
147 | | - if len(runlist) > 0: |
148 | | - done = True |
149 | 148 |
|
150 | | - assert done, "Timed out waiting for LangSmith run to be ingested" |
151 | 149 | # Since we have a newly created project, the above workflow should have created exactly one root run |
152 | 150 | assert len(runlist) == 1 |
153 | 151 |
|
154 | 152 |
|
155 | 153 | @pytest.mark.integration |
156 | 154 | @pytest.mark.usefixtures("galileo_api_key") |
157 | | -async def test_galileo_full_workflow(config_dir: Path, question: str, expected_answer: str): |
| 155 | +async def test_galileo_full_workflow(config_dir: Path, |
| 156 | + galileo_project: "galileo.projects.Project", |
| 157 | + galileo_log_stream: "galileo.log_streams.LogStream", |
| 158 | + question: str, |
| 159 | + expected_answer: str): |
158 | 160 | config_file = config_dir / "config-galileo.yml" |
159 | 161 | config = load_config(config_file) |
| 162 | + config.general.telemetry.tracing["galileo"].project = galileo_project.name |
| 163 | + config.general.telemetry.tracing["galileo"].logstream = galileo_log_stream.name |
160 | 164 |
|
161 | 165 | await run_workflow(config=config, question=question, expected_answer=expected_answer) |
| 166 | + |
| 167 | + import galileo.search |
| 168 | + |
| 169 | + sessions = [] |
| 170 | + deadline = time.time() + 10 |
| 171 | + while len(sessions) == 0 and time.time() < deadline: |
| 172 | + # Wait for traces to be ingested |
| 173 | + await asyncio.sleep(0.5) |
| 174 | + results = galileo.search.get_sessions(project_id=galileo_project.id, log_stream_id=galileo_log_stream.id) |
| 175 | + sessions = results.records or [] |
| 176 | + |
| 177 | + assert len(sessions) == 1 |
| 178 | + |
| 179 | + traces = galileo.search.get_traces(project_id=galileo_project.id, log_stream_id=galileo_log_stream.id) |
| 180 | + assert len(traces.records) == 1 |
| 181 | + |
| 182 | + spans = galileo.search.get_spans(project_id=galileo_project.id, log_stream_id=galileo_log_stream.id) |
| 183 | + assert len(spans.records) > 1 |
0 commit comments