-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into pydantic-v2
- Loading branch information
Showing
9 changed files
with
199 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
"""a backport for the nebari version references.""" | ||
|
||
import re | ||
from importlib.metadata import distribution | ||
|
||
from packaging.version import Version | ||
|
||
__version__ = distribution("nebari").version | ||
|
||
|
||
def rounded_ver_parse(versionstr): | ||
def rounded_ver_parse(version: str) -> Version: | ||
""" | ||
Take a package version string and return an int tuple of only (major,minor,patch), | ||
ignoring and post/dev etc. | ||
Rounds a version string to the nearest patch version. | ||
Parameters | ||
---------- | ||
version : str | ||
A version string. | ||
So: | ||
rounded_ver_parse("0.1.2") returns (0,1,2) | ||
rounded_ver_parse("0.1.2.dev65+g2de53174") returns (0,1,2) | ||
rounded_ver_parse("0.1") returns (0,1,0) | ||
Returns | ||
------- | ||
packaging.version.Version | ||
A version object. | ||
""" | ||
m = re.match( | ||
"^(?P<major>[0-9]+)(\\.(?P<minor>[0-9]+)(\\.(?P<patch>[0-9]+))?)?", versionstr | ||
) | ||
assert m is not None | ||
major = int(m.group("major") or 0) | ||
minor = int(m.group("minor") or 0) | ||
patch = int(m.group("patch") or 0) | ||
return (major, minor, patch) | ||
base_version = Version(version).base_version | ||
return Version(base_version) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from contextlib import nullcontext | ||
|
||
import pytest | ||
|
||
from _nebari.provider.cloud.google_cloud import check_missing_service | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"activated_services, exception", | ||
[ | ||
( | ||
{ | ||
"Compute Engine API", | ||
"Kubernetes Engine API", | ||
"Cloud Monitoring API", | ||
"Cloud Autoscaling API", | ||
"Identity and Access Management (IAM) API", | ||
"Cloud Resource Manager API", | ||
}, | ||
nullcontext(), | ||
), | ||
( | ||
{ | ||
"Compute Engine API", | ||
"Kubernetes Engine API", | ||
"Cloud Monitoring API", | ||
"Cloud Autoscaling API", | ||
"Identity and Access Management (IAM) API", | ||
"Cloud Resource Manager API", | ||
"Cloud SQL Admin API", | ||
}, | ||
nullcontext(), | ||
), | ||
( | ||
{ | ||
"Compute Engine API", | ||
"Kubernetes Engine API", | ||
"Cloud Monitoring API", | ||
"Cloud Autoscaling API", | ||
"Cloud SQL Admin API", | ||
}, | ||
pytest.raises(ValueError, match=r"Missing required services:.*"), | ||
), | ||
], | ||
) | ||
def test_gcp_missing_service(monkeypatch, activated_services, exception): | ||
def mock_return(): | ||
return activated_services | ||
|
||
monkeypatch.setattr( | ||
"_nebari.provider.cloud.google_cloud.activated_services", mock_return | ||
) | ||
with exception: | ||
check_missing_service() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters