Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First argument parsed incorrectly #117

Open
cirobr opened this issue Aug 3, 2022 · 3 comments
Open

First argument parsed incorrectly #117

cirobr opened this issue Aug 3, 2022 · 3 comments

Comments

@cirobr
Copy link

cirobr commented Aug 3, 2022

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:

  • On REPL, both execute the code correctly;
  • On VS-Code, PC-A runs the code correctly, but PC-B does not;
  • On Anaconda Jupyter, PC-B runs the code with failure, whilst PC-A does not.

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
Copy link

mahiki commented Aug 6, 2024

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

@carlobaldassi
Copy link
Owner

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
Copy link
Author

cirobr commented Aug 26, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants