Skip to content

Python rewrite - Enjoy the 50x speedup! #14

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

Merged
merged 6 commits into from
Oct 3, 2021
Merged

Python rewrite - Enjoy the 50x speedup! #14

merged 6 commits into from
Oct 3, 2021

Conversation

unixorn
Copy link
Owner

@unixorn unixorn commented Oct 3, 2021

Description

Rewrote in Python, mainly because the bash was starting to get too large to work with comfortably, and Python's way more maintainable.

On top of that, the original bash version was slow, because there were a lot of cases where it was running lima nerdctl XYZ | jq to parse out information about containers and images, and it wasn't caching the lima nerdctl output.

The Python version caches the image and container information, and is much faster - 0.355 seconds on my MBP, the shell version takes 17.332 seconds.

Closes #7
Closes #8

Checklist

  • All new and existing tests pass.
  • Any added/updated scripts added use #!/usr/bin/env interpreter instead of potentially platform-specific direct paths (#!/bin/sh and #!/bin/bash are allowed exceptions)
  • Added/updated scripts are marked executable
  • Scripts do not have a language file extension unless they are meant to be sourced and not run standalone. No end-user should have to know if a script was written in bash, python, ruby or whatever. Not including file extensions makes it easier to rewrite the script in another language later without having to change every reference to the previous version.
  • I have confirmed that the link(s) in my PR are valid.

License Acceptance

  • This repository is Apache version 2.0 licensed (some scripts may have alternate licensing inline in their code) and by making this PR, I am contributing my changes to the repository under the terms of the Apache 2 license.

- Initial poetry setup
- Add coverage

Signed-off-by: Joe Block <[email protected]>
- Add format and test stanzas to Makefile
- Update requirements stanza in Makefile

Signed-off-by: Joe Block <[email protected]>
The shell version is too slow. Too many calls to `jq` that weren't
cached.

Rewrite in python3 for speed and maintainability.

Signed-off-by: Joe Block <[email protected]>
Some of our operations like VM starts or image pulls can take a while.
Use the notification manager to display notifications before & after we
do a lima operation.

Signed-off-by: Joe Block <[email protected]>
@unixorn unixorn force-pushed the python-conversion branch from 5d40d3f to 084f61d Compare October 3, 2021 00:11
Signed-off-by: Joe Block <[email protected]>
@unixorn unixorn force-pushed the python-conversion branch from 084f61d to d888caf Compare October 3, 2021 00:17
@unixorn unixorn merged commit 1fb3786 into main Oct 3, 2021
@unixorn unixorn deleted the python-conversion branch October 3, 2021 00:23
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.

Add submenu for running containers Python3 rewrite
1 participant