carlobaldassi / ArgParse.jl

Package for parsing command-line arguments to Julia programs.
Other
236 stars 36 forks source link

First argument parsed incorrectly #117

Open cirobr opened 2 years ago

cirobr commented 2 years ago

Consider the following code, written on a Jupyter notebook:

using ArgParse

function parse_commandline()
    s = ArgParseSettings()
    @add_arg_table s begin
        "arg1"
            help     = "learning rate"
            default  = 0.001

        "arg2"
            help     = "minibatch size for dataloader"
            default  = 1

        "arg3"
            help     = "number of epochs"
            default  = 10
    end

    return parse_args(ARGS, s)
end

parsed_args = parse_commandline()

When executed correctly, it gives the following reply:

Dict{String, Any} with 3 entries:
  "arg1" => 0.001
  "arg2" => 1
  "arg3" => 10

I have two computers running latest Ubuntu 20.04 and Julia 1.6.7, presenting very adverse results:

Whenever failure occurs, output is as follows:

Dict{String, Any} with 3 entries:
  "arg1" => "/home/myuser/.local/share/jupyter/runtime/kernel-v2-1571XvxDGHmL0T9W…
  "arg2" => 1
  "arg3" => 10

Despite extensive effort, could not find the cause and fix it.

Any advise is appreciated. Thanks.

mahiki commented 3 months ago

This issue is interesting, but old. Please close it unless poster responds.

carlobaldassi commented 2 months ago

I don't think we should close this, someone may still experience the problem and figure out what's going wrong. That is, unless the issue got magically solved by upgrades in Julia. @cirobr is the problem still present with the latest Julia version?

cirobr commented 2 months ago

Cheers, I'm no longer using argparse for handling arguments. Instead, the command parse() works flawlessly under all circumstances.