Skip to content

Commit 1b64ead

Browse files
committed
generalized pb2 module path
1 parent b09ebb7 commit 1b64ead

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

substreams/substream.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
import pandas as pd
1313
from google.protobuf.descriptor_pb2 import DescriptorProto
1414
from google.protobuf.json_format import MessageToDict
15+
from importlib import import_module
1516

1617
DEFAULT_ENDPOINT = "api.streamingfast.io:443"
1718

1819

1920
def retrieve_class(module_name: str, class_name: str):
20-
module = __import__(module_name)
21+
module = import_module(module_name)
2122
return getattr(module, class_name)
2223

2324

@@ -95,8 +96,7 @@ def _class_from_module(self, module_name: str):
9596
raw_module_path: str = self.proto_file_map.get(output_type)
9697
if raw_module_path is None:
9798
return None
98-
module_path: str = raw_module_path.split("/")[-1].split(".proto")[0]
99-
pb2_path: str = f"{module_path}_pb2"
99+
pb2_path: str = raw_module_path.replace('.proto', '_pb2').replace('/', '.')
100100
return retrieve_class(pb2_path, output_type)
101101

102102
def _parse_from_string(self, raw: str, key: str, output_class) -> dict:

0 commit comments

Comments
 (0)