mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
pypeline.Model: make deserialize to static
Change the `Model.deserialize` to a static function, which will return a new instance of the Model.
This commit is contained in:
@@ -131,9 +131,8 @@ def build_run_analysis_command(
|
||||
name=analysis_name,
|
||||
)
|
||||
# Load the model
|
||||
loaded_model: Model = model_ty()
|
||||
with open(model, "rb") as model_file:
|
||||
loaded_model.deserialize(model_file.read())
|
||||
loaded_model = model_ty.deserialize(model_file.read())
|
||||
|
||||
logger.debug("Model loaded: `%s`", loaded_model)
|
||||
|
||||
|
||||
@@ -154,9 +154,8 @@ def build_pipe_command(
|
||||
static_configuration=static_configuration,
|
||||
)
|
||||
# Load the model
|
||||
loaded_model: Model = model_ty()
|
||||
with open(model, "rb") as model_file:
|
||||
loaded_model.deserialize(model_file.read())
|
||||
loaded_model = model_ty.deserialize(model_file.read())
|
||||
# Load the containers with args form the command line
|
||||
containers = []
|
||||
for arg in pipe.arguments:
|
||||
|
||||
@@ -117,8 +117,7 @@ def build_analysis_command(
|
||||
|
||||
# Load the model
|
||||
storage_provider = storage_provider_factory(model_path=model)
|
||||
loaded_model: Model = model_ty()
|
||||
loaded_model.deserialize(storage_provider.get_model())
|
||||
loaded_model = model_ty.deserialize(storage_provider.get_model())
|
||||
|
||||
logger.debug("Model loaded: `%s`", loaded_model)
|
||||
|
||||
|
||||
@@ -128,8 +128,7 @@ def build_artifact_command(
|
||||
|
||||
# Load the model
|
||||
storage_provider = storage_provider_factory(model_path=model)
|
||||
loaded_model: Model = model_ty()
|
||||
loaded_model.deserialize(storage_provider.get_model())
|
||||
loaded_model = model_ty.deserialize(storage_provider.get_model())
|
||||
|
||||
logger.debug("Model loaded: `%s`", loaded_model)
|
||||
|
||||
|
||||
@@ -103,8 +103,9 @@ class Model(ABC):
|
||||
def serialize(self) -> bytes:
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@abstractmethod
|
||||
def deserialize(self, data: bytes):
|
||||
def deserialize(cls, data: bytes) -> Model:
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user