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
3 changes: 1 addition & 2 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ scenarios:
release_type: "gbOpen"
BEL:
subtype: 1
source: "geoboundaries"
release_type: "gbOpen"
source: "gadm"
CHE:
subtype: "country"
source: "overture"
Expand Down
Binary file modified figures/rulegraph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions workflow/rules/download.smk
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
"""Rules to used to download resource files."""


rule download_duckdb_extensions:
output:
path="<resources>/automatic/overture/duckdb_extensions.txt",
log:
"<logs>/download_duckdb_extensions.log",
localrule: True
conda:
"../envs/shape.yaml"
threads: 1
message:
"Downloading DuckDB extensions."
script:
"../scripts/download_duckdb_extensions.py"


rule download_geoboundaries:
output:
path="<resources>/automatic/geoboundaries/download/{country}_{subtype}_{release_type}.parquet",
Expand Down
2 changes: 2 additions & 0 deletions workflow/rules/harmonise.smk
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ rule harmonise_geoboundaries:


rule download_harmonised_overture:
input:
duckdb_extensions=rules.download_duckdb_extensions.output.path,
output:
path="<resources>/automatic/overture/harmonise/{country}_{subtype}.parquet",
log:
Expand Down
28 changes: 28 additions & 0 deletions workflow/scripts/download_duckdb_extensions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Download DuckDB extensions needed by datasources using it."""

import sys
from pathlib import Path
from typing import TYPE_CHECKING, Any

import duckdb

if TYPE_CHECKING:
snakemake: Any


def main() -> None:
"""Install DuckDB extensions."""
connection = duckdb.connect()
installed_extensions = []
for extension in ["spatial", "httpfs"]:
connection.install_extension(extension)
installed_extensions.append(extension)

output_path = Path(snakemake.output.path)
output_path.parent.mkdir(parents=True, exist_ok=True)
output_path.write_text("\n".join(installed_extensions) + "\n")


if __name__ == "__main__":
sys.stderr = open(snakemake.log[0], "w")
main()
1 change: 0 additions & 1 deletion workflow/scripts/download_harmonised_overture.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def download_country_overture(country: str, subtype: str, version: str, path: st
# Setup SQL connection to the remote dataset
connection = duckdb.connect()
for extension in ["spatial", "httpfs"]:
connection.install_extension(extension)
connection.load_extension(extension)
connection.sql("SET s3_region='us-west-2'")

Expand Down
Loading