-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add start_record interface #3128
Changes from 1 commit
3322e8b
f15c62b
7327697
0379f03
59f43d5
e888456
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,9 @@ def reader(): | |
return dec.buffered(reader, buf_size) | ||
|
||
|
||
pass_num = 0 | ||
|
||
|
||
def recordio(paths, buf_size=100): | ||
""" | ||
Creates a data reader that outputs record one one by one | ||
|
@@ -90,6 +93,7 @@ def recordio(paths, buf_size=100): | |
""" | ||
import os | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need some demo code of how to use this reader. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
import paddle.v2.master.client as cloud | ||
import cPickle as pickle | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this, not see anywhere it being used. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, it's my mistake, we need |
||
|
||
if "KUBERNETES_SERVICE_HOST" not in os.environ.keys(): | ||
return recordio_local(paths) | ||
|
@@ -98,14 +102,17 @@ def recordio(paths, buf_size=100): | |
if host_name not in os.environ.keys(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the line There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
raise Exception('not find ' + host_name + ' in environment variable.') | ||
|
||
addr = os.environ(host) | ||
addr = os.getenv(host_name) | ||
|
||
def reader(): | ||
c = cloud(addr, buf_size) | ||
c.set_dataset(paths) | ||
c.paddle_start_get_records(pass_id) | ||
global pass_num | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
pass_num += 1 | ||
|
||
while True: | ||
r, err = client.next_record() | ||
r, err = c.next_record() | ||
if err < 0: | ||
break | ||
yield r | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the name
recordio
ascloud_reader
is more clear?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, done.