-
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] Support encoding and decoding JSONL datasets
Signed-off-by: Juan Cruz Viotti <[email protected]>
- Loading branch information
Showing
6 changed files
with
114 additions
and
18 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
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,31 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
cat << 'EOF' > "$TMP/document.jsonl" | ||
{ "count": 1 } | ||
{ "count": 2 } | ||
{ "count": 3 } | ||
{ "count": 4 } | ||
{ "count": 5 } | ||
EOF | ||
|
||
"$1" encode "$TMP/document.jsonl" "$TMP/output.binpack" > "$TMP/output.txt" 2>&1 | ||
xxd "$TMP/output.binpack" > "$TMP/output.hex" | ||
|
||
cat << 'EOF' > "$TMP/expected.txt" | ||
00000000: 1306 636f 756e 7415 1300 091d 1300 0525 ..count........% | ||
00000010: 1300 052d 1300 0535 ...-...5 | ||
EOF | ||
|
||
cat << 'EOF' > "$TMP/expected-output.txt" | ||
total size: 24 bytes | ||
EOF | ||
|
||
diff "$TMP/expected.txt" "$TMP/output.hex" | ||
diff "$TMP/output.txt" "$TMP/expected-output.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,37 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
cat << 'EOF' > "$TMP/document.jsonl" | ||
{ "count": 1 } | ||
{ "count": 2 } | ||
{ "count": 3 } | ||
{ "count": 4 } | ||
{ "count": 5 } | ||
EOF | ||
|
||
"$1" encode "$TMP/document.jsonl" "$TMP/output.binpack" --verbose > "$TMP/output.txt" 2>&1 | ||
xxd "$TMP/output.binpack" > "$TMP/output.hex" | ||
|
||
cat << 'EOF' > "$TMP/expected.txt" | ||
00000000: 1306 636f 756e 7415 1300 091d 1300 0525 ..count........% | ||
00000010: 1300 052d 1300 0535 ...-...5 | ||
EOF | ||
|
||
cat << EOF > "$TMP/expected-output.txt" | ||
Interpreting input as JSONL: $(realpath "$TMP")/document.jsonl | ||
Encoding entry #0 | ||
Encoding entry #1 | ||
Encoding entry #2 | ||
Encoding entry #3 | ||
Encoding entry #4 | ||
total size: 24 bytes | ||
EOF | ||
|
||
diff "$TMP/expected.txt" "$TMP/output.hex" | ||
diff "$TMP/output.txt" "$TMP/expected-output.txt" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.