def cached_or_fail

mlbend-datasets@0.1.6.0 · main.bend:261

import mlbend-datasets@0.1.6.0/main.bend as MlbendDatasets
import Base
import mlbend-huggingface@0.1.1.0/main.bend as Hf

261# A table from the cache when it is there. With MLBEND_DATA set the cache is
262# the source of the run: a miss is an error, not a quiet fetch, or the
263# manifest would hash one file and the program would read another.
264def cached_or_fail(m: Maybe<&1, String>, +repo: String, +path: String, header: Bool,
265  drop: Nat) -> IO(Result<&1, &1, Hf.Err, Table>):
266  match m:
267    case Some{text}:
268      IO.pure(Result<&1, &1, Hf.Err, Table>, Done{csv_text(text, header, drop)})
269    case None{}:
270      IO.pure(Result<&1, &1, Hf.Err, Table>,
271        Fail{Hf.ErrNet{0, String.append("MLBEND_DATA: no readable file at ",
272          String.append(repo, String.append("/", path)))}})

Uses (11)

Used by (1)