2025-01-20 13:50.53: New job: test geocaml/ocaml-tiff https://github.com/geocaml/ocaml-tiff.git#refs/pull/5/head (ae384fa1b502f5a49508a856fb0ac3dd86a44842) (linux-x86_64:(lint-fmt)) Base: ocaml/opam:debian-12-ocaml-4.08@sha256:5ed944c28bc353d9e7177b46518ac79c4f79307a96346ab47f69f23048661167 ocamlformat version: version 0.26.2 (from opam) To reproduce locally: git clone --recursive "https://github.com/geocaml/ocaml-tiff.git" && cd "ocaml-tiff" && git fetch origin "refs/pull/5/head" && git reset --hard ae384fa1 cat > Dockerfile <<'END-OF-DOCKERFILE' FROM ocaml/opam:debian-12-ocaml-4.08@sha256:5ed944c28bc353d9e7177b46518ac79c4f79307a96346ab47f69f23048661167 USER 1000:1000 RUN cd ~/opam-repository && (git cat-file -e 82749c0bc5cc2afb8d47b6abd46d44554f7bf5bc || git fetch origin master) && git reset -q --hard 82749c0bc5cc2afb8d47b6abd46d44554f7bf5bc && git log --no-decorate -n1 --oneline && opam update -u RUN opam depext -i dune WORKDIR /src RUN opam depext -i ocamlformat=0.26.2 COPY --chown=1000:1000 . /src/ RUN opam exec -- dune build @fmt --ignore-promoted-rules || (echo "dune build @fmt failed"; exit 2) END-OF-DOCKERFILE docker build . END-REPRO-BLOCK 2025-01-20 13:50.53: Using cache hint "geocaml/ocaml-tiff-ocaml/opam:debian-12-ocaml-4.08@sha256:5ed944c28bc353d9e7177b46518ac79c4f79307a96346ab47f69f23048661167-debian-12-4.08_opam-2.3-ocamlformat-82749c0bc5cc2afb8d47b6abd46d44554f7bf5bc" 2025-01-20 13:50.53: Using OBuilder spec: ((from ocaml/opam:debian-12-ocaml-4.08@sha256:5ed944c28bc353d9e7177b46518ac79c4f79307a96346ab47f69f23048661167) (user (uid 1000) (gid 1000)) (run (cache (opam-archives (target /home/opam/.opam/download-cache))) (network host) (shell "cd ~/opam-repository && (git cat-file -e 82749c0bc5cc2afb8d47b6abd46d44554f7bf5bc || git fetch origin master) && git reset -q --hard 82749c0bc5cc2afb8d47b6abd46d44554f7bf5bc && git log --no-decorate -n1 --oneline && opam update -u")) (run (cache (opam-archives (target /home/opam/.opam/download-cache))) (network host) (shell "opam depext -i dune")) (workdir /src) (run (cache (opam-archives (target /home/opam/.opam/download-cache))) (network host) (shell "opam depext -i ocamlformat=0.26.2")) (copy (src .) (dst /src/)) (run (shell "opam exec -- dune build @fmt --ignore-promoted-rules || (echo \"dune build @fmt failed\"; exit 2)")) ) 2025-01-20 13:50.53: Waiting for resource in pool OCluster 2025-01-20 13:50.53: Waiting for worker… 2025-01-20 13:50.53: Got resource from pool OCluster Building on x86-bm-c3.sw.ocaml.org HEAD is now at d42405c Merge pull request #3 from geocaml/working HEAD is now at ae384fa add tiff data in tiff object (from ocaml/opam:debian-12-ocaml-4.08@sha256:5ed944c28bc353d9e7177b46518ac79c4f79307a96346ab47f69f23048661167) 2025-01-20 13:50.54 ---> using "12d8e57f55730dcaba296a0cfe8a3658e193293e6af74e1cd089421a248727f7" from cache /: (user (uid 1000) (gid 1000)) /: (run (cache (opam-archives (target /home/opam/.opam/download-cache))) (network host) (shell "cd ~/opam-repository && (git cat-file -e 82749c0bc5cc2afb8d47b6abd46d44554f7bf5bc || git fetch origin master) && git reset -q --hard 82749c0bc5cc2afb8d47b6abd46d44554f7bf5bc && git log --no-decorate -n1 --oneline && opam update -u")) 82749c0bc5 Merge pull request #27235 from dbuenzli/erratique-maintenance-intent <><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><> [default] synchronised from file:///home/opam/opam-repository default (at file:///home/opam/opam-repository): [INFO] opam 2.1 and 2.2 include many performance and security improvements over 2.0; please consider upgrading (https://opam.ocaml.org/doc/Install.html) Everything as up-to-date as possible (run with --verbose to show unavailable upgrades). However, you may "opam upgrade" these packages explicitly, which will ask permission to downgrade or uninstall the conflicting packages. Nothing to do. # Run eval $(opam env) to update the current shell environment 2025-01-20 13:51.45 ---> saved as "a687ee6cc32d87a3f6b804864f4567b4f7a2dad6426611dcf9fa12bcb4bad493" /: (run (cache (opam-archives (target /home/opam/.opam/download-cache))) (network host) (shell "opam depext -i dune")) # Detecting depexts using vars: arch=x86_64, os=linux, os-distribution=debian, os-family=debian # No extra OS packages requirements found. # All required OS packages found. # Now letting opam install the packages The following actions will be performed: - install dune 3.17.1 <><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><> [dune.3.17.1] found in cache <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -> installed dune.3.17.1 Done. # Run eval $(opam env) to update the current shell environment 2025-01-20 13:52.42 ---> saved as "6da97e0e7ff7e22b3a082b313e7e1e7712784cf55fbacac401d7a304ec7aaa06" /: (workdir /src) /src: (run (cache (opam-archives (target /home/opam/.opam/download-cache))) (network host) (shell "opam depext -i ocamlformat=0.26.2")) # Detecting depexts using vars: arch=x86_64, os=linux, os-distribution=debian, os-family=debian # No extra OS packages requirements found. # All required OS packages found. # Now letting opam install the packages The following actions will be performed: - install ocaml-version 3.7.3 [required by ocamlformat-lib] - install sexplib0 v0.14.0 [required by base] - install menhirLib 20240715 [required by ocamlformat-lib] - install menhirCST 20240715 [required by menhir] - install menhirSdk 20240715 [required by ocamlformat-lib] - install ocamlbuild 0.15.0 [required by fpath, astring, uuseg] - install either 1.0.0 [required by ocamlformat-lib] - install ocamlfind 1.9.6 [required by ocp-indent, astring, fpath, uuseg] - install cmdliner 1.3.0 [required by ocamlformat] - install result 1.5 [required by ocamlformat-lib] - install seq base [required by re] - install csexp 1.5.2 [required by ocamlformat-lib] - install camlp-streams 5.0.1 [required by ocamlformat-lib] - install dune-build-info 3.17.1 [required by ocamlformat-lib] - install fix 20230505 [required by ocamlformat-lib] - install menhir 20240715 [required by ocamlformat-lib] - install topkg 1.0.7 [required by fpath, astring, uuseg] - install base-bytes base [required by ocp-indent] - install re 1.11.0 [required by ocamlformat] - install dune-configurator 3.17.1 [required by base] - install uutf 1.0.3 [required by ocamlformat-lib] - install astring 0.8.5 [required by ocamlformat-lib] - install ocp-indent 1.8.1 [required by ocamlformat-lib] - install base v0.14.3 [required by ocamlformat-lib] - install uucp 15.0.0 [required by uuseg] - install fpath 0.7.3 [required by ocamlformat-lib] - install stdio v0.14.0 [required by ocamlformat-lib] - install uuseg 15.0.0 [required by ocamlformat-lib] - install ocamlformat-lib 0.26.2 [required by ocamlformat] - install ocamlformat 0.26.2 ===== 30 to install ===== <><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><> [astring.0.8.5] found in cache [base.v0.14.3] found in cache [camlp-streams.5.0.1] found in cache [cmdliner.1.3.0] found in cache [csexp.1.5.2] found in cache [dune-build-info.3.17.1] found in cache [dune-configurator.3.17.1] found in cache [either.1.0.0] found in cache [fix.20230505] found in cache [fpath.0.7.3] found in cache [menhir.20240715] found in cache [menhirCST.20240715] found in cache [menhirLib.20240715] found in cache [menhirSdk.20240715] found in cache [ocaml-version.3.7.3] found in cache [ocamlbuild.0.15.0] found in cache [ocamlfind.1.9.6] found in cache [ocamlformat.0.26.2] found in cache [ocamlformat-lib.0.26.2] found in cache [ocp-indent.1.8.1] found in cache [re.1.11.0] found in cache [result.1.5] found in cache [sexplib0.v0.14.0] found in cache [stdio.v0.14.0] found in cache [topkg.1.0.7] found in cache [uucp.15.0.0] found in cache [uuseg.15.0.0] found in cache [uutf.1.0.3] found in cache <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -> installed seq.base -> installed camlp-streams.5.0.1 -> installed csexp.1.5.2 -> installed either.1.0.0 -> installed fix.20230505 -> installed cmdliner.1.3.0 -> installed menhirCST.20240715 -> installed menhirLib.20240715 -> installed menhirSdk.20240715 -> installed ocaml-version.3.7.3 -> installed re.1.11.0 -> installed result.1.5 -> installed sexplib0.v0.14.0 -> installed dune-build-info.3.17.1 -> installed dune-configurator.3.17.1 -> installed ocamlfind.1.9.6 -> installed base-bytes.base -> installed ocamlbuild.0.15.0 -> installed ocp-indent.1.8.1 -> installed base.v0.14.3 -> installed topkg.1.0.7 -> installed stdio.v0.14.0 -> installed uutf.1.0.3 -> installed astring.0.8.5 -> installed fpath.0.7.3 -> installed menhir.20240715 -> installed uucp.15.0.0 -> installed uuseg.15.0.0 -> installed ocamlformat-lib.0.26.2 -> installed ocamlformat.0.26.2 Done. <><> ocp-indent.1.8.1 installed successfully ><><><><><><><><><><><><><><><><><> => This package requires additional configuration for use in editors. Install package 'user-setup', or manually: * for Emacs, add these lines to ~/.emacs: (add-to-list 'load-path "/home/opam/.opam/4.08/share/emacs/site-lisp") (require 'ocp-indent) * for Vim, add this line to ~/.vimrc: set rtp^="/home/opam/.opam/4.08/share/ocp-indent/vim" # Run eval $(opam env) to update the current shell environment 2025-01-20 13:53.52 ---> saved as "3da96559b3a57f36f5f90bd9cea1f769426433232c7b36cc3d7b00f2f374fe0a" /src: (copy (src .) (dst /src/)) 2025-01-20 13:53.52 ---> saved as "fa47089ea6242e815fc15f1bfb06dd5e88171da0a029751bb4422dba11795227" /src: (run (shell "opam exec -- dune build @fmt --ignore-promoted-rules || (echo \"dune build @fmt failed\"; exit 2)")) File "dune", line 1, characters 0-0: diff --git a/_build/default/dune b/_build/default/.formatted/dune index bed772f..359f2a1 100644 --- a/_build/default/dune +++ b/_build/default/.formatted/dune @@ -11,4 +11,4 @@ (deps test/cea.tiff) (targets cea.tiff) (action - (copy test/cea.tiff cea.tiff))) \ No newline at end of file + (copy test/cea.tiff cea.tiff))) File "src/dune", line 1, characters 0-0: diff --git a/_build/default/src/dune b/_build/default/src/.formatted/dune index d200bcd..1d5b420 100644 --- a/_build/default/src/dune +++ b/_build/default/src/.formatted/dune @@ -1,4 +1,4 @@ (library (name tiff) (public_name tiff) - (libraries fmt cstruct optint eio)) \ No newline at end of file + (libraries fmt cstruct optint eio)) File "main.ml", line 1, characters 0-0: diff --git a/_build/default/main.ml b/_build/default/.formatted/main.ml index ac0f5cb..81d659b 100644 --- a/_build/default/main.ml +++ b/_build/default/.formatted/main.ml @@ -5,7 +5,8 @@ let () = Eio.Switch.run @@ fun sw -> let r = Path.(open_in ~sw (env#fs / Sys.argv.(1))) in let r = File.pread_exact r in - let tiff = Tiff.from_file r in (* need to add data_type as param *) + let tiff = Tiff.from_file r in + (* need to add data_type as param *) let ifd = Tiff.ifd tiff in let entries = Tiff.Ifd.entries ifd in Eio.traceln "%a" Fmt.(list Tiff.Ifd.pp_entry) entries; @@ -15,4 +16,4 @@ let () = let b = Int64.float_of_bits (Cstruct.LE.get_uint64 (List.hd (List.tl bufs)) 0) in - Eio.traceln "%.20f, %.20f" a b \ No newline at end of file + Eio.traceln "%.20f, %.20f" a b File "test/test.ml", line 1, characters 0-0: diff --git a/_build/default/test/test.ml b/_build/default/test/.formatted/test.ml index 09a3a13..6461399 100644 --- a/_build/default/test/test.ml +++ b/_build/default/test/.formatted/test.ml @@ -5,7 +5,7 @@ let () = Eio.Switch.run @@ fun sw -> let r = Path.(open_in ~sw (env#fs / Sys.argv.(1))) in let r = File.pread_exact r in - let tiff = Tiff.from_file r (Tiff.Data.UINT8) in + let tiff = Tiff.from_file r Tiff.Data.UINT8 in let ifd = Tiff.ifd tiff in let entries = Tiff.Ifd.entries ifd in Eio.traceln "%a" Fmt.(list Tiff.Ifd.pp_entry) entries; @@ -19,4 +19,4 @@ let () = (Tiff.Ifd.data_offsets ifd); Eio.traceln "counts: %a" Fmt.(list ~sep:(any ", ") int) - (Tiff.Ifd.data_bytecounts ifd) \ No newline at end of file + (Tiff.Ifd.data_bytecounts ifd) File "src/tiff.mli", line 1, characters 0-0: diff --git a/_build/default/src/tiff.mli b/_build/default/src/.formatted/tiff.mli index bfb406c..4282289 100644 --- a/_build/default/src/tiff.mli +++ b/_build/default/src/.formatted/tiff.mli @@ -173,8 +173,8 @@ module Ifd : sig (** {2 Reading entries} *) (* val read_entry_short : entry -> int - (** Reads the value of the entry as a short if the entry field matches - otherwise it will raise [Invalid_argument _]. *) *) + (** Reads the value of the entry as a short if the entry field matches + otherwise it will raise [Invalid_argument _]. *) *) val read_entry : entry -> int (** Reads the value of the entry as a short if the entry field matches @@ -188,17 +188,15 @@ end module Data : sig type data_type = UINT8 | FLOAT - type ('a, 'b) tiff_data = ('a, 'b, c_layout) Array1.t - - type t = - | UInt8Data of (int, int8_unsigned_elt) tiff_data - | FloatData of (float, float64_elt) tiff_data - - exception TiffDataHasWrongType + type t = + | UInt8Data of (int, int8_unsigned_elt) tiff_data + | FloatData of (float, float64_elt) tiff_data + exception TiffDataHasWrongType end + type t (** A TIFF file *) File "src/tiff.ml", line 1, characters 0-0: diff --git a/_build/default/src/tiff.ml b/_build/default/src/.formatted/tiff.ml index b751290..941710a 100644 --- a/_build/default/src/tiff.ml +++ b/_build/default/src/.formatted/tiff.ml @@ -276,11 +276,11 @@ module Ifd = struct let lookup_exn e tag = List.find (fun e -> e.tag = tag) e (* let read_entry e = - match e.field with - | Short -> e.offset |> Int64.to_int - | _ -> - raise - (Invalid_argument (Fmt.str "Bad entry for short read: %a" pp_entry e)) *) + match e.field with + | Short -> e.offset |> Int64.to_int + | _ -> + raise + (Invalid_argument (Fmt.str "Bad entry for short read: %a" pp_entry e)) *) let read_entry e = match e.field with @@ -292,12 +292,8 @@ module Ifd = struct let height e = lookup_exn e.entries ImageLength |> read_entry let width e = lookup_exn e.entries ImageWidth |> read_entry - let rows_per_strip e = lookup_exn e.entries RowsPerStrip |> read_entry - - let samples_per_pixel e = - lookup_exn e.entries SamplesPerPixel |> read_entry - + let samples_per_pixel e = lookup_exn e.entries SamplesPerPixel |> read_entry let add_int optint i = Optint.Int63.(add optint (of_int i)) let get_dataset_offsets endian entries reader = @@ -567,7 +563,7 @@ module Ifd = struct | _ -> invalid_arg "GeoKeyDirectory Malformed!" let get_geo_entries t = t.geo_entries - + let pp ppf t = Fmt.pf ppf "version: %i, revision: %i, minor: %i, count: %i\n" t.version t.revision t.minor @@ -697,92 +693,99 @@ module Ifd = struct { entries; data_offsets; data_bytecounts; ro = reader; header } end - module Data = struct - type data_type = UINT8 | FLOAT - type ('a, 'b) tiff_data = ('a, 'b, c_layout) Array1.t type t = - | UInt8Data of (int, int8_unsigned_elt) tiff_data - | FloatData of (float, float64_elt) tiff_data - - exception TiffDataHasWrongType + | UInt8Data of (int, int8_unsigned_elt) tiff_data + | FloatData of (float, float64_elt) tiff_data + + exception TiffDataHasWrongType let read_strip_uint8 ro strip_offset strip_bytecount index arr = let buf = Cstruct.create strip_bytecount in let opt_strip_offset = Optint.Int63.of_int strip_offset in ro ~file_offset:opt_strip_offset [ buf ]; - - for i = 0 to strip_bytecount - 1 do (* Loop should go to strip_bytecount - 1 *) + + for i = 0 to strip_bytecount - 1 do + (* Loop should go to strip_bytecount - 1 *) let uint8_value = Cstruct.get_uint8 buf i in - Array1.set arr (index + i) uint8_value; + Array1.set arr (index + i) uint8_value done; - index + 1 - - - let rec read_data_helper_uint8 ro strip_offsets strip_bytecounts index arr = - match strip_offsets, strip_bytecounts with + index + 1 + + let rec read_data_helper_uint8 ro strip_offsets strip_bytecounts index arr = + match (strip_offsets, strip_bytecounts) with | [], [] -> arr - | _, [] -> raise (Invalid_argument "Strip offsets list bigger than strip bytecounts list") - | [], _ -> raise (Invalid_argument "Strip bytecounts list bigger than strip offsets list") - | offset::strip_offsets, bytecount::strip_bytecounts -> - let index = read_strip_uint8 ro offset bytecount index arr in - read_data_helper_uint8 ro strip_offsets strip_bytecounts index arr - - - let read_data_uint8 ro strip_offsets strip_bytecounts rows_per_strip image_width = - let strip_offsets_length = List.length strip_offsets in - if strip_offsets_length = (List.length strip_bytecounts) then - let array_length = (strip_offsets_length * rows_per_strip * image_width) in + | _, [] -> + raise + (Invalid_argument + "Strip offsets list bigger than strip bytecounts list") + | [], _ -> + raise + (Invalid_argument + "Strip bytecounts list bigger than strip offsets list") + | offset :: strip_offsets, bytecount :: strip_bytecounts -> + let index = read_strip_uint8 ro offset bytecount index arr in + read_data_helper_uint8 ro strip_offsets strip_bytecounts index arr + + let read_data_uint8 ro strip_offsets strip_bytecounts rows_per_strip + image_width = + let strip_offsets_length = List.length strip_offsets in + if strip_offsets_length = List.length strip_bytecounts then + let array_length = strip_offsets_length * rows_per_strip * image_width in let data_array = Array1.create int8_unsigned c_layout array_length in read_data_helper_uint8 ro strip_offsets strip_bytecounts 0 data_array - else - raise (OffsetsBytecountsDifferentLengthsError "strip_offsets and strip_bytecounts are of different lengths") - + else + raise + (OffsetsBytecountsDifferentLengthsError + "strip_offsets and strip_bytecounts are of different lengths") + let read_strip_float32 ro strip_offset strip_bytecount index arr = let buf = Cstruct.create strip_bytecount in let opt_strip_offset = Optint.Int63.of_int strip_offset in ro ~file_offset:opt_strip_offset [ buf ]; - + (* Each 32-bit float takes 4 bytes, so we process `strip_bytecount / 4` floats *) for i = 0 to (strip_bytecount / 4) - 1 do let int_value = Cstruct.LE.get_uint32 buf (i * 4) in let float_value = Int32.float_of_bits int_value in - Array1.set arr (index + i) float_value; + Array1.set arr (index + i) float_value done; index + (strip_bytecount / 4) - - - let rec read_data_helper_float32 ro strip_offsets strip_bytecounts index arr = - match strip_offsets, strip_bytecounts with + + let rec read_data_helper_float32 ro strip_offsets strip_bytecounts index arr = + match (strip_offsets, strip_bytecounts) with | [], [] -> arr - | _, [] -> raise (OffsetsBytecountsDifferentLengthsError "Strip offsets list is bigger than strip bytecounts list") - | [], _ -> raise (OffsetsBytecountsDifferentLengthsError "Strip bytecounts list is bigger than strip offsets list") - | offset:: strip_offsets, bytecount:: strip_bytecounts -> - let index = read_strip_float32 ro offset bytecount index arr in - read_data_helper_float32 ro strip_offsets strip_bytecounts index arr - - - let read_data_float32 ro strip_offsets strip_bytecounts rows_per_strip image_width = + | _, [] -> + raise + (OffsetsBytecountsDifferentLengthsError + "Strip offsets list is bigger than strip bytecounts list") + | [], _ -> + raise + (OffsetsBytecountsDifferentLengthsError + "Strip bytecounts list is bigger than strip offsets list") + | offset :: strip_offsets, bytecount :: strip_bytecounts -> + let index = read_strip_float32 ro offset bytecount index arr in + read_data_helper_float32 ro strip_offsets strip_bytecounts index arr + + let read_data_float32 ro strip_offsets strip_bytecounts rows_per_strip + image_width = let strip_offsets_length = List.length strip_offsets in - if strip_offsets_length = (List.length strip_bytecounts) then - let array_length = (strip_offsets_length * rows_per_strip * image_width) in + if strip_offsets_length = List.length strip_bytecounts then + let array_length = strip_offsets_length * rows_per_strip * image_width in let data_array = Array1.create float64 c_layout array_length in read_data_helper_float32 ro strip_offsets strip_bytecounts 0 data_array - else - raise (OffsetsBytecountsDifferentLengthsError "strip_offsets and strip_bytecounts are of different lengths") + else + raise + (OffsetsBytecountsDifferentLengthsError + "strip_offsets and strip_bytecounts are of different lengths") end -type t = { - header : header; - ifd : Ifd.t; - data: Data.t -} +type t = { header : header; ifd : Ifd.t; data : Data.t } let ifd t = t.ifd - let data t = t.data let from_file (f : File.ro) (data_type : Data.data_type) = @@ -790,17 +793,23 @@ let from_file (f : File.ro) (data_type : Data.data_type) = let ifd = Ifd.v ~file_offset:header.offset header f in let data_offsets = Ifd.data_offsets ifd in let data_bytecounts = Ifd.data_bytecounts ifd in - let rows_per_strip = Ifd.rows_per_strip ifd in - let width = Ifd.width ifd in + let rows_per_strip = Ifd.rows_per_strip ifd in + let width = Ifd.width ifd in (* reads whole tiff file into memory every time... *) - let data = + let data = match data_type with | Data.UINT8 -> - let data_arr = Data.read_data_uint8 f data_offsets data_bytecounts rows_per_strip width in - Data.UInt8Data(data_arr) - | Data.FLOAT -> - let data_arr = Data.read_data_float32 f data_offsets data_bytecounts rows_per_strip width in - Data.FloatData(data_arr) + let data_arr = + Data.read_data_uint8 f data_offsets data_bytecounts rows_per_strip + width + in + Data.UInt8Data data_arr + | Data.FLOAT -> + let data_arr = + Data.read_data_float32 f data_offsets data_bytecounts rows_per_strip + width + in + Data.FloatData data_arr in { header; ifd; data } dune build @fmt failed "/usr/bin/env" "bash" "-c" "opam exec -- dune build @fmt --ignore-promoted-rules || (echo "dune build @fmt failed"; exit 2)" failed with exit status 2 2025-01-20 13:53.54: Job failed: Failed: Build failed