Skip to content

Commit

Permalink
Corrections to requirements for Python 3.9 modules
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisMaunder committed Aug 9, 2022
1 parent da2c26a commit 1081307
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 100 deletions.
63 changes: 19 additions & 44 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
"configurations": [

{
"name": "Build All (Win)",
"name": "Build All",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-all-win",
"linux": {
"preLaunchTask": "build-all-linux",
},
"osx": {
"preLaunchTask": "build-all-linux",
},
"program": "dotnet",
"args": [
"--version"
Expand All @@ -19,52 +25,20 @@
},

{
"name": "Build All (Linux/macOS)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-all-linux",
"program": "dotnet",
"args": [
"--version"
],
"cwd": "${workspaceFolder}/src/API/Server/FrontEnd/",
"stopAtEntry": false,
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},

{
"name": "Launch CodeProject.AI (Win)",
"name": "Launch Server",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-all-win",
"program": "${workspaceFolder}/src/API/Server/FrontEnd/bin/Debug/net6.0/CodeProject.AI.Server.exe",
"args": [],
"cwd": "${workspaceFolder}/src/API/Server/FrontEnd/",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)",
"uriFormat": "http://localhost:%s/swagger"
"linux": {
"preLaunchTask": "build-all-linux",
},
"osx": {
"preLaunchTask": "build-all-linux",
},

"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"RUNNING_IN_VSCODE": "true"
}
},

{
"name": "Launch CodeProject.AI (Linux/macOS)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-all-linux",
"program": "${workspaceFolder}/src/API/Server/FrontEnd/bin/Debug/net6.0/CodeProject.AI.Server",
"args": [],
"cwd": "${workspaceFolder}",
"cwd": "${workspaceFolder}/src/API/Server/FrontEnd/",
"stopAtEntry": false,

"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)",
Expand All @@ -74,14 +48,15 @@
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"RUNNING_IN_VSCODE": "true"
},

}
/*
"logging": {
"engineLogging": false,
"moduleLoad": false,
"exceptions": false,
"browserStdOut": false
},
}
*/
},

{
Expand Down Expand Up @@ -116,7 +91,7 @@
},

{
"name": "Launch CodeProject.AI Explorer (Win)",
"name": "[Win] Explorer App",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "launch-server-win",
Expand Down
10 changes: 5 additions & 5 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
"command": "dotnet",
"args": [
"build",
"${workspaceFolder}/src/AnalysisLayer/CodeProject.AI.AnalysisLayer.Yolo",
"${workspaceFolder}/src/AnalysisLayer/ObjectDetectionNet",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},

{
"label": "build-portraitfilter", // Builds ONLY the Yolo .NET analysis module
"label": "build-portraitfilter", // Builds ONLY the .NET portrait filter module
"type": "process",
"group": "build",
"command": "dotnet",
Expand All @@ -61,7 +61,7 @@
},

{
"label": "build-sentimentanalysis", // Builds ONLY the Yolo .NET analysis module
"label": "build-sentimentanalysis", // Builds ONLY the the .NET sentiment analysis module
"type": "process",
"group": "build",
"command": "dotnet",
Expand All @@ -75,7 +75,7 @@
},

{
"label": "build-explorer", // Builds ONLY the Yolo .NET analysis module
"label": "build-explorer", // Builds ONLY the Yolo .NET demo explorer
"type": "process",
"group": "build",
"command": "dotnet",
Expand All @@ -99,7 +99,7 @@
},

{
"label": "build-all-win", // Builds all projects that can be built for Linux (ie not any Windows Forms apps)
"label": "build-all-win", // Builds all projects that can be built for Windows (ie everything)
"group": "build",
"dependsOrder": "sequence",
"dependsOn": [
Expand Down
30 changes: 20 additions & 10 deletions CodeProject.AI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
THIRD-PARTY-NOTICES.md = THIRD-PARTY-NOTICES.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_PRIVATE REPO", "_PRIVATE REPO", "{78509730-6FBA-44E5-98C0-083DB7F52027}"
ProjectSection(SolutionItems) = preProject
README.txt = README.txt
rebrand.txt = rebrand.txt
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SDK", "SDK", "{FF0C329F-41E8-4540-BCDB-97690911077D}"
ProjectSection(SolutionItems) = preProject
src\AnalysisLayer\SDK\install.bat = src\AnalysisLayer\SDK\install.bat
src\AnalysisLayer\SDK\install.sh = src\AnalysisLayer\SDK\install.sh
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ModelRunners", "ModelRunners", "{55C41D48-17AC-4ED5-9440-B42AF65CCE4E}"
EndProject
Expand Down Expand Up @@ -255,7 +265,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ObjectDetectionNet", "src\A
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CudaVersionCustomAction", "Installers\Windows\CudaVersionCustomAction\CudaVersionCustomAction.csproj", "{214949E0-B56C-4F23-809A-07DA4DBDF925}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeProject.SenseAI.API.Server.Backend.Tests", "tests\QueueServiceTests\CodeProject.SenseAI.API.Server.Backend.Tests.csproj", "{BF307B78-E985-4787-A1FC-41D860650F39}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeProject.SenseAI.API.Server.Backend.Tests", "tests\QueueServiceTests\CodeProject.SenseAI.API.Server.Backend.Tests.csproj", "{F94FBD1C-02FB-4169-8C26-2D52234D4311}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -470,14 +480,14 @@ Global
{214949E0-B56C-4F23-809A-07DA4DBDF925}.Release|Any CPU.Build.0 = Release|x86
{214949E0-B56C-4F23-809A-07DA4DBDF925}.Release|x86.ActiveCfg = Release|x86
{214949E0-B56C-4F23-809A-07DA4DBDF925}.Release|x86.Build.0 = Release|x86
{BF307B78-E985-4787-A1FC-41D860650F39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BF307B78-E985-4787-A1FC-41D860650F39}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BF307B78-E985-4787-A1FC-41D860650F39}.Debug|x86.ActiveCfg = Debug|Any CPU
{BF307B78-E985-4787-A1FC-41D860650F39}.Debug|x86.Build.0 = Debug|Any CPU
{BF307B78-E985-4787-A1FC-41D860650F39}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BF307B78-E985-4787-A1FC-41D860650F39}.Release|Any CPU.Build.0 = Release|Any CPU
{BF307B78-E985-4787-A1FC-41D860650F39}.Release|x86.ActiveCfg = Release|Any CPU
{BF307B78-E985-4787-A1FC-41D860650F39}.Release|x86.Build.0 = Release|Any CPU
{F94FBD1C-02FB-4169-8C26-2D52234D4311}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F94FBD1C-02FB-4169-8C26-2D52234D4311}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F94FBD1C-02FB-4169-8C26-2D52234D4311}.Debug|x86.ActiveCfg = Debug|Any CPU
{F94FBD1C-02FB-4169-8C26-2D52234D4311}.Debug|x86.Build.0 = Debug|Any CPU
{F94FBD1C-02FB-4169-8C26-2D52234D4311}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F94FBD1C-02FB-4169-8C26-2D52234D4311}.Release|Any CPU.Build.0 = Release|Any CPU
{F94FBD1C-02FB-4169-8C26-2D52234D4311}.Release|x86.ActiveCfg = Release|Any CPU
{F94FBD1C-02FB-4169-8C26-2D52234D4311}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -536,7 +546,7 @@ Global
{4ED567B5-C28D-48BB-AEDC-864E2B2C7204} = {B10B59B5-9F63-41C2-BFBB-6C7311DC4E99}
{25D75AFE-BEC9-43BF-BE44-B9068FF8E395} = {156BFEDA-D477-43B2-92DA-FCC9BAF1F893}
{214949E0-B56C-4F23-809A-07DA4DBDF925} = {83C828B9-2B1E-4982-B4B7-69D173DFBB27}
{BF307B78-E985-4787-A1FC-41D860650F39} = {D982BD8C-2257-413B-8513-8043AB3035F3}
{F94FBD1C-02FB-4169-8C26-2D52234D4311} = {D982BD8C-2257-413B-8513-8043AB3035F3}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {83740BD9-AEEF-49C7-A722-D7703D3A38CB}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ApiClient
/// <summary>
/// Gets or sets the timeout in seconds for making calls to the API
/// </summary>
public int Timeout { get; set; } = 120;
public int Timeout { get; set; } = 300;

/// <summary>
/// Gets the HttpClient
Expand All @@ -49,7 +49,7 @@ private HttpClient Client
_client = new HttpClient
{
BaseAddress = new Uri($"http://localhost:{Port}/v1/"),
Timeout = new TimeSpan(0, 0, Timeout)
Timeout = TimeSpan.FromSeconds(Timeout)
};
}

Expand Down
2 changes: 1 addition & 1 deletion demos/dotNet/CodeProject.AI.Explorer/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ private async void RunBenchmark(bool useCustom)
ShowError("Image must be selected.");
return;
}
var nIterations = 512;
var nIterations = 100;
var taskList = new List<Task<ResponseBase>>();
Stopwatch sw = Stopwatch.StartNew();
for (int i = 0; i < nIterations; i++){
Expand Down
2 changes: 1 addition & 1 deletion src/API/Server/Backend/QueueServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class QueueServices
ILogger<QueueServices> logger)
{
_settings = options.Value;
_logger = logger;
_logger = logger;
}

public bool EnsureQueueExists(string queueName)
Expand Down
24 changes: 15 additions & 9 deletions src/API/Server/FrontEnd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,30 @@ RUN dotnet restore "src/API/Server/FrontEnd/Frontend.csproj"
COPY . .

WORKDIR "/src/src/API/Server/FrontEnd"
RUN dotnet build "Frontend.csproj" -c Release --no-self-contained -o /app/build/server
RUN dotnet build "Frontend.csproj" -c Release -r linux-x64 --self-contained -o /app/build/server

WORKDIR "/src/src/AnalysisLayer/ObjectDetectionNet"
RUN dotnet build "ObjectDetectionNet.csproj" -c Release --no-self-contained -o /app/build/AnalysisLayer/ObjectDetectionNet
RUN dotnet build "ObjectDetectionNet.csproj" -c Release -r linux-x64 --self-contained -o /app/build/AnalysisLayer/ObjectDetectionNet

WORKDIR "/src/src/AnalysisLayer/PortraitFilter"
RUN dotnet build "PortraitFilter.csproj" -c Release --no-self-contained -o /app/build/AnalysisLayer/PortraitFilter
RUN dotnet build "PortraitFilter.csproj" -c Release -r linux-x64 --self-contained -o /app/build/AnalysisLayer/PortraitFilter

#WORKDIR "/src/src/AnalysisLayer/SentimentAnalysis"
#RUN dotnet build "SentimentAnalysis.csproj" -c Release --no-self-contained -o /app/build/AnalysisLayer/SentimentAnalysis
#RUN dotnet build "SentimentAnalysis.csproj" -c Release -r linux-x64 --self-contained -o /app/build/AnalysisLayer/SentimentAnalysis

FROM build AS publish

WORKDIR "/src/src/API/Server/FrontEnd"
RUN dotnet publish "Frontend.csproj" -c Release --no-self-contained -o /app/publish/server
RUN dotnet publish "Frontend.csproj" -c Release -r linux-x64 --self-contained -o /app/publish/server

WORKDIR "/src/src/AnalysisLayer/ObjectDetectionNet"
RUN dotnet publish "ObjectDetectionNet.csproj" -c Release --no-self-contained -o /app/publish/AnalysisLayer/ObjectDetectionNet
RUN dotnet publish "ObjectDetectionNet.csproj" -c Release -r linux-x64 --self-contained -o /app/publish/AnalysisLayer/ObjectDetectionNet

WORKDIR "/src/src/AnalysisLayer/PortraitFilter"
RUN dotnet publish "PortraitFilter.csproj" -c Release --no-self-contained -o /app/publish/AnalysisLayer/PortraitFilter
RUN dotnet publish "PortraitFilter.csproj" -c Release -r linux-x64 --self-contained -o /app/publish/AnalysisLayer/PortraitFilter

#WORKDIR "/src/src/AnalysisLayer/SentimentAnalysis"
#RUN dotnet publish "SentimentAnalysis.csproj" -c Release --no-self-contained -o /app/publish/AnalysisLayer/SentimentAnalysis
#RUN dotnet publish "SentimentAnalysis.csproj" -c Release -r linux-x64 --self-contained -o /app/publish/AnalysisLayer/SentimentAnalysis

# zipping up the test images and moving to the server wwwroot directory so it can be downloaded from server.
RUN apt-get update -y && apt-get upgrade -y
Expand Down Expand Up @@ -81,14 +81,20 @@ WORKDIR /app
COPY --from=publish /app/publish .
RUN add-apt-repository ppa:deadsnakes/ppa -y
RUN apt update -y

#needed for opencv-python
RUN apt-get install ffmpeg libsm6 libxext6 -y

RUN apt-get install python3.9 -y
RUN python3.8 -m pip install --upgrade pip
RUN python3.9 -m pip install --upgrade pip

# CM: Added --no-cache-dir here to reduce the size of the image
RUN python3.8 -m pip --no-cache-dir install -r /app/AnalysisLayer/Vision/intelligencelayer/requirements.txt
RUN python3.8 -m pip --no-cache-dir install -r /app/AnalysisLayer/Vision/requirements.txt
RUN python3.8 -m pip --no-cache-dir install -r /app/AnalysisLayer/SDK/Python/requirements.txt
#RUN python3.8 -m pip --no-cache-dir install -r /app/AnalysisLayer/TextSummary/requirements.txt
RUN python3.9 -m pip --no-cache-dir install -r /app/AnalysisLayer/BackgroundRemover/requirements.txt
RUN python3.9 -m pip --no-cache-dir install -r /app/AnalysisLayer/SDK/Python/requirements.txt

WORKDIR /app/server
ENTRYPOINT ["dotnet", "CodeProject.AI.Server.dll"]
26 changes: 16 additions & 10 deletions src/API/Server/FrontEnd/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ public static async Task Main(string[] args)
};

bool inVScode = (Environment.GetEnvironmentVariable("RUNNING_IN_VSCODE") ?? "") == "true";
bool reloadConfigOnChange = !inDocker;

// TODO: 1. Reorder the config loading so that command line is last
// 2. Stop appsettings being reloaded on change when in docker for the default
// appsettings.json files
IHost? host = CreateHostBuilder(args)
.ConfigureAppConfiguration((hostingContext, config) =>
{
Expand All @@ -95,36 +99,36 @@ public static async Task Main(string[] args)
if (inVScode && platform != "windows")
{
config.AddJsonFile(Path.Combine(baseDir, "appsettings.json"),
optional: false, reloadOnChange: true);
optional: false, reloadOnChange: reloadConfigOnChange);
if (!string.IsNullOrWhiteSpace(aspNetEnv))
{
config.AddJsonFile(Path.Combine(baseDir, $"appsettings.{aspNetEnv}.json"),
optional: true, reloadOnChange: true);
optional: true, reloadOnChange: reloadConfigOnChange);
}
}
config.AddJsonFile(Path.Combine(baseDir, $"appsettings.{platform}.json"),
optional: true, reloadOnChange: true);
optional: true, reloadOnChange: reloadConfigOnChange);
// Load appsettings.platform.env.json files to allow slightly more
// convenience for settings on other platforms
if (!string.IsNullOrWhiteSpace(aspNetEnv))
{
config.AddJsonFile(Path.Combine(baseDir, $"appsettings.{platform}.{aspNetEnv}.json"),
optional: true, reloadOnChange: true);
optional: true, reloadOnChange: reloadConfigOnChange);
}
// This allows us to add ad-hoc settings such as ApplicationDataDir
config.AddInMemoryCollection(inMemoryConfigData);
// Load the installconfig.json file so we have access to the install ID
config.AddJsonFile(Path.Combine(applicationDataDir, InstallConfig.InstallCfgFilename),
reloadOnChange: true, optional: true);
reloadOnChange: reloadConfigOnChange, optional: true);
// Load the version.json file so we have access to the Version info
config.AddJsonFile(Path.Combine(baseDir, VersionConfig.VersionCfgFilename),
reloadOnChange: true, optional: true);
reloadOnChange: reloadConfigOnChange, optional: true);
// Load the modulesettings.json files to get analysis module settings
LoadModulesConfiguration(config, aspNetEnv);
Expand Down Expand Up @@ -198,6 +202,8 @@ public static async Task Main(string[] args)
// things. To be done at a later date.
private static void LoadModulesConfiguration(IConfigurationBuilder config, string? aspNetEnv)
{
bool reloadOnChange = (Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER") ?? "") != "true";

IConfiguration configuration = config.Build();
var options = configuration.GetSection("FrontEndOptions");
string? rootPath = options["ROOT_PATH"];
Expand Down Expand Up @@ -243,21 +249,21 @@ private static void LoadModulesConfiguration(IConfigurationBuilder config, strin
foreach (string? directory in directories)
{
config.AddJsonFile(Path.Combine(directory, "modulesettings.json"),
optional: true, reloadOnChange: true);
optional: true, reloadOnChange: reloadOnChange);

if (!string.IsNullOrEmpty(aspNetEnv))
{
config.AddJsonFile(Path.Combine(directory, $"modulesettings.{aspNetEnv}.json"),
optional: true, reloadOnChange: true);
optional: true, reloadOnChange: reloadOnChange);
}

config.AddJsonFile(Path.Combine(directory, $"modulesettings.{platform}.json"),
optional: true, reloadOnChange: true);
optional: true, reloadOnChange: reloadOnChange);

if (!string.IsNullOrEmpty(aspNetEnv))
{
config.AddJsonFile(Path.Combine(directory, $"modulesettings.{platform}.{aspNetEnv}.json"),
optional: true, reloadOnChange: true);
optional: true, reloadOnChange: reloadOnChange);
}
}
}
Expand Down

0 comments on commit 1081307

Please sign in to comment.