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

feat: remote access with --server-url

parent aa8e7ce8
No related branches found
No related tags found
1 merge request!23Set of commits to be tagged 0.19.1
...@@ -52,7 +52,7 @@ import|merge|--version|-V) ...@@ -52,7 +52,7 @@ import|merge|--version|-V)
LarvaTagger LarvaTagger
Usage: Usage:
larvatagger open [<file-path>] [--backends=<path>] [--port=<number>] [--quiet] [--viewer] [--browser] [--view-factor=<real>] [--manual-label=<label>] larvatagger open [<file-path>] [--backends=<path>] [--port=<number>] [--server-url=<url>] [--quiet] [--viewer] [--browser] [--view-factor=<real>] [--manual-label=<label>]
larvatagger import <input-path> [<output-file>] [--id=<id>] [--framerate=<fps>] [--pixelsize=<μm>] [--overrides=<comma-separated-list>] [--default-label=<label>] [--manual-label=<label>] [--decode] [--copy-labels] larvatagger import <input-path> [<output-file>] [--id=<id>] [--framerate=<fps>] [--pixelsize=<μm>] [--overrides=<comma-separated-list>] [--default-label=<label>] [--manual-label=<label>] [--decode] [--copy-labels]
larvatagger train <backend-path> <data-path> <model-instance> [--pretrained-model=<instance>] [--labels=<comma-separated-list>] [--sample-size=<N>] [--balancing-strategy=<strategy>] [--class-weights=<csv>] [--manual-label=<label>] [--layers=<N>] [--iterations=<N>] [--seed=<seed>] [--debug] larvatagger train <backend-path> <data-path> <model-instance> [--pretrained-model=<instance>] [--labels=<comma-separated-list>] [--sample-size=<N>] [--balancing-strategy=<strategy>] [--class-weights=<csv>] [--manual-label=<label>] [--layers=<N>] [--iterations=<N>] [--seed=<seed>] [--debug]
larvatagger train <backend-path> <data-path> <model-instance> --fine-tune=<instance> [--balancing-strategy=<strategy>] [--manual-label=<label>] [--iterations=<N>] [--seed=<seed>] [--debug] larvatagger train <backend-path> <data-path> <model-instance> --fine-tune=<instance> [--balancing-strategy=<strategy>] [--manual-label=<label>] [--iterations=<N>] [--seed=<seed>] [--debug]
...@@ -71,6 +71,7 @@ Options: ...@@ -71,6 +71,7 @@ Options:
--pixelsize=<μm> Camera pixel size, in micrometers. --pixelsize=<μm> Camera pixel size, in micrometers.
--backends=<path> Path to backend repository. --backends=<path> Path to backend repository.
--port=<number> Port number the server listens to. --port=<number> Port number the server listens to.
--server-url=<url> Server address, for remote access.
--viewer Disable editing capabilities. --viewer Disable editing capabilities.
--browser Automatically open a browser tab at the served location. --browser Automatically open a browser tab at the served location.
--view-factor=<real> Scaling factor for the larva views; default is 2 on macOS, 1 elsewhere. --view-factor=<real> Scaling factor for the larva views; default is 2 on macOS, 1 elsewhere.
...@@ -104,6 +105,8 @@ Commands: ...@@ -104,6 +105,8 @@ Commands:
The optional positional argument <file-path> can also be the data root directory. The optional positional argument <file-path> can also be the data root directory.
Backends defined in LarvaTagger project root directory are automatically found. Other Backends defined in LarvaTagger project root directory are automatically found. Other
backend locations can be specified with the --backends argument. backend locations can be specified with the --backends argument.
By default, if --server-url is specified, the port is appended to the ip address or
domain name. To prevent this behavior, include the desired port number in the url.
import Generate a label file and store metadata. import Generate a label file and store metadata.
......
...@@ -9,7 +9,7 @@ export main ...@@ -9,7 +9,7 @@ export main
usage = """LarvaTagger.jl - launch the server-based GUI. usage = """LarvaTagger.jl - launch the server-based GUI.
Usage: Usage:
larvatagger-gui.jl [<file-path>] [--backends=<path>] [--port=<number>] [--quiet] [--viewer] [--browser] [--view-factor=<real>] [--manual-label=<label>] larvatagger-gui.jl [<file-path>] [--backends=<path>] [--port=<number>] [--server-url=<url>] [--quiet] [--viewer] [--browser] [--view-factor=<real>] [--manual-label=<label>]
larvatagger-gui.jl -h | --help larvatagger-gui.jl -h | --help
Options: Options:
...@@ -17,6 +17,7 @@ Options: ...@@ -17,6 +17,7 @@ Options:
-q --quiet Do not show instructions. -q --quiet Do not show instructions.
--backends=<path> Path to backend repository. --backends=<path> Path to backend repository.
--port=<number> Port number the server listens to. --port=<number> Port number the server listens to.
--server-url=<url> Server address, for remote access.
--viewer Disable editing capabilities. --viewer Disable editing capabilities.
--browser Automatically open a browser tab at the served location. --browser Automatically open a browser tab at the served location.
--view-factor=<real> Scaling factor for the larva views; default is 2 on macOS, 1 elsewhere. --view-factor=<real> Scaling factor for the larva views; default is 2 on macOS, 1 elsewhere.
...@@ -25,6 +26,9 @@ Options: ...@@ -25,6 +26,9 @@ Options:
The optional positional argument <file-path> can also be the data root directory. The optional positional argument <file-path> can also be the data root directory.
Backends defined in LarvaTagger project root directory are automatically found. Other Backends defined in LarvaTagger project root directory are automatically found. Other
backend locations can be specified with the --backends argument. backend locations can be specified with the --backends argument.
By default, if --server-url is specified, the port is appended to the ip address or domain
name. To prevent this behavior, include the desired port number in the url.
""" """
function main(args=ARGS; exit_on_error=false) function main(args=ARGS; exit_on_error=false)
...@@ -82,12 +86,30 @@ function main(args=ARGS; exit_on_error=false) ...@@ -82,12 +86,30 @@ function main(args=ARGS; exit_on_error=false)
# #
port = parsed_args["--port"] port = parsed_args["--port"]
port = isnothing(port) ? 9284 : parse(Int, port) port = isnothing(port) ? 9284 : parse(Int, port)
server = Server(app, "0.0.0.0", port) proxy_url = parsed_args["--server-url"]
if isnothing(proxy_url)
proxy_url = ""
elseif !startswith(proxy_url, "http")
proxy_url = "http://$(proxy_url)"
end
server = Server(app, "0.0.0.0", port; proxy_url=proxy_url)
port = server.port
if !isempty(proxy_url)
protocol, remainder = split(proxy_url, "://")
if !(':' in remainder)
server.proxy_url = proxy_url = if '/' in remainder
server_name, path = split(remainder, '/'; limit=2)
"$(protocol)://$(server_name):$(port)/$(path)"
else
"$(protocol)://$(remainder):$(port)"
end
end
end
if parsed_args["--browser"] if parsed_args["--browser"]
Bonito.HTTPServer.openurl("http://127.0.0.1:$(port)") Bonito.HTTPServer.openurl("http://127.0.0.1:$(port)")
end end
if verbose if verbose
@info "The server is ready at http://127.0.0.1:$(port)" @info "The server is ready at $(Bonito.HTTPServer.online_url(server, ""))"
end end
if verbose if verbose
@info "Press Ctrl+D to stop the server (or Ctrl+C if in PowerShell)" @info "Press Ctrl+D to stop the server (or Ctrl+C if in PowerShell)"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment