Skip to content

Commit

Permalink
Owl_io.head: avoid log message about assertion failure on large CSV file
Browse files Browse the repository at this point in the history
Executing `Owl_dataframe.of_csv "large.csv"` prints:
```
2023-04-13 14:01:52.922 WARN : Owl_io.head: ignored exception File "src/base/misc/owl_io.ml", line 138, characters 9-15: Assertion failed
```

Using assertions for control-flow (early exit of loop) seems wrong,
and causes log messages to be shown on the console.
Raise an [End_of_file] exception instead which will be handled by the
iteration function just as if the file ended early.
Use [raise_notrace] because the exception is immediately caught and we
don't need a backtrace.

Signed-off-by: Edwin Török <[email protected]>
  • Loading branch information
edwintorok committed Apr 13, 2023
1 parent 48434ea commit 688782d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/base/misc/owl_io.ml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ let head n fname =
(try
iteri_lines_of_file
(fun i s ->
assert (i < n);
if i >= n then raise_notrace End_of_file;
Owl_utils.Stack.push lines s)
fname
with
Expand Down

0 comments on commit 688782d

Please sign in to comment.