visit-dav / visit

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

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

Open JustinPrivitera opened 5 months ago

JustinPrivitera commented 5 months 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 5 months 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

cyrush commented 4 months ago

Also add a warning when this case occurs (visit args that appear after -s being eaten by visit)

JustinPrivitera commented 4 months ago
Traceback (most recent call last):
  File "/usr/gapps/visit/bin/frontendlauncher.py", line 416, in <module>
    ret = internallauncher(launcher, visitdir, progname, ver, visitpluginver, visitargs)
  File "/usr/gapps/visit/3.4.1/bin/internallauncher", line 3787, in internallauncher
    return launcher.Launch()
  File "/usr/gapps/visit/3.4.1/bin/internallauncher", line 3575, in Launch
    args = submitter.CreateCommand(args, debugger)
  File "/usr/gapps/visit/3.4.1/bin/internallauncher", line 153, in CreateCommand
    parcmd = parcmd + [self.PPNArgument(), self.PPN()]
  File "/usr/gapps/visit/3.4.1/bin/internallauncher", line 77, in PPN
    return str(int(math.ceil(float(self.parallel.np) / float(self.parallel.nn))))
TypeError: float() argument must be a string or a number, not 'NoneType'
JustinPrivitera commented 4 months ago

moving -nn 1 before the script name doesn't work.

-nn itself is broken.

cyrush commented 4 months ago

^C[harrison37@zeliak ascent-checkout (task/2024_07_tutorial_updates)]$ visit -nowin -nn 1 -cli 
Running: cli3.4.1 -nowin -engineargs -l;mpiexec;-nn;1 -launchengine localhost
Running: viewer3.4.1 -nowin -noint -engineargs -l;mpiexec;-nn;1 -host 127.0.0.1 -port 5600 -launchengine localhost
Traceback (most recent call last):
  File "/Users/harrison37/Desktop/VisIt.app/Contents/Resources/bin/frontendlauncher.py", line 416, in <module>
    ret = internallauncher(launcher, visitdir, progname, ver, visitpluginver, visitargs)
  File "/Users/harrison37/Desktop/VisIt.app/Contents/Resources/3.4.1/bin/internallauncher", line 3787, in internallauncher
    return launcher.Launch()
  File "/Users/harrison37/Desktop/VisIt.app/Contents/Resources/3.4.1/bin/internallauncher", line 3575, in Launch
    args = submitter.CreateCommand(args, debugger)
  File "/Users/harrison37/Desktop/VisIt.app/Contents/Resources/3.4.1/bin/internallauncher", line 223, in CreateCommand
    parcmd = parcmd + [self.PPNArgument(), self.PPN()]
  File "/Users/harrison37/Desktop/VisIt.app/Contents/Resources/3.4.1/bin/internallauncher", line 77, in PPN
    return str(int(math.ceil(float(self.parallel.np) / float(self.parallel.nn))))
TypeError: float() argument must be a string or a number, not 'NoneType'
``