Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RuntimeError in covid_datasette example #701

Merged
merged 12 commits into from
Apr 18, 2024
Merged
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
7 changes: 4 additions & 3 deletions 10_integrations/covid_datasette.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def download_dataset(cache=True):


def load_daily_reports():
volume.reload()
daily_reports = list(REPORTS_DIR.glob("*.csv"))
if not daily_reports:
raise RuntimeError(
Expand Down Expand Up @@ -167,6 +166,7 @@ def chunks(it, size):
def prep_db():
import sqlite_utils

volume.reload()
print("Loading daily reports...")
records = load_daily_reports()

Expand All @@ -184,10 +184,9 @@ def prep_db():
table.create_index(["province_or_state"], if_not_exists=True)
table.create_index(["country_or_region"], if_not_exists=True)

db.close()

print("Syncing DB with volume.")
volume.commit()
db.close()


# ## Keep it fresh
Expand All @@ -202,6 +201,8 @@ def refresh_db():
print(f"Running scheduled refresh at {datetime.now()}")
download_dataset.remote(cache=False)
prep_db.remote()
volume.commit()
print("Volume changes committed.")


# ## Web endpoint
Expand Down
Loading