From 1d242ca73a4855d59dc61c1faf92307eb9153c41 Mon Sep 17 00:00:00 2001 From: Evan Griffiths <56087052+evangriffiths@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:30:25 +0200 Subject: [PATCH] Fix Metaculus `get_questions` api (#304) --- .../markets/metaculus/api.py | 12 +++++------- .../markets/metaculus/data_models.py | 6 ++++++ pyproject.toml | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/prediction_market_agent_tooling/markets/metaculus/api.py b/prediction_market_agent_tooling/markets/metaculus/api.py index 6dfc99d2..08dc0444 100644 --- a/prediction_market_agent_tooling/markets/metaculus/api.py +++ b/prediction_market_agent_tooling/markets/metaculus/api.py @@ -7,11 +7,9 @@ from prediction_market_agent_tooling.gtypes import Probability from prediction_market_agent_tooling.markets.metaculus.data_models import ( MetaculusQuestion, + MetaculusQuestions, ) -from prediction_market_agent_tooling.tools.utils import ( - response_list_to_model, - response_to_model, -) +from prediction_market_agent_tooling.tools.utils import response_to_model METACULUS_API_BASE_URL = "https://www.metaculus.com/api2" @@ -91,7 +89,7 @@ def get_questions( url_params["status"] = status url = f"{METACULUS_API_BASE_URL}/questions/" - return response_list_to_model( + return response_to_model( response=requests.get(url, headers=get_auth_headers(), params=url_params), - model=MetaculusQuestion, - ) + model=MetaculusQuestions, + ).results diff --git a/prediction_market_agent_tooling/markets/metaculus/data_models.py b/prediction_market_agent_tooling/markets/metaculus/data_models.py index 12e113f1..11c57408 100644 --- a/prediction_market_agent_tooling/markets/metaculus/data_models.py +++ b/prediction_market_agent_tooling/markets/metaculus/data_models.py @@ -88,3 +88,9 @@ class MetaculusQuestion(BaseModel): community_prediction: CommunityPredictionStats my_predictions: UserPredictions | None = None # TODO add the rest of the fields https://github.com/gnosis/prediction-market-agent-tooling/issues/301 + + +class MetaculusQuestions(BaseModel): + next: str | None + previous: str | None + results: list[MetaculusQuestion] diff --git a/pyproject.toml b/pyproject.toml index 48ff5769..457fa33b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "prediction-market-agent-tooling" -version = "0.41.0" +version = "0.41.1" description = "Tools to benchmark, deploy and monitor prediction market agents." authors = ["Gnosis"] readme = "README.md"