Skip to content

Commit

Permalink
Fix ocannl_config parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
lukstafi committed Dec 29, 2024
1 parent 5104527 commit f48985d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 11 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
## [0.5.0] -- current
## [0.5.1] -- current

## Added

- Automatic transfers to host from the context that most recently updated a node.

## Fixed

- Added `#` as alternative to `~~` for comment lines in `ocannl_config` files, and a bug in parsing.

## [0.5.0] -- 2024-12-18

### Added

Expand Down
8 changes: 5 additions & 3 deletions arrayjit/lib/utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ let config_file_args =
in
Stdio.printf "\nWelcome to OCANNL! Reading configuration defaults from %s.\n%!" fname;
config_lines
|> List.filter ~f:(Fn.non @@ String.is_prefix ~prefix:"~~")
|> List.filter ~f:(fun l ->
not (String.is_prefix ~prefix:"~~" l || String.is_prefix ~prefix:"#" l))
|> List.map ~f:(String.split ~on:'=')
|> List.filter_map ~f:(function
| [] -> None
| [ s ] when String.is_empty s -> None
| key :: [ v ] ->
let key =
String.(
Expand All @@ -133,9 +135,9 @@ let config_file_args =
if String.is_prefix key ~prefix:"ocannl" then String.drop_prefix key 6 else key
in
Some (String.strip ~drop:(equal_char '_') key, v)
| _ ->
| l ->
failwith @@ "OCANNL: invalid syntax in the config file " ^ fname
^ ", should have a single '=' on each non-empty line")
^ ", should have a single '=' on each non-empty line, found: " ^ String.concat l)
|> Hashtbl.of_alist_exn (module String)
| Some _ ->
Stdio.printf "\nWelcome to OCANNL! Configuration defaults file is disabled.\n%!";
Expand Down

0 comments on commit f48985d

Please sign in to comment.