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

completions - generate_completions script works in py3 #5315

Merged
merged 3 commits into from
May 23, 2024

Conversation

mapellidario
Copy link
Member

@mapellidario mapellidario commented May 14, 2024

fixes #5314

status

tested on my laptop, but i have a small question before merging

solution

This PR serves multiple purposes:

  • make bash autocompletion respect the order at which we provide the commands. see the use of -o nosort in complete -F _UseCrab -o filenames -o nosort crab
  • do not edit the etc/crab-bashpcimpletion.sh directly, generate it programmatically from scripts/generate-completions.py
    • make generate-completions.py work with python3
      • use importlib instead of imp
    • make generate-completions.py generate the completion in our desired ordering, see the use of the weights variable.

open questions:

  • I did not replicate to the variable weights the exact sorting that we have now yet.
    • take a look at etc/crab-bash-completion.sh line 26. the order here is what bash shows when you press crab <tab><tab> (the order of line 32 will be the same as line 26)
    • what is the exact order that we want here?

comment

I decided to revamp the generate_completion.py script because I did not want to think about adding manually all the new commands introduced with crab recover :)

@mapellidario mapellidario added the do not merge the PR is not ready yet, do not merge yet label May 14, 2024
@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Pylint check: failed
    • 8 warnings and errors that must be fixed
    • 22 comments to review
  • Pycodestyle check: succeeded
    • 19 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-CRABClient-PR-test/1057/artifact/artifacts/PullRequestReport.html

@belforte
Copy link
Member

thanks Dario. I am not able to review this. I never knew that generate_completion.py existed and have no idea how and when to use it. Can you simply describe how things will work ?
Do we need to run it by hand every time we add or remove a command and pipe output to etc/crab-bash-completion.sh ?
Do you intend to have GH do this at any PR or tag ?

@belforte
Copy link
Member

And for sure I do not understand the code inside those scripts !

@mapellidario
Copy link
Member Author

I added a commit with and improved comment that i hope is clear enough.

So, at the moment I think we can use it instead of manually editing the file, which means run this script "only" when we add a crab client command or change an option in an existing command.

In the future we can integrate this as part of the crab client build process, so that the completions are generated for every new deployment. I do not think the effort is worth at the moment.

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Pylint check: failed
    • 8 warnings and errors that must be fixed
    • 23 comments to review
  • Pycodestyle check: succeeded
    • 20 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-CRABClient-PR-test/1058/artifact/artifacts/PullRequestReport.html

@mapellidario
Copy link
Member Author

I addressed the some comments from pylint (the ones that i could quickly get rid of without a proper and useless refactoring). If everything goes well, I will merge this PR

@mapellidario mapellidario added Done and removed do not merge the PR is not ready yet, do not merge yet labels May 17, 2024
@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Pylint check: failed
    • 4 warnings and errors that must be fixed
    • 20 comments to review
  • Pycodestyle check: succeeded
    • 19 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-CRABClient-PR-test/1059/artifact/artifacts/PullRequestReport.html

@mapellidario
Copy link
Member Author

jenkins looks good to me, i will merge

@mapellidario mapellidario merged commit 033e254 into dmwm:master May 23, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

crab client bash completions do not respect custom sorting order
3 participants