-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Extend the
validate
command to validate JSONL datasets
Signed-off-by: Juan Cruz Viotti <[email protected]>
- Loading branch information
Showing
8 changed files
with
130 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
if(NOT JSONToolkit_FOUND) | ||
set(JSONTOOLKIT_INSTALL OFF CACHE BOOL "disable installation") | ||
set(JSONTOOLKIT_JSONL OFF CACHE BOOL "disable JSONL support") | ||
add_subdirectory("${PROJECT_SOURCE_DIR}/vendor/jsontoolkit") | ||
set(JSONToolkit_FOUND ON) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
cat << 'EOF' > "$TMP/schema.json" | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"properties": { | ||
"foo": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
EOF | ||
|
||
cat << 'EOF' > "$TMP/instance.jsonl" | ||
{ "foo": "first" } | ||
{ "foo": "second" } | ||
{ "foo": "third" } | ||
EOF | ||
|
||
"$1" validate "$TMP/schema.json" "$TMP/instance.jsonl" 2> "$TMP/output.txt" 1>&2 | ||
|
||
cat << EOF > "$TMP/expected.txt" | ||
EOF | ||
|
||
diff "$TMP/output.txt" "$TMP/expected.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
cat << 'EOF' > "$TMP/schema.json" | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"properties": { | ||
"foo": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
EOF | ||
|
||
cat << 'EOF' > "$TMP/instance.jsonl" | ||
{ "foo": "first" } | ||
{ "foo": "second" } | ||
{ "foo": "third" } | ||
EOF | ||
|
||
"$1" validate "$TMP/schema.json" "$TMP/instance.jsonl" --verbose 2> "$TMP/output.txt" 1>&2 | ||
|
||
cat << EOF > "$TMP/expected.txt" | ||
Interpreting input as JSONL | ||
ok: $(realpath "$TMP")/instance.jsonl (entry #0) | ||
matches $(realpath "$TMP")/schema.json | ||
ok: $(realpath "$TMP")/instance.jsonl (entry #1) | ||
matches $(realpath "$TMP")/schema.json | ||
ok: $(realpath "$TMP")/instance.jsonl (entry #2) | ||
matches $(realpath "$TMP")/schema.json | ||
EOF | ||
|
||
diff "$TMP/output.txt" "$TMP/expected.txt" |