-
Notifications
You must be signed in to change notification settings - Fork 845
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
Add metadata to json decode errors #2860
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class MetadataException(Exception): | ||
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. [pylint] reported by reviewdog 🐶 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. [pylint] reported by reviewdog 🐶 |
||
def __init__(self, original_exception, additional_metadata): | ||
self.original_exception = original_exception | ||
self.additional_metadata = additional_metadata | ||
|
||
super().__init__(f"{str(self.original_exception)} | Additional metadata: {self.additional_metadata}") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#SPDX-License-Identifier: MIT | ||
Check warning on line 1 in augur/tasks/util/worker_util.py GitHub Actions / runner / pylint
|
||
import json | ||
#import gunicorn.app.base | ||
import numpy as np | ||
|
@@ -11,6 +11,9 @@ | |
import json | ||
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. [pylint] reported by reviewdog 🐶 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. [pylint] reported by reviewdog 🐶 |
||
import subprocess | ||
|
||
from augur.tasks.util.metadata_exception import MetadataException | ||
|
||
|
||
def create_grouped_task_load(*args,processes=8,dataList=[],task=None): | ||
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. [pylint] reported by reviewdog 🐶 |
||
|
||
if not dataList or not task: | ||
|
@@ -70,7 +73,7 @@ | |
# if a KeyError does not occur then a dict with those values has already been processed | ||
# if a KeyError occurs a dict with those values has not been found yet | ||
try: | ||
unique_values[key] | ||
Check warning on line 76 in augur/tasks/util/worker_util.py GitHub Actions / runner / pylint
|
||
continue | ||
except KeyError: | ||
unique_values[key] = 1 | ||
|
@@ -108,7 +111,7 @@ | |
|
||
def calculate_date_weight_from_timestamps(added,last_collection,domain_start_days=30): | ||
#Get the time since last collection as well as when the repo was added. | ||
if last_collection is None: | ||
Check warning on line 114 in augur/tasks/util/worker_util.py GitHub Actions / runner / pylint
|
||
delta = datetime.now() - added | ||
return date_weight_factor(delta.days) | ||
else: | ||
|
@@ -117,7 +120,7 @@ | |
factor = date_weight_factor(delta.days,domain_shift=domain_start_days) | ||
|
||
#If the repo is older than thirty days, start to decrease its weight. | ||
if delta.days >= domain_start_days: | ||
Check warning on line 123 in augur/tasks/util/worker_util.py GitHub Actions / runner / pylint
|
||
return factor | ||
else: | ||
#Else increase its weight | ||
|
@@ -126,9 +129,9 @@ | |
def parse_json_from_subprocess_call(logger, subprocess_arr, cwd=None): | ||
logger.info(f"running subprocess {subprocess_arr[0]}") | ||
if cwd: | ||
p = subprocess.run(subprocess_arr,cwd=cwd,capture_output=True, text=True, timeout=None) | ||
Check warning on line 132 in augur/tasks/util/worker_util.py GitHub Actions / runner / pylint
|
||
else: | ||
p = subprocess.run(subprocess_arr,capture_output=True, text=True, timeout=None) | ||
Check warning on line 134 in augur/tasks/util/worker_util.py GitHub Actions / runner / pylint
|
||
|
||
logger.info('subprocess completed... ') | ||
|
||
|
@@ -141,7 +144,7 @@ | |
required_output = {} | ||
except json.decoder.JSONDecodeError as e: | ||
logger.error(f"Could not parse required output! \n output: {output} \n Error: {e}") | ||
raise e | ||
raise MetadataException(e, f"output : {output}") | ||
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. [pylint] reported by reviewdog 🐶 |
||
|
||
return required_output | ||
|
||
|
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.
[pylint] reported by reviewdog 🐶
W0707: Consider explicitly re-raising using 'raise MetadataException(e, f'required_output: {required_output}') from e' (raise-missing-from)