Skip to content

Commit

Permalink
[ENH] Update add_data_to_graph.sh to also upload TTL files (#196)
Browse files Browse the repository at this point in the history
* upload .ttl files as well as .jsonld files in a directory

* clarify upload behaviour
  • Loading branch information
alyssadai authored Oct 4, 2023
1 parent f00a1ff commit d6eba9f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions add_data_to_graph.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# ARG_HELP([Upload JSONLD data to a Neurobagel graph])
# ARG_POSITIONAL_SINGLE([dir],[Path to directory containing .jsonld files to be uploaded])
# ARG_HELP([Upload JSONLD and Turtle data to a Neurobagel graph])
# ARG_POSITIONAL_SINGLE([dir],[Path to directory containing .jsonld and/or .ttl files. ALL .jsonld and .ttl files in this directory will be uploaded.])
# ARG_POSITIONAL_SINGLE([graph-url],[Host and port at which to access the graph database to add data to (e.g., localhost:7200)])
# ARG_POSITIONAL_SINGLE([graph-db],[Name of graph database to add data to])
# ARG_POSITIONAL_SINGLE([user],[Username for graph database access])
Expand Down Expand Up @@ -39,9 +39,9 @@ _arg_clear_data="off"

print_help()
{
printf '%s\n' "Upload JSONLD data to a Neurobagel graph"
printf '%s\n' "Upload JSONLD and Turtle data to a Neurobagel graph"
printf 'Usage: %s [-h|--help] [--(no-)clear-data] <dir> <graph-url> <graph-db> <user> <password>\n' "$0"
printf '\t%s\n' "<dir>: Path to directory containing .jsonld files to be uploaded"
printf '\t%s\n' "<dir>: Path to directory containing .jsonld and/or .ttl files. ALL .jsonld and .ttl files in this directory will be uploaded."
printf '\t%s\n' "<graph-url>: Host and port at which to access the graph database to add data to (e.g., localhost:7200)"
printf '\t%s\n' "<graph-db>: Name of graph database to add data to"
printf '\t%s\n' "<user>: Username for graph database access"
Expand Down Expand Up @@ -149,6 +149,12 @@ for db in ${jsonld_dir}/*.jsonld; do
--data-binary @${db}
done

for file in ${jsonld_dir}/*.ttl; do
curl -u "${user}:${password}" -i -X POST http://${graph_url}/${graph_db} \
-H "Content-Type: text/turtle" \
--data-binary @${file}
done

echo "Finished uploading data from ${jsonld_dir} to ${graph_db}"

# ] <-- needed because of Argbash

0 comments on commit d6eba9f

Please sign in to comment.