Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanzwicknagl committed Apr 7, 2023
1 parent b27790a commit 33ab300
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions backend/src/viasp/shared/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,9 @@ def object_hook(obj):
# Reconstruct the class definition
# Get the path to the module containing MyClass
my_module_path = obj["Path"]

# Add the directory containing my_module to sys.path
my_module_dir = os.path.dirname(my_module_path)
sys.path.append(my_module_dir)

# Load the module containing MyClass
module_name = os.path.splitext(os.path.basename(my_module_path))[0]
module_spec = importlib.util.spec_from_file_location(module_name, my_module_path)
Expand All @@ -84,20 +82,9 @@ def object_hook(obj):
module.__file__ = my_module.__file__
sys.modules[module_name] = module

# # Reconstruct the class definition
# class_definition = compile(class_definition_str, '<string>', 'exec')
# with open("t.log", "a") as f:
# f.write(f"Class Definition:\n {class_definition_str}\n")


# Execute the class definition in the temporary module
exec(class_definition_str, module.__dict__)

transformer = getattr(module, "Transformer") ## ? Does the name have to be Transformer?

# o_bytes = obj["Transformer_bytes"].encode("latin-1")
# transformer = pickle.loads(o_bytes, encoding="latin-1")
return transformer
return getattr(module, "Transformer")
return obj


Expand Down

0 comments on commit 33ab300

Please sign in to comment.