Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ANTHROPIC_API_KEY=

# Fill this in if using the Metaculus API
METACULUS_TOKEN=
METACULUS_API_BASE_URL=https://www.metaculus.com/api

# As of Jan 23rd 2025, only used for free semantic similarity calculation in Deduplicator, but defaults to OpenAI if not filled in
HUGGINGFACE_API_KEY=
Expand Down
11 changes: 9 additions & 2 deletions forecasting_tools/data_models/questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,15 @@ def _get_bounds_from_api_json(
lower_bound = api_json["question"]["scaling"]["range_min"]
zero_point = api_json["question"]["scaling"]["zero_point"]

assert isinstance(upper_bound, float), f"Upper bound is {upper_bound}"
assert isinstance(lower_bound, float), f"Lower bound is {lower_bound}"
try:
upper_bound = float(upper_bound)
lower_bound = float(lower_bound)
except (TypeError, ValueError):
logger.error(
f"Error parsing bounds from API JSON. "
f"Upper bound: {upper_bound}, Lower bound: {lower_bound}"
)
raise
return (
open_upper_bound,
open_lower_bound,
Expand Down
4 changes: 3 additions & 1 deletion forecasting_tools/helpers/metaculus_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

logger = logging.getLogger(__name__)

API_BASE_URL = os.getenv("METACULUS_API_BASE_URL", "https://www.metaculus.com/api")

Q = TypeVar("Q", bound=MetaculusQuestion)
T = TypeVar("T", bound=BaseModel)

Expand Down Expand Up @@ -138,7 +140,7 @@ class MetaculusClient:

def __init__(
self,
base_url: str = "https://www.metaculus.com/api",
base_url: str = API_BASE_URL,
timeout: int = 30,
sleep_time_between_requests_min: float = 1.5,
sleep_jitter_seconds: float = 0.5,
Expand Down