Skip to content

Commit bbeb450

Browse files
committed
Merge branch 'master' of github.com:pywren/pywren-ibm-cloud
2 parents abe975d + 8b21af0 commit bbeb450

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

install_pywren.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
#!/bin/sh
2-
LAST_RELEASE=`wget -q --no-check-certificate https://api.github.com/repos/pywren/pywren-ibm-cloud/releases/latest -O - | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'`
3-
echo "Installing PyWren for IBM Cloud Functions - Release $LAST_RELEASE ..."
2+
if [ -z "$1" ]
3+
then
4+
# If no version provided, get last release
5+
RELEASE=`wget -q --no-check-certificate https://api.github.com/repos/pywren/pywren-ibm-cloud/releases/latest -O - | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'`
6+
else
7+
RELEASE=$1
8+
fi
9+
10+
echo "Installing PyWren for IBM Cloud Functions - Release $RELEASE ..."
411
rm -rf pywren-ibm-cloud* > /dev/null
5-
wget --no-check-certificate 'https://github.com/pywren/pywren-ibm-cloud/archive/'$LAST_RELEASE'.zip' -O pywren-ibm-cloud.zip 2> /dev/null
12+
wget --no-check-certificate 'https://github.com/pywren/pywren-ibm-cloud/archive/'$RELEASE'.zip' -O pywren-ibm-cloud.zip 2> /dev/null
613
unzip pywren-ibm-cloud.zip > /dev/null
7-
mv pywren-ibm-cloud-$LAST_RELEASE pywren-ibm-cloud
14+
mv pywren-ibm-cloud-$RELEASE pywren-ibm-cloud
815
cd pywren-ibm-cloud/pywren; pip install -U . > /dev/null
916
echo "done!"

pywren/pywren_ibm_cloud/partitioner.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ def __init__(self, sb, size, byterange):
228228
self.eof = False
229229

230230
def read(self, n=None):
231+
if self.eof:
232+
raise EOFError()
231233
# Data always contain one byte from the previous chunk,
232234
# so l'ets check if it is a \n or not
233235
self.first_byte = self.sb.read(self.plusbytes)
@@ -238,24 +240,22 @@ def read(self, n=None):
238240

239241
self.pos += len(retval)
240242

241-
first_row_end_pos = 0
243+
first_row_start_pos = 0
242244
if self.first_byte != b'\n' and self.plusbytes != 0:
243245
logger.debug('Discarding first partial row')
244246
# Previous byte is not \n
245247
# This means that we have to discard first row because it is cut
246-
first_row_end_pos = retval.find(b'\n')
248+
first_row_start_pos = retval.find(b'\n')+1
247249

248250
last_row_end_pos = self.pos
249251
# Find end of the line in threshold
250252
if self.pos > self.size:
251-
buf = io.BytesIO(retval)
252-
while not self.eof:
253-
buf.readline()
254-
if buf.tell() > self.size:
255-
last_row_end_pos = buf.tell()
256-
self.eof = True
257-
258-
return retval[first_row_end_pos+self.plusbytes:last_row_end_pos]
253+
buf = io.BytesIO(retval[self.size:])
254+
buf.readline()
255+
last_row_end_pos = self.size+buf.tell()
256+
self.eof = True
257+
258+
return retval[first_row_start_pos:last_row_end_pos]
259259

260260
def readline(self):
261261
if self.eof:

0 commit comments

Comments
 (0)