Skip to content

Commit

Permalink
Made ProductInfo.version a cached_property to avoid failure when …
Browse files Browse the repository at this point in the history
…comparing wheel uploads in development (#105)

Nightly is failing due to #103
- Made `ProductInfo.version` a `cached_property`, to avoid failure when
comparing wheel uploads in development
- Sorted upgrade scripts to ensure they are applied in semver order
  • Loading branch information
nkvuong authored May 21, 2024
1 parent f073416 commit 2511cf5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/databricks/labs/blueprint/upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def apply(self, ws: WorkspaceClient):
logger.warning(f"No upgrades folder: {upgrades_folder}")
return
applied = self._installation.load_or_default(AppliedUpgrades)
for script in self._diff(upgrades_folder):
for script in sorted(self._diff(upgrades_folder)):
if script.name in applied.upgrades:
logger.info(f"Already applied: {script.name}")
continue
Expand Down
21 changes: 13 additions & 8 deletions src/databricks/labs/blueprint/wheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ def version_file(self) -> Path:
See https://packaging.python.org/guides/single-sourcing-package-version/"""
return self._version_file

def version(self):
@cached_property
def _version(self):
"""Returns current version of the project"""
if hasattr(self, "__version"):
return self.__version # pylint: disable=access-member-before-definition
if not self.is_git_checkout():
# normal install, downloaded releases won't have the .git folder
self.__version = self.released_version()
return self.__version
self.__version = self.unreleased_version()
return self.__version
return self.released_version()
return self.unreleased_version()

def version(self):
return self._version

def as_semver(self) -> SemVer:
"""Returns the version as SemVer object."""
Expand Down Expand Up @@ -334,7 +334,12 @@ class Wheels(WheelsV2):
"""Wheel builder"""

def __init__(
self, ws: WorkspaceClient, install_state: InstallState, product_info: ProductInfo, *, verbose: bool = False
self,
ws: WorkspaceClient,
install_state: InstallState,
product_info: ProductInfo,
*,
verbose: bool = False,
):
warnings.warn("Wheels is deprecated, use WheelsV2 instead", DeprecationWarning)
installation = Installation(ws, product_info.product_name(), install_folder=install_state.install_folder())
Expand Down

0 comments on commit 2511cf5

Please sign in to comment.