-
Notifications
You must be signed in to change notification settings - Fork 1
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
Autocompletion of ioc and version #60
Autocompletion of ioc and version #60
Conversation
The performance is not amazing - some caching would help speed up subsequent calls |
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.
This looks really promising. One other thing we need completion on is files in the file system.
e.g. when you type:
ec ioc deploy-local iocs/ tab tab
I had hoped that typer would have built in support for this but I did not find it when I looked, so you may have to resort to implementing your own using PathLib.
src/epics_containers_cli/git.py
Outdated
tag | ||
""" | ||
check_beamline_repo(beamline_repo) | ||
typer.echo(f"Available instance versions for {ioc_name}:") | ||
|
||
run_command(f"git clone {beamline_repo} {folder}", interactive=False) |
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.
shallow clone would probably help here
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, as this is a cli, we could lazily clone this the first time we need it, grab the info out of it and store it as a global, then use it multiple times
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.
Or we could make it a pure function with no side effects (i.e. clone, get instance and version info, delete, then return info) and cache 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 believe we need the full history to get all the available tags for each IOC so I don't believe shallow clone is an option. Im not sure the global works as each auto complete is a new run of the code, or is there a nice way to have persistent variables i am not aware of? Giles and I did discuss creating a graph of IOCs and versions once and just sharing it as you have mentioned. I have an attempt at pure functions like you have descibed and I think it works quite well but I will try a graph approach as well
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 you only need to list the tags, what about git ls-remote --tags <repo>
?
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.
Its not just listing the tags - there is a relationship between the tags and last changes to the IOC
* Attempt caching for autocomplete * Create available IOC & version graph
@marcelldls this looks really good. I have tried it and it works well. Things still to do (you probably already know this but let's make sure we are on the same page):
|
|
From that issue:
That can't be right surely? If you use |
I believe if it expects a string but you dont give it a list of strings to use for auto complete it reverts to some behavior which is a path autocompletion I think this is a click issue which is broken for Path type arguments - which should be giving nice path autocompletion. The problem with the work around to use str arguments is that you dont get the built in path validation. I have found my own work around which is to give an autocompletion function which returns [] - this seems to force path autocompletion and still retain the path validation |
Let's make sure we get a minimum reproduction of this issue reported to typer, please. |
Just trying this out and it looks freakin awesome! Some pedantry:
I just checked and |
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'm happy with this now.
I feel like we could go ahead and merge, then add some unit tests when you return from vacation.
@marcelldls much better error handling. One niggle: (ec-venv) (python3.11) (ioc-autocomplete) [hgv27681@pc0116 epics-containers-cli]$ ec ioc exec Please set EC_K8S_NAMESPACE or pass --namespace
Please set EC_K8S_NAMESPACE or pass --namespace
docs/ get_helm.sh .github/ LICENSE pyproject.toml src/ .vscode/
environment.sh .git/ .gitignore .pre-commit-config.yaml README.rst tests/
(ec-venv) (python3.11) (ioc-autocomplete) [hgv27681@pc0116 epics-containers-cli]$ ec ioc exec We still get the file completion after printing the error message, which could be confusing. |
Something is horribly wrong: (ec-venv) (python3.11) (dev) [hgv27681@pc0116 bl20j]$ ec ioc deploy-local iocs/bl20j-
bl20j-di-phdgn-02/ bl20j-di-phdgn-03/ bl20j-di-phdgn-05/ bl20j-di-phdgn-07/ bl20j-di-phdgn-08/ bl20j-mo-brick-06/
(ec-venv) (python3.11) (dev) [hgv27681@pc0116 bl20j]$ ec ioc deploy bl20j-
bl20j-di-ioc-01 bl20j-ea-phdgn-02 bl20j-ea-phdgn-03 bl20j-ea-phdgn-05 bl20j-ea-phdgn-07 bl20j-ea-phdgn-08 What I have in my iocs folder and what is available to deploy disagree - this is probably my issue rather than yours. |
Fair enough. A difficulty is if you dont want that you have to give something to autocomplete... (ec-dev) (base) vboxuser@Ubuntu-dev:~/WIP/epics-containers-cli$ ec ioc attach Please set EC_K8S_NAMESPACE or pass --namespace
Please set EC_K8S_NAMESPACE or pass --namespace
Please set EC_K8S_NAMESPACE or pass --namespace
Please set EC_K8S_NAMESPACE or pass --namespace But I dont really understand fully why it works |
Yep I think that is better. |
So I got my bl20j repo to look OK: (ec-venv) (python3.11) (dev) [hgv27681@pc0116 bl20j]$ ec ioc deploy-local iocs/bl20j-
bl20j-di-phdgn-02/ bl20j-di-phdgn-03/ bl20j-di-phdgn-05/ bl20j-di-phdgn-07/ bl20j-di-phdgn-08/ bl20j-mo-brick-06/
(ec-venv) (python3.11) (dev) [hgv27681@pc0116 bl20j]$ ec ioc deploy bl20j-
bl20j-di-phdgn-02 bl20j-di-phdgn-03 bl20j-di-phdgn-05 bl20j-di-phdgn-07 bl20j-di-phdgn-08 bl20j-mo-brick-06 The thing that I did was push my changes to main (from dev). It's not clear to me why this was needed. I have been putting my tags on the dev branch for that repo (and probably should not be doing that!). Perhaps I will allow working in the main branch for beamline repos anyway - anything else seems to make extra work. |
* More general ioc versions function * Add autocomplete skeleton * More skeleton code * Implement autocomplete * Linting * Ioc autocomplete cached (#2) * Attempt caching for autocomplete * Create available IOC & version graph * Add catch for version autocomplete * Remove caching from ioc instances call * Handle --repo option * Implement unique cache per domain repo * Ignore files present in iocs/ * Add workaround for path autocompletion * Add kubectl autocompletions * Change ec logs autocomplete to running iocs * Add some typing + error handling for autocomplete * Ignore typer deprecated warning * Make mypy happier * Linting * Make autocomplete keyerror behavior consistant * Autocomplete with error rather than files * fix instances test * Fix f-string for failed test * Include directory context manager addition --------- Co-authored-by: Giles Knap <[email protected]>
Possibly resolves #46 - have only applied to deploy command