Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CU-8692kpchc Fix for Rosalind link not working #342

Merged
merged 2 commits into from
Sep 4, 2023
Merged
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
15 changes: 13 additions & 2 deletions tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ async def __call__(self, *args, **kwargs):
</body></html>
"""

ERROR_403 = b"""<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access this resource.</p>
</body></html>
"""

SIMPLE_WORDS = """house 34444 0.3232 0.123213 1.231231
dog 14444 0.76762 0.76767 1.45454"""

Expand All @@ -45,7 +54,7 @@ def generate_simple_vocab():


class VocabDownloader:
url = 'https://medcat.rosalind.kcl.ac.uk/media/vocab.dat'
url = 'https://cogstack-medcat-example-models.s3.eu-west-2.amazonaws.com/medcat-example-models/vocab.dat'
vocab_path = "./tmp_vocab.dat"
_has_simple = False

Expand All @@ -54,6 +63,8 @@ def is_valid(self):
content = f.read()
if content == ERROR_503:
return False
if content == ERROR_403:
return False
v = Vocab.load(self.vocab_path)
if len(v.vocab) == 2: # simple one
self._has_simple = True
Expand All @@ -64,7 +75,7 @@ def check_or_download(self):
if os.path.exists(self.vocab_path) and self.is_valid():
return
tmp = requests.get(self.url)
if tmp.content == ERROR_503:
if tmp.content == ERROR_503 or tmp.content == ERROR_403:
print('Rosalind server unavailable')
if self._has_simple:
print('Local simple vocab already present')
Expand Down
Loading