Skip to content

Commit c54be0e

Browse files
authored
Merge pull request #47 from stvoutsin/main
Fix for loading config from http / fix for propagating errors
2 parents 7209a58 + 184fd20 commit c54be0e

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

gdmp_benchmark/gdmp_benchmark.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -523,14 +523,18 @@ def __init__(self, userconfig: str = "", zeppelin_url: str = "",
523523
self.notebook_handler = notebook_handler
524524

525525
@staticmethod
526-
def get_note(urlpath: str) -> Dict[str, str]:
526+
def get_note(path: str) -> Dict[str, str]:
527527
"""
528-
Get the json file given a URL, and return as a json object
529-
:type urlpath: str
528+
Get the json file given a path (URL or file), and return as a json object
529+
:type path: str
530530
:rtype: dict
531531
"""
532-
response = requests.get(urlpath, timeout=30).text
533-
data = json.loads(response, strict=False)
532+
if path.startswith("http"):
533+
res = requests.get(path, timeout=30).text
534+
data = json.loads(res, strict=False)
535+
else:
536+
with open(path, encoding="utf-8") as config_file:
537+
data = json.load(config_file)
534538
return data
535539

536540
def generate_zdairi_user_configs(self) -> int:
@@ -628,7 +632,7 @@ def run_notebook(self, filepath: str, name: str,
628632
starttime_iso = datetime.now()
629633

630634
config = self._get_user_config(concurrent)
631-
data = self.get_note(urlpath=filepath)
635+
data = self.get_note(path=filepath)
632636
self._write_data_to_file(data=data, filepath=tmpfile)
633637

634638
# Create Notebook
@@ -680,14 +684,9 @@ def parse_notebook_config(note_config: str):
680684
list: Notebook list
681685
"""
682686
notebook_list = []
683-
if note_config:
684-
if note_config.startswith("http"):
685-
notebook_list = self.get_note(urlpath=note_config)["notebooks"]
686-
else:
687-
with open(note_config, encoding="utf-8") as config_file:
688-
notebook_json = json.load(config_file)["notebooks"]
689-
for notebook in notebook_json:
690-
notebook_list.append(Notebook(**notebook))
687+
notebook_json = self.get_note(path=note_config)["notebooks"]
688+
for notebook in notebook_json:
689+
notebook_list.append(Notebook(**notebook))
691690
return notebook_list
692691

693692
notebooks = parse_notebook_config(notebook_config)
@@ -789,7 +788,7 @@ def _run_single(self, iterable: int = 0, notebooks: List = None, concurrent: boo
789788
result = self.run_notebook(notebook.filepath, generated_name, concurrent) # Results
790789
created_notebooks.append([result.notebookid, result.user_config])
791790

792-
if len(notebook.expected_output) > 0:
791+
if len(notebook.expected_output) > 0 and result.result!=Status.ERROR:
793792
for i, cell in enumerate(result.output):
794793
actual_output = hashlib.md5(str(cell).encode('utf-8')).hexdigest()
795794
expected_output = notebook.expected_output.get(str(i), "")
@@ -897,7 +896,6 @@ def main(args: List[str] = None):
897896
"delaystart": "{delay_start}",
898897
"delaynotebook": "{delay_notebook}"
899898
}},
900-
"output":
901899
"""
902900
)
903901
print("}")

0 commit comments

Comments
 (0)