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
DM -20325: Add interactive option #44
Conversation
af75940
to
42ce4c0
Compare
Turns out, I'm not ready for review yet. |
2337abb
to
c74ae38
Compare
OK. Now ready. I'd be open to suggestions on how to test the command line tool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about automatically falling back to the prompt if the other ways of getting a password in aren't used?
@@ -128,6 +129,12 @@ def parse_args(): | |||
default=False, | |||
help='Ignore data blobs even if they are available in the verification' | |||
'job.') | |||
parser.add_argument( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend dropping the flag and if neither the args.api_password
is set nor is the SQUASH_password
set, then automatically fallback to prompting for the password.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to do that, but then I realized that in non-interactive situations it will hang forever if neither is set. That seemed like a bad failure mode.
My other thought was to fall back to prompting, but put a timeout on the input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to do that, but then I realized that in non-interactive situations it will hang forever if neither is set. That seemed like a bad failure mode.
I think that's fine, to be honest. Most jobs will timeout on their own if it actually happens.
I can't think of any command line program that has a command line option to open an interactive prompt rather than doing it automatically if necessary, so this --interactive
option seems to run against convention.
self.api_password = getpass.getpass(prompt="SQuaSH password: ") | ||
else: | ||
self.api_password = (args.api_password or | ||
os.getenv('SQUASH_password')) | ||
if not self.test and self.api_password is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't recall what self.test
is, but I think you'd want to make the logic for opening a prompt also be bypass-able through the self.test
flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean bypass if --interactive
is set and test
is set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the --test
flag was set by a user, don't use getpass.getpass
to request a password since that password won't be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, you might want to update the help string for the --password
option to say something along the lines that if neither --password
nor $SQUASH_password
are set, the program will prompt you for a password.
c74ae38
to
9c2e087
Compare
@jonathansick is this more to your liking? |
9c2e087
to
bc00585
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect thanks. Just one more idea about the help message :)
@@ -182,7 +183,7 @@ def parse_args(): | |||
dest='api_password', | |||
metavar='PASSWORD', | |||
help='Password for SQUASH API. Equivalent to the $SQUASH_PASSWORD ' | |||
'environment variable.') | |||
'environment variable. If neither is set, user will be prompted.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user -> you
This will keep passwords secret when running from the command line.
bc00585
to
c2d9751
Compare
This will keep passwords secret when running from the command line.
{Summary of changes. Prefix PR title with ticket handle.}
Preview the docs at: https://pipelines.lsst.io/v/DM-FIXME