-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 334b03c
Showing
13 changed files
with
679 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
n | ||
n | ||
library(tidyverse) | ||
read_csv("https://raw.githubusercontent.com/ft-interactive/fetch_superforecasts/refs/heads/main/data/superforecasts.csv?token=GHSAT0AAAAAACRBXEEMQZI52AEUFBKYBPLIZYCVSRQ") |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @ft-interactive/visual-data-journalism-admins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: run-pipeline | ||
|
||
on: | ||
push: | ||
schedule: | ||
- cron: '5 12 * * *' | ||
|
||
jobs: | ||
pipeline: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
# Allow the action to update the repo | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.x | ||
cache: pipenv | ||
|
||
- name: Install pipenv | ||
run: pip install pipenv | ||
|
||
- name: Install dependencies | ||
run: pipenv install --ignore-pipfile | ||
|
||
- name: Run python code | ||
env: # Set the secret as an input | ||
FUTURE_FIRST: ${{ secrets.FUTURE_FIRST }} | ||
# FIRST_NAME: Joel | ||
# LAST_NAME: Suss | ||
run: pipenv run start | ||
|
||
- uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: Data update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.DS_Store | ||
.venv | ||
.env | ||
.Rproj.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[[source]] | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
name = "pypi" | ||
|
||
[packages] | ||
requests = "*" | ||
pandas = "*" | ||
|
||
[dev-packages] | ||
|
||
[requires] | ||
python_version = "3" | ||
|
||
[scripts] | ||
start = "python3 run.py" |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Retrieve latest superforecasts from FutureFirst (https://goodjudgment.io/futurefirst/index.php) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Version: 1.0 | ||
|
||
RestoreWorkspace: Default | ||
SaveWorkspace: Default | ||
AlwaysSaveHistory: Default | ||
|
||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 2 | ||
Encoding: UTF-8 | ||
|
||
RnwWeave: Sweave | ||
LaTeX: pdfLaTeX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import pandas as pd | ||
import json | ||
|
||
from src.fetch import get_data | ||
from os.path import abspath | ||
|
||
data = get_data() | ||
|
||
# Write string to CSV file | ||
with open(abspath("./data/superforecasts.csv"), 'w') as f: | ||
f.write(data) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import requests | ||
import os | ||
|
||
def get_data(): | ||
|
||
# Retrieve the environment variable "key" | ||
key = os.getenv("FUTURE_FIRST") | ||
|
||
r = requests.get( | ||
"https://goodjudgment.io/futurefirst/api/fcsv", | ||
headers = {"Authorization": "Bearer " + key} | ||
) | ||
|
||
data = r.json()["data"] | ||
print(f"Loaded {len(data)} rows of CSV from the API") | ||
return data | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import csv | ||
|
||
def write_data(path, data): | ||
with open(path, 'w') as csvfile: | ||
writer = csv.DictWriter(csvfile, fieldnames=data[0].keys()) | ||
writer.writeheader() | ||
for row in data: | ||
writer.writerow(row) | ||
print(f"Wrote {len(data)} rows to {path}") |