Skip to content

Commit 1081307

Browse files
author
ChrisMaunder
committed
Corrections to requirements for Python 3.9 modules
1 parent da2c26a commit 1081307

File tree

13 files changed

+88
-100
lines changed

13 files changed

+88
-100
lines changed

.vscode/launch.json

Lines changed: 19 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
"configurations": [
44

55
{
6-
"name": "Build All (Win)",
6+
"name": "Build All",
77
"type": "coreclr",
88
"request": "launch",
99
"preLaunchTask": "build-all-win",
10+
"linux": {
11+
"preLaunchTask": "build-all-linux",
12+
},
13+
"osx": {
14+
"preLaunchTask": "build-all-linux",
15+
},
1016
"program": "dotnet",
1117
"args": [
1218
"--version"
@@ -19,52 +25,20 @@
1925
},
2026

2127
{
22-
"name": "Build All (Linux/macOS)",
23-
"type": "coreclr",
24-
"request": "launch",
25-
"preLaunchTask": "build-all-linux",
26-
"program": "dotnet",
27-
"args": [
28-
"--version"
29-
],
30-
"cwd": "${workspaceFolder}/src/API/Server/FrontEnd/",
31-
"stopAtEntry": false,
32-
"env": {
33-
"ASPNETCORE_ENVIRONMENT": "Development"
34-
}
35-
},
36-
37-
{
38-
"name": "Launch CodeProject.AI (Win)",
28+
"name": "Launch Server",
3929
"type": "coreclr",
4030
"request": "launch",
4131
"preLaunchTask": "build-all-win",
42-
"program": "${workspaceFolder}/src/API/Server/FrontEnd/bin/Debug/net6.0/CodeProject.AI.Server.exe",
43-
"args": [],
44-
"cwd": "${workspaceFolder}/src/API/Server/FrontEnd/",
45-
"stopAtEntry": false,
46-
"serverReadyAction": {
47-
"action": "openExternally",
48-
"pattern": "\\bNow listening on:\\s+(https?://\\S+)",
49-
"uriFormat": "http://localhost:%s/swagger"
32+
"linux": {
33+
"preLaunchTask": "build-all-linux",
34+
},
35+
"osx": {
36+
"preLaunchTask": "build-all-linux",
5037
},
51-
52-
"env": {
53-
"ASPNETCORE_ENVIRONMENT": "Development",
54-
"RUNNING_IN_VSCODE": "true"
55-
}
56-
},
57-
58-
{
59-
"name": "Launch CodeProject.AI (Linux/macOS)",
60-
"type": "coreclr",
61-
"request": "launch",
62-
"preLaunchTask": "build-all-linux",
6338
"program": "${workspaceFolder}/src/API/Server/FrontEnd/bin/Debug/net6.0/CodeProject.AI.Server",
6439
"args": [],
65-
"cwd": "${workspaceFolder}",
40+
"cwd": "${workspaceFolder}/src/API/Server/FrontEnd/",
6641
"stopAtEntry": false,
67-
6842
"serverReadyAction": {
6943
"action": "openExternally",
7044
"pattern": "\\bNow listening on:\\s+(https?://\\S+)",
@@ -74,14 +48,15 @@
7448
"env": {
7549
"ASPNETCORE_ENVIRONMENT": "Development",
7650
"RUNNING_IN_VSCODE": "true"
77-
},
78-
51+
}
52+
/*
7953
"logging": {
8054
"engineLogging": false,
8155
"moduleLoad": false,
8256
"exceptions": false,
8357
"browserStdOut": false
84-
},
58+
}
59+
*/
8560
},
8661

8762
{
@@ -116,7 +91,7 @@
11691
},
11792

11893
{
119-
"name": "Launch CodeProject.AI Explorer (Win)",
94+
"name": "[Win] Explorer App",
12095
"type": "coreclr",
12196
"request": "launch",
12297
"preLaunchTask": "launch-server-win",

.vscode/tasks.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@
3939
"command": "dotnet",
4040
"args": [
4141
"build",
42-
"${workspaceFolder}/src/AnalysisLayer/CodeProject.AI.AnalysisLayer.Yolo",
42+
"${workspaceFolder}/src/AnalysisLayer/ObjectDetectionNet",
4343
"/property:GenerateFullPaths=true",
4444
"/consoleloggerparameters:NoSummary"
4545
],
4646
"problemMatcher": "$msCompile"
4747
},
4848

4949
{
50-
"label": "build-portraitfilter", // Builds ONLY the Yolo .NET analysis module
50+
"label": "build-portraitfilter", // Builds ONLY the .NET portrait filter module
5151
"type": "process",
5252
"group": "build",
5353
"command": "dotnet",
@@ -61,7 +61,7 @@
6161
},
6262

6363
{
64-
"label": "build-sentimentanalysis", // Builds ONLY the Yolo .NET analysis module
64+
"label": "build-sentimentanalysis", // Builds ONLY the the .NET sentiment analysis module
6565
"type": "process",
6666
"group": "build",
6767
"command": "dotnet",
@@ -75,7 +75,7 @@
7575
},
7676

7777
{
78-
"label": "build-explorer", // Builds ONLY the Yolo .NET analysis module
78+
"label": "build-explorer", // Builds ONLY the Yolo .NET demo explorer
7979
"type": "process",
8080
"group": "build",
8181
"command": "dotnet",
@@ -99,7 +99,7 @@
9999
},
100100

101101
{
102-
"label": "build-all-win", // Builds all projects that can be built for Linux (ie not any Windows Forms apps)
102+
"label": "build-all-win", // Builds all projects that can be built for Windows (ie everything)
103103
"group": "build",
104104
"dependsOrder": "sequence",
105105
"dependsOn": [

CodeProject.AI.sln

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
7474
THIRD-PARTY-NOTICES.md = THIRD-PARTY-NOTICES.md
7575
EndProjectSection
7676
EndProject
77+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_PRIVATE REPO", "_PRIVATE REPO", "{78509730-6FBA-44E5-98C0-083DB7F52027}"
78+
ProjectSection(SolutionItems) = preProject
79+
README.txt = README.txt
80+
rebrand.txt = rebrand.txt
81+
EndProjectSection
82+
EndProject
7783
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SDK", "SDK", "{FF0C329F-41E8-4540-BCDB-97690911077D}"
84+
ProjectSection(SolutionItems) = preProject
85+
src\AnalysisLayer\SDK\install.bat = src\AnalysisLayer\SDK\install.bat
86+
src\AnalysisLayer\SDK\install.sh = src\AnalysisLayer\SDK\install.sh
87+
EndProjectSection
7888
EndProject
7989
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ModelRunners", "ModelRunners", "{55C41D48-17AC-4ED5-9440-B42AF65CCE4E}"
8090
EndProject
@@ -255,7 +265,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ObjectDetectionNet", "src\A
255265
EndProject
256266
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CudaVersionCustomAction", "Installers\Windows\CudaVersionCustomAction\CudaVersionCustomAction.csproj", "{214949E0-B56C-4F23-809A-07DA4DBDF925}"
257267
EndProject
258-
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}"
268+
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}"
259269
EndProject
260270
Global
261271
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -470,14 +480,14 @@ Global
470480
{214949E0-B56C-4F23-809A-07DA4DBDF925}.Release|Any CPU.Build.0 = Release|x86
471481
{214949E0-B56C-4F23-809A-07DA4DBDF925}.Release|x86.ActiveCfg = Release|x86
472482
{214949E0-B56C-4F23-809A-07DA4DBDF925}.Release|x86.Build.0 = Release|x86
473-
{BF307B78-E985-4787-A1FC-41D860650F39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
474-
{BF307B78-E985-4787-A1FC-41D860650F39}.Debug|Any CPU.Build.0 = Debug|Any CPU
475-
{BF307B78-E985-4787-A1FC-41D860650F39}.Debug|x86.ActiveCfg = Debug|Any CPU
476-
{BF307B78-E985-4787-A1FC-41D860650F39}.Debug|x86.Build.0 = Debug|Any CPU
477-
{BF307B78-E985-4787-A1FC-41D860650F39}.Release|Any CPU.ActiveCfg = Release|Any CPU
478-
{BF307B78-E985-4787-A1FC-41D860650F39}.Release|Any CPU.Build.0 = Release|Any CPU
479-
{BF307B78-E985-4787-A1FC-41D860650F39}.Release|x86.ActiveCfg = Release|Any CPU
480-
{BF307B78-E985-4787-A1FC-41D860650F39}.Release|x86.Build.0 = Release|Any CPU
483+
{F94FBD1C-02FB-4169-8C26-2D52234D4311}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
484+
{F94FBD1C-02FB-4169-8C26-2D52234D4311}.Debug|Any CPU.Build.0 = Debug|Any CPU
485+
{F94FBD1C-02FB-4169-8C26-2D52234D4311}.Debug|x86.ActiveCfg = Debug|Any CPU
486+
{F94FBD1C-02FB-4169-8C26-2D52234D4311}.Debug|x86.Build.0 = Debug|Any CPU
487+
{F94FBD1C-02FB-4169-8C26-2D52234D4311}.Release|Any CPU.ActiveCfg = Release|Any CPU
488+
{F94FBD1C-02FB-4169-8C26-2D52234D4311}.Release|Any CPU.Build.0 = Release|Any CPU
489+
{F94FBD1C-02FB-4169-8C26-2D52234D4311}.Release|x86.ActiveCfg = Release|Any CPU
490+
{F94FBD1C-02FB-4169-8C26-2D52234D4311}.Release|x86.Build.0 = Release|Any CPU
481491
EndGlobalSection
482492
GlobalSection(SolutionProperties) = preSolution
483493
HideSolutionNode = FALSE
@@ -536,7 +546,7 @@ Global
536546
{4ED567B5-C28D-48BB-AEDC-864E2B2C7204} = {B10B59B5-9F63-41C2-BFBB-6C7311DC4E99}
537547
{25D75AFE-BEC9-43BF-BE44-B9068FF8E395} = {156BFEDA-D477-43B2-92DA-FCC9BAF1F893}
538548
{214949E0-B56C-4F23-809A-07DA4DBDF925} = {83C828B9-2B1E-4982-B4B7-69D173DFBB27}
539-
{BF307B78-E985-4787-A1FC-41D860650F39} = {D982BD8C-2257-413B-8513-8043AB3035F3}
549+
{F94FBD1C-02FB-4169-8C26-2D52234D4311} = {D982BD8C-2257-413B-8513-8043AB3035F3}
540550
EndGlobalSection
541551
GlobalSection(ExtensibilityGlobals) = postSolution
542552
SolutionGuid = {83740BD9-AEEF-49C7-A722-D7703D3A38CB}

demos/dotNet/CodeProject.AI.Explorer/CodeProject.AI.ApiClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class ApiClient
2626
/// <summary>
2727
/// Gets or sets the timeout in seconds for making calls to the API
2828
/// </summary>
29-
public int Timeout { get; set; } = 120;
29+
public int Timeout { get; set; } = 300;
3030

3131
/// <summary>
3232
/// Gets the HttpClient
@@ -49,7 +49,7 @@ private HttpClient Client
4949
_client = new HttpClient
5050
{
5151
BaseAddress = new Uri($"http://localhost:{Port}/v1/"),
52-
Timeout = new TimeSpan(0, 0, Timeout)
52+
Timeout = TimeSpan.FromSeconds(Timeout)
5353
};
5454
}
5555

demos/dotNet/CodeProject.AI.Explorer/Form1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ private async void RunBenchmark(bool useCustom)
504504
ShowError("Image must be selected.");
505505
return;
506506
}
507-
var nIterations = 512;
507+
var nIterations = 100;
508508
var taskList = new List<Task<ResponseBase>>();
509509
Stopwatch sw = Stopwatch.StartNew();
510510
for (int i = 0; i < nIterations; i++){

src/API/Server/Backend/QueueServices.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public QueueServices(IOptions<QueueProcessingOptions> options,
3636
ILogger<QueueServices> logger)
3737
{
3838
_settings = options.Value;
39-
_logger = logger;
39+
_logger = logger;
4040
}
4141

4242
public bool EnsureQueueExists(string queueName)

src/API/Server/FrontEnd/Dockerfile

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,30 @@ RUN dotnet restore "src/API/Server/FrontEnd/Frontend.csproj"
2121
COPY . .
2222

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

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

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

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

3535
FROM build AS publish
3636

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

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

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

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

4949
# zipping up the test images and moving to the server wwwroot directory so it can be downloaded from server.
5050
RUN apt-get update -y && apt-get upgrade -y
@@ -81,14 +81,20 @@ WORKDIR /app
8181
COPY --from=publish /app/publish .
8282
RUN add-apt-repository ppa:deadsnakes/ppa -y
8383
RUN apt update -y
84+
85+
#needed for opencv-python
86+
RUN apt-get install ffmpeg libsm6 libxext6 -y
87+
8488
RUN apt-get install python3.9 -y
8589
RUN python3.8 -m pip install --upgrade pip
8690
RUN python3.9 -m pip install --upgrade pip
8791

8892
# CM: Added --no-cache-dir here to reduce the size of the image
89-
RUN python3.8 -m pip --no-cache-dir install -r /app/AnalysisLayer/Vision/intelligencelayer/requirements.txt
93+
RUN python3.8 -m pip --no-cache-dir install -r /app/AnalysisLayer/Vision/requirements.txt
94+
RUN python3.8 -m pip --no-cache-dir install -r /app/AnalysisLayer/SDK/Python/requirements.txt
9095
#RUN python3.8 -m pip --no-cache-dir install -r /app/AnalysisLayer/TextSummary/requirements.txt
9196
RUN python3.9 -m pip --no-cache-dir install -r /app/AnalysisLayer/BackgroundRemover/requirements.txt
97+
RUN python3.9 -m pip --no-cache-dir install -r /app/AnalysisLayer/SDK/Python/requirements.txt
9298

9399
WORKDIR /app/server
94100
ENTRYPOINT ["dotnet", "CodeProject.AI.Server.dll"]

src/API/Server/FrontEnd/Program.cs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ public static async Task Main(string[] args)
8585
};
8686

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

90+
// TODO: 1. Reorder the config loading so that command line is last
91+
// 2. Stop appsettings being reloaded on change when in docker for the default
92+
// appsettings.json files
8993
IHost? host = CreateHostBuilder(args)
9094
.ConfigureAppConfiguration((hostingContext, config) =>
9195
{
@@ -95,36 +99,36 @@ public static async Task Main(string[] args)
9599
if (inVScode && platform != "windows")
96100
{
97101
config.AddJsonFile(Path.Combine(baseDir, "appsettings.json"),
98-
optional: false, reloadOnChange: true);
102+
optional: false, reloadOnChange: reloadConfigOnChange);
99103

100104
if (!string.IsNullOrWhiteSpace(aspNetEnv))
101105
{
102106
config.AddJsonFile(Path.Combine(baseDir, $"appsettings.{aspNetEnv}.json"),
103-
optional: true, reloadOnChange: true);
107+
optional: true, reloadOnChange: reloadConfigOnChange);
104108
}
105109
}
106110

107111
config.AddJsonFile(Path.Combine(baseDir, $"appsettings.{platform}.json"),
108-
optional: true, reloadOnChange: true);
112+
optional: true, reloadOnChange: reloadConfigOnChange);
109113

110114
// Load appsettings.platform.env.json files to allow slightly more
111115
// convenience for settings on other platforms
112116
if (!string.IsNullOrWhiteSpace(aspNetEnv))
113117
{
114118
config.AddJsonFile(Path.Combine(baseDir, $"appsettings.{platform}.{aspNetEnv}.json"),
115-
optional: true, reloadOnChange: true);
119+
optional: true, reloadOnChange: reloadConfigOnChange);
116120
}
117121

118122
// This allows us to add ad-hoc settings such as ApplicationDataDir
119123
config.AddInMemoryCollection(inMemoryConfigData);
120124

121125
// Load the installconfig.json file so we have access to the install ID
122126
config.AddJsonFile(Path.Combine(applicationDataDir, InstallConfig.InstallCfgFilename),
123-
reloadOnChange: true, optional: true);
127+
reloadOnChange: reloadConfigOnChange, optional: true);
124128

125129
// Load the version.json file so we have access to the Version info
126130
config.AddJsonFile(Path.Combine(baseDir, VersionConfig.VersionCfgFilename),
127-
reloadOnChange: true, optional: true);
131+
reloadOnChange: reloadConfigOnChange, optional: true);
128132

129133
// Load the modulesettings.json files to get analysis module settings
130134
LoadModulesConfiguration(config, aspNetEnv);
@@ -198,6 +202,8 @@ public static async Task Main(string[] args)
198202
// things. To be done at a later date.
199203
private static void LoadModulesConfiguration(IConfigurationBuilder config, string? aspNetEnv)
200204
{
205+
bool reloadOnChange = (Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER") ?? "") != "true";
206+
201207
IConfiguration configuration = config.Build();
202208
var options = configuration.GetSection("FrontEndOptions");
203209
string? rootPath = options["ROOT_PATH"];
@@ -243,21 +249,21 @@ private static void LoadModulesConfiguration(IConfigurationBuilder config, strin
243249
foreach (string? directory in directories)
244250
{
245251
config.AddJsonFile(Path.Combine(directory, "modulesettings.json"),
246-
optional: true, reloadOnChange: true);
252+
optional: true, reloadOnChange: reloadOnChange);
247253

248254
if (!string.IsNullOrEmpty(aspNetEnv))
249255
{
250256
config.AddJsonFile(Path.Combine(directory, $"modulesettings.{aspNetEnv}.json"),
251-
optional: true, reloadOnChange: true);
257+
optional: true, reloadOnChange: reloadOnChange);
252258
}
253259

254260
config.AddJsonFile(Path.Combine(directory, $"modulesettings.{platform}.json"),
255-
optional: true, reloadOnChange: true);
261+
optional: true, reloadOnChange: reloadOnChange);
256262

257263
if (!string.IsNullOrEmpty(aspNetEnv))
258264
{
259265
config.AddJsonFile(Path.Combine(directory, $"modulesettings.{platform}.{aspNetEnv}.json"),
260-
optional: true, reloadOnChange: true);
266+
optional: true, reloadOnChange: reloadOnChange);
261267
}
262268
}
263269
}

0 commit comments

Comments
 (0)