diff --git a/Code/Os/Python.cs b/Code/Os/Python.cs index e24ac43..7eb97cb 100644 --- a/Code/Os/Python.cs +++ b/Code/Os/Python.cs @@ -106,18 +106,25 @@ namespace Flowframes.Os return ""; } - - public static bool IsPytorchReady () - { - if (HasEmbeddedPyFolder()) - return true; + private static bool? pytorchReadyCached = null; + + public static bool IsPytorchReady (bool clearCachedValue = false) + { + if (clearCachedValue) + pytorchReadyCached = null; + + if (pytorchReadyCached != null) + return (bool)pytorchReadyCached; + + bool pytorchReady = false; + + bool hasPyFolder = HasEmbeddedPyFolder(); string torchVer = GetPytorchVer(); - if (!string.IsNullOrWhiteSpace(torchVer) && torchVer.Length <= 35 && !torchVer.Contains("ModuleNotFoundError")) - return true; - else - return false; + pytorchReady = hasPyFolder || (!string.IsNullOrWhiteSpace(torchVer) && torchVer.Length <= 35 && !torchVer.Contains("ModuleNotFoundError")); + pytorchReadyCached = pytorchReady; + return pytorchReady; } static string GetPytorchVer()