Skip to content

Commit

Permalink
resolve paths for github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Busch committed May 8, 2024
1 parent 519d3de commit 4b095ee
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
Empty file removed definitions.py
Empty file.
4 changes: 4 additions & 0 deletions omDownloadInputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import os
from omUtils import getenv

root_path = os.path.dirname(os.path.realpath(__file__))

remote = getenv("PRIOR_REMOTE")

electricityFile = getenv("CH4_ELECTRICITY")
Expand Down Expand Up @@ -59,6 +61,8 @@
]

for filename, filepath in downloads:
filepath = os.path.join(root_path, filepath)
print(filepath)
url = f"{remote}{filename}"

if not os.path.exists(filepath):
Expand Down
9 changes: 7 additions & 2 deletions omInputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@
domainFilename = getenv("DOMAIN")
domainPath = os.path.join(inputsPath, domainFilename)
electricityPath = os.path.join(inputsPath, getenv("CH4_ELECTRICITY"))
oilGasPath = os.path.join( fossilPath, getenv("OILGAS"))
coalPath = os.path.join( fossilPath, getenv("COAL"))
# TODO: Changing this to match with the rest of the download file paths.
# The originally specified directory does not exist and stops the download.
# Maybe needs to be changed back later in the process.
# oilGasPath = os.path.join( fossilPath, getenv("OILGAS"))
oilGasPath = os.path.join( inputsPath, getenv("OILGAS"))
# coalPath = os.path.join( fossilPath, getenv("COAL"))
coalPath = os.path.join( inputsPath, getenv("COAL"))
landUsePath = os.path.join(inputsPath, getenv("LAND_USE"))
sectoralEmissionsPath = os.path.join(inputsPath, getenv("SECTORAL_EMISSIONS"))
sectoralMappingsPath = os.path.join(inputsPath, getenv("SECTORAL_MAPPING"))
Expand Down
7 changes: 6 additions & 1 deletion tests/test_download_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
sys.path.insert(1, os.getcwd())

from temporary_file_for_tests import downloads, remote
from definitions import ROOT_DIRECTORY
import pytest
import requests
from pathlib import Path
import subprocess

# Are we in the root directory (for github actions)
if os.path.exists("tests"):
ROOT_DIRECTORY = Path(__file__).parent
else:
ROOT_DIRECTORY = Path(__file__).parent.parent

def test_001_response_for_download_links() :
for filename, filepath in downloads :
url = f"{remote}{filename}"
Expand Down

0 comments on commit 4b095ee

Please sign in to comment.