Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,33 @@ namespace Microsoft.ML.Scenarios

internal sealed class TensorFlowScenariosTestsFixture : IDisposable
{
public static string tempFolder;
public static string parentWorkspacePath;
public static string assetsPath;
internal void CreateParentWorkspacePathForImageClassification()
internal static void CreateParentWorkspacePathForImageClassification()
{
string assetsRelativePath = @"assets";
assetsPath = GetAbsolutePath(assetsRelativePath);
string workspacePath = Path.Combine(assetsPath, "cached");
tempFolder = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
Copy link

@yaeldekel yaeldekel Feb 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path.GetTempPath(), Path.GetRandomFileName() [](start = 38, length = 44)

Are these guaranteed to be shorter? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, these are guaranteed to be shorter. Path.GetRandomeFile() only produces a 12 character random filename and in combination with Path.GetTempPath() (which is typically %USERPROFILE%\AppData\Local\Temp) the overall path will be significantly shorter than what what produced earlier.


In reply to: 376950593 [](ancestors = 376950593)

assetsPath = Path.Combine(tempFolder, "assets");
parentWorkspacePath = Path.Combine(assetsPath, "cached");
// Delete if the workspace path already exists
if (Directory.Exists(workspacePath))
if (Directory.Exists(parentWorkspacePath))
{
Directory.Delete(workspacePath, true);
Directory.Delete(parentWorkspacePath, true);
}

// Create a new empty workspace path
Directory.CreateDirectory(workspacePath);
parentWorkspacePath = workspacePath;
Directory.CreateDirectory(parentWorkspacePath);
}

public TensorFlowScenariosTestsFixture()
static TensorFlowScenariosTestsFixture()
{
CreateParentWorkspacePathForImageClassification();
}

public void Dispose()
{
// clean up test data
Directory.Delete(tempFolder, true);
}

public static string GetAbsolutePath(string relativePath) =>
Path.Combine(new FileInfo(typeof(
TensorFlowScenariosTestsFixture).Assembly.Location).Directory.FullName, relativePath);
}

[Collection("NoParallelization")]
Expand Down Expand Up @@ -1880,11 +1876,6 @@ private static void UnZip(String gzArchiveName, String destFolder)
File.Create(Path.Combine(destFolder, flag));
}

public static string GetAbsolutePath(string relativePath) =>
Path.Combine(new FileInfo(typeof(
TensorFlowScenariosTests).Assembly.Location).Directory.FullName, relativePath);


public class ImageData
{
[LoadColumn(0)]
Expand Down