Skip to content

Commit

Permalink
Code cleaning and commenting
Browse files Browse the repository at this point in the history
  • Loading branch information
fyvon committed Oct 22, 2024
1 parent 9b6416b commit 8a08cf7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
10 changes: 5 additions & 5 deletions validator/static/validator/js/metadata_consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ function report_items_2_html(reports_list) {
}
let message = report_item.message;
// Value highlighting
message = message.replace(/\"(.+?)\"/g, "\"<b>$1</b>\"");
message = message.replace(/"(.+?)"/g, "\"<b>$1</b>\"");
// Leading space
message = message.replace(/\"<b>\s+/g, "\"<b><span class=\"pgs_color_red\">_</span>");
message = message.replace(/"<b>\s+/g, "\"<b><span class=\"pgs_color_red\">_</span>");
// Trailing space
message = message.replace(/\s+<\/b>\"/g, "<span class=\"pgs_color_red\">_</span></b>\"");
message = message.replace(/\s+<\/b>"/g, "<span class=\"pgs_color_red\">_</span></b>\"");
// Column highlighting
message = message.replace(/\'(.+?)\'/g, "\'<span class=\"pgs_color_1\">$1</span>\'");
message = message.replace(/'(.+?)'/g, "\'<span class=\"pgs_color_1\">$1</span>\'");
report += "<li>"+lines+message+"</li>";
});
report += '</ul>';
Expand Down Expand Up @@ -102,7 +102,7 @@ function showResults(results){
function showSystemError(errors){
let status_html = '<div><b>File validation:</b> <i class="fa fa-times-circle-o pgs_color_red"></i> Failed</div>';
$('#check_status').html(status_html);
let error_msg = (errors && errors != '') ? errors : 'Internal error';
let error_msg = (errors && errors !== '') ? errors : 'Internal error';
let error_html = '<div class="clearfix">'+
' <div class="mt-3 float_left pgs_note pgs_note_2">'+
' <div><b>Error:</b> '+error_msg+'</div>'+
Expand Down
1 change: 0 additions & 1 deletion validator/static/validator/js/scores_consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ async function validation(validateFileHandle) {
return results;
} else if (error) {
validation_out.value = '';
console.log(typeof error);
console.log("pyodideWorker error: ", error);
appendAlertToElement("error",'Error: '+error,'danger')
}
Expand Down
4 changes: 4 additions & 0 deletions validator/static/validator/python/bin/validation_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ def debug(self, message, name):


class PyodideConnector(Connector):
"""This customised connector is necessary as the 'requests' python module is not supported in WebAssembly.
Moreover, the requests for EFO traits must be redirected to a proxy to avoid cross-origin errors."""

def __init__(self):
super().__init__(logger=PyodideLogger())

def request(self, url, payload=None) -> dict:
if payload:
query = '&'.join([f"{k}={v}" for k, v in payload.items()])
url = url + '?' + query
# Using pyodide open_url instead of python requests.get()
query_result_io = open_url(url)
query_result = query_result_io.read()

Expand Down
2 changes: 1 addition & 1 deletion validator/static/validator/python/bin/validation_scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ class Args:
'response': response
}

json.dumps(data)
json.dumps(data) # Is returned by pyodide.runPythonAsync()

0 comments on commit 8a08cf7

Please sign in to comment.