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

Fix history file usage in SQL CLI tool. #1077

Merged
merged 4 commits into from
Nov 23, 2022

Conversation

Yury-Fridlyand
Copy link
Collaborator

Signed-off-by: Yury-Fridlyand yuryf@bitquilltech.com

Description

Changes include:

  • Fix usage of FileHistory.
  • Fix reading history_file and log_file parameters from config.
  • Fix interpreting the default or custom user value.

Config location: ~/.config/opensearchsql-cli/config
Default location for saving history and log files: ~/.config/opensearchsql-cli
Inspired by: https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/examples/prompts/history/persistent-history.py

See team review at Bit-Quill#155

Test

  1. Run SQL CLI in venv (see instructions below)
  2. Run a query
  3. Exit from SQL CLI
  4. Open it back
  5. Hit arrow-up keyboard button

How to test

Ref: https://github.com/opensearch-project/sql/blob/2.x/sql-cli/development_guide.md#development-environment-set-up

Do once:

cd sql-cli
pip install virtualenv
virtualenv venv
pip install --editable .

Then every time you want to debug SQL CLI:

<checkout>
cd sql-cli
source ./venv/bin/activate

To exit from venv:

deactivate

You can run SQL CLI and switch branch. It will keep working with given timeout until closed.

Issues Resolved

Query history didn't persist across SQL CLI runs.

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
Fix history file usage in SQL CLI tool.
@codecov-commenter
Copy link

codecov-commenter commented Nov 15, 2022

Codecov Report

Merging #1077 (5aa0cdc) into 2.x (03f30e3) will decrease coverage by 2.56%.
The diff coverage is n/a.

@@             Coverage Diff              @@
##                2.x    #1077      +/-   ##
============================================
- Coverage     98.27%   95.71%   -2.57%     
  Complexity     3351     3351              
============================================
  Files           327      337      +10     
  Lines          8457     9115     +658     
  Branches        553      672     +119     
============================================
+ Hits           8311     8724     +413     
- Misses          142      334     +192     
- Partials          4       57      +53     
Flag Coverage Δ
query-workbench 62.76% <ø> (?)
sql-engine 98.27% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ublic/components/QueryResults/QueryResultsBody.tsx 68.32% <0.00%> (ø)
...ch/public/components/QueryResults/QueryResults.tsx 61.60% <0.00%> (ø)
...h/public/components/QueryLanguageSwitch/Switch.tsx 85.71% <0.00%> (ø)
workbench/public/components/SQLPage/SQLPage.tsx 100.00% <0.00%> (ø)
workbench/public/utils/PanelWrapper.tsx 100.00% <0.00%> (ø)
workbench/public/components/Header/Header.tsx 100.00% <0.00%> (ø)
workbench/public/application.tsx 0.00% <0.00%> (ø)
workbench/public/components/PPLPage/PPLPage.tsx 56.52% <0.00%> (ø)
workbench/public/components/app.tsx 0.00% <0.00%> (ø)
workbench/public/components/Main/main.tsx 53.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

joshuali925
joshuali925 previously approved these changes Nov 15, 2022
@dai-chen dai-chen added the CLI label Nov 16, 2022
@@ -57,9 +61,21 @@ def __init__(self, clirc_file=None, always_use_pager=False, use_aws_authenticati
self.multiline_continuation_char = config["main"]["multiline_continuation_char"]
self.multi_line = config["main"].as_bool("multi_line")
self.multiline_mode = config["main"].get("multi_line_mode", "src")
self.history_file = config["main"]["history_file"]
self.log_file = config["main"]["log_file"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is this being used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

History file used for history, log file - for logging errors. For example, if config has incorrect path to the history file.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it - do you need to pass this in anywhere like you do the history file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No actually. Good point, thank you. self.log_file removed in f79e5a9.

Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
Copy link
Collaborator

@derek-ho derek-ho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@penghuo penghuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@dai-chen dai-chen merged commit 334cd46 into opensearch-project:2.x Nov 23, 2022
@Yury-Fridlyand Yury-Fridlyand deleted the integ-cli-history-fix branch December 19, 2022 21:37
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

Successfully merging this pull request may close these issues.

6 participants