Skip to content

Commit

Permalink
Merge pull request #824 from parea-ai/PAI-1079-add-get-exp-endpoint-py
Browse files Browse the repository at this point in the history
add uuids to filter conditions
  • Loading branch information
jalexanderII committed Apr 30, 2024
2 parents a9fedcb + 6a173f8 commit c3dcdd8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
14 changes: 14 additions & 0 deletions parea/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,20 @@ async def aget_experiment_trace_logs(self, experiment_uuid: str, filters: TraceL
response = await self._client.request_async("POST", GET_EXPERIMENT_LOGS_ENDPOINT.format(experiment_uuid=experiment_uuid), data=asdict(filters))
return structure_trace_logs_from_api(response.json())

def get_experiment(self, experiment_uuid: str) -> Optional[ExperimentWithPinnedStatsSchema]:
filter_conditions = ListExperimentUUIDsFilters(experiment_uuids=[experiment_uuid])
response = self._client.request("POST", LIST_EXPERIMENTS_ENDPOINT, data=asdict(filter_conditions))
response_json = response.json()
result = response_json[0] if isinstance(response_json, list) else None
return structure(result, ExperimentWithPinnedStatsSchema)

async def aget_experiment(self, experiment_uuid: str) -> Optional[ExperimentWithPinnedStatsSchema]:
filter_conditions = ListExperimentUUIDsFilters(experiment_uuids=[experiment_uuid])
response = await self._client.request_async("POST", LIST_EXPERIMENTS_ENDPOINT, data=asdict(filter_conditions))
response_json = response.json()
result = response_json[0] if isinstance(response_json, list) else None
return structure(result, ExperimentWithPinnedStatsSchema)


def patch_openai_client_classes(openai_client, parea_client: Parea):
"""Creates a subclass of the given openai_client to always wrap it with Parea at instantiation."""
Expand Down
1 change: 1 addition & 0 deletions parea/schemas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ class ListExperimentUUIDsFilters:
metadata_filter: Optional[Dict[str, Any]] = None
experiment_name_filter: Optional[str] = None
run_name_filter: Optional[str] = None
experiment_uuids: Optional[List[str]] = None


class ExperimentStatus(str, Enum):
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.144"
version = "0.2.145"
description = "Parea python sdk"
readme = "README.md"
authors = ["joel-parea-ai <[email protected]>"]
Expand Down

0 comments on commit c3dcdd8

Please sign in to comment.