- write_model(model, model_path, backup=True, log_input=False, version=None)#
Write model to files.
modelto text files in a folder(directory) tree at
Model attributes, such as its name and refs, are output in the file named _model.py, directly under model_path. For each space in the model, a text file is created with the same name as the space with “.py” extension. The tree structure of the spaces is represented by the tree of folders, i.e. child spaces of a space is stored in a folder named the space.
Generated text files are Python pseudo-scripts, i.e. they are syntactically correct but semantically not-correct Python scripts, that can only be interpreted through
Dynamic spaces and cells values are not stored.
For spaces and cells created by
new_cells_from_excel(), the source Excel files are copied into the same directory where the text files for the spaces the methods are associated with are located. Then when the model is read by
read_model()function, the methods are invoked to create the spaces or cells.
write()performs the same operation.
Changed in version 0.8.0:
log_inputparameter is added.
Changed in version 0.1.0:
versionparameter is added.
New in version 0.0.22.
model – Model object to write.
model_path (str) – Folder path where the model will be output.
backup (bool, optional) – Whether to backup the directory/folder if it already exists. Defaults to
log_input (bool, optional) – If
True, input values in Cells are output to _input_log.txt under
model_path. Defaults to
version (int, optional) – Format version to write model. Defaults to the most recent version.