Skip to content

File already exists error when loading LightGbmBinaryTrainer from MemoryStream #5210

Description

@dasokolo

System information

os version Windows (not sure)
.net version 3.1.202
mlnet version 1.3.1

Issue

I am loading LightGbmBinaryTrainer from memory stream

            ITransformer model = null;
            using (MemoryStream ms = new MemoryStream(kv.Value))
            {
                model = _mLContext.Model.Load(ms, out _inputSchema);
            }

Note, this code is executed in several threads in parallel over the same model.

And I occasionally get the following exception:

System.IO.IOException: The file 'D:\SvcFab_App\AIBuilder.Platform.Host_App157\temp\TLC_1CBA6C2E\0' already exists.

This happens occasionally and I can't reliably reproduce this 100%.

  • What did you expect?
  1. I expected that no file operations are performed during loading from memory stream. My models are relatively small, but I can't guarantee that the filesystem is always available. I would appreciate to at least have some control over this behavior.

  2. But if file operations cannot be avoided, I expect to have no naming conflicts.

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.IOException: The file 'D:\SvcFab_App\AIBuilder.Platform.Host_App157\temp\TLC_1CBA6C2E\0' already exists.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.IO.Compression.ZipFileExtensions.ExtractToFile(ZipArchiveEntry source, String destinationFileName, Boolean overwrite)
at Microsoft.ML.RepositoryReader.OpenEntryOrNull(String dir, String name)
at Microsoft.ML.ModelOperationsCatalog.Load(Stream stream, DataViewSchema& inputSchema)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

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