Skip to content

Commit

Permalink
DEV-1185: fix AWG download of related files
Browse files Browse the repository at this point in the history
Previously, requests for file metadata in the AWG environment were
unauthenticated. However, the metadata endpoint in AWG requires proper
authenticated requests. This change allows for requests for file
metadata in the AWG environment to be properly authenticated.
  • Loading branch information
jiakf committed Feb 5, 2024
1 parent 254c55b commit 66fff99
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
15 changes: 12 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
hooks:
- id: end-of-file-fixer
- id: no-commit-to-branch
args: [--branch, develop, --branch, master, --pattern, release/.*]
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
- repo: [email protected]:Yelp/detect-secrets
rev: v0.13.0
hooks:
- id: end-of-file-fixer
- id: no-commit-to-branch
Expand Down
5 changes: 3 additions & 2 deletions gdc_client/download/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def download(parser, args):

ids = ids_map.values() if args.latest else ids_map.keys()

index_client = GDCIndexClient(args.server, not args.no_verify)
index_client = GDCIndexClient(
uri=args.server, token=args.token_file, verify=not args.no_verify
)
client = get_client(args, index_client)

# separate the smaller files from the larger files
Expand Down Expand Up @@ -163,7 +165,6 @@ def download(parser, args):


def retry_download(client, url, retry_amount, no_auto_retry, wait_time):

log.debug("Retrying download {0}".format(url))

error = True
Expand Down
6 changes: 4 additions & 2 deletions gdc_client/query/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@


class GDCIndexClient(object):
def __init__(self, uri, verify=True):
def __init__(self, uri, token=None, verify=True):
self.uri = uri
self.active_meta_endpoint = "/v0/files"
self.legacy_meta_endpoint = "/v0/legacy/files"
self.metadata = dict()
self.verify = verify
self.token = token

def get_related_files(self, uuid):
# type: (str) -> list[str]
Expand Down Expand Up @@ -54,7 +55,8 @@ def _get_hits(self, url, metadata_query):
"""
json_response = {}
# using a POST request lets us avoid the MAX URL character length limit
r = requests.post(url, json=metadata_query, verify=self.verify)
headers = {"X-Auth-Token": self.token}
r = requests.post(url, json=metadata_query, headers=headers, verify=self.verify)

if r is None:
return []
Expand Down

0 comments on commit 66fff99

Please sign in to comment.