visit-dav / visit

VisIt - Visualization and Data Analysis for Mesh-based Scientific Data
https://visit.llnl.gov
BSD 3-Clause "New" or "Revised" License
408 stars 110 forks source link

VisIt doesn't handle the case where scripts have arguments named the same as VisIt arguments #19616

Open JustinPrivitera opened 3 weeks ago

JustinPrivitera commented 3 weeks ago

Taken from a conversation with a user:

#!/usr/bin/env python3
import argparse
import visit # type: ignore

def cli_args() -> argparse.Namespace:
    parser = argparse.ArgumentParser()
    parser.add_argument('-nn', type=int)
    #parser.add_argument('-nodes', type=int)
    return parser.parse_args(visit.Argv())

def main():
    print(cli_args())

main()
exit()

so if you do visit -nowin -cli -s test.py -nn 1 you'll get an error but if you comment out the -nn and uncomment the -nodes in cli_args and then run visit -nowin -cli -s test.py -nodes 1 then it works

What are our thoughts on this? Should we support this case? At the very least it's a pitfall users can run into.

JustinPrivitera commented 3 weeks ago

At the very least we should put a note here: https://visit-sphinx-github-user-manual.readthedocs.io/en/stable/python_scripting/quickrecipes.html?highlight=Handling%20Command%20line%20arguments%C2%B6#handling-command-line-arguments