MCPcopy
hub / github.com/microsoft/qlib / load

Method load

qlib/utils/serial.py:136–154  ·  view source on GitHub ↗

Load the serializable class from a filepath. Args: filepath (str): the path of file Raises: TypeError: the pickled file must be `type(cls)` Returns: `type(cls)`: the instance of `type(cls)`

(cls, filepath)

Source from the content-addressed store, hash-verified

134
135 @classmethod
136 def load(cls, filepath):
137 """
138 Load the serializable class from a filepath.
139
140 Args:
141 filepath (str): the path of file
142
143 Raises:
144 TypeError: the pickled file must be `type(cls)`
145
146 Returns:
147 `type(cls)`: the instance of `type(cls)`
148 """
149 with open(filepath, "rb") as f:
150 object = cls.get_backend().load(f)
151 if isinstance(object, cls):
152 return object
153 else:
154 raise TypeError(f"The instance of {type(object)} is not a valid `{type(cls)}`!")
155
156 @classmethod
157 def get_backend(cls):

Callers 3

parse_configFunction · 0.45
load_objMethod · 0.45
init_instance_by_configFunction · 0.45

Calls 1

get_backendMethod · 0.80

Tested by

no test coverage detected