diff --git a/backend/dace_vscode/transformations.py b/backend/dace_vscode/transformations.py index 989318c..c08ca83 100644 --- a/backend/dace_vscode/transformations.py +++ b/backend/dace_vscode/transformations.py @@ -309,9 +309,16 @@ def get_transformations(sdfg_json, selected_elements, permissive): # an older version of dace (<= 0.13.1) is being used - attempt # to construct subgraph transformations using the old API. xform_obj = xform(subgraph) - if xform_obj.can_be_applied(selected_sdfg, subgraph): - transformations.append(xform_obj.to_json()) - docstrings[xform.__name__] = xform_obj.__doc__ + try: + if xform_obj.can_be_applied(selected_sdfg, subgraph): + transformations.append(xform_obj.to_json()) + docstrings[xform.__name__] = xform_obj.__doc__ + except Exception as can_be_applied_exception: + # If something fails here, that is most likely due to a + # transformation bug. Fail gracefully. + print('Warning: ' + xform.__name__ + ' caused an exception') + print(can_be_applied_exception) + print('Most likely a transformation bug, ignoring...') utils.restore_save_metadata(old_meta) return { @@ -319,6 +326,7 @@ def get_transformations(sdfg_json, selected_elements, permissive): 'docstrings': docstrings, } except Exception as e: + traceback.print_exc() return { 'error': { 'message': 'Failed to load transformations', diff --git a/backend/run_dace.py b/backend/run_dace.py index 4d7d1ab..b08cd21 100644 --- a/backend/run_dace.py +++ b/backend/run_dace.py @@ -45,6 +45,7 @@ import sys from argparse import ArgumentParser from os import path +import json # Then, load the rest of the modules import aenum @@ -54,7 +55,8 @@ from dace_vscode import arith_ops, transformations from dace_vscode.utils import (disable_save_metadata, get_exception_message, - load_sdfg_from_file, restore_save_metadata) + load_sdfg_from_file, restore_save_metadata, + load_sdfg_from_json) meta_dict = {} @@ -296,10 +298,10 @@ def compile_sdfg(path, suppress_instrumentation=False): } -def specialize_sdfg(path, symbol_map, remove_undef=True): +def specialize_sdfg(sdfg_string, symbol_map, remove_undef=True): old_meta = disable_save_metadata() - loaded = load_sdfg_from_file(path) + loaded = load_sdfg_from_json(json.loads(sdfg_string)) if loaded['error'] is not None: return loaded['error'] sdfg: dace.sdfg.SDFG = loaded['sdfg'] @@ -414,7 +416,7 @@ def _compile_sdfg_from_file(): @daemon.route('/specialize_sdfg', methods=['POST']) def _specialize_sdfg(): request_json = request.get_json() - return specialize_sdfg(request_json['path'], request_json['symbol_map']) + return specialize_sdfg(request_json['sdfg'], request_json['symbol_map']) @daemon.route('/get_metadata', methods=['GET']) def _get_metadata(): diff --git a/media/components/dace/index.html b/media/components/dace/index.html new file mode 100644 index 0000000..4c71ac0 --- /dev/null +++ b/media/components/dace/index.html @@ -0,0 +1,65 @@ + + + + + + +
+ + +