Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading TesseractEngine on Linux #1939

Merged
merged 10 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Oo]bj/
Expand Down
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ repos:
hooks:
# General
- id: check-added-large-files
exclude: |
(?x)^(
src/SmiServices/runtimes/x64/.*|
)$
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-json
Expand Down
4 changes: 3 additions & 1 deletion bin/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def start_containers(
"compose",
"-f", compose_file,
"up",
"--quiet-pull",
"--detach",
"--force-recreate",
)
Expand All @@ -133,7 +134,8 @@ def start_containers(
except subprocess.CalledProcessError:
# NOTE(rkm 2022-03-01) Print container logs when a check fails
cmd = (
f"{docker}-compose",
f"{docker}",
"compose",
"-f", compose_file,
"logs"
)
Expand Down
2 changes: 1 addition & 1 deletion bin/smi/startDockerLinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def main() -> int:
"rabbitmq rabbitmq-diagnostics -q ping",
f"mariadb mysqladmin -uroot -p{args.db_password} status",
"redis /usr/local/bin/redis-cli PING",
f"mssql /opt/mssql-tools/bin/sqlcmd -U sa -P {args.db_password} -l 1 -Q 'SELECT @@VERSION'",
f"mssql /opt/mssql-tools18/bin/sqlcmd -U sa -P {args.db_password} -No -l 1 -Q 'SELECT @@VERSION'",
"mongodb /usr/bin/mongo --quiet --eval 'db.stats().ok'",
),
)
Expand Down
1 change: 1 addition & 0 deletions news/1939-bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix loading of TesseractEngine on Linux
1 change: 1 addition & 0 deletions news/1940-bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bump sqlserver to 2022 in CI to fix startup crash
7 changes: 7 additions & 0 deletions src/SmiServices/SmiServices.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,11 @@
<PackageReference Include="System.IO.Abstractions" />
<PackageReference Include="YamlDotNet" />
</ItemGroup>
<ItemGroup>
<NativeLibs Include="$(MSBuildThisFileDirectory)runtimes\**\*.so" />
<None Include="@(NativeLibs)">
<Link>runtimes\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Binary file not shown.
Binary file added src/SmiServices/runtimes/x64/libtesseract41.so
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using IsIdentifiable;
using IsIdentifiable.Options;
using NUnit.Framework;
using SmiServices.Microservices.IsIdentifiable;
using System.IO;
using Tesseract;

namespace SmiServices.UnitTests.Microservices.IsIdentifiable
{
Expand All @@ -22,5 +24,20 @@ public void TestDataDirectory_Empty()
d.Create();
Assert.Throws<FileNotFoundException>(() => new TesseractStanfordDicomFileClassifier(d, new IsIdentifiableDicomFileOptions()));
}

[Test]
[Platform(Exclude="Win")]
public void TesseractEngine_CanBeConstructed()
{
// Arrange
const string tessdataDirectory = @"../../../../../data/tessdata";
var d = new DirectoryInfo(tessdataDirectory);

TesseractLinuxLoaderFix.Patch();

// Act
// Assert
Assert.DoesNotThrow(() => new TesseractEngine(d.FullName, "eng", EngineMode.Default));
}
}
}
2 changes: 1 addition & 1 deletion utils/docker-compose/linux-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ services:
- 6379:6379
mssql:
container_name: mssql
image: mcr.microsoft.com/mssql/server:2017-latest
image: mcr.microsoft.com/mssql/server:2022-latest
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=${DB_PASSWORD:-YourStrongPassw0rd}
Expand Down
4 changes: 2 additions & 2 deletions utils/docker-compose/linux-dotnet.yml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
},
{
"name": "mcr.microsoft.com/mssql/server",
"tag": "2017-latest",
"digest": "c9832ca564c8410bf13a7d6276a0bf6f5d83d0f6a15c6a5004ba07a04bf93920",
"tag": "2022-latest",
"digest": "8ca3956bcb1f3373e5b04f946a527abb24c07655c2044bd5c9c8852d02fbec7c",
"service": "mssql"
},
{
Expand Down
Loading