-
Notifications
You must be signed in to change notification settings - Fork 18
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
MAINT: IPython history file per host + configurable #381
Conversation
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 guess I should start doing this dataclass-namespace-for-cli-args thing too.
If I understand this right, the way to return to the previous behavior (storing in the ~/.ipython
directory) is to invoke:
hutch-python --hist-file=:memory"
?
hutch_python/cli.py
Outdated
@@ -109,6 +130,20 @@ def configure_ipython_session(): | |||
] | |||
ipy_config.InteractiveShellApp.exec_files = files | |||
|
|||
# Set up history from local disk (not NFS) | |||
if args.hist_file is None: | |||
hist_file = f"/u1/{os.environ['USER']}/hutch-python/history.sqlite" |
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.
So the default is now to have each user write to their own history file? What exactly are the conditions for having a /u1/<user>
directory on a given host? I don't have one on psbuild so this defaults to the standard location (~/.ipython/profile_default/...)
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.
As written this only affects e.g. xppopr running on xpp-daq and similar operator accounts.
If you run as zlentz or on psbuild for example, you'll use the normal per-user file.
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.
Would it be prudent for normal users to have a fallback to some per-host NFS location in the ipython config directory?
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 think so, in the interest of keeping original ipython functionality available. I'd personally have left that as the default, and made the flag generate the file on a local disk.
Is it possible to do:
- no-flag: normal NFS location
- flag, no filename: default hist_file name in
/u1/...
- flag, filename: history at the provided filename?
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'll look into the flexibility of argparse tomorrow, but I agree that I should have made the default behavior no change from normal.
I'd like it to "just work" without too much bash-fu in e.g. the xcs3 launcher script (e.g. if xppopr do this, if not do that... is very annoying).
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 imagine adding just switching the xpppython script to read:
hutch-python --cfg "${HERE}/conf.yml" --hist-file
isn't too invasive, and we can switch it on as we get complaints about it.
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 think nargs='?'
might work here:
parser = argparse.ArgumentParser()
parser.add_argument('--hist-file', dest='hist_file', nargs='?', const='/u1/...')
parser.parse_args([]) # Namespace(hist_file=None)
parser.parse_args(['--hist-file']) # Namespace(hist_file='/u1/...')
parser.parse_args(['--hist-file', 'my_file/path']) # Namespace(hist_file='my_file/path')
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'll implement it exactly as you suggest, it's the cleanest overall and is opt-in
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.
Implemented as suggested, edited a bit so I could include another test, expanded to allow any environment vars, not just user, because why not
You've made me realize that the opr actually has no simple way to return the old previous behavior, as written. The only supported solution is to not make the special folder.
|
I'm a fan of this because it helps vscode keep track of which arg is supposed to be which type |
- Default behavior is now unchanged from before PR - Providing the new cli arg with empty option uses the correct default - Switch to using template strings for easy environment variable inclusions - Added an assert that runs through the const/default case
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.
LGTM, nice little extra mile with the env vars but I'd be immensely surprised if anyone used it.
tbh it just makes it so I can add $HOSTNAME to the default later if we decide to do something like that |
Description
Main changes:
/u1/${USER}/hutch-python/history.sqlite
(local disk)Minor changes:
Motivation and Context
https://jira.slac.stanford.edu/browse/ECS-5096
How Has This Been Tested?
Where Has This Been Documented?
Only here, I need to write pre-release docs
Pre-merge checklist
docs/pre-release-notes.sh
and created a pre-release documentation page