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

Specifying parser in a function using non-module reference #10

Open
thedannymarsh opened this issue Jan 28, 2022 · 2 comments
Open

Specifying parser in a function using non-module reference #10

thedannymarsh opened this issue Jan 28, 2022 · 2 comments

Comments

@thedannymarsh
Copy link

I have a function in a file which parses arguments:

def get_args():
    #Set up parser and top level args
    parser = argparse.ArgumentParser(description='ASCENT: Automated Simulations to Characterize Electrical Nerve Thresholds')
    parser.add_argument('run_indices', nargs = '+', help = 'Space separated indices to submit NEURON sims for')
    parser.add_argument('-p','--partition', help = 'If submitting on a cluster, overrides default partition assignment')
    args = parser.parse_args()
    return args

This file is not part of a module, therefore I am using the filename to point to the function:


Command-Line Arguments
***********************

submit.py
---------

.. argparse::
   :filename: ../../src/neuron/submit.py
   :func: parser
   :prog: submit.py

This results in the following error:

Exception occurred:
  File "/home/docs/checkouts/readthedocs.org/user_builds/ascent-docs/envs/latest/lib/python3.7/site-packages/sphinxarg/ext.py", line 476, in run
    func = mod[attr_name]
KeyError: 'parser'

I am assuming since it is contained within a function, sphinx-argparse cannot find the parser object. How can I point to the parser within the function get_args()?

Thanks!

@psychpsych
Copy link

Hi,
I'm having the same issue. Any updates?

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