Skip to content

Commit 232b6e9

Browse files
authored
Fixed Coda integration with workflow (#14)
* Added coda api key to workflows so runs can be saved to database * Updated .env.template
1 parent 4d08f2d commit 232b6e9

File tree

6 files changed

+20
-8
lines changed

6 files changed

+20
-8
lines changed

.env.template

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ METACULUS_TOKEN=
1111
# Right now only used for free semantic similarity calculation in Deduplicator, but defaults to OpenAI if not filled in
1212
HUGGINGFACE_API_KEY=
1313

14-
# Only needed in Streamlit Cloud in order to save responses to a database and track usage
14+
# Only needed if saving responses to a database (e.g. in Streamlit Cloud)
15+
# Right now its hardcoded for a specific database, later this should be made more interchangeable
1516
CODA_API_KEY=
1617

1718
# Disable if in Streamlit Cloud

.github/workflows/hourly-run-main.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ jobs:
4343
EXA_API_KEY: ${{ secrets.EXA_API_KEY }}
4444
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
4545
HUGGINGFACE_API_KEY: ${{ secrets.HUGGINGFACE_API_KEY }}
46+
CODA_API_KEY: ${{ secrets.CODA_API_KEY }}
4647
PYTHONPATH: .

.github/workflows/hourly-run-template.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ jobs:
4040
METACULUS_TOKEN: ${{ secrets.METACULUS_TOKEN }}
4141
PERPLEXITY_API_KEY: ${{ secrets.PERPLEXITY_API_KEY }}
4242
EXA_API_KEY: ${{ secrets.EXA_API_KEY }}
43+
CODA_API_KEY: ${{ secrets.CODA_API_KEY }}
4344
PYTHONPATH: .

.github/workflows/pre-commit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: pre-commit
1+
name: Pre-Commit
22

33
on:
44
pull_request:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "forecasting-tools"
3-
version = "0.2.1"
3+
version = "0.2.2"
44
description = "AI forecasting and research tools to help humans reason about and forecast the future"
55
authors = ["Benjamin Wilson <[email protected]>"]
66
license = "MIT"

scripts/run_forecasts_for_ai_tournament.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
sys.path.append(top_level_dir)
1414
dotenv.load_dotenv()
1515

16+
import logging
17+
1618
from forecasting_tools.forecasting.forecast_bots.main_bot import MainBot
1719
from forecasting_tools.forecasting.forecast_bots.template_bot import (
1820
TemplateBot,
@@ -24,6 +26,8 @@
2426
from forecasting_tools.forecasting.helpers.metaculus_api import MetaculusApi
2527
from forecasting_tools.util.custom_logger import CustomLogger
2628

29+
logger = logging.getLogger(__name__)
30+
2731

2832
def get_forecaster(bot_type: str, allow_rerun: bool) -> TemplateBot | MainBot:
2933
bot_classes = {
@@ -59,11 +63,16 @@ async def run_morning_forecasts(bot_type: str, allow_rerun: bool) -> None:
5963
forecaster = get_forecaster(bot_type, allow_rerun)
6064
TOURNAMENT_ID = MetaculusApi.AI_COMPETITION_ID_Q4
6165
reports = await forecaster.forecast_on_tournament(TOURNAMENT_ID)
62-
for report in reports:
63-
await asyncio.sleep(5)
64-
ForecastDatabaseManager.add_forecast_report_to_database(
65-
report, ForecastRunType.REGULAR_FORECAST
66-
)
66+
67+
if os.environ.get("CODA_API_KEY"):
68+
for report in reports:
69+
await asyncio.sleep(5)
70+
try:
71+
ForecastDatabaseManager.add_forecast_report_to_database(
72+
report, ForecastRunType.REGULAR_FORECAST
73+
)
74+
except Exception as e:
75+
logger.error(f"Error adding forecast report to database: {e}")
6776

6877

6978
if __name__ == "__main__":

0 commit comments

Comments
 (0)