Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Panaetius committed Apr 27, 2022
1 parent 239ea7b commit e798e1f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
5 changes: 4 additions & 1 deletion renku/command/command_builder/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ def _injection_pre_hook(self, builder: Command, context: dict, *args, **kwargs)
try:
with open(client.database_path / "project", "r") as f:
project = json.load(f)
minimum_renku_version = Version(project.get("minimum_renku_version"))
min_version = project.get("minimum_renku_version")
if min_version is None:
return
minimum_renku_version = Version(min_version)
except (KeyError, OSError, json.JSONDecodeError):
# NOTE: We don't check minimum version if there's no project metadata available
return
Expand Down
5 changes: 3 additions & 2 deletions renku/domain_model/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from renku.core.util.os import normalize_to_ascii
from renku.domain_model.provenance.agent import Person
from renku.domain_model.provenance.annotation import Annotation
from renku.version import __minimum_project_version__


class Project(persistent.Persistent):
Expand All @@ -37,8 +38,8 @@ class Project(persistent.Persistent):
keywords: List[str] = list()

# NOTE: the minimum version of renku to needed to work with a project
# This should be bumped on metadata version changes and when we do non forward-compatible on-the-fly migrations
minimum_renku_version: str = "1.2.0"
# This should be bumped on metadata version changes and when we do not forward-compatible on-the-fly migrations
minimum_renku_version: str = __minimum_project_version__

def __init__(
self,
Expand Down
1 change: 1 addition & 0 deletions renku/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

__version__ = "0.0.0"
__template_version__ = "0.3.1"
__minimum_project_version__ = "1.2.0"


def is_release():
Expand Down
8 changes: 4 additions & 4 deletions tests/core/commands/test_renku.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def mocked_getter(self, key):
try:
Command().command(lambda: "").with_database(write=False).build().execute()
except errors.MinimumVersionError:
assert False, "Shouldn't raise an exception"
pytest.fail("Shouldn't raise an exception.")

# NOTE: Check doesn't raise with higher current version
mocker.patch("renku.domain_model.project.Project.minimum_renku_version", "0.9.0")
Expand All @@ -64,7 +64,7 @@ def mocked_getter(self, key):
try:
Command().command(lambda: "").with_database(write=False).build().execute()
except errors.MinimumVersionError:
assert False, "Shouldn't raise an exception"
pytest.fail("Shouldn't raise an exception.")
assert "0.9.0" == project.minimum_renku_version

# NOTE: Check that accessing a project with newer version fails
Expand All @@ -84,7 +84,7 @@ def mocked_getter(self, key):
try:
Command().command(lambda: "").with_database(write=False).build().execute()
except errors.MinimumVersionError:
assert False, "Shouldn't raise an exception"
pytest.fail("Shouldn't raise an exception.")

# NOTE: Assert that minimum_version is increased on write
mocker.patch("renku.domain_model.project.Project.minimum_renku_version", "1.0.0")
Expand All @@ -94,5 +94,5 @@ def mocked_getter(self, key):
try:
Command().command(lambda: "").with_database(write=True).build().execute()
except errors.MinimumVersionError:
assert False, "Shouldn't raise an exception"
pytest.fail("Shouldn't raise an exception.")
assert "1.0.0" == project.minimum_renku_version

0 comments on commit e798e1f

Please sign in to comment.