Skip to content

Commit 95112db

Browse files
committed
Fix release OCR script paths
1 parent de24eba commit 95112db

6 files changed

Lines changed: 33 additions & 15 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ external backup.
208208
The production image is published to GitHub Container Registry:
209209

210210
```sh
211-
docker pull ghcr.io/cfbender/manavault:0.1.0
211+
docker pull ghcr.io/cfbender/manavault:0.2.0
212212
```
213213

214214
Generate a secret for production cookies:
@@ -229,7 +229,7 @@ docker run -d \
229229
-v "$PWD/data:/data" \
230230
-e SECRET_KEY_BASE="$(mise exec -- mix phx.gen.secret)" \
231231
-e PHX_HOST=localhost \
232-
ghcr.io/cfbender/manavault:0.1.0
232+
ghcr.io/cfbender/manavault:0.2.0
233233
```
234234

235235
Health check:
@@ -289,8 +289,8 @@ Expected tags:
289289

290290
- `latest` from the default branch
291291
- branch tags from branch pushes
292-
- `0.1.0` and `0.1` from tag `v0.1.0`
293-
- `v0.1.0` from the raw tag ref
292+
- `0.2.0` and `0.2` from tag `v0.2.0`
293+
- `v0.2.0` from the raw tag ref
294294

295295
## Roadmap
296296

lib/manavault/catalog/image_matcher.ex

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ defmodule Manavault.Catalog.ImageMatcher do
1010
import Bitwise
1111
require Logger
1212

13-
@hash_script Path.join(:code.priv_dir(:manavault), "image_hash.py")
1413
@default_limit 5
1514
@default_threshold 0.82
1615

@@ -100,7 +99,9 @@ defmodule Manavault.Catalog.ImageMatcher do
10099
defp hash_paths([], _crop), do: {:ok, %{}}
101100

102101
defp hash_paths(paths, crop) do
103-
case System.cmd(rapidocr_python_path(), [@hash_script, crop | paths], stderr_to_stdout: true) do
102+
case System.cmd(rapidocr_python_path(), [hash_script_path(), crop | paths],
103+
stderr_to_stdout: true
104+
) do
104105
{output, 0} ->
105106
decode_hash_output(output)
106107

@@ -111,6 +112,10 @@ defmodule Manavault.Catalog.ImageMatcher do
111112
ErlangError -> {:error, "image hash Python environment is not available"}
112113
end
113114

115+
defp hash_script_path do
116+
Application.app_dir(:manavault, "priv/image_hash.py")
117+
end
118+
114119
defp decode_hash_output(output) do
115120
with {:ok, decoded} <- Jason.decode(output) do
116121
hashes =

lib/manavault/catalog/rapidocr_daemon.ex

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ defmodule Manavault.Catalog.RapidOCRDaemon do
99
use GenServer
1010
require Logger
1111

12-
@python_path Path.expand(".venv/bin/python", File.cwd!())
13-
@script_path Path.join(:code.priv_dir(:manavault), "rapidocr_daemon.py")
1412
@read_timeout 60_000
1513

1614
# --- Public API ---
@@ -44,10 +42,11 @@ defmodule Manavault.Catalog.RapidOCRDaemon do
4442

4543
defp start_port do
4644
port =
47-
Port.open({:spawn, "#{@python_path} #{@script_path}"}, [
45+
Port.open({:spawn_executable, rapidocr_python_path()}, [
4846
:binary,
4947
:use_stdio,
50-
:exit_status
48+
:exit_status,
49+
args: [rapidocr_script_path()]
5150
])
5251

5352
receive do
@@ -69,6 +68,18 @@ defmodule Manavault.Catalog.RapidOCRDaemon do
6968
{:error, Exception.message(e)}
7069
end
7170

71+
defp rapidocr_python_path do
72+
Application.get_env(
73+
:manavault,
74+
:rapidocr_python,
75+
Path.expand(".venv/bin/python", File.cwd!())
76+
)
77+
end
78+
79+
defp rapidocr_script_path do
80+
Application.app_dir(:manavault, "priv/rapidocr_daemon.py")
81+
end
82+
7283
@impl true
7384
def handle_call({:recognize, _image_path}, _from, %{port: nil} = state) do
7485
{:reply, :not_running, state}

lib/manavault/catalog/scan_recognition.ex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,6 @@ defmodule Manavault.Catalog.ScanRecognition do
499499
Application.get_env(:manavault, :ocr_runner, &rapidocr_ocr/1)
500500
end
501501

502-
@rapidocr_script Path.join(:code.priv_dir(:manavault), "rapidocr_scan.py")
503-
504502
defp rapidocr_python_path do
505503
Application.get_env(
506504
:manavault,
@@ -509,6 +507,10 @@ defmodule Manavault.Catalog.ScanRecognition do
509507
)
510508
end
511509

510+
defp rapidocr_script_path do
511+
Application.app_dir(:manavault, "priv/rapidocr_scan.py")
512+
end
513+
512514
defp rapidocr_ocr(image_path) do
513515
# Try the persistent daemon first (fast, model already loaded).
514516
# Fall back only to the one-shot RapidOCR script if the daemon is not running.
@@ -529,7 +531,7 @@ defmodule Manavault.Catalog.ScanRecognition do
529531
end
530532

531533
defp fallback_ocr(image_path) do
532-
case System.cmd(rapidocr_python_path(), [@rapidocr_script, image_path],
534+
case System.cmd(rapidocr_python_path(), [rapidocr_script_path(), image_path],
533535
stderr_to_stdout: true
534536
) do
535537
{text, 0} when is_binary(text) and byte_size(text) > 0 ->

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defmodule Manavault.MixProject do
44
def project do
55
[
66
app: :manavault,
7-
version: "0.1.0",
7+
version: "0.2.0",
88
elixir: "~> 1.20",
99
elixirc_paths: elixirc_paths(Mix.env()),
1010
start_permanent: Mix.env() == :prod,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "manavault",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"private": true,
55
"description": "ManaVault Phoenix application with Capacitor native shell tooling.",
66
"scripts": {

0 commit comments

Comments
 (0)