-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add list-jdks and list-vendors commands #22
Conversation
August 2024 update of my thoughts relating to the above:
|
6263565
to
5951468
Compare
And simplify the existing _match_version function by delegating to the new _match_versions. Technically this is slower time-complexity-wise, but it's also more Pythonic, with performance unlikely to matter for the number of available JDKs in the index.
It's helpful to be able to query the index to know what is available.
* list-jdks -> ls * list-vendors -> ls-vendors
9a53465
to
2b0bca3
Compare
And add some type hints around adjacent functions, too. And rename _cached_index function to _cached_index_path because it returns a Path, not an Index dict.
And let `ls --available` list all matches from the index.
Most things above are now done. Still to do:
|
So that the computed data structures are consumable, rather than only printed.
This patch is kind of horrible, but it gets the job done correctly for more challenging version strings like 21.0.1+12_openj9-0.42.0.
I believe everything is addressed now. Probably simplest to just read through the patches to see how I solved various things. Happy to elaborate verbally here as needed. The CI should pass now as well. Edit: I should probably add more tests, but... 😴 |
@marktsuchida What do you think? Is this a good direction? |
Yes! Thanks so much for this. |
I'll write some tests right now. |
_api: - _get_vendors - _get_jdks _conf: - configure: fallback_to_default_vendor=False _index: - jdk_url: exact_version=non-None - _postprocess_index - _match_versions
* Add ls and ls-vendors commands. * Rename cache-jdk command to cache.
@marktsuchida OK, all set. The tests are pretty basic, but do cover the new functions. Here's a code coverage report diff from diff --git a/../before.txt b/../after.txt
index 2e11e0e..8547965 100644
--- a/../before.txt
+++ b/../after.txt
@@ -2,26 +2,26 @@
Name Stmts Miss Cover
-------------------------------------------------------------
src/cjdk/__init__.py 3 0 100%
-src/cjdk/_api.py 56 12 79%
+src/cjdk/_api.py 96 17 82%
src/cjdk/_cache.py 128 11 91%
-src/cjdk/_conf.py 113 13 88%
+src/cjdk/_conf.py 114 13 89%
src/cjdk/_download.py 51 8 84%
-src/cjdk/_index.py 81 7 91%
-src/cjdk/_install.py 16 0 100%
+src/cjdk/_index.py 106 8 92%
+src/cjdk/_install.py 17 0 100%
src/cjdk/_jdk.py 33 0 100%
src/cjdk/_progress.py 62 26 58%
src/cjdk/_version.py 11 2 82%
tests/mock_server.py 80 0 100%
-tests/test_api.py 68 0 100%
+tests/test_api.py 97 0 100%
tests/test_cache.py 83 3 96%
tests/test_cache_atomic_file.py 114 15 87%
tests/test_cache_permanent_directory.py 54 3 94%
tests/test_cjdk.py 16 0 100%
-tests/test_conf.py 107 0 100%
+tests/test_conf.py 110 0 100%
tests/test_download.py 84 1 99%
-tests/test_index.py 98 0 100%
+tests/test_index.py 115 0 100%
tests/test_install.py 38 2 95%
tests/test_jdk.py 43 0 100%
tests/test_mock_server.py 25 0 100%
-------------------------------------------------------------
-TOTAL 1364 103 92%
+TOTAL 1480 109 93% I have no idea if I got the syntax right for the directives in the docs, but I followed existing patterns. |
Pushed a commit to clarify test results. I can fix the tests for macOS and Windows. |
It's not an error for the versions to be empty unless we are trying to resolve to a single version.
(Better if we avoid remote-dependent unit tests, or course, but I'll leave that for another time :)
Also avoid printing an empty line when the result is empty.
Thanks again, @ctrueden, for putting the work into this! I've reviewed all your changes and pushed a few minor changes. The main one is to move the print-to-stdout from Python API to CLI (so that the API functions return the data to the caller instead). The only other thing I might change is that I feel that |
This patchset adds a command to list matching JDKs, and another to list available vendors.
I don't love it, so I dragged my feet before filing this PR, but the two new commands ostensibly work.
I already discussed these changes directly with @marktsuchida 1.5 years ago now... as a starting point for discussion, here is a transcript of that conversation:
@ctrueden wrote:
@marktsuchida: We could build our own index, or supplement it. Either by forking and extending the original one (it's Scala code) or upstreaming, or by making cjdk use multiple indexes.
@ctrueden: Supplementing the index would make sense to me... I'll see if anyone filed an issue in the Coursier repo.
@ctrueden: Heh, they don't have Issues. So yeah, either updating their code to include it, or making cjdk support unioning multiple indices. Eh, punting!
@marktsuchida wrote:
@ctrueden: Agreed about
ls
overlist-jdks
. This is also the command used bypass
for example. (git
usesls-files
but I just aliased it.)