-
Notifications
You must be signed in to change notification settings - Fork 4
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
EVA-3590 update initial check for validation required or not #40
Merged
nitin-ebi
merged 4 commits into
EBIvariation:main
from
nitin-ebi:update_validation_required
Jun 17, 2024
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,4 @@ | ||
class SubmissionNotFoundException(Exception): | ||
def __init__(self, message): | ||
self.message = message | ||
super().__init__(self.message) |
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,5 @@ | ||
|
||
class SubmissionStatusException(Exception): | ||
def __init__(self, message): | ||
self.message = message | ||
super().__init__(self.message) |
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,61 @@ | ||||||
import os | ||||||
|
||||||
import requests | ||||||
from ebi_eva_common_pyutils.logger import AppLogger | ||||||
from requests import HTTPError | ||||||
from retry import retry | ||||||
|
||||||
from eva_sub_cli import SUBMISSION_WS_VAR | ||||||
from eva_sub_cli.auth import get_auth | ||||||
|
||||||
|
||||||
class SubmissionWSClient(AppLogger): | ||||||
""" | ||||||
Python client for interfacing with the Submission WS API. | ||||||
""" | ||||||
|
||||||
def __init__(self, username=None, password=None): | ||||||
self.auth = get_auth(username, password) | ||||||
self.base_url = self._submission_ws_url | ||||||
|
||||||
SUBMISSION_WS_URL = 'https://www.ebi.ac.uk/eva/webservices/submission-ws/v1/' | ||||||
SUBMISSION_INITIATE_PATH = 'submission/initiate' | ||||||
SUBMISSION_UPLOADED_PATH = 'submission/{submissionId}/uploaded' | ||||||
SUBMISSION_STATUS_PATH = 'submission/{submissionId}/status' | ||||||
|
||||||
@property | ||||||
def _submission_ws_url(self): | ||||||
"""Retrieve the base URL for the submission web services. In order of preference from the user of this class, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||||||
the environment variable or the hardcoded value.""" | ||||||
if os.environ.get(SUBMISSION_WS_VAR): | ||||||
return os.environ.get(SUBMISSION_WS_VAR) | ||||||
else: | ||||||
return self.SUBMISSION_WS_URL | ||||||
|
||||||
def _submission_initiate_url(self): | ||||||
return os.path.join(self.base_url, self.SUBMISSION_INITIATE_PATH) | ||||||
|
||||||
def _submission_uploaded_url(self, submission_id): | ||||||
return os.path.join(self.base_url, self.SUBMISSION_UPLOADED_PATH.format(submissionId=submission_id)) | ||||||
|
||||||
def _submission_status_url(self, submission_id): | ||||||
return os.path.join(self.base_url, self.SUBMISSION_STATUS_PATH.format(submissionId=submission_id)) | ||||||
|
||||||
def mark_submission_uploaded(self, submission_id, metadata_json): | ||||||
response = requests.put(self._submission_uploaded_url(submission_id), | ||||||
headers={'Accept': 'application/hal+json', 'Authorization': 'Bearer ' + self.auth.token}, | ||||||
data=metadata_json) | ||||||
response.raise_for_status() | ||||||
return response.json() | ||||||
|
||||||
def initiate_submission(self): | ||||||
response = requests.post(self._submission_initiate_url(), headers={'Accept': 'application/hal+json', | ||||||
'Authorization': 'Bearer ' + self.auth.token}) | ||||||
response.raise_for_status() | ||||||
return response.json() | ||||||
|
||||||
@retry(exceptions=(HTTPError,), tries=3, delay=2, backoff=1.2, jitter=(1, 3)) | ||||||
def get_submission_status(self, submission_id): | ||||||
response = requests.get(self.get_submission_status_url(submission_id)) | ||||||
response.raise_for_status() | ||||||
return response.text |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure the user will know the submission ID since it's just stored in the config, there's not a command line option to set it or anything. Since this is just when it's not found in the WS maybe just contact helpdesk in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated