From e85d0ba7e9e4b4839b6c7ad5a8655cda2ec959a0 Mon Sep 17 00:00:00 2001 From: Kharec Date: Thu, 15 Oct 2026 17:54:44 +0200 Subject: [PATCH] chore: remove marian's duplicate installation check marian.Installed and marian.Files were only used by the package's own test, while the app has its own check in translation.go - with a different rule (pinned size there, size > 0 here), so the two definitions of 'installed' could disagree. The app's check is the canonical one (it owns the pins); Load already fails on an incomplete model, which the test keeps asserting. --- internal/marian/download.go | 10 ---------- internal/marian/marian_test.go | 6 ------ internal/marian/model.go | 3 --- 3 files changed, 19 deletions(-) diff --git a/internal/marian/download.go b/internal/marian/download.go index 8d13540..525502c 100644 --- a/internal/marian/download.go +++ b/internal/marian/download.go @@ -21,16 +21,6 @@ type RemoteFile struct { SHA256 string } -// Installed reports whether dir holds every file of a model. -func Installed(dir string) bool { - for _, f := range Files { - if st, err := os.Stat(filepath.Join(dir, f)); err != nil || st.Size() == 0 { - return false - } - } - return true -} - // Download fetches files into dir. A file already there with the right // size and digest is skipped. A file is downloaded into a ".partial" file // that is renamed only once its digest checks out, so an interrupted diff --git a/internal/marian/marian_test.go b/internal/marian/marian_test.go index 533e1b1..29ff8cb 100644 --- a/internal/marian/marian_test.go +++ b/internal/marian/marian_test.go @@ -251,9 +251,6 @@ func tinyModel(t *testing.T) string { func TestTinyModel(t *testing.T) { dir := tinyModel(t) - if !Installed(dir) { - t.Fatal("tiny model not installed") - } m, err := Load(context.Background(), dir) if err != nil { t.Fatal(err) @@ -281,9 +278,6 @@ func TestTinyModel(t *testing.T) { } os.Remove(filepath.Join(dir, "vocab.json")) - if Installed(dir) { - t.Error("incomplete model reported installed") - } if _, err := Load(context.Background(), dir); err == nil { t.Error("incomplete model loaded") } diff --git a/internal/marian/model.go b/internal/marian/model.go index 86057de..17789f5 100644 --- a/internal/marian/model.go +++ b/internal/marian/model.go @@ -26,9 +26,6 @@ import ( "path/filepath" ) -// Files are the files a model directory must contain. -var Files = []string{"config.json", "model.safetensors", "source.spm", "target.spm", "vocab.json"} - type config struct { DModel int `json:"d_model"` EncoderLayers int `json:"encoder_layers"`