Skip to content

Commit

Permalink
--no_python CLI arg to disable python check and implems
Browse files Browse the repository at this point in the history
  • Loading branch information
n00mkrad committed Aug 11, 2024
1 parent 3138e7f commit 8df4e31
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Code/Data/Implementations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace Flowframes.Data
{
class Implementations
{
public static bool DisablePython = false;

public static AI rifeCuda = new AI()
{
Backend = AI.AiBackend.Pytorch,
Expand Down Expand Up @@ -70,7 +72,6 @@ class Implementations
SupportedFactors = new int[] { 2 },
};


public static List<AI> NetworksAll
{
get
Expand All @@ -83,7 +84,7 @@ public static List<AI> NetworksAvailable
{
get
{
bool pytorchAvailable = Python.IsPytorchReady();
bool pytorchAvailable = !DisablePython && Python.IsPytorchReady();

if (pytorchAvailable)
return NetworksAll;
Expand Down
3 changes: 3 additions & 0 deletions Code/Flowframes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@
<Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\WindowsAPICodePack-Shell.1.1.1\lib\Microsoft.WindowsAPICodePack.Shell.dll</HintPath>
</Reference>
<Reference Include="NDesk.Options, Version=0.2.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\NDesk.Options.0.2.1\lib\NDesk.Options.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
Expand Down
6 changes: 5 additions & 1 deletion Code/Os/Python.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Flowframes.IO;
using Flowframes.Data;
using Flowframes.IO;
using Flowframes.MiscUtils;
using Flowframes.Ui;
using System;
Expand Down Expand Up @@ -129,6 +130,9 @@ public static bool IsPytorchReady (bool clearCachedValue = false)

static string GetPytorchVer()
{
if(Implementations.DisablePython)
return "";

try
{
Process py = OsUtils.NewProcess(true);
Expand Down
15 changes: 15 additions & 0 deletions Code/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Flowframes.MiscUtils;
using Flowframes.Os;
using Flowframes.Ui;
using NDesk.Options;
using System;
using System.Collections.Generic;
using System.Globalization;
Expand Down Expand Up @@ -49,6 +50,20 @@ static void Main()
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

var opts = new OptionSet
{
{ "np|no_python", "Disable Python implementations", v => Implementations.DisablePython = v != null },
};

try
{
opts.Parse(Environment.GetCommandLineArgs());
}
catch (OptionException e)
{
Logger.Log($"Error parsing CLI option: {e.Message}", true);
}

Task.Run(() => DiskSpaceCheckLoop());
fileArgs = Environment.GetCommandLineArgs().Where(a => a[0] != '-' && File.Exists(a)).ToList().Skip(1).ToArray();
args = Environment.GetCommandLineArgs().Where(a => a[0] == '-').Select(x => x.Trim().Substring(1).ToLowerInvariant()).ToArray();
Expand Down
1 change: 1 addition & 0 deletions Code/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net472" />
<package id="Microsoft-WindowsAPICodePack-Core" version="1.1.4" targetFramework="net472" />
<package id="Microsoft-WindowsAPICodePack-Shell" version="1.1.4" targetFramework="net472" />
<package id="NDesk.Options" version="0.2.1" targetFramework="net472" />
<package id="NETStandard.Library" version="1.6.1" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
<package id="NvAPIWrapper.Net" version="0.8.1.101" targetFramework="net472" />
Expand Down

0 comments on commit 8df4e31

Please sign in to comment.