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

Create a macro utility function to parse the version of dependencies #2023

Open
parthea opened this issue May 2, 2024 · 0 comments
Open
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: cleanup An internal cleanup or hygiene concern.

Comments

@parthea
Copy link
Contributor

parthea commented May 2, 2024

See this comment from PR #1999 related to duplication of code to extract the version.

# Test the case when there is a universe mismatch from the client.
#
# TODO: Make this test unconditional once the minimum supported version of
# google-api-core becomes 2.15.0 or higher.
api_core_major, api_core_minor = [int(part) for part in api_core_version.__version__.split(".")[0:2]]
if api_core_major > 2 or (api_core_major == 2 and api_core_minor >= 15):
client = client_class(client_options={"universe_domain": "bar.com"}, transport=transport_class(credentials=ga_credentials.AnonymousCredentials(),))
with pytest.raises(ValueError) as excinfo:
client._validate_universe_domain()
assert str(excinfo.value) == "The configured universe domain (bar.com) does not match the universe domain found in the credentials (googleapis.com). If you haven't configured the universe domain explicitly, `googleapis.com` is the default."

We're using this construct to get the version number of a dependency in other places as well. We should factor it out into a static member function that can be called like this is_version_atleast(api_core_version, (2,19,0))

No need to block this PR, but we should at least file an issue. And come to think of it, we should consider wherever we have version strings, to have the SoT be a tuple like (2, 19, 0, "rc0"). The version string can then be automatically constructed from the tuple, and we would continue to export it. But we would also export the tuple. This would get rid of string splitting/manipulation in various places of the generated code.

@parthea parthea added the type: cleanup An internal cleanup or hygiene concern. label May 2, 2024
@vchudnov-g vchudnov-g added the priority: p2 Moderately-important priority. Fix may not be included in next release. label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: cleanup An internal cleanup or hygiene concern.
Projects
None yet
Development

No branches or pull requests

2 participants