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

lib/scylla_cloud: use functool.cache to cache identify_cloud_async() #514

Merged
merged 1 commit into from
Mar 27, 2024

Conversation

tchaikov
Copy link
Contributor

this change is a follow-up of d97e311, which caches the result of identify_cloud_async() using a global variable. it would be more idiomatic to use functool.cache for caching a costy function like identify_cloud_async(), so in this change we use it for caching. simpler this way. and more importantly, it is more readable.

@tchaikov tchaikov requested a review from syuu1228 March 27, 2024 06:03
@yaronkaikov
Copy link
Collaborator

@tchaikov It seems that this change is breaking tests. please check it as well https://github.com/scylladb/scylla-machine-image/actions/runs/8447372797/job/23137618753?pr=514

@tchaikov
Copy link
Contributor Author

@tchaikov It seems that this change is breaking tests. please check it as well https://github.com/scylladb/scylla-machine-image/actions/runs/8447372797/job/23137618753?pr=514

it does. so we are testing w/ python 3.8.18, while functools.cache was introduced in 3.9! see https://docs.python.org/3/library/functools.html#functools.cache

@tchaikov
Copy link
Contributor Author

@fruch hi Israel, do we need to support python 3.8? on RHEL8 python 3.6 is the default. so we are not likely to be stuck with RHEL8. in RHEL9, Python 3.9 is the default. Fedora 38, 3.11. ubuntu 22.04 3.10. but yeah, ubuntu 20.04, 3.8. so are we trying to be compatible with ubuntu 20.04?

@tchaikov tchaikov marked this pull request as draft March 27, 2024 06:26
@fruch
Copy link
Collaborator

fruch commented Mar 27, 2024

@fruch hi Israel, do we need to support python 3.8? on RHEL8 python 3.6 is the default. so we are not likely to be stuck with RHEL8. in RHEL9, Python 3.9 is the default. Fedora 38, 3.11. ubuntu 22.04 3.10. but yeah, ubuntu 20.04, 3.8. so are we trying to be compatible with ubuntu 20.04?

None of the above, we are using our own python version from scylla-python3, and currently on master it's 3.11 (if I remember correctly)

Copy link
Collaborator

@fruch fruch left a comment

Choose a reason for hiding this comment

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

LGTM

@tchaikov
Copy link
Contributor Author

@fruch thanks for confirmation. lemme bump the github workflow to use Python 3.11 then. that should match with the version we use in production.

@tchaikov

This comment was marked as resolved.

this change is a follow-up of d97e311, which caches the result
of `identify_cloud_async()` using a global variable. it would be
more idiomatic to use `functool.cache` for caching a costy function
like `identify_cloud_async()`, so in this change we use it for
caching. simpler this way. and more importantly, it is more readable.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
@tchaikov tchaikov marked this pull request as ready for review March 27, 2024 07:48
@tchaikov
Copy link
Contributor Author

@fruch good to merge?

@fruch
Copy link
Collaborator

fruch commented Mar 27, 2024

@fruch good to merge?

I think yes

but leave it to @yaronkaikov to take it further (and if needed backport or not)

@tchaikov
Copy link
Contributor Author

ack. it's more of a cleanup. so IMHO, no need to backport.

@yaronkaikov yaronkaikov merged commit c70ef65 into scylladb:next Mar 27, 2024
1 check passed
@tchaikov tchaikov deleted the cached-identify-cloud branch March 27, 2024 11:24
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.

3 participants