Skip to content

Commit

Permalink
Removed ConfigPaths dependency external files retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenbrinkerink committed Dec 20, 2024
1 parent 92cc09c commit 7476a89
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion workflow/rules/retrieve.smk
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ rule download_external_files:
message:
"Downloading external files..."
params:
files = get_external_links()
files = get_external_links(),
input_data_dir = 'resources/data'
log:
log = "results/logs/external_files.log"
output:
Expand Down
8 changes: 3 additions & 5 deletions workflow/scripts/osemosys_global/external_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
logging.basicConfig(format="%(levelname)s:%(message)s", level=logging.INFO)

from pathlib import Path
from configuration import ConfigPaths
import os
import requests
import sys
Expand All @@ -21,14 +20,11 @@ def download_file(file: str, url: Path | str) -> None:
with open(path, "wb") as f:
f.write(data.content)

# CONFIGURATION PARAMETERS
config_paths = ConfigPaths()
input_data_dir = config_paths.input_data_dir

if __name__ == "__main__":

if "snakemake" in globals():
external_files = snakemake.params.files
input_data_dir = snakemake.params.input_data_dir
else:
if len(sys.argv) != 3:
msg = "Usage: python {} <save_name> <url>"
Expand All @@ -38,6 +34,8 @@ def download_file(file: str, url: Path | str) -> None:
in_file = sys.argv[1]
in_url = sys.argv[2]
external_files = {in_file: in_url}

input_data_dir = 'resources/data'

for file, url in external_files.items():
path = os.path.join(input_data_dir, file)
Expand Down

0 comments on commit 7476a89

Please sign in to comment.