Skip to content

Include the "save file" action (.ZIP file) as part of model.SaveFile() #1689

Closed
@CESARDELATORRE

Description

@CESARDELATORRE

Currently, whenever we are saving a .ZIP model file, you always need to handle the code for the File stream class.

I think that is repetitive code that could be included in the API.
Instead of:

using (var fs = new FileStream(ModelPath, FileMode.Create, FileAccess.Write, FileShare.Write))
                mlContext.Model.Save(trainedModel, fs);

We could have an overridden method so I could simply do the following:

mlContext.Model.Save(trainedModel, modelPath);

Or even the following, if those methods were part of the model class itself instead of a utility class in the MLContext:

model.Save(modelPath);

Currently, this kind of line using the file stream class is something you need to repeat over and over in every/most training app (even when the constructor can be simplified):

using (var fs = new FileStream(ModelPath, FileMode.Create, FileAccess.Write, FileShare.Write))

Handling a FileStream object might should not be mandatory for the user but optional:

Of course, I would also maintain the current methods because in some cases you might want to just provide an existing stream object, but as opt-in.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions