From 15da119480ff8aa296ba7a55f3b0d0e807dd811e Mon Sep 17 00:00:00 2001 From: Joschka Braun Date: Mon, 15 Jan 2024 10:08:34 -0500 Subject: [PATCH 1/2] feat: call finish experiment --- parea/client.py | 15 +++++++++++++++ parea/experiment/experiment.py | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/parea/client.py b/parea/client.py index 92a0d195..531dffc2 100644 --- a/parea/client.py +++ b/parea/client.py @@ -34,6 +34,7 @@ RECORD_FEEDBACK_ENDPOINT = "/feedback" EXPERIMENT_ENDPOINT = "/experiment" EXPERIMENT_STATS_ENDPOINT = "/experiment/{experiment_uuid}/stats" +EXPERIMENT_FINISHED_ENDPOINT = "/experiment/{experiment_uuid}/finished" @define @@ -147,6 +148,20 @@ async def aget_experiment_stats(self, experiment_uuid: str) -> ExperimentStatsSc ) return structure(r.json(), ExperimentStatsSchema) + def finish_experiment(self, experiment_uuid: str) -> ExperimentStatsSchema: + r = self._client.request( + "POST", + EXPERIMENT_FINISHED_ENDPOINT.format(experiment_uuid=experiment_uuid), + ) + return structure(r.json(), ExperimentStatsSchema) + + async def afinish_experiment(self, experiment_uuid: str) -> ExperimentSchema: + r = await self._client.request_async( + "POST", + EXPERIMENT_FINISHED_ENDPOINT.format(experiment_uuid=experiment_uuid), + ) + return structure(r.json(), ExperimentStatsSchema) + _initialized_parea_wrapper = False diff --git a/parea/experiment/experiment.py b/parea/experiment/experiment.py index 62784f8e..010aa935 100644 --- a/parea/experiment/experiment.py +++ b/parea/experiment/experiment.py @@ -67,8 +67,8 @@ def experiment(name: str, data: Iterable[Dict], func: Callable) -> ExperimentSta asyncio.run(func(**data_input)) else: func(**data_input) - time.sleep(5) # wait for all trace logs to be written to DB - experiment_stats: ExperimentStatsSchema = p.get_experiment_stats(experiment_uuid) + time.sleep(5) # wait for any evaluation to finish which is executed in the background + experiment_stats: ExperimentStatsSchema = p.finish_experiment(experiment_uuid) stat_name_to_avg_std = calculate_avg_std_for_experiment(experiment_stats) print(f"Experiment stats:\n{json.dumps(stat_name_to_avg_std, indent=2)}\n\n") print(f"View experiment & its traces at: https://app.parea.ai/experiments/{experiment_uuid}\n") From 1100af5b54e6d2c47f578d751bd9946a9dec4abd Mon Sep 17 00:00:00 2001 From: Joschka Braun Date: Mon, 15 Jan 2024 14:39:43 -0500 Subject: [PATCH 2/2] chore: update version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 12cb7de8..bba6c61e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "parea-ai" packages = [{ include = "parea" }] -version = "0.2.31" +version = "0.2.32" description = "Parea python sdk" readme = "README.md" authors = ["joel-parea-ai "]