Utilities#

class besser.utilities.utils.ModelSerializer[source]#

Bases: object

ModelSerializer is a simple class for serializing and deserializing BESSER models and Python objects.

None#

Note

This class uses the pickle module for serialization and deserialization. Ensure that the models/objects you are serializing are safe and trusted since pickle can execute arbitrary code.

dump(model: any, output_dir: str = None, output_file_name: str = None)[source]#

Serialize and save a model to a file.

Parameters:
  • model (any) – the B-UML model to be serialized and saved.

  • output_dir (str, optional) – the directory where the file should be saved. If not provided, the file will be saved in the current working directory.

  • output_file_name (str, optional) – The name of the output file. If not provided, a default name will be used based on the type of the model: For objects of type DomainModel: “{model_name}.buml” For other types: “model.pkl”

Returns:

None, but store the model as a file.

load(model_path=<class 'str'>)[source]#

Deserialize and load a model from a serialized file using pickle.

Parameters:

model_path (str) – the path to the serialized model file.

Returns:

the deserialized model object.

Return type:

model_loaded