Skip to content

Commit

Permalink
added set height after shard is built
Browse files Browse the repository at this point in the history
  • Loading branch information
F483 committed Aug 15, 2015
1 parent fb9a8a0 commit ad77dfe
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@ devsetup: clean
@virtualenv -p /usr/bin/python3 env/py3

@# install esky for builds (required before setup :/)
@env/py2/bin/pip install esky
@env/py3/bin/pip install esky
@#env/py2/bin/pip install esky
@#env/py3/bin/pip install esky

@# install dependencies
@env/py2/bin/python setup.py develop
@env/py3/bin/python setup.py develop

@# install usefull dev tools
@# install dataserv for tests
@env/py2/bin/pip install dataserv
@env/py3/bin/pip install dataserv

@# install usefull dev tools
@env/py2/bin/pip install ipython
@env/py3/bin/pip install ipython
@env/py2/bin/pip install pudb
Expand Down
7 changes: 5 additions & 2 deletions dataserv_client/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,12 @@ def poll(self, register_address=False, delay=common.DEFAULT_DELAY,
def build(self, cleanup=False, rebuild=False):
"""TODO doc string"""
self._ensure_address_given()
bldr = builder.Builder(self.address, common.SHARD_SIZE, self.max_size)
def on_generate_shard(height, seed, file_hash):
self._querry('/api/height/{0}/{1}'.format(self.address, height))
bldr = builder.Builder(self.address, common.SHARD_SIZE, self.max_size,
on_generate_shard=on_generate_shard)
generated = bldr.build(self.store_path, debug=self.debug,
cleanup=cleanup, rebuild=rebuild)
height = len(generated)
self._querry('/api/height/{0}/{1}'.format(self.address, height))
return generated # FIXME check where height is expected and fix it
return generated
6 changes: 5 additions & 1 deletion dataserv_client/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

class Builder:

def __init__(self, address, shard_size, max_size):
def __init__(self, address, shard_size, max_size, on_generate_shard=None):
self.address = address
self.shard_size = shard_size
self.max_size = max_size
self.on_generate_shard = on_generate_shard

@staticmethod
def sha256(content):
Expand Down Expand Up @@ -59,6 +60,9 @@ def build(self, store_path, debug=False, cleanup=False, rebuild=False):
if (not will_generate) and debug:
print("Skipping seed {0}. Already exists.".format(seed))

if self.on_generate_shard:
self.on_generate_shard(shard_num + 1, seed, file_hash)

return generated

def clean(self, store_path):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@
install_requires=[
'RandomIO == 0.2.1',
'future == 0.15.0', # for python 2.7 support
'partialhash == 1.1.0'
],
tests_require=[
'dataserv',
'coverage',
'coveralls'
],
Expand Down

0 comments on commit ad77dfe

Please sign in to comment.