Skip to content

Commit

Permalink
Merge pull request #326 from parea-ai/PAI-533-create-experiments-over…
Browse files Browse the repository at this point in the history
…view-table

Pai 533 create experiments overview table
  • Loading branch information
joschkabraun committed Jan 15, 2024
2 parents 9c08418 + 1100af5 commit 32c0fa2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
15 changes: 15 additions & 0 deletions parea/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions parea/experiment/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>"]
Expand Down

0 comments on commit 32c0fa2

Please sign in to comment.