diff --git a/depyf/explain/patched_lazy_format_graph_code.py b/depyf/explain/patched_lazy_format_graph_code.py index 8cfa35da..c258154c 100644 --- a/depyf/explain/patched_lazy_format_graph_code.py +++ b/depyf/explain/patched_lazy_format_graph_code.py @@ -2,8 +2,8 @@ def patched_lazy_format_graph_code(name, gm, maybe_id=None, **kwargs): from depyf.explain.utils import get_current_compiled_fn_name, write_code_to_file_template from depyf.utils import get_code_owner func_name = get_current_compiled_fn_name() - file_name = name if name != func_name else "Captured Graph" - file_name = func_name + " " + file_name + file_name = str(name).replace(" ", "_") if name != func_name else "Captured_Graph" + file_name = func_name + "_" + file_name import inspect import os @@ -35,7 +35,7 @@ def patched_lazy_format_graph_code(name, gm, maybe_id=None, **kwargs): src = simple_code + commented_src if filepath is not None: new_filepath = write_code_to_file_template( - src, os.path.dirname(filepath) + "/" + file_name + " " + "%s" + ".py") + src, os.path.dirname(filepath) + "/" + file_name + "_" + "%s" + ".py") scope = fn.__globals__ exec(compile(src, filename=new_filepath, mode="exec"), scope) fn.__code__ = scope[fn.__name__].__code__ diff --git a/depyf/explain/patched_load_by_key_path.py b/depyf/explain/patched_load_by_key_path.py index adab9afc..73f54471 100644 --- a/depyf/explain/patched_load_by_key_path.py +++ b/depyf/explain/patched_load_by_key_path.py @@ -16,6 +16,6 @@ def patched_load_by_key_path( func_name = get_current_compiled_fn_name() new_filepath = write_code_to_file_template(src, os.path.join( - dump_src_dir, func_name + " kernel " + "%s" + ".py")) + dump_src_dir, func_name + "_kernel_" + "%s" + ".py")) path = new_filepath return unpatched_load_by_key_path(key, path, linemap, attrs)