-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #562 from gridsingularity/feature/GSYE-818
GSYE-818: Use default CDS from gsy-web for testimg the CDS parser
- Loading branch information
Showing
6 changed files
with
462 additions
and
148 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,10 @@ | ||
## Reason for the proposed changes | ||
|
||
Please describe what we want to achieve and why. | ||
|
||
## Proposed changes | ||
|
||
- | ||
|
||
<!--- If needed, choose which branch of the gsy-backend-integration-tests repository will be used to run integration tests. Please only edit the name of the branch. --> | ||
**GSY_WEB_BRANCH**=master |
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
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,39 @@ | ||
import os | ||
import shutil | ||
import tempfile | ||
|
||
import requests | ||
|
||
|
||
class DefaultCDSDownloader: | ||
"""Handle CDS file download""" | ||
|
||
def __init__(self): | ||
self.workdir = tempfile.mkdtemp() | ||
self.cds_file_path = os.path.join(self.workdir, "CommunityDataSheet.xlsx") | ||
|
||
def download(self): | ||
"""Download cds file to temp dir""" | ||
header = { | ||
"Authorization": f"Bearer {os.environ['GITHUB_ACCESS_TOKEN']}", | ||
"X-GitHub-Api-Version": "2022-11-28", | ||
"Accept": "application/vnd.github.raw+json", | ||
} | ||
url = ( | ||
f"https://api.github.com/repos/gridsingularity/gsy-web/contents/config/static/" | ||
f"CommunityDataSheet.xlsx?ref={os.environ.get('TARGET_BRANCH', 'master')}" | ||
) | ||
response = requests.get(url, headers=header) | ||
if response.status_code == 200: | ||
with open(self.cds_file_path, "wb") as file: | ||
file.write(response.content) | ||
return | ||
|
||
assert False, ( | ||
f"Default CDS could not be downloaded because of: " | ||
f"{response.status_code}; {response.json()}" | ||
) | ||
|
||
def cleanup(self): | ||
"""Remove temporary directory.""" | ||
shutil.rmtree(self.workdir) |
Binary file not shown.
Oops, something went wrong.