Skip to content

Commit

Permalink
Merge pull request #145 from rlizzo/version-0-4-0b0
Browse files Browse the repository at this point in the history
Version 0.4.0b0
  • Loading branch information
rlizzo committed Oct 19, 2019
2 parents 9d66727 + 320006b commit f1c5d05
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 40 deletions.
18 changes: 12 additions & 6 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
[bumpversion]
current_version = 0.3.0
current_version = 0.4.0b0
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<release>[a-z]+)(?P<build>\d+))?
serialize =
{major}.{minor}.{patch}{release}{build}
{major}.{minor}.{patch}

[bumpversion:part:release]
optional_value = rc
values =
b
rc

[bumpversion:file:setup.py]
search = version='{current_version}'
replace = version='{new_version}'

[bumpversion:file:README.rst]
search = v{current_version}.
replace = v{new_version}.

[bumpversion:file:docs/conf.py]
search = version = release = '{current_version}'
replace = version = release = '{new_version}'
Expand All @@ -21,4 +28,3 @@ replace = __version__ = '{new_version}'
[bumpversion:file:src/hangar/diagnostics/__init__.py]
search = __version__ = '{current_version}'
replace = __version__ = '{new_version}'

8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Overview
* - package
- | |version| |wheel| |conda-forge|
| |supported-versions| |supported-implementations|
| |commits-since|
| |license|
.. |docs| image:: https://readthedocs.org/projects/hangar-py/badge/?style=flat
:target: https://readthedocs.org/projects/hangar-py
:alt: Documentation Status
Expand All @@ -31,9 +31,9 @@ Overview
:alt: PyPI Package latest release
:target: https://pypi.org/project/hangar

.. |commits-since| image:: https://img.shields.io/github/commits-since/tensorwerk/hangar-py/v0.3.0.svg
:alt: Commits since latest release
:target: https://github.com/tensorwerk/hangar-py/compare/v0.3.0...master
.. |license| image:: https://img.shields.io/github/license/tensorwerk/hangar-py
:alt: GitHub license
:target: https://github.com/tensorwerk/hangar-py/blob/master/LICENSE

.. |conda-forge| image:: https://img.shields.io/conda/vn/conda-forge/hangar.svg
:alt: Conda-Forge Latest Version
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
year = '2019-2020'
author = 'Richard Izzo'
copyright = '{0}, {1}'.format(year, author)
version = release = '0.3.0'
version = release = '0.4.0b0'

pygments_style = 'default'
pygments_lexer = 'PythonConsoleLexer'
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def read(*names, **kwargs):

setup(
name='hangar',
version='0.3.0',
version='0.4.0b0',
license='Apache 2.0',
description=
'Hangar is version control for tensor data. Commit, branch, merge, revert, and collaborate in the data-defined software era.',
Expand Down
2 changes: 1 addition & 1 deletion src/hangar/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.3.0'
__version__ = '0.4.0b0'
__all__ = ['Repository', 'serve', 'make_tf_dataset', 'make_torch_dataset']

from functools import partial
Expand Down
2 changes: 1 addition & 1 deletion src/hangar/diagnostics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.3.0'
__version__ = '0.4.0b0'

from .graphing import Graph

Expand Down
3 changes: 2 additions & 1 deletion src/hangar/records/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from time import sleep
from time import perf_counter
from random import randint
import string
from typing import Union, NamedTuple, Tuple, Iterable
from hashlib import blake2b

Expand Down Expand Up @@ -56,7 +57,7 @@ def repo_version_raw_spec_from_raw_string(v_str: str) -> VersionSpec:
NamedTuple containing int fileds of `major`, `minor`, `micro` version.
"""
smajor, sminor, smicro = v_str.split('.')
res = VersionSpec(major=int(smajor), minor=int(sminor), micro=int(smicro))
res = VersionSpec(major=int(smajor), minor=int(sminor), micro=int(smicro[0]))
return res


Expand Down
22 changes: 13 additions & 9 deletions src/hangar/records/vcompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .parsing import VersionSpec
from .. import constants as c
from ..context import TxnRegister
from ..utils import pairwise


"""
Expand Down Expand Up @@ -161,7 +162,10 @@ def startup_check_repo_version(repo_path: os.PathLike) -> VersionSpec:
"""


incompatible_changes_after = [VersionSpec(major=0, minor=2, micro=0)]
incompatible_changes_after = [
VersionSpec(major=0, minor=2, micro=0),
VersionSpec(major=0, minor=3, micro=0),
VersionSpec(major=0, minor=4, micro=0)]


def is_repo_software_version_compatible(repo_v: VersionSpec, curr_v: VersionSpec) -> bool:
Expand All @@ -179,12 +183,12 @@ def is_repo_software_version_compatible(repo_v: VersionSpec, curr_v: VersionSpec
bool
True if compatible, False if not.
"""
if repo_v in incompatible_changes_after:
if curr_v.major > repo_v.major:
return False
elif curr_v.minor > repo_v.minor:
return False
elif curr_v.micro > repo_v.micro:
return False

for start, end in pairwise(incompatible_changes_after):
if (repo_v >= start) and (repo_v < end):
if (curr_v < start) or (curr_v >= end):
return False
elif (curr_v >= start) and (curr_v < end):
return True
if (repo_v >= end) and (curr_v < end):
return False
return True
8 changes: 8 additions & 0 deletions src/hangar/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import weakref
from io import StringIO
from functools import partial
from itertools import tee
from typing import Union, Any
import importlib
import types
Expand Down Expand Up @@ -166,6 +167,13 @@ def is_ascii(str_data: str) -> bool:
return True


def pairwise(iterable):
"s -> (s0,s1), (s1,s2), (s2, s3), ..."
a, b = tee(iterable)
next(b, None)
return zip(a, b)


def find_next_prime(N: int) -> int:
"""Find next prime >= N
Expand Down
30 changes: 14 additions & 16 deletions tests/test_initiate.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,23 @@ def test_get_ecosystem_details(managed_tmpdir):

def test_check_repository_version(written_repo):
from hangar import __version__
from pkg_resources import parse_version

repo = written_repo
assert repo.version == __version__
assert repo.version == parse_version(__version__).base_version


def test_check_repository_software_version_startup(managed_tmpdir):
from hangar import Repository, __version__
from pkg_resources import parse_version

repo = Repository(managed_tmpdir, exists=False)
repo.init('test user', 'test@foo.bar', remove_old=True)
repo._env._close_environments()

nrepo = Repository(managed_tmpdir, exists=True)
assert nrepo.initialized is True
assert nrepo.version == __version__
assert nrepo.version == parse_version(__version__).base_version
nrepo._env._close_environments()


Expand All @@ -214,24 +217,19 @@ def test_check_repository_software_version_fails_on_older_repo(managed_tmpdir):
Repository(managed_tmpdir, exists=True)


@pytest.mark.parametrize('failVersions', ['1.0.0', '0.4.0', '0.3.1', '1.4.1'])
def test_check_repository_software_version_fails_on_newer_hangar_version(managed_tmpdir, monkeypatch, failVersions):
import hangar
@pytest.mark.parametrize('futureVersion', ['1.0.0', '0.14.1', '0.15.0', '1.4.1'])
def test_check_repository_software_version_works_on_newer_hangar_version(managed_tmpdir, monkeypatch, futureVersion):
from hangar import Repository
from hangar.records.parsing import repo_version_raw_spec_from_raw_string
from hangar.records import vcompat
from hangar import context

currentVspec = repo_version_raw_spec_from_raw_string(hangar.__version__)
new_incomp = vcompat.incompatible_changes_after
new_incomp.append(currentVspec)
monkeypatch.setattr(vcompat, 'incompatible_changes_after', new_incomp)

repo = Repository(managed_tmpdir, exists=False)
repo.init('test user', 'test@foo.bar', remove_old=True)
old_version = repo.version
# force writing of new software version. should trigger error on next read.
repo._env._close_environments()

monkeypatch.setattr(context, '__version__', failVersions)
with pytest.raises(RuntimeError):
Repository(managed_tmpdir, exists=True)
import hangar
monkeypatch.setattr(hangar, '__version__', futureVersion)
nrepo = Repository(managed_tmpdir, exists=True)
assert hangar.__version__ == futureVersion
assert nrepo.version == old_version
nrepo._env._close_environments()

0 comments on commit f1c5d05

Please sign in to comment.