Skip to content
Snippets Groups Projects
Commit 53a879ee authored by François  LAURENT's avatar François LAURENT
Browse files

feat: REST api

parent 09e0467f
No related branches found
No related tags found
1 merge request!24Set of commits to be tagged v0.20
Pipeline #153485 passed with stage
in 25 minutes and 4 seconds
This diff is collapsed.
This diff is collapsed.
......@@ -50,8 +50,8 @@ end
function listfiles(tagger::RemoteTagger, srcdir::String)
resp = HTTP.get("$(url(tagger, "list-files"))/$srcdir")
@info "listfiles" transcode(String, resp.body)
String[]
resp = transcode(String, resp.body)
return JSON3.read(resp)
end
function Taggers.pull(tagger::RemoteTagger, destdir::String)
......@@ -85,7 +85,13 @@ end
function Taggers.pushfile(tagger::RemoteTagger, src)
request = url(tagger, "push-file")
@info "dummy push-file" src
filename = basename(src)
content = read(src, String)
# emulate curl's behavior
boundary = "------------------------8vna2TYHERnQGhqhQLdlHq" # whatever
headers = [("Content-Type" => "multipart/form-data; boundary=$boundary")]
body = "$boundary\r\nContent-Disposition: form-data; filename=\"$filename\"\r\nContent-Type: application/octet-steam\r\n\r\n$content\r\n$boundary--\r\n"
HTTP.post(request, headers, body)
end
function Taggers.push(tagger::RemoteTagger, file::String, metadata; clean=true)
......
......@@ -6,6 +6,12 @@ this_script=$(realpath "${BASH_SOURCE[0]}")
larvatagger_jl_project_root=$(dirname "$(dirname "${this_script}")")
larvatagger_project_root=$(dirname "${larvatagger_jl_project_root}")
if [ -z "$JULIA_VERSION" ]; then
JULIA_VERSION=1.10
else
echo "Using environment variable: JULIA_VERSION= $JULIA_VERSION"
fi
tagging_backend=MaggotUBA
tagging_model=20230311
lt_backend_port=9285
......@@ -13,20 +19,23 @@ lt_backend_port=9285
# pre-requisites are similar to rest_server.sh
# pre-compile
julia +1.10 --project="${larvatagger_jl_project_root}" -q -e "using LarvaTagger"
julia "+$JULIA_VERSION" --project="${larvatagger_jl_project_root}" -q -e "using LarvaTagger"
# run and background the backend server
JULIA_PROJECT="${larvatagger_project_root}/TaggingBackends" \
julia +1.10 --project="${larvatagger_jl_project_root}" -i \
julia "+$JULIA_VERSION" --project="${larvatagger_jl_project_root}" -i \
-e "using LarvaTagger.REST.Server; run_backend(\"${larvatagger_project_root}\"; port=${lt_backend_port})" &
lt_backend_pid=$!
# run the frontend server
JULIA="julia +1.10" ${larvatagger_jl_project_root}/scripts/larvatagger-gui.jl http://localhost:${lt_backend_port}
JULIA="julia +$JULIA_VERSION" ${larvatagger_jl_project_root}/scripts/larvatagger-gui.jl http://localhost:${lt_backend_port}
# scenarii:
# * click on "Autotag" prior to loading any files (if not disabled, as with a bug in v0.19)
# * load a tracking data file, and then click on "Autotag"
# * load a tracking data file, and then click on "Autotag";
# expected: a predicted.label is generated and the GUI reloads
# * load a second tracking data file (binary if first was ascii or vice versa), select another model instance, click again on "Autotag";
# expected: a new token was issued + similar outcome as previous step, with tracking data file and tagging model properly identified in the predicted.label file
kill $lt_backend_pid
wait $lt_backend_pid
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment