Skip to content
Open
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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.17
2.6.18
4 changes: 4 additions & 0 deletions refs/heads/main/doi-redirect/doi-redirects.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
hubmap_id landing_page_to_register data_information_page doi
HBM377.WFSM.936 test_landing_page1 https://purl.humanatlas.io/omap/1-human-lymph-node-ibex/v1. test_doi1
HBM522.KQLL.594 test_landing_page2 https://purl.humanatlas.io/asct-b/lymph-vasculature/v1.5 test_doi2
HBM838.CHFF.356 test_landing_page3 https://purl.humanatlas.io/asct-b/main-bronchus/v1.2 test_doi3
42 changes: 25 additions & 17 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,29 +265,37 @@ def http_internal_server_error(e):
## sets the reference_redirects dict which is used
## by the /redirect method below
try:
csv_reader_list = []
reference_redirects = {}
url = app.config['REDIRECTION_INFO_URL']
url2 = app.config['SECONDARY_REDIRECTION_INFO_URL']
# Use Memcached to improve performance
response = schema_manager.make_request_get(url)
resp_txt = response.content.decode('utf-8')
cr = csv.reader(resp_txt.splitlines(), delimiter='\t')

first = True
id_column = None
redir_url_column = None
for row in cr:
if first:
first = False
header = row
column = 0
for label in header:
if label == 'hubmap_id': id_column = column
if label == 'data_information_page': redir_url_column = column
column = column + 1
if id_column is None: raise Exception(f"Column hubmap_id not found in {url}")
if redir_url_column is None: raise Exception (f"Column data_information_page not found in {url}")
else:
reference_redirects[row[id_column].upper().strip()] = row[redir_url_column]
csv_reader_list.append(cr)
response2 = schema_manager.make_request_get(url2)
resp_txt2 = response2.content.decode('utf-8')
cr2 = csv.reader(resp_txt2.splitlines(), delimiter='\t')
csv_reader_list.append(cr2)

for csv_reader in csv_reader_list:
first = True
id_column = None
redir_url_column = None
for row in csv_reader:
if first:
first = False
header = row
column = 0
for label in header:
if label == 'hubmap_id': id_column = column
if label == 'data_information_page': redir_url_column = column
column = column + 1
if id_column is None: raise Exception(f"Column hubmap_id not found in {url}")
if redir_url_column is None: raise Exception (f"Column data_information_page not found in {url}")
else:
reference_redirects[row[id_column].upper().strip()] = row[redir_url_column]
rr = redirect('abc', code = 307)
print(rr)
except Exception:
Expand Down
Loading