repo stringlengths 7 54 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 20 28.4k | docstring stringlengths 1 46.3k | docstring_tokens listlengths 1 1.66k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value | summary stringlengths 4 350 | obf_code stringlengths 7.85k 764k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
binux/pyspider | pyspider/fetcher/cookie_utils.py | MockResponse.get_all | def get_all(self, name, default=None):
"""make cookie python 3 version use this instead of getheaders"""
if default is None:
default = []
return self._headers.get_list(name) or default | python | def get_all(self, name, default=None):
"""make cookie python 3 version use this instead of getheaders"""
if default is None:
default = []
return self._headers.get_list(name) or default | [
"def",
"get_all",
"(",
"self",
",",
"name",
",",
"default",
"=",
"None",
")",
":",
"if",
"default",
"is",
"None",
":",
"default",
"=",
"[",
"]",
"return",
"self",
".",
"_headers",
".",
"get_list",
"(",
"name",
")",
"or",
"default"
] | make cookie python 3 version use this instead of getheaders | [
"make",
"cookie",
"python",
"3",
"version",
"use",
"this",
"instead",
"of",
"getheaders"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/fetcher/cookie_utils.py#L23-L27 | train | get all cookies with the given name | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/database/redis/taskdb.py | TaskDB.status_count | def status_count(self, project):
'''
return a dict
'''
pipe = self.redis.pipeline(transaction=False)
for status in range(1, 5):
pipe.scard(self._gen_status_key(project, status))
ret = pipe.execute()
result = {}
for status, count in enumerate(r... | python | def status_count(self, project):
'''
return a dict
'''
pipe = self.redis.pipeline(transaction=False)
for status in range(1, 5):
pipe.scard(self._gen_status_key(project, status))
ret = pipe.execute()
result = {}
for status, count in enumerate(r... | [
"def",
"status_count",
"(",
"self",
",",
"project",
")",
":",
"pipe",
"=",
"self",
".",
"redis",
".",
"pipeline",
"(",
"transaction",
"=",
"False",
")",
"for",
"status",
"in",
"range",
"(",
"1",
",",
"5",
")",
":",
"pipe",
".",
"scard",
"(",
"self"... | return a dict | [
"return",
"a",
"dict"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/database/redis/taskdb.py#L118-L131 | train | return a dict with the number of active items in the given project | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/libs/multiprocessing_queue.py | SharedCounter.increment | def increment(self, n=1):
""" Increment the counter by n (default = 1) """
with self.count.get_lock():
self.count.value += n | python | def increment(self, n=1):
""" Increment the counter by n (default = 1) """
with self.count.get_lock():
self.count.value += n | [
"def",
"increment",
"(",
"self",
",",
"n",
"=",
"1",
")",
":",
"with",
"self",
".",
"count",
".",
"get_lock",
"(",
")",
":",
"self",
".",
"count",
".",
"value",
"+=",
"n"
] | Increment the counter by n (default = 1) | [
"Increment",
"the",
"counter",
"by",
"n",
"(",
"default",
"=",
"1",
")"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/multiprocessing_queue.py#L25-L28 | train | Increment the counter by n. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/database/elasticsearch/taskdb.py | TaskDB.refresh | def refresh(self):
"""
Explicitly refresh one or more index, making all operations
performed since the last refresh available for search.
"""
self._changed = False
self.es.indices.refresh(index=self.index) | python | def refresh(self):
"""
Explicitly refresh one or more index, making all operations
performed since the last refresh available for search.
"""
self._changed = False
self.es.indices.refresh(index=self.index) | [
"def",
"refresh",
"(",
"self",
")",
":",
"self",
".",
"_changed",
"=",
"False",
"self",
".",
"es",
".",
"indices",
".",
"refresh",
"(",
"index",
"=",
"self",
".",
"index",
")"
] | Explicitly refresh one or more index, making all operations
performed since the last refresh available for search. | [
"Explicitly",
"refresh",
"one",
"or",
"more",
"index",
"making",
"all",
"operations",
"performed",
"since",
"the",
"last",
"refresh",
"available",
"for",
"search",
"."
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/database/elasticsearch/taskdb.py#L119-L125 | train | Refreshes the index | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/fetcher/tornado_fetcher.py | Fetcher.send_result | def send_result(self, type, task, result):
'''Send fetch result to processor'''
if self.outqueue:
try:
self.outqueue.put((task, result))
except Exception as e:
logger.exception(e) | python | def send_result(self, type, task, result):
'''Send fetch result to processor'''
if self.outqueue:
try:
self.outqueue.put((task, result))
except Exception as e:
logger.exception(e) | [
"def",
"send_result",
"(",
"self",
",",
"type",
",",
"task",
",",
"result",
")",
":",
"if",
"self",
".",
"outqueue",
":",
"try",
":",
"self",
".",
"outqueue",
".",
"put",
"(",
"(",
"task",
",",
"result",
")",
")",
"except",
"Exception",
"as",
"e",
... | Send fetch result to processor | [
"Send",
"fetch",
"result",
"to",
"processor"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/fetcher/tornado_fetcher.py#L108-L114 | train | Send fetch result to processor | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/fetcher/tornado_fetcher.py | Fetcher.async_fetch | def async_fetch(self, task, callback=None):
'''Do one fetch'''
url = task.get('url', 'data:,')
if callback is None:
callback = self.send_result
type = 'None'
start_time = time.time()
try:
if url.startswith('data:'):
type = 'data'
... | python | def async_fetch(self, task, callback=None):
'''Do one fetch'''
url = task.get('url', 'data:,')
if callback is None:
callback = self.send_result
type = 'None'
start_time = time.time()
try:
if url.startswith('data:'):
type = 'data'
... | [
"def",
"async_fetch",
"(",
"self",
",",
"task",
",",
"callback",
"=",
"None",
")",
":",
"url",
"=",
"task",
".",
"get",
"(",
"'url'",
",",
"'data:,'",
")",
"if",
"callback",
"is",
"None",
":",
"callback",
"=",
"self",
".",
"send_result",
"type",
"=",... | Do one fetch | [
"Do",
"one",
"fetch"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/fetcher/tornado_fetcher.py#L123-L153 | train | Do one fetch | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/fetcher/tornado_fetcher.py | Fetcher.sync_fetch | def sync_fetch(self, task):
'''Synchronization fetch, usually used in xmlrpc thread'''
if not self._running:
return self.ioloop.run_sync(functools.partial(self.async_fetch, task, lambda t, _, r: True))
wait_result = threading.Condition()
_result = {}
def callback(ty... | python | def sync_fetch(self, task):
'''Synchronization fetch, usually used in xmlrpc thread'''
if not self._running:
return self.ioloop.run_sync(functools.partial(self.async_fetch, task, lambda t, _, r: True))
wait_result = threading.Condition()
_result = {}
def callback(ty... | [
"def",
"sync_fetch",
"(",
"self",
",",
"task",
")",
":",
"if",
"not",
"self",
".",
"_running",
":",
"return",
"self",
".",
"ioloop",
".",
"run_sync",
"(",
"functools",
".",
"partial",
"(",
"self",
".",
"async_fetch",
",",
"task",
",",
"lambda",
"t",
... | Synchronization fetch, usually used in xmlrpc thread | [
"Synchronization",
"fetch",
"usually",
"used",
"in",
"xmlrpc",
"thread"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/fetcher/tornado_fetcher.py#L155-L176 | train | Synchronization fetch for a specific task | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/fetcher/tornado_fetcher.py | Fetcher.data_fetch | def data_fetch(self, url, task):
'''A fake fetcher for dataurl'''
self.on_fetch('data', task)
result = {}
result['orig_url'] = url
result['content'] = dataurl.decode(url)
result['headers'] = {}
result['status_code'] = 200
result['url'] = url
result... | python | def data_fetch(self, url, task):
'''A fake fetcher for dataurl'''
self.on_fetch('data', task)
result = {}
result['orig_url'] = url
result['content'] = dataurl.decode(url)
result['headers'] = {}
result['status_code'] = 200
result['url'] = url
result... | [
"def",
"data_fetch",
"(",
"self",
",",
"url",
",",
"task",
")",
":",
"self",
".",
"on_fetch",
"(",
"'data'",
",",
"task",
")",
"result",
"=",
"{",
"}",
"result",
"[",
"'orig_url'",
"]",
"=",
"url",
"result",
"[",
"'content'",
"]",
"=",
"dataurl",
"... | A fake fetcher for dataurl | [
"A",
"fake",
"fetcher",
"for",
"dataurl"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/fetcher/tornado_fetcher.py#L178-L200 | train | A fake fetcher for dataurl | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/fetcher/tornado_fetcher.py | Fetcher.http_fetch | def http_fetch(self, url, task):
'''HTTP fetcher'''
start_time = time.time()
self.on_fetch('http', task)
handle_error = lambda x: self.handle_error('http', url, task, start_time, x)
# setup request parameters
fetch = self.pack_tornado_request_parameters(url, task)
... | python | def http_fetch(self, url, task):
'''HTTP fetcher'''
start_time = time.time()
self.on_fetch('http', task)
handle_error = lambda x: self.handle_error('http', url, task, start_time, x)
# setup request parameters
fetch = self.pack_tornado_request_parameters(url, task)
... | [
"def",
"http_fetch",
"(",
"self",
",",
"url",
",",
"task",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"on_fetch",
"(",
"'http'",
",",
"task",
")",
"handle_error",
"=",
"lambda",
"x",
":",
"self",
".",
"handle_error",
"("... | HTTP fetcher | [
"HTTP",
"fetcher"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/fetcher/tornado_fetcher.py#L327-L428 | train | HTTP fetcher. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/fetcher/tornado_fetcher.py | Fetcher.phantomjs_fetch | def phantomjs_fetch(self, url, task):
'''Fetch with phantomjs proxy'''
start_time = time.time()
self.on_fetch('phantomjs', task)
handle_error = lambda x: self.handle_error('phantomjs', url, task, start_time, x)
# check phantomjs proxy is enabled
if not self.phantomjs_pro... | python | def phantomjs_fetch(self, url, task):
'''Fetch with phantomjs proxy'''
start_time = time.time()
self.on_fetch('phantomjs', task)
handle_error = lambda x: self.handle_error('phantomjs', url, task, start_time, x)
# check phantomjs proxy is enabled
if not self.phantomjs_pro... | [
"def",
"phantomjs_fetch",
"(",
"self",
",",
"url",
",",
"task",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"on_fetch",
"(",
"'phantomjs'",
",",
"task",
")",
"handle_error",
"=",
"lambda",
"x",
":",
"self",
".",
"handle_err... | Fetch with phantomjs proxy | [
"Fetch",
"with",
"phantomjs",
"proxy"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/fetcher/tornado_fetcher.py#L431-L529 | train | Fetch with phantomjs proxy | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/fetcher/tornado_fetcher.py | Fetcher.run | def run(self):
'''Run loop'''
logger.info("fetcher starting...")
def queue_loop():
if not self.outqueue or not self.inqueue:
return
while not self._quit:
try:
if self.outqueue.full():
break
... | python | def run(self):
'''Run loop'''
logger.info("fetcher starting...")
def queue_loop():
if not self.outqueue or not self.inqueue:
return
while not self._quit:
try:
if self.outqueue.full():
break
... | [
"def",
"run",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"fetcher starting...\"",
")",
"def",
"queue_loop",
"(",
")",
":",
"if",
"not",
"self",
".",
"outqueue",
"or",
"not",
"self",
".",
"inqueue",
":",
"return",
"while",
"not",
"self",
".",
... | Run loop | [
"Run",
"loop"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/fetcher/tornado_fetcher.py#L743-L778 | train | Run the fetch loop. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/fetcher/tornado_fetcher.py | Fetcher.quit | def quit(self):
'''Quit fetcher'''
self._running = False
self._quit = True
self.ioloop.add_callback(self.ioloop.stop)
if hasattr(self, 'xmlrpc_server'):
self.xmlrpc_ioloop.add_callback(self.xmlrpc_server.stop)
self.xmlrpc_ioloop.add_callback(self.xmlrpc_io... | python | def quit(self):
'''Quit fetcher'''
self._running = False
self._quit = True
self.ioloop.add_callback(self.ioloop.stop)
if hasattr(self, 'xmlrpc_server'):
self.xmlrpc_ioloop.add_callback(self.xmlrpc_server.stop)
self.xmlrpc_ioloop.add_callback(self.xmlrpc_io... | [
"def",
"quit",
"(",
"self",
")",
":",
"self",
".",
"_running",
"=",
"False",
"self",
".",
"_quit",
"=",
"True",
"self",
".",
"ioloop",
".",
"add_callback",
"(",
"self",
".",
"ioloop",
".",
"stop",
")",
"if",
"hasattr",
"(",
"self",
",",
"'xmlrpc_serv... | Quit fetcher | [
"Quit",
"fetcher"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/fetcher/tornado_fetcher.py#L780-L787 | train | Quit fetcher. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/fetcher/tornado_fetcher.py | Fetcher.xmlrpc_run | def xmlrpc_run(self, port=24444, bind='127.0.0.1', logRequests=False):
'''Run xmlrpc server'''
import umsgpack
from pyspider.libs.wsgi_xmlrpc import WSGIXMLRPCApplication
try:
from xmlrpc.client import Binary
except ImportError:
from xmlrpclib import Binar... | python | def xmlrpc_run(self, port=24444, bind='127.0.0.1', logRequests=False):
'''Run xmlrpc server'''
import umsgpack
from pyspider.libs.wsgi_xmlrpc import WSGIXMLRPCApplication
try:
from xmlrpc.client import Binary
except ImportError:
from xmlrpclib import Binar... | [
"def",
"xmlrpc_run",
"(",
"self",
",",
"port",
"=",
"24444",
",",
"bind",
"=",
"'127.0.0.1'",
",",
"logRequests",
"=",
"False",
")",
":",
"import",
"umsgpack",
"from",
"pyspider",
".",
"libs",
".",
"wsgi_xmlrpc",
"import",
"WSGIXMLRPCApplication",
"try",
":"... | Run xmlrpc server | [
"Run",
"xmlrpc",
"server"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/fetcher/tornado_fetcher.py#L792-L825 | train | Run xmlrpc server | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/fetcher/tornado_fetcher.py | Fetcher.on_result | def on_result(self, type, task, result):
'''Called after task fetched'''
status_code = result.get('status_code', 599)
if status_code != 599:
status_code = (int(status_code) / 100 * 100)
self._cnt['5m'].event((task.get('project'), status_code), +1)
self._cnt['1h'].even... | python | def on_result(self, type, task, result):
'''Called after task fetched'''
status_code = result.get('status_code', 599)
if status_code != 599:
status_code = (int(status_code) / 100 * 100)
self._cnt['5m'].event((task.get('project'), status_code), +1)
self._cnt['1h'].even... | [
"def",
"on_result",
"(",
"self",
",",
"type",
",",
"task",
",",
"result",
")",
":",
"status_code",
"=",
"result",
".",
"get",
"(",
"'status_code'",
",",
"599",
")",
"if",
"status_code",
"!=",
"599",
":",
"status_code",
"=",
"(",
"int",
"(",
"status_cod... | Called after task fetched | [
"Called",
"after",
"task",
"fetched"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/fetcher/tornado_fetcher.py#L831-L846 | train | Called after task fetched | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/libs/counter.py | CounterValue.to_dict | def to_dict(self, get_value=None):
"""Dump counters as a dict"""
result = {}
for key, value in iteritems(self):
if isinstance(value, BaseCounter):
if get_value is not None:
value = getattr(value, get_value)
result[key] = value
... | python | def to_dict(self, get_value=None):
"""Dump counters as a dict"""
result = {}
for key, value in iteritems(self):
if isinstance(value, BaseCounter):
if get_value is not None:
value = getattr(value, get_value)
result[key] = value
... | [
"def",
"to_dict",
"(",
"self",
",",
"get_value",
"=",
"None",
")",
":",
"result",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"iteritems",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"BaseCounter",
")",
":",
"if",
"get_value",
... | Dump counters as a dict | [
"Dump",
"counters",
"as",
"a",
"dict"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/counter.py#L316-L326 | train | Dump counters as a dict | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/libs/counter.py | CounterManager.value | def value(self, key, value=1):
"""Set value of a counter by counter key"""
if isinstance(key, six.string_types):
key = (key, )
# assert all(isinstance(k, six.string_types) for k in key)
assert isinstance(key, tuple), "event key type error"
if key not in self.counters:... | python | def value(self, key, value=1):
"""Set value of a counter by counter key"""
if isinstance(key, six.string_types):
key = (key, )
# assert all(isinstance(k, six.string_types) for k in key)
assert isinstance(key, tuple), "event key type error"
if key not in self.counters:... | [
"def",
"value",
"(",
"self",
",",
"key",
",",
"value",
"=",
"1",
")",
":",
"if",
"isinstance",
"(",
"key",
",",
"six",
".",
"string_types",
")",
":",
"key",
"=",
"(",
"key",
",",
")",
"# assert all(isinstance(k, six.string_types) for k in key)",
"assert",
... | Set value of a counter by counter key | [
"Set",
"value",
"of",
"a",
"counter",
"by",
"counter",
"key"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/counter.py#L355-L364 | train | Set a counter by counter key | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/libs/counter.py | CounterManager.trim | def trim(self):
"""Clear not used counters"""
for key, value in list(iteritems(self.counters)):
if value.empty():
del self.counters[key] | python | def trim(self):
"""Clear not used counters"""
for key, value in list(iteritems(self.counters)):
if value.empty():
del self.counters[key] | [
"def",
"trim",
"(",
"self",
")",
":",
"for",
"key",
",",
"value",
"in",
"list",
"(",
"iteritems",
"(",
"self",
".",
"counters",
")",
")",
":",
"if",
"value",
".",
"empty",
"(",
")",
":",
"del",
"self",
".",
"counters",
"[",
"key",
"]"
] | Clear not used counters | [
"Clear",
"not",
"used",
"counters"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/counter.py#L366-L370 | train | Clear not used counters | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/libs/counter.py | CounterManager.to_dict | def to_dict(self, get_value=None):
"""Dump counters as a dict"""
self.trim()
result = {}
for key, value in iteritems(self.counters):
if get_value is not None:
value = getattr(value, get_value)
r = result
for _key in key[:-1]:
... | python | def to_dict(self, get_value=None):
"""Dump counters as a dict"""
self.trim()
result = {}
for key, value in iteritems(self.counters):
if get_value is not None:
value = getattr(value, get_value)
r = result
for _key in key[:-1]:
... | [
"def",
"to_dict",
"(",
"self",
",",
"get_value",
"=",
"None",
")",
":",
"self",
".",
"trim",
"(",
")",
"result",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"iteritems",
"(",
"self",
".",
"counters",
")",
":",
"if",
"get_value",
"is",
"not",
... | Dump counters as a dict | [
"Dump",
"counters",
"as",
"a",
"dict"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/counter.py#L410-L421 | train | Dump counters as a dict | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/libs/counter.py | CounterManager.dump | def dump(self, filename):
"""Dump counters to file"""
try:
with open(filename, 'wb') as fp:
cPickle.dump(self.counters, fp)
except Exception as e:
logging.warning("can't dump counter to file %s: %s", filename, e)
return False
return Tru... | python | def dump(self, filename):
"""Dump counters to file"""
try:
with open(filename, 'wb') as fp:
cPickle.dump(self.counters, fp)
except Exception as e:
logging.warning("can't dump counter to file %s: %s", filename, e)
return False
return Tru... | [
"def",
"dump",
"(",
"self",
",",
"filename",
")",
":",
"try",
":",
"with",
"open",
"(",
"filename",
",",
"'wb'",
")",
"as",
"fp",
":",
"cPickle",
".",
"dump",
"(",
"self",
".",
"counters",
",",
"fp",
")",
"except",
"Exception",
"as",
"e",
":",
"l... | Dump counters to file | [
"Dump",
"counters",
"to",
"file"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/counter.py#L423-L431 | train | Dump counters to file | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/libs/counter.py | CounterManager.load | def load(self, filename):
"""Load counters to file"""
try:
with open(filename, 'rb') as fp:
self.counters = cPickle.load(fp)
except:
logging.debug("can't load counter from file: %s", filename)
return False
return True | python | def load(self, filename):
"""Load counters to file"""
try:
with open(filename, 'rb') as fp:
self.counters = cPickle.load(fp)
except:
logging.debug("can't load counter from file: %s", filename)
return False
return True | [
"def",
"load",
"(",
"self",
",",
"filename",
")",
":",
"try",
":",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"fp",
":",
"self",
".",
"counters",
"=",
"cPickle",
".",
"load",
"(",
"fp",
")",
"except",
":",
"logging",
".",
"debug",
"... | Load counters to file | [
"Load",
"counters",
"to",
"file"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/counter.py#L433-L441 | train | Load counters from file | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/run.py | cli | def cli(ctx, **kwargs):
"""
A powerful spider system in python.
"""
if kwargs['add_sys_path']:
sys.path.append(os.getcwd())
logging.config.fileConfig(kwargs['logging_config'])
# get db from env
for db in ('taskdb', 'projectdb', 'resultdb'):
if kwargs[db] is not None:
... | python | def cli(ctx, **kwargs):
"""
A powerful spider system in python.
"""
if kwargs['add_sys_path']:
sys.path.append(os.getcwd())
logging.config.fileConfig(kwargs['logging_config'])
# get db from env
for db in ('taskdb', 'projectdb', 'resultdb'):
if kwargs[db] is not None:
... | [
"def",
"cli",
"(",
"ctx",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
"[",
"'add_sys_path'",
"]",
":",
"sys",
".",
"path",
".",
"append",
"(",
"os",
".",
"getcwd",
"(",
")",
")",
"logging",
".",
"config",
".",
"fileConfig",
"(",
"kwargs",
... | A powerful spider system in python. | [
"A",
"powerful",
"spider",
"system",
"in",
"python",
"."
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/run.py#L91-L173 | train | A powerful spider system in python. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/run.py | scheduler | def scheduler(ctx, xmlrpc, xmlrpc_host, xmlrpc_port,
inqueue_limit, delete_time, active_tasks, loop_limit, fail_pause_num,
scheduler_cls, threads, get_object=False):
"""
Run Scheduler, only one scheduler is allowed.
"""
g = ctx.obj
Scheduler = load_cls(None, None, schedul... | python | def scheduler(ctx, xmlrpc, xmlrpc_host, xmlrpc_port,
inqueue_limit, delete_time, active_tasks, loop_limit, fail_pause_num,
scheduler_cls, threads, get_object=False):
"""
Run Scheduler, only one scheduler is allowed.
"""
g = ctx.obj
Scheduler = load_cls(None, None, schedul... | [
"def",
"scheduler",
"(",
"ctx",
",",
"xmlrpc",
",",
"xmlrpc_host",
",",
"xmlrpc_port",
",",
"inqueue_limit",
",",
"delete_time",
",",
"active_tasks",
",",
"loop_limit",
",",
"fail_pause_num",
",",
"scheduler_cls",
",",
"threads",
",",
"get_object",
"=",
"False",... | Run Scheduler, only one scheduler is allowed. | [
"Run",
"Scheduler",
"only",
"one",
"scheduler",
"is",
"allowed",
"."
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/run.py#L192-L220 | train | Run a scheduler. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/run.py | fetcher | def fetcher(ctx, xmlrpc, xmlrpc_host, xmlrpc_port, poolsize, proxy, user_agent,
timeout, phantomjs_endpoint, puppeteer_endpoint, splash_endpoint, fetcher_cls,
async_mode=True, get_object=False, no_input=False):
"""
Run Fetcher.
"""
g = ctx.obj
Fetcher = load_cls(None, None, f... | python | def fetcher(ctx, xmlrpc, xmlrpc_host, xmlrpc_port, poolsize, proxy, user_agent,
timeout, phantomjs_endpoint, puppeteer_endpoint, splash_endpoint, fetcher_cls,
async_mode=True, get_object=False, no_input=False):
"""
Run Fetcher.
"""
g = ctx.obj
Fetcher = load_cls(None, None, f... | [
"def",
"fetcher",
"(",
"ctx",
",",
"xmlrpc",
",",
"xmlrpc_host",
",",
"xmlrpc_port",
",",
"poolsize",
",",
"proxy",
",",
"user_agent",
",",
"timeout",
",",
"phantomjs_endpoint",
",",
"puppeteer_endpoint",
",",
"splash_endpoint",
",",
"fetcher_cls",
",",
"async_m... | Run Fetcher. | [
"Run",
"Fetcher",
"."
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/run.py#L237-L269 | train | Run Fetcher. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/run.py | processor | def processor(ctx, processor_cls, process_time_limit, enable_stdout_capture=True, get_object=False):
"""
Run Processor.
"""
g = ctx.obj
Processor = load_cls(None, None, processor_cls)
processor = Processor(projectdb=g.projectdb,
inqueue=g.fetcher2processor, status_queu... | python | def processor(ctx, processor_cls, process_time_limit, enable_stdout_capture=True, get_object=False):
"""
Run Processor.
"""
g = ctx.obj
Processor = load_cls(None, None, processor_cls)
processor = Processor(projectdb=g.projectdb,
inqueue=g.fetcher2processor, status_queu... | [
"def",
"processor",
"(",
"ctx",
",",
"processor_cls",
",",
"process_time_limit",
",",
"enable_stdout_capture",
"=",
"True",
",",
"get_object",
"=",
"False",
")",
":",
"g",
"=",
"ctx",
".",
"obj",
"Processor",
"=",
"load_cls",
"(",
"None",
",",
"None",
",",... | Run Processor. | [
"Run",
"Processor",
"."
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/run.py#L277-L294 | train | Run a single Processor instance. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/run.py | result_worker | def result_worker(ctx, result_cls, get_object=False):
"""
Run result worker.
"""
g = ctx.obj
ResultWorker = load_cls(None, None, result_cls)
result_worker = ResultWorker(resultdb=g.resultdb, inqueue=g.processor2result)
g.instances.append(result_worker)
if g.get('testing_mode') or get_o... | python | def result_worker(ctx, result_cls, get_object=False):
"""
Run result worker.
"""
g = ctx.obj
ResultWorker = load_cls(None, None, result_cls)
result_worker = ResultWorker(resultdb=g.resultdb, inqueue=g.processor2result)
g.instances.append(result_worker)
if g.get('testing_mode') or get_o... | [
"def",
"result_worker",
"(",
"ctx",
",",
"result_cls",
",",
"get_object",
"=",
"False",
")",
":",
"g",
"=",
"ctx",
".",
"obj",
"ResultWorker",
"=",
"load_cls",
"(",
"None",
",",
"None",
",",
"result_cls",
")",
"result_worker",
"=",
"ResultWorker",
"(",
"... | Run result worker. | [
"Run",
"result",
"worker",
"."
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/run.py#L301-L314 | train | Run result worker. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/run.py | webui | def webui(ctx, host, port, cdn, scheduler_rpc, fetcher_rpc, max_rate, max_burst,
username, password, need_auth, webui_instance, process_time_limit, get_object=False):
"""
Run WebUI
"""
app = load_cls(None, None, webui_instance)
g = ctx.obj
app.config['taskdb'] = g.taskdb
app.confi... | python | def webui(ctx, host, port, cdn, scheduler_rpc, fetcher_rpc, max_rate, max_burst,
username, password, need_auth, webui_instance, process_time_limit, get_object=False):
"""
Run WebUI
"""
app = load_cls(None, None, webui_instance)
g = ctx.obj
app.config['taskdb'] = g.taskdb
app.confi... | [
"def",
"webui",
"(",
"ctx",
",",
"host",
",",
"port",
",",
"cdn",
",",
"scheduler_rpc",
",",
"fetcher_rpc",
",",
"max_rate",
",",
"max_burst",
",",
"username",
",",
"password",
",",
"need_auth",
",",
"webui_instance",
",",
"process_time_limit",
",",
"get_obj... | Run WebUI | [
"Run",
"WebUI"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/run.py#L337-L393 | train | Run WebUI. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/run.py | phantomjs | def phantomjs(ctx, phantomjs_path, port, auto_restart, args):
"""
Run phantomjs fetcher if phantomjs is installed.
"""
args = args or ctx.default_map and ctx.default_map.get('args', [])
import subprocess
g = ctx.obj
_quit = []
phantomjs_fetcher = os.path.join(
os.path.dirname(py... | python | def phantomjs(ctx, phantomjs_path, port, auto_restart, args):
"""
Run phantomjs fetcher if phantomjs is installed.
"""
args = args or ctx.default_map and ctx.default_map.get('args', [])
import subprocess
g = ctx.obj
_quit = []
phantomjs_fetcher = os.path.join(
os.path.dirname(py... | [
"def",
"phantomjs",
"(",
"ctx",
",",
"phantomjs_path",
",",
"port",
",",
"auto_restart",
",",
"args",
")",
":",
"args",
"=",
"args",
"or",
"ctx",
".",
"default_map",
"and",
"ctx",
".",
"default_map",
".",
"get",
"(",
"'args'",
",",
"[",
"]",
")",
"im... | Run phantomjs fetcher if phantomjs is installed. | [
"Run",
"phantomjs",
"fetcher",
"if",
"phantomjs",
"is",
"installed",
"."
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/run.py#L402-L443 | train | Run phantomjs fetcher if phantomjs is installed. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/run.py | puppeteer | def puppeteer(ctx, port, auto_restart, args):
"""
Run puppeteer fetcher if puppeteer is installed.
"""
import subprocess
g = ctx.obj
_quit = []
puppeteer_fetcher = os.path.join(
os.path.dirname(pyspider.__file__), 'fetcher/puppeteer_fetcher.js')
cmd = ['node', puppeteer_fetcher,... | python | def puppeteer(ctx, port, auto_restart, args):
"""
Run puppeteer fetcher if puppeteer is installed.
"""
import subprocess
g = ctx.obj
_quit = []
puppeteer_fetcher = os.path.join(
os.path.dirname(pyspider.__file__), 'fetcher/puppeteer_fetcher.js')
cmd = ['node', puppeteer_fetcher,... | [
"def",
"puppeteer",
"(",
"ctx",
",",
"port",
",",
"auto_restart",
",",
"args",
")",
":",
"import",
"subprocess",
"g",
"=",
"ctx",
".",
"obj",
"_quit",
"=",
"[",
"]",
"puppeteer_fetcher",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
... | Run puppeteer fetcher if puppeteer is installed. | [
"Run",
"puppeteer",
"fetcher",
"if",
"puppeteer",
"is",
"installed",
"."
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/run.py#L450-L486 | train | Run puppeteer fetcher if puppeteer is installed. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/run.py | all | def all(ctx, fetcher_num, processor_num, result_worker_num, run_in):
"""
Run all the components in subprocess or thread
"""
ctx.obj['debug'] = False
g = ctx.obj
# FIXME: py34 cannot run components with threads
if run_in == 'subprocess' and os.name != 'nt':
run_in = utils.run_in_sub... | python | def all(ctx, fetcher_num, processor_num, result_worker_num, run_in):
"""
Run all the components in subprocess or thread
"""
ctx.obj['debug'] = False
g = ctx.obj
# FIXME: py34 cannot run components with threads
if run_in == 'subprocess' and os.name != 'nt':
run_in = utils.run_in_sub... | [
"def",
"all",
"(",
"ctx",
",",
"fetcher_num",
",",
"processor_num",
",",
"result_worker_num",
",",
"run_in",
")",
":",
"ctx",
".",
"obj",
"[",
"'debug'",
"]",
"=",
"False",
"g",
"=",
"ctx",
".",
"obj",
"# FIXME: py34 cannot run components with threads",
"if",
... | Run all the components in subprocess or thread | [
"Run",
"all",
"the",
"components",
"in",
"subprocess",
"or",
"thread"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/run.py#L498-L570 | train | Run all the components in subprocess or thread. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/run.py | bench | def bench(ctx, fetcher_num, processor_num, result_worker_num, run_in, total, show,
taskdb_bench, message_queue_bench, all_bench):
"""
Run Benchmark test.
In bench mode, in-memory sqlite database is used instead of on-disk sqlite database.
"""
from pyspider.libs import bench
from pyspid... | python | def bench(ctx, fetcher_num, processor_num, result_worker_num, run_in, total, show,
taskdb_bench, message_queue_bench, all_bench):
"""
Run Benchmark test.
In bench mode, in-memory sqlite database is used instead of on-disk sqlite database.
"""
from pyspider.libs import bench
from pyspid... | [
"def",
"bench",
"(",
"ctx",
",",
"fetcher_num",
",",
"processor_num",
",",
"result_worker_num",
",",
"run_in",
",",
"total",
",",
"show",
",",
"taskdb_bench",
",",
"message_queue_bench",
",",
"all_bench",
")",
":",
"from",
"pyspider",
".",
"libs",
"import",
... | Run Benchmark test.
In bench mode, in-memory sqlite database is used instead of on-disk sqlite database. | [
"Run",
"Benchmark",
"test",
".",
"In",
"bench",
"mode",
"in",
"-",
"memory",
"sqlite",
"database",
"is",
"used",
"instead",
"of",
"on",
"-",
"disk",
"sqlite",
"database",
"."
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/run.py#L589-L711 | train | Run Benchmark test. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/run.py | one | def one(ctx, interactive, enable_phantomjs, enable_puppeteer, scripts):
"""
One mode not only means all-in-one, it runs every thing in one process over
tornado.ioloop, for debug purpose
"""
ctx.obj['debug'] = False
g = ctx.obj
g['testing_mode'] = True
if scripts:
from pyspider.... | python | def one(ctx, interactive, enable_phantomjs, enable_puppeteer, scripts):
"""
One mode not only means all-in-one, it runs every thing in one process over
tornado.ioloop, for debug purpose
"""
ctx.obj['debug'] = False
g = ctx.obj
g['testing_mode'] = True
if scripts:
from pyspider.... | [
"def",
"one",
"(",
"ctx",
",",
"interactive",
",",
"enable_phantomjs",
",",
"enable_puppeteer",
",",
"scripts",
")",
":",
"ctx",
".",
"obj",
"[",
"'debug'",
"]",
"=",
"False",
"g",
"=",
"ctx",
".",
"obj",
"g",
"[",
"'testing_mode'",
"]",
"=",
"True",
... | One mode not only means all-in-one, it runs every thing in one process over
tornado.ioloop, for debug purpose | [
"One",
"mode",
"not",
"only",
"means",
"all",
"-",
"in",
"-",
"one",
"it",
"runs",
"every",
"thing",
"in",
"one",
"process",
"over",
"tornado",
".",
"ioloop",
"for",
"debug",
"purpose"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/run.py#L723-L793 | train | One mode only means all - in - one it runs every thing in one process over tornado. ioloop for debug purpose | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/run.py | send_message | def send_message(ctx, scheduler_rpc, project, message):
"""
Send Message to project from command line
"""
if isinstance(scheduler_rpc, six.string_types):
scheduler_rpc = connect_rpc(ctx, None, scheduler_rpc)
if scheduler_rpc is None and os.environ.get('SCHEDULER_NAME'):
scheduler_rpc... | python | def send_message(ctx, scheduler_rpc, project, message):
"""
Send Message to project from command line
"""
if isinstance(scheduler_rpc, six.string_types):
scheduler_rpc = connect_rpc(ctx, None, scheduler_rpc)
if scheduler_rpc is None and os.environ.get('SCHEDULER_NAME'):
scheduler_rpc... | [
"def",
"send_message",
"(",
"ctx",
",",
"scheduler_rpc",
",",
"project",
",",
"message",
")",
":",
"if",
"isinstance",
"(",
"scheduler_rpc",
",",
"six",
".",
"string_types",
")",
":",
"scheduler_rpc",
"=",
"connect_rpc",
"(",
"ctx",
",",
"None",
",",
"sche... | Send Message to project from command line | [
"Send",
"Message",
"to",
"project",
"from",
"command",
"line"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/run.py#L801-L823 | train | Send a message to a project from command line | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/libs/pprint.py | pprint | def pprint(object, stream=None, indent=1, width=80, depth=None):
"""Pretty-print a Python object to a stream [default is sys.stdout]."""
printer = PrettyPrinter(
stream=stream, indent=indent, width=width, depth=depth)
printer.pprint(object) | python | def pprint(object, stream=None, indent=1, width=80, depth=None):
"""Pretty-print a Python object to a stream [default is sys.stdout]."""
printer = PrettyPrinter(
stream=stream, indent=indent, width=width, depth=depth)
printer.pprint(object) | [
"def",
"pprint",
"(",
"object",
",",
"stream",
"=",
"None",
",",
"indent",
"=",
"1",
",",
"width",
"=",
"80",
",",
"depth",
"=",
"None",
")",
":",
"printer",
"=",
"PrettyPrinter",
"(",
"stream",
"=",
"stream",
",",
"indent",
"=",
"indent",
",",
"wi... | Pretty-print a Python object to a stream [default is sys.stdout]. | [
"Pretty",
"-",
"print",
"a",
"Python",
"object",
"to",
"a",
"stream",
"[",
"default",
"is",
"sys",
".",
"stdout",
"]",
"."
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/pprint.py#L54-L58 | train | Pretty - print a Python object to a stream [ default is sys. stdout | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/libs/pprint.py | pformat | def pformat(object, indent=1, width=80, depth=None):
"""Format a Python object into a pretty-printed representation."""
return PrettyPrinter(indent=indent, width=width, depth=depth).pformat(object) | python | def pformat(object, indent=1, width=80, depth=None):
"""Format a Python object into a pretty-printed representation."""
return PrettyPrinter(indent=indent, width=width, depth=depth).pformat(object) | [
"def",
"pformat",
"(",
"object",
",",
"indent",
"=",
"1",
",",
"width",
"=",
"80",
",",
"depth",
"=",
"None",
")",
":",
"return",
"PrettyPrinter",
"(",
"indent",
"=",
"indent",
",",
"width",
"=",
"width",
",",
"depth",
"=",
"depth",
")",
".",
"pfor... | Format a Python object into a pretty-printed representation. | [
"Format",
"a",
"Python",
"object",
"into",
"a",
"pretty",
"-",
"printed",
"representation",
"."
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/pprint.py#L61-L63 | train | Format a Python object into a pretty - printed representation. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/libs/pprint.py | PrettyPrinter.format | def format(self, object, context, maxlevels, level):
"""Format object for a specific context, returning a string
and flags indicating whether the representation is 'readable'
and whether the object represents a recursive construct.
"""
return _safe_repr(object, context, maxlevels... | python | def format(self, object, context, maxlevels, level):
"""Format object for a specific context, returning a string
and flags indicating whether the representation is 'readable'
and whether the object represents a recursive construct.
"""
return _safe_repr(object, context, maxlevels... | [
"def",
"format",
"(",
"self",
",",
"object",
",",
"context",
",",
"maxlevels",
",",
"level",
")",
":",
"return",
"_safe_repr",
"(",
"object",
",",
"context",
",",
"maxlevels",
",",
"level",
")"
] | Format object for a specific context, returning a string
and flags indicating whether the representation is 'readable'
and whether the object represents a recursive construct. | [
"Format",
"object",
"for",
"a",
"specific",
"context",
"returning",
"a",
"string",
"and",
"flags",
"indicating",
"whether",
"the",
"representation",
"is",
"readable",
"and",
"whether",
"the",
"object",
"represents",
"a",
"recursive",
"construct",
"."
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/pprint.py#L243-L248 | train | Format object for a specific context returning a string containing the representation of the object. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/result/result_worker.py | ResultWorker.on_result | def on_result(self, task, result):
'''Called every result'''
if not result:
return
if 'taskid' in task and 'project' in task and 'url' in task:
logger.info('result %s:%s %s -> %.30r' % (
task['project'], task['taskid'], task['url'], result))
re... | python | def on_result(self, task, result):
'''Called every result'''
if not result:
return
if 'taskid' in task and 'project' in task and 'url' in task:
logger.info('result %s:%s %s -> %.30r' % (
task['project'], task['taskid'], task['url'], result))
re... | [
"def",
"on_result",
"(",
"self",
",",
"task",
",",
"result",
")",
":",
"if",
"not",
"result",
":",
"return",
"if",
"'taskid'",
"in",
"task",
"and",
"'project'",
"in",
"task",
"and",
"'url'",
"in",
"task",
":",
"logger",
".",
"info",
"(",
"'result %s:%s... | Called every result | [
"Called",
"every",
"result"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/result/result_worker.py#L27-L42 | train | Called every result | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/result/result_worker.py | ResultWorker.run | def run(self):
'''Run loop'''
logger.info("result_worker starting...")
while not self._quit:
try:
task, result = self.inqueue.get(timeout=1)
self.on_result(task, result)
except Queue.Empty as e:
continue
except ... | python | def run(self):
'''Run loop'''
logger.info("result_worker starting...")
while not self._quit:
try:
task, result = self.inqueue.get(timeout=1)
self.on_result(task, result)
except Queue.Empty as e:
continue
except ... | [
"def",
"run",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"result_worker starting...\"",
")",
"while",
"not",
"self",
".",
"_quit",
":",
"try",
":",
"task",
",",
"result",
"=",
"self",
".",
"inqueue",
".",
"get",
"(",
"timeout",
"=",
"1",
")... | Run loop | [
"Run",
"loop"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/result/result_worker.py#L47-L66 | train | Run the loop in order to get the result from the inqueue and call the on_result method. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/result/result_worker.py | OneResultWorker.on_result | def on_result(self, task, result):
'''Called every result'''
if not result:
return
if 'taskid' in task and 'project' in task and 'url' in task:
logger.info('result %s:%s %s -> %.30r' % (
task['project'], task['taskid'], task['url'], result))
pr... | python | def on_result(self, task, result):
'''Called every result'''
if not result:
return
if 'taskid' in task and 'project' in task and 'url' in task:
logger.info('result %s:%s %s -> %.30r' % (
task['project'], task['taskid'], task['url'], result))
pr... | [
"def",
"on_result",
"(",
"self",
",",
"task",
",",
"result",
")",
":",
"if",
"not",
"result",
":",
"return",
"if",
"'taskid'",
"in",
"task",
"and",
"'project'",
"in",
"task",
"and",
"'url'",
"in",
"task",
":",
"logger",
".",
"info",
"(",
"'result %s:%s... | Called every result | [
"Called",
"every",
"result"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/result/result_worker.py#L71-L87 | train | Called every result | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/scheduler/token_bucket.py | Bucket.get | def get(self):
'''Get the number of tokens in bucket'''
now = time.time()
if self.bucket >= self.burst:
self.last_update = now
return self.bucket
bucket = self.rate * (now - self.last_update)
self.mutex.acquire()
if bucket > 1:
self.buc... | python | def get(self):
'''Get the number of tokens in bucket'''
now = time.time()
if self.bucket >= self.burst:
self.last_update = now
return self.bucket
bucket = self.rate * (now - self.last_update)
self.mutex.acquire()
if bucket > 1:
self.buc... | [
"def",
"get",
"(",
"self",
")",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"if",
"self",
".",
"bucket",
">=",
"self",
".",
"burst",
":",
"self",
".",
"last_update",
"=",
"now",
"return",
"self",
".",
"bucket",
"bucket",
"=",
"self",
".",
"ra... | Get the number of tokens in bucket | [
"Get",
"the",
"number",
"of",
"tokens",
"in",
"bucket"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/token_bucket.py#L33-L47 | train | Get the number of tokens in bucket | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | tools/migrate.py | migrate | def migrate(pool, from_connection, to_connection):
"""
Migrate tool for pyspider
"""
f = connect_database(from_connection)
t = connect_database(to_connection)
if isinstance(f, ProjectDB):
for each in f.get_all():
each = unicode_obj(each)
logging.info("projectdb: ... | python | def migrate(pool, from_connection, to_connection):
"""
Migrate tool for pyspider
"""
f = connect_database(from_connection)
t = connect_database(to_connection)
if isinstance(f, ProjectDB):
for each in f.get_all():
each = unicode_obj(each)
logging.info("projectdb: ... | [
"def",
"migrate",
"(",
"pool",
",",
"from_connection",
",",
"to_connection",
")",
":",
"f",
"=",
"connect_database",
"(",
"from_connection",
")",
"t",
"=",
"connect_database",
"(",
"to_connection",
")",
"if",
"isinstance",
"(",
"f",
",",
"ProjectDB",
")",
":... | Migrate tool for pyspider | [
"Migrate",
"tool",
"for",
"pyspider"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/tools/migrate.py#L43-L65 | train | Migrate the database from one database to another. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/libs/dataurl.py | encode | def encode(data, mime_type='', charset='utf-8', base64=True):
"""
Encode data to DataURL
"""
if isinstance(data, six.text_type):
data = data.encode(charset)
else:
charset = None
if base64:
data = utils.text(b64encode(data))
else:
data = utils.text(quote(data))... | python | def encode(data, mime_type='', charset='utf-8', base64=True):
"""
Encode data to DataURL
"""
if isinstance(data, six.text_type):
data = data.encode(charset)
else:
charset = None
if base64:
data = utils.text(b64encode(data))
else:
data = utils.text(quote(data))... | [
"def",
"encode",
"(",
"data",
",",
"mime_type",
"=",
"''",
",",
"charset",
"=",
"'utf-8'",
",",
"base64",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"six",
".",
"text_type",
")",
":",
"data",
"=",
"data",
".",
"encode",
"(",
"char... | Encode data to DataURL | [
"Encode",
"data",
"to",
"DataURL"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/dataurl.py#L14-L38 | train | Encode data to DataURL | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/libs/dataurl.py | decode | def decode(data_url):
"""
Decode DataURL data
"""
metadata, data = data_url.rsplit(',', 1)
_, metadata = metadata.split('data:', 1)
parts = metadata.split(';')
if parts[-1] == 'base64':
data = b64decode(data)
else:
data = unquote(data)
for part in parts:
if p... | python | def decode(data_url):
"""
Decode DataURL data
"""
metadata, data = data_url.rsplit(',', 1)
_, metadata = metadata.split('data:', 1)
parts = metadata.split(';')
if parts[-1] == 'base64':
data = b64decode(data)
else:
data = unquote(data)
for part in parts:
if p... | [
"def",
"decode",
"(",
"data_url",
")",
":",
"metadata",
",",
"data",
"=",
"data_url",
".",
"rsplit",
"(",
"','",
",",
"1",
")",
"_",
",",
"metadata",
"=",
"metadata",
".",
"split",
"(",
"'data:'",
",",
"1",
")",
"parts",
"=",
"metadata",
".",
"spli... | Decode DataURL data | [
"Decode",
"DataURL",
"data"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/dataurl.py#L41-L56 | train | Decode data_url into a list of base64 encoded strings. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/libs/url.py | _build_url | def _build_url(url, _params):
"""Build the actual URL to use."""
# Support for unicode domain names and paths.
scheme, netloc, path, params, query, fragment = urlparse(url)
netloc = netloc.encode('idna').decode('utf-8')
if not path:
path = '/'
if six.PY2:
if isinstance(scheme, ... | python | def _build_url(url, _params):
"""Build the actual URL to use."""
# Support for unicode domain names and paths.
scheme, netloc, path, params, query, fragment = urlparse(url)
netloc = netloc.encode('idna').decode('utf-8')
if not path:
path = '/'
if six.PY2:
if isinstance(scheme, ... | [
"def",
"_build_url",
"(",
"url",
",",
"_params",
")",
":",
"# Support for unicode domain names and paths.",
"scheme",
",",
"netloc",
",",
"path",
",",
"params",
",",
"query",
",",
"fragment",
"=",
"urlparse",
"(",
"url",
")",
"netloc",
"=",
"netloc",
".",
"e... | Build the actual URL to use. | [
"Build",
"the",
"actual",
"URL",
"to",
"use",
"."
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/url.py#L29-L59 | train | Build the actual URL to use. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/libs/url.py | quote_chinese | def quote_chinese(url, encodeing="utf-8"):
"""Quote non-ascii characters"""
if isinstance(url, six.text_type):
return quote_chinese(url.encode(encodeing))
if six.PY3:
res = [six.int2byte(b).decode('latin-1') if b < 128 else '%%%02X' % b for b in url]
else:
res = [b if ord(b) < 12... | python | def quote_chinese(url, encodeing="utf-8"):
"""Quote non-ascii characters"""
if isinstance(url, six.text_type):
return quote_chinese(url.encode(encodeing))
if six.PY3:
res = [six.int2byte(b).decode('latin-1') if b < 128 else '%%%02X' % b for b in url]
else:
res = [b if ord(b) < 12... | [
"def",
"quote_chinese",
"(",
"url",
",",
"encodeing",
"=",
"\"utf-8\"",
")",
":",
"if",
"isinstance",
"(",
"url",
",",
"six",
".",
"text_type",
")",
":",
"return",
"quote_chinese",
"(",
"url",
".",
"encode",
"(",
"encodeing",
")",
")",
"if",
"six",
"."... | Quote non-ascii characters | [
"Quote",
"non",
"-",
"ascii",
"characters"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/url.py#L62-L70 | train | Quote non - ascii characters in a Chinese URL. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
lanpa/tensorboardX | examples/demo_caffe2.py | DownloadResource | def DownloadResource(url, path):
'''Downloads resources from s3 by url and unzips them to the provided path'''
import requests
from six import BytesIO
import zipfile
print("Downloading... {} to {}".format(url, path))
r = requests.get(url, stream=True)
z = zipfile.ZipFile(BytesIO(r.content))
... | python | def DownloadResource(url, path):
'''Downloads resources from s3 by url and unzips them to the provided path'''
import requests
from six import BytesIO
import zipfile
print("Downloading... {} to {}".format(url, path))
r = requests.get(url, stream=True)
z = zipfile.ZipFile(BytesIO(r.content))
... | [
"def",
"DownloadResource",
"(",
"url",
",",
"path",
")",
":",
"import",
"requests",
"from",
"six",
"import",
"BytesIO",
"import",
"zipfile",
"print",
"(",
"\"Downloading... {} to {}\"",
".",
"format",
"(",
"url",
",",
"path",
")",
")",
"r",
"=",
"requests",
... | Downloads resources from s3 by url and unzips them to the provided path | [
"Downloads",
"resources",
"from",
"s3",
"by",
"url",
"and",
"unzips",
"them",
"to",
"the",
"provided",
"path"
] | 0bf6c07d97b0745654fd9fab8ee3261ec707f253 | https://github.com/lanpa/tensorboardX/blob/0bf6c07d97b0745654fd9fab8ee3261ec707f253/examples/demo_caffe2.py#L28-L37 | train | Downloads resources from s3 by url and unzips them to the provided path | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
lanpa/tensorboardX | examples/demo_caffe2.py | AddLeNetModel | def AddLeNetModel(model, data):
'''
This part is the standard LeNet model: from data to the softmax prediction.
For each convolutional layer we specify dim_in - number of input channels
and dim_out - number or output channels. Also each Conv and MaxPool layer changes the
image size. For example, ke... | python | def AddLeNetModel(model, data):
'''
This part is the standard LeNet model: from data to the softmax prediction.
For each convolutional layer we specify dim_in - number of input channels
and dim_out - number or output channels. Also each Conv and MaxPool layer changes the
image size. For example, ke... | [
"def",
"AddLeNetModel",
"(",
"model",
",",
"data",
")",
":",
"# Image size: 28 x 28 -> 24 x 24",
"conv1",
"=",
"brew",
".",
"conv",
"(",
"model",
",",
"data",
",",
"'conv1'",
",",
"dim_in",
"=",
"1",
",",
"dim_out",
"=",
"20",
",",
"kernel",
"=",
"5",
... | This part is the standard LeNet model: from data to the softmax prediction.
For each convolutional layer we specify dim_in - number of input channels
and dim_out - number or output channels. Also each Conv and MaxPool layer changes the
image size. For example, kernel of size 5 reduces each side of an image... | [
"This",
"part",
"is",
"the",
"standard",
"LeNet",
"model",
":",
"from",
"data",
"to",
"the",
"softmax",
"prediction",
"."
] | 0bf6c07d97b0745654fd9fab8ee3261ec707f253 | https://github.com/lanpa/tensorboardX/blob/0bf6c07d97b0745654fd9fab8ee3261ec707f253/examples/demo_caffe2.py#L102-L127 | train | This part is the standard LeNet model that uses the data to predict the image size of the image. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
lanpa/tensorboardX | examples/demo_caffe2.py | AddAccuracy | def AddAccuracy(model, softmax, label):
"""Adds an accuracy op to the model"""
accuracy = brew.accuracy(model, [softmax, label], "accuracy")
return accuracy | python | def AddAccuracy(model, softmax, label):
"""Adds an accuracy op to the model"""
accuracy = brew.accuracy(model, [softmax, label], "accuracy")
return accuracy | [
"def",
"AddAccuracy",
"(",
"model",
",",
"softmax",
",",
"label",
")",
":",
"accuracy",
"=",
"brew",
".",
"accuracy",
"(",
"model",
",",
"[",
"softmax",
",",
"label",
"]",
",",
"\"accuracy\"",
")",
"return",
"accuracy"
] | Adds an accuracy op to the model | [
"Adds",
"an",
"accuracy",
"op",
"to",
"the",
"model"
] | 0bf6c07d97b0745654fd9fab8ee3261ec707f253 | https://github.com/lanpa/tensorboardX/blob/0bf6c07d97b0745654fd9fab8ee3261ec707f253/examples/demo_caffe2.py#L130-L133 | train | Adds an accuracy op to the model | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
lanpa/tensorboardX | examples/demo_caffe2.py | AddTrainingOperators | def AddTrainingOperators(model, softmax, label):
"""Adds training operators to the model."""
xent = model.LabelCrossEntropy([softmax, label], 'xent')
# compute the expected loss
loss = model.AveragedLoss(xent, "loss")
# track the accuracy of the model
AddAccuracy(model, softmax, label)
# use... | python | def AddTrainingOperators(model, softmax, label):
"""Adds training operators to the model."""
xent = model.LabelCrossEntropy([softmax, label], 'xent')
# compute the expected loss
loss = model.AveragedLoss(xent, "loss")
# track the accuracy of the model
AddAccuracy(model, softmax, label)
# use... | [
"def",
"AddTrainingOperators",
"(",
"model",
",",
"softmax",
",",
"label",
")",
":",
"xent",
"=",
"model",
".",
"LabelCrossEntropy",
"(",
"[",
"softmax",
",",
"label",
"]",
",",
"'xent'",
")",
"# compute the expected loss",
"loss",
"=",
"model",
".",
"Averag... | Adds training operators to the model. | [
"Adds",
"training",
"operators",
"to",
"the",
"model",
"."
] | 0bf6c07d97b0745654fd9fab8ee3261ec707f253 | https://github.com/lanpa/tensorboardX/blob/0bf6c07d97b0745654fd9fab8ee3261ec707f253/examples/demo_caffe2.py#L136-L160 | train | Adds training operators to the model. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
lanpa/tensorboardX | examples/demo_caffe2.py | AddBookkeepingOperators | def AddBookkeepingOperators(model):
"""This adds a few bookkeeping operators that we can inspect later.
These operators do not affect the training procedure: they only collect
statistics and prints them to file or to logs.
"""
# Print basically prints out the content of the blob. to_file=1 routes t... | python | def AddBookkeepingOperators(model):
"""This adds a few bookkeeping operators that we can inspect later.
These operators do not affect the training procedure: they only collect
statistics and prints them to file or to logs.
"""
# Print basically prints out the content of the blob. to_file=1 routes t... | [
"def",
"AddBookkeepingOperators",
"(",
"model",
")",
":",
"# Print basically prints out the content of the blob. to_file=1 routes the",
"# printed output to a file. The file is going to be stored under",
"# root_folder/[blob name]",
"model",
".",
"Print",
"(",
"'accuracy'",
",",
"[... | This adds a few bookkeeping operators that we can inspect later.
These operators do not affect the training procedure: they only collect
statistics and prints them to file or to logs. | [
"This",
"adds",
"a",
"few",
"bookkeeping",
"operators",
"that",
"we",
"can",
"inspect",
"later",
"."
] | 0bf6c07d97b0745654fd9fab8ee3261ec707f253 | https://github.com/lanpa/tensorboardX/blob/0bf6c07d97b0745654fd9fab8ee3261ec707f253/examples/demo_caffe2.py#L163-L178 | train | Adds a few bookkeeping operators that we can inspect later. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
lanpa/tensorboardX | examples/chainer/plain_logger/net.py | VAE.get_loss_func | def get_loss_func(self, C=1.0, k=1):
"""Get loss function of VAE.
The loss value is equal to ELBO (Evidence Lower Bound)
multiplied by -1.
Args:
C (int): Usually this is 1.0. Can be changed to control the
second term of ELBO bound, which works as regularizat... | python | def get_loss_func(self, C=1.0, k=1):
"""Get loss function of VAE.
The loss value is equal to ELBO (Evidence Lower Bound)
multiplied by -1.
Args:
C (int): Usually this is 1.0. Can be changed to control the
second term of ELBO bound, which works as regularizat... | [
"def",
"get_loss_func",
"(",
"self",
",",
"C",
"=",
"1.0",
",",
"k",
"=",
"1",
")",
":",
"def",
"lf",
"(",
"x",
")",
":",
"mu",
",",
"ln_var",
"=",
"self",
".",
"encode",
"(",
"x",
")",
"batchsize",
"=",
"len",
"(",
"mu",
".",
"data",
")",
... | Get loss function of VAE.
The loss value is equal to ELBO (Evidence Lower Bound)
multiplied by -1.
Args:
C (int): Usually this is 1.0. Can be changed to control the
second term of ELBO bound, which works as regularization.
k (int): Number of Monte Carlo ... | [
"Get",
"loss",
"function",
"of",
"VAE",
"."
] | 0bf6c07d97b0745654fd9fab8ee3261ec707f253 | https://github.com/lanpa/tensorboardX/blob/0bf6c07d97b0745654fd9fab8ee3261ec707f253/examples/chainer/plain_logger/net.py#L41-L65 | train | Returns loss function of VAE. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/core.py | Agent.fit | def fit(self, env, nb_steps, action_repetition=1, callbacks=None, verbose=1,
visualize=False, nb_max_start_steps=0, start_step_policy=None, log_interval=10000,
nb_max_episode_steps=None):
"""Trains the agent on the given environment.
# Arguments
env: (`Env` instance)... | python | def fit(self, env, nb_steps, action_repetition=1, callbacks=None, verbose=1,
visualize=False, nb_max_start_steps=0, start_step_policy=None, log_interval=10000,
nb_max_episode_steps=None):
"""Trains the agent on the given environment.
# Arguments
env: (`Env` instance)... | [
"def",
"fit",
"(",
"self",
",",
"env",
",",
"nb_steps",
",",
"action_repetition",
"=",
"1",
",",
"callbacks",
"=",
"None",
",",
"verbose",
"=",
"1",
",",
"visualize",
"=",
"False",
",",
"nb_max_start_steps",
"=",
"0",
",",
"start_step_policy",
"=",
"None... | Trains the agent on the given environment.
# Arguments
env: (`Env` instance): Environment that the agent interacts with. See [Env](#env) for details.
nb_steps (integer): Number of training steps to be performed.
action_repetition (integer): Number of times the agent repeats ... | [
"Trains",
"the",
"agent",
"on",
"the",
"given",
"environment",
"."
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/core.py#L53-L238 | train | Trains the agent on the given environment. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/core.py | Processor.process_step | def process_step(self, observation, reward, done, info):
"""Processes an entire step by applying the processor to the observation, reward, and info arguments.
# Arguments
observation (object): An observation as obtained by the environment.
reward (float): A reward as obtained by... | python | def process_step(self, observation, reward, done, info):
"""Processes an entire step by applying the processor to the observation, reward, and info arguments.
# Arguments
observation (object): An observation as obtained by the environment.
reward (float): A reward as obtained by... | [
"def",
"process_step",
"(",
"self",
",",
"observation",
",",
"reward",
",",
"done",
",",
"info",
")",
":",
"observation",
"=",
"self",
".",
"process_observation",
"(",
"observation",
")",
"reward",
"=",
"self",
".",
"process_reward",
"(",
"reward",
")",
"i... | Processes an entire step by applying the processor to the observation, reward, and info arguments.
# Arguments
observation (object): An observation as obtained by the environment.
reward (float): A reward as obtained by the environment.
done (boolean): `True` if the environm... | [
"Processes",
"an",
"entire",
"step",
"by",
"applying",
"the",
"processor",
"to",
"the",
"observation",
"reward",
"and",
"info",
"arguments",
"."
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/core.py#L511-L526 | train | Processes a single step by applying the processor to the observation reward and info arguments. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/policy.py | LinearAnnealedPolicy.get_current_value | def get_current_value(self):
"""Return current annealing value
# Returns
Value to use in annealing
"""
if self.agent.training:
# Linear annealed: f(x) = ax + b.
a = -float(self.value_max - self.value_min) / float(self.nb_steps)
b = float(s... | python | def get_current_value(self):
"""Return current annealing value
# Returns
Value to use in annealing
"""
if self.agent.training:
# Linear annealed: f(x) = ax + b.
a = -float(self.value_max - self.value_min) / float(self.nb_steps)
b = float(s... | [
"def",
"get_current_value",
"(",
"self",
")",
":",
"if",
"self",
".",
"agent",
".",
"training",
":",
"# Linear annealed: f(x) = ax + b.",
"a",
"=",
"-",
"float",
"(",
"self",
".",
"value_max",
"-",
"self",
".",
"value_min",
")",
"/",
"float",
"(",
"self",
... | Return current annealing value
# Returns
Value to use in annealing | [
"Return",
"current",
"annealing",
"value"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/policy.py#L62-L75 | train | Returns current annealing value | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/policy.py | LinearAnnealedPolicy.select_action | def select_action(self, **kwargs):
"""Choose an action to perform
# Returns
Action to take (int)
"""
setattr(self.inner_policy, self.attr, self.get_current_value())
return self.inner_policy.select_action(**kwargs) | python | def select_action(self, **kwargs):
"""Choose an action to perform
# Returns
Action to take (int)
"""
setattr(self.inner_policy, self.attr, self.get_current_value())
return self.inner_policy.select_action(**kwargs) | [
"def",
"select_action",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"setattr",
"(",
"self",
".",
"inner_policy",
",",
"self",
".",
"attr",
",",
"self",
".",
"get_current_value",
"(",
")",
")",
"return",
"self",
".",
"inner_policy",
".",
"select_actio... | Choose an action to perform
# Returns
Action to take (int) | [
"Choose",
"an",
"action",
"to",
"perform"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/policy.py#L77-L84 | train | Choose an action to perform | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/policy.py | LinearAnnealedPolicy.get_config | def get_config(self):
"""Return configurations of LinearAnnealedPolicy
# Returns
Dict of config
"""
config = super(LinearAnnealedPolicy, self).get_config()
config['attr'] = self.attr
config['value_max'] = self.value_max
config['value_min'] = self.valu... | python | def get_config(self):
"""Return configurations of LinearAnnealedPolicy
# Returns
Dict of config
"""
config = super(LinearAnnealedPolicy, self).get_config()
config['attr'] = self.attr
config['value_max'] = self.value_max
config['value_min'] = self.valu... | [
"def",
"get_config",
"(",
"self",
")",
":",
"config",
"=",
"super",
"(",
"LinearAnnealedPolicy",
",",
"self",
")",
".",
"get_config",
"(",
")",
"config",
"[",
"'attr'",
"]",
"=",
"self",
".",
"attr",
"config",
"[",
"'value_max'",
"]",
"=",
"self",
".",... | Return configurations of LinearAnnealedPolicy
# Returns
Dict of config | [
"Return",
"configurations",
"of",
"LinearAnnealedPolicy"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/policy.py#L105-L118 | train | Returns configurations of LinearAnnealedPolicy
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/policy.py | SoftmaxPolicy.select_action | def select_action(self, nb_actions, probs):
"""Return the selected action
# Arguments
probs (np.ndarray) : Probabilty for each action
# Returns
action
"""
action = np.random.choice(range(nb_actions), p=probs)
return action | python | def select_action(self, nb_actions, probs):
"""Return the selected action
# Arguments
probs (np.ndarray) : Probabilty for each action
# Returns
action
"""
action = np.random.choice(range(nb_actions), p=probs)
return action | [
"def",
"select_action",
"(",
"self",
",",
"nb_actions",
",",
"probs",
")",
":",
"action",
"=",
"np",
".",
"random",
".",
"choice",
"(",
"range",
"(",
"nb_actions",
")",
",",
"p",
"=",
"probs",
")",
"return",
"action"
] | Return the selected action
# Arguments
probs (np.ndarray) : Probabilty for each action
# Returns
action | [
"Return",
"the",
"selected",
"action"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/policy.py#L128-L139 | train | Select a random action from the set of actions. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/policy.py | EpsGreedyQPolicy.select_action | def select_action(self, q_values):
"""Return the selected action
# Arguments
q_values (np.ndarray): List of the estimations of Q for each action
# Returns
Selection action
"""
assert q_values.ndim == 1
nb_actions = q_values.shape[0]
if n... | python | def select_action(self, q_values):
"""Return the selected action
# Arguments
q_values (np.ndarray): List of the estimations of Q for each action
# Returns
Selection action
"""
assert q_values.ndim == 1
nb_actions = q_values.shape[0]
if n... | [
"def",
"select_action",
"(",
"self",
",",
"q_values",
")",
":",
"assert",
"q_values",
".",
"ndim",
"==",
"1",
"nb_actions",
"=",
"q_values",
".",
"shape",
"[",
"0",
"]",
"if",
"np",
".",
"random",
".",
"uniform",
"(",
")",
"<",
"self",
".",
"eps",
... | Return the selected action
# Arguments
q_values (np.ndarray): List of the estimations of Q for each action
# Returns
Selection action | [
"Return",
"the",
"selected",
"action"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/policy.py#L153-L169 | train | Returns the selected action from the estimations of Q for each action in the list q_values. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/policy.py | EpsGreedyQPolicy.get_config | def get_config(self):
"""Return configurations of EpsGreedyQPolicy
# Returns
Dict of config
"""
config = super(EpsGreedyQPolicy, self).get_config()
config['eps'] = self.eps
return config | python | def get_config(self):
"""Return configurations of EpsGreedyQPolicy
# Returns
Dict of config
"""
config = super(EpsGreedyQPolicy, self).get_config()
config['eps'] = self.eps
return config | [
"def",
"get_config",
"(",
"self",
")",
":",
"config",
"=",
"super",
"(",
"EpsGreedyQPolicy",
",",
"self",
")",
".",
"get_config",
"(",
")",
"config",
"[",
"'eps'",
"]",
"=",
"self",
".",
"eps",
"return",
"config"
] | Return configurations of EpsGreedyQPolicy
# Returns
Dict of config | [
"Return",
"configurations",
"of",
"EpsGreedyQPolicy"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/policy.py#L171-L179 | train | Returns configurations of EpsGreedyQPolicy | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/policy.py | GreedyQPolicy.select_action | def select_action(self, q_values):
"""Return the selected action
# Arguments
q_values (np.ndarray): List of the estimations of Q for each action
# Returns
Selection action
"""
assert q_values.ndim == 1
action = np.argmax(q_values)
return ... | python | def select_action(self, q_values):
"""Return the selected action
# Arguments
q_values (np.ndarray): List of the estimations of Q for each action
# Returns
Selection action
"""
assert q_values.ndim == 1
action = np.argmax(q_values)
return ... | [
"def",
"select_action",
"(",
"self",
",",
"q_values",
")",
":",
"assert",
"q_values",
".",
"ndim",
"==",
"1",
"action",
"=",
"np",
".",
"argmax",
"(",
"q_values",
")",
"return",
"action"
] | Return the selected action
# Arguments
q_values (np.ndarray): List of the estimations of Q for each action
# Returns
Selection action | [
"Return",
"the",
"selected",
"action"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/policy.py#L187-L198 | train | Returns the selected action from the estimations of Q for each action in the list q_values | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/policy.py | BoltzmannQPolicy.get_config | def get_config(self):
"""Return configurations of BoltzmannQPolicy
# Returns
Dict of config
"""
config = super(BoltzmannQPolicy, self).get_config()
config['tau'] = self.tau
config['clip'] = self.clip
return config | python | def get_config(self):
"""Return configurations of BoltzmannQPolicy
# Returns
Dict of config
"""
config = super(BoltzmannQPolicy, self).get_config()
config['tau'] = self.tau
config['clip'] = self.clip
return config | [
"def",
"get_config",
"(",
"self",
")",
":",
"config",
"=",
"super",
"(",
"BoltzmannQPolicy",
",",
"self",
")",
".",
"get_config",
"(",
")",
"config",
"[",
"'tau'",
"]",
"=",
"self",
".",
"tau",
"config",
"[",
"'clip'",
"]",
"=",
"self",
".",
"clip",
... | Return configurations of BoltzmannQPolicy
# Returns
Dict of config | [
"Return",
"configurations",
"of",
"BoltzmannQPolicy"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/policy.py#L230-L239 | train | Returns configurations of BoltzmannQPolicy
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/policy.py | MaxBoltzmannQPolicy.select_action | def select_action(self, q_values):
"""Return the selected action
The selected action follows the BoltzmannQPolicy with probability epsilon
or return the Greedy Policy with probability (1 - epsilon)
# Arguments
q_values (np.ndarray): List of the estimations of Q for each acti... | python | def select_action(self, q_values):
"""Return the selected action
The selected action follows the BoltzmannQPolicy with probability epsilon
or return the Greedy Policy with probability (1 - epsilon)
# Arguments
q_values (np.ndarray): List of the estimations of Q for each acti... | [
"def",
"select_action",
"(",
"self",
",",
"q_values",
")",
":",
"assert",
"q_values",
".",
"ndim",
"==",
"1",
"q_values",
"=",
"q_values",
".",
"astype",
"(",
"'float64'",
")",
"nb_actions",
"=",
"q_values",
".",
"shape",
"[",
"0",
"]",
"if",
"np",
"."... | Return the selected action
The selected action follows the BoltzmannQPolicy with probability epsilon
or return the Greedy Policy with probability (1 - epsilon)
# Arguments
q_values (np.ndarray): List of the estimations of Q for each action
# Returns
Selection ac... | [
"Return",
"the",
"selected",
"action",
"The",
"selected",
"action",
"follows",
"the",
"BoltzmannQPolicy",
"with",
"probability",
"epsilon",
"or",
"return",
"the",
"Greedy",
"Policy",
"with",
"probability",
"(",
"1",
"-",
"epsilon",
")"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/policy.py#L257-L278 | train | Select the action from the set of estimations of Q for each action in the cluster. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/policy.py | MaxBoltzmannQPolicy.get_config | def get_config(self):
"""Return configurations of MaxBoltzmannQPolicy
# Returns
Dict of config
"""
config = super(MaxBoltzmannQPolicy, self).get_config()
config['eps'] = self.eps
config['tau'] = self.tau
config['clip'] = self.clip
return confi... | python | def get_config(self):
"""Return configurations of MaxBoltzmannQPolicy
# Returns
Dict of config
"""
config = super(MaxBoltzmannQPolicy, self).get_config()
config['eps'] = self.eps
config['tau'] = self.tau
config['clip'] = self.clip
return confi... | [
"def",
"get_config",
"(",
"self",
")",
":",
"config",
"=",
"super",
"(",
"MaxBoltzmannQPolicy",
",",
"self",
")",
".",
"get_config",
"(",
")",
"config",
"[",
"'eps'",
"]",
"=",
"self",
".",
"eps",
"config",
"[",
"'tau'",
"]",
"=",
"self",
".",
"tau",... | Return configurations of MaxBoltzmannQPolicy
# Returns
Dict of config | [
"Return",
"configurations",
"of",
"MaxBoltzmannQPolicy"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/policy.py#L280-L290 | train | Return configurations of MaxBoltzmannQPolicy | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/policy.py | BoltzmannGumbelQPolicy.select_action | def select_action(self, q_values):
"""Return the selected action
# Arguments
q_values (np.ndarray): List of the estimations of Q for each action
# Returns
Selection action
"""
# We can't use BGE during testing, since we don't have access to the
#... | python | def select_action(self, q_values):
"""Return the selected action
# Arguments
q_values (np.ndarray): List of the estimations of Q for each action
# Returns
Selection action
"""
# We can't use BGE during testing, since we don't have access to the
#... | [
"def",
"select_action",
"(",
"self",
",",
"q_values",
")",
":",
"# We can't use BGE during testing, since we don't have access to the",
"# action_counts at the end of training.",
"assert",
"self",
".",
"agent",
".",
"training",
",",
"\"BoltzmannGumbelQPolicy should only be used for... | Return the selected action
# Arguments
q_values (np.ndarray): List of the estimations of Q for each action
# Returns
Selection action | [
"Return",
"the",
"selected",
"action"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/policy.py#L314-L346 | train | Select the next action from the set of estimations of Q for each action in the cluster. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/policy.py | BoltzmannGumbelQPolicy.get_config | def get_config(self):
"""Return configurations of BoltzmannGumbelQPolicy
# Returns
Dict of config
"""
config = super(BoltzmannGumbelQPolicy, self).get_config()
config['C'] = self.C
return config | python | def get_config(self):
"""Return configurations of BoltzmannGumbelQPolicy
# Returns
Dict of config
"""
config = super(BoltzmannGumbelQPolicy, self).get_config()
config['C'] = self.C
return config | [
"def",
"get_config",
"(",
"self",
")",
":",
"config",
"=",
"super",
"(",
"BoltzmannGumbelQPolicy",
",",
"self",
")",
".",
"get_config",
"(",
")",
"config",
"[",
"'C'",
"]",
"=",
"self",
".",
"C",
"return",
"config"
] | Return configurations of BoltzmannGumbelQPolicy
# Returns
Dict of config | [
"Return",
"configurations",
"of",
"BoltzmannGumbelQPolicy"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/policy.py#L348-L356 | train | Returns configurations of BoltzmannGumbelQPolicy | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/callbacks.py | CallbackList._set_env | def _set_env(self, env):
""" Set environment for each callback in callbackList """
for callback in self.callbacks:
if callable(getattr(callback, '_set_env', None)):
callback._set_env(env) | python | def _set_env(self, env):
""" Set environment for each callback in callbackList """
for callback in self.callbacks:
if callable(getattr(callback, '_set_env', None)):
callback._set_env(env) | [
"def",
"_set_env",
"(",
"self",
",",
"env",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"if",
"callable",
"(",
"getattr",
"(",
"callback",
",",
"'_set_env'",
",",
"None",
")",
")",
":",
"callback",
".",
"_set_env",
"(",
"env",
"... | Set environment for each callback in callbackList | [
"Set",
"environment",
"for",
"each",
"callback",
"in",
"callbackList"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/callbacks.py#L45-L49 | train | Set the environment for all the callbacks in callbackList. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/callbacks.py | CallbackList.on_episode_begin | def on_episode_begin(self, episode, logs={}):
""" Called at beginning of each episode for each callback in callbackList"""
for callback in self.callbacks:
# Check if callback supports the more appropriate `on_episode_begin` callback.
# If not, fall back to `on_epoch_begin` to be ... | python | def on_episode_begin(self, episode, logs={}):
""" Called at beginning of each episode for each callback in callbackList"""
for callback in self.callbacks:
# Check if callback supports the more appropriate `on_episode_begin` callback.
# If not, fall back to `on_epoch_begin` to be ... | [
"def",
"on_episode_begin",
"(",
"self",
",",
"episode",
",",
"logs",
"=",
"{",
"}",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"# Check if callback supports the more appropriate `on_episode_begin` callback.",
"# If not, fall back to `on_epoch_begin` t... | Called at beginning of each episode for each callback in callbackList | [
"Called",
"at",
"beginning",
"of",
"each",
"episode",
"for",
"each",
"callback",
"in",
"callbackList"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/callbacks.py#L51-L59 | train | Called at beginning of each episode for each callback in callbackList | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/callbacks.py | CallbackList.on_episode_end | def on_episode_end(self, episode, logs={}):
""" Called at end of each episode for each callback in callbackList"""
for callback in self.callbacks:
# Check if callback supports the more appropriate `on_episode_end` callback.
# If not, fall back to `on_epoch_end` to be compatible w... | python | def on_episode_end(self, episode, logs={}):
""" Called at end of each episode for each callback in callbackList"""
for callback in self.callbacks:
# Check if callback supports the more appropriate `on_episode_end` callback.
# If not, fall back to `on_epoch_end` to be compatible w... | [
"def",
"on_episode_end",
"(",
"self",
",",
"episode",
",",
"logs",
"=",
"{",
"}",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"# Check if callback supports the more appropriate `on_episode_end` callback.",
"# If not, fall back to `on_epoch_end` to be c... | Called at end of each episode for each callback in callbackList | [
"Called",
"at",
"end",
"of",
"each",
"episode",
"for",
"each",
"callback",
"in",
"callbackList"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/callbacks.py#L61-L69 | train | Called at end of each episode for each callback in callbackList | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/callbacks.py | CallbackList.on_step_begin | def on_step_begin(self, step, logs={}):
""" Called at beginning of each step for each callback in callbackList"""
for callback in self.callbacks:
# Check if callback supports the more appropriate `on_step_begin` callback.
# If not, fall back to `on_batch_begin` to be compatible w... | python | def on_step_begin(self, step, logs={}):
""" Called at beginning of each step for each callback in callbackList"""
for callback in self.callbacks:
# Check if callback supports the more appropriate `on_step_begin` callback.
# If not, fall back to `on_batch_begin` to be compatible w... | [
"def",
"on_step_begin",
"(",
"self",
",",
"step",
",",
"logs",
"=",
"{",
"}",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"# Check if callback supports the more appropriate `on_step_begin` callback.",
"# If not, fall back to `on_batch_begin` to be comp... | Called at beginning of each step for each callback in callbackList | [
"Called",
"at",
"beginning",
"of",
"each",
"step",
"for",
"each",
"callback",
"in",
"callbackList"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/callbacks.py#L71-L79 | train | Called at beginning of each step for each callback in callbackList | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/callbacks.py | CallbackList.on_step_end | def on_step_end(self, step, logs={}):
""" Called at end of each step for each callback in callbackList"""
for callback in self.callbacks:
# Check if callback supports the more appropriate `on_step_end` callback.
# If not, fall back to `on_batch_end` to be compatible with built-in... | python | def on_step_end(self, step, logs={}):
""" Called at end of each step for each callback in callbackList"""
for callback in self.callbacks:
# Check if callback supports the more appropriate `on_step_end` callback.
# If not, fall back to `on_batch_end` to be compatible with built-in... | [
"def",
"on_step_end",
"(",
"self",
",",
"step",
",",
"logs",
"=",
"{",
"}",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"# Check if callback supports the more appropriate `on_step_end` callback.",
"# If not, fall back to `on_batch_end` to be compatible... | Called at end of each step for each callback in callbackList | [
"Called",
"at",
"end",
"of",
"each",
"step",
"for",
"each",
"callback",
"in",
"callbackList"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/callbacks.py#L81-L89 | train | Called at end of each step for each callback in callbackList | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/callbacks.py | CallbackList.on_action_begin | def on_action_begin(self, action, logs={}):
""" Called at beginning of each action for each callback in callbackList"""
for callback in self.callbacks:
if callable(getattr(callback, 'on_action_begin', None)):
callback.on_action_begin(action, logs=logs) | python | def on_action_begin(self, action, logs={}):
""" Called at beginning of each action for each callback in callbackList"""
for callback in self.callbacks:
if callable(getattr(callback, 'on_action_begin', None)):
callback.on_action_begin(action, logs=logs) | [
"def",
"on_action_begin",
"(",
"self",
",",
"action",
",",
"logs",
"=",
"{",
"}",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"if",
"callable",
"(",
"getattr",
"(",
"callback",
",",
"'on_action_begin'",
",",
"None",
")",
")",
":",... | Called at beginning of each action for each callback in callbackList | [
"Called",
"at",
"beginning",
"of",
"each",
"action",
"for",
"each",
"callback",
"in",
"callbackList"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/callbacks.py#L91-L95 | train | Called at beginning of each action for each callback in callbackList | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/callbacks.py | CallbackList.on_action_end | def on_action_end(self, action, logs={}):
""" Called at end of each action for each callback in callbackList"""
for callback in self.callbacks:
if callable(getattr(callback, 'on_action_end', None)):
callback.on_action_end(action, logs=logs) | python | def on_action_end(self, action, logs={}):
""" Called at end of each action for each callback in callbackList"""
for callback in self.callbacks:
if callable(getattr(callback, 'on_action_end', None)):
callback.on_action_end(action, logs=logs) | [
"def",
"on_action_end",
"(",
"self",
",",
"action",
",",
"logs",
"=",
"{",
"}",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"if",
"callable",
"(",
"getattr",
"(",
"callback",
",",
"'on_action_end'",
",",
"None",
")",
")",
":",
"... | Called at end of each action for each callback in callbackList | [
"Called",
"at",
"end",
"of",
"each",
"action",
"for",
"each",
"callback",
"in",
"callbackList"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/callbacks.py#L97-L101 | train | Called at end of each action for each callback in callbackList | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/callbacks.py | TrainEpisodeLogger.on_train_begin | def on_train_begin(self, logs):
""" Print training values at beginning of training """
self.train_start = timeit.default_timer()
self.metrics_names = self.model.metrics_names
print('Training for {} steps ...'.format(self.params['nb_steps'])) | python | def on_train_begin(self, logs):
""" Print training values at beginning of training """
self.train_start = timeit.default_timer()
self.metrics_names = self.model.metrics_names
print('Training for {} steps ...'.format(self.params['nb_steps'])) | [
"def",
"on_train_begin",
"(",
"self",
",",
"logs",
")",
":",
"self",
".",
"train_start",
"=",
"timeit",
".",
"default_timer",
"(",
")",
"self",
".",
"metrics_names",
"=",
"self",
".",
"model",
".",
"metrics_names",
"print",
"(",
"'Training for {} steps ...'",
... | Print training values at beginning of training | [
"Print",
"training",
"values",
"at",
"beginning",
"of",
"training"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/callbacks.py#L133-L137 | train | Print training values at beginning of training | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/callbacks.py | TrainEpisodeLogger.on_train_end | def on_train_end(self, logs):
""" Print training time at end of training """
duration = timeit.default_timer() - self.train_start
print('done, took {:.3f} seconds'.format(duration)) | python | def on_train_end(self, logs):
""" Print training time at end of training """
duration = timeit.default_timer() - self.train_start
print('done, took {:.3f} seconds'.format(duration)) | [
"def",
"on_train_end",
"(",
"self",
",",
"logs",
")",
":",
"duration",
"=",
"timeit",
".",
"default_timer",
"(",
")",
"-",
"self",
".",
"train_start",
"print",
"(",
"'done, took {:.3f} seconds'",
".",
"format",
"(",
"duration",
")",
")"
] | Print training time at end of training | [
"Print",
"training",
"time",
"at",
"end",
"of",
"training"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/callbacks.py#L139-L142 | train | Print training time at end of training | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/callbacks.py | TrainEpisodeLogger.on_episode_begin | def on_episode_begin(self, episode, logs):
""" Reset environment variables at beginning of each episode """
self.episode_start[episode] = timeit.default_timer()
self.observations[episode] = []
self.rewards[episode] = []
self.actions[episode] = []
self.metrics[episode] = [... | python | def on_episode_begin(self, episode, logs):
""" Reset environment variables at beginning of each episode """
self.episode_start[episode] = timeit.default_timer()
self.observations[episode] = []
self.rewards[episode] = []
self.actions[episode] = []
self.metrics[episode] = [... | [
"def",
"on_episode_begin",
"(",
"self",
",",
"episode",
",",
"logs",
")",
":",
"self",
".",
"episode_start",
"[",
"episode",
"]",
"=",
"timeit",
".",
"default_timer",
"(",
")",
"self",
".",
"observations",
"[",
"episode",
"]",
"=",
"[",
"]",
"self",
".... | Reset environment variables at beginning of each episode | [
"Reset",
"environment",
"variables",
"at",
"beginning",
"of",
"each",
"episode"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/callbacks.py#L144-L150 | train | Reset environment variables at beginning of each episode | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/callbacks.py | TrainEpisodeLogger.on_episode_end | def on_episode_end(self, episode, logs):
""" Compute and print training statistics of the episode when done """
duration = timeit.default_timer() - self.episode_start[episode]
episode_steps = len(self.observations[episode])
# Format all metrics.
metrics = np.array(self.metrics[e... | python | def on_episode_end(self, episode, logs):
""" Compute and print training statistics of the episode when done """
duration = timeit.default_timer() - self.episode_start[episode]
episode_steps = len(self.observations[episode])
# Format all metrics.
metrics = np.array(self.metrics[e... | [
"def",
"on_episode_end",
"(",
"self",
",",
"episode",
",",
"logs",
")",
":",
"duration",
"=",
"timeit",
".",
"default_timer",
"(",
")",
"-",
"self",
".",
"episode_start",
"[",
"episode",
"]",
"episode_steps",
"=",
"len",
"(",
"self",
".",
"observations",
... | Compute and print training statistics of the episode when done | [
"Compute",
"and",
"print",
"training",
"statistics",
"of",
"the",
"episode",
"when",
"done"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/callbacks.py#L152-L203 | train | Compute and print training statistics of the episode when done | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/callbacks.py | TrainEpisodeLogger.on_step_end | def on_step_end(self, step, logs):
""" Update statistics of episode after each step """
episode = logs['episode']
self.observations[episode].append(logs['observation'])
self.rewards[episode].append(logs['reward'])
self.actions[episode].append(logs['action'])
self.metrics[... | python | def on_step_end(self, step, logs):
""" Update statistics of episode after each step """
episode = logs['episode']
self.observations[episode].append(logs['observation'])
self.rewards[episode].append(logs['reward'])
self.actions[episode].append(logs['action'])
self.metrics[... | [
"def",
"on_step_end",
"(",
"self",
",",
"step",
",",
"logs",
")",
":",
"episode",
"=",
"logs",
"[",
"'episode'",
"]",
"self",
".",
"observations",
"[",
"episode",
"]",
".",
"append",
"(",
"logs",
"[",
"'observation'",
"]",
")",
"self",
".",
"rewards",
... | Update statistics of episode after each step | [
"Update",
"statistics",
"of",
"episode",
"after",
"each",
"step"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/callbacks.py#L205-L212 | train | Update statistics of episode after each step | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/callbacks.py | TrainIntervalLogger.reset | def reset(self):
""" Reset statistics """
self.interval_start = timeit.default_timer()
self.progbar = Progbar(target=self.interval)
self.metrics = []
self.infos = []
self.info_names = None
self.episode_rewards = [] | python | def reset(self):
""" Reset statistics """
self.interval_start = timeit.default_timer()
self.progbar = Progbar(target=self.interval)
self.metrics = []
self.infos = []
self.info_names = None
self.episode_rewards = [] | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"interval_start",
"=",
"timeit",
".",
"default_timer",
"(",
")",
"self",
".",
"progbar",
"=",
"Progbar",
"(",
"target",
"=",
"self",
".",
"interval",
")",
"self",
".",
"metrics",
"=",
"[",
"]",
"sel... | Reset statistics | [
"Reset",
"statistics"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/callbacks.py#L221-L228 | train | Reset statistics to empty | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/callbacks.py | TrainIntervalLogger.on_step_begin | def on_step_begin(self, step, logs):
""" Print metrics if interval is over """
if self.step % self.interval == 0:
if len(self.episode_rewards) > 0:
metrics = np.array(self.metrics)
assert metrics.shape == (self.interval, len(self.metrics_names))
... | python | def on_step_begin(self, step, logs):
""" Print metrics if interval is over """
if self.step % self.interval == 0:
if len(self.episode_rewards) > 0:
metrics = np.array(self.metrics)
assert metrics.shape == (self.interval, len(self.metrics_names))
... | [
"def",
"on_step_begin",
"(",
"self",
",",
"step",
",",
"logs",
")",
":",
"if",
"self",
".",
"step",
"%",
"self",
".",
"interval",
"==",
"0",
":",
"if",
"len",
"(",
"self",
".",
"episode_rewards",
")",
">",
"0",
":",
"metrics",
"=",
"np",
".",
"ar... | Print metrics if interval is over | [
"Print",
"metrics",
"if",
"interval",
"is",
"over"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/callbacks.py#L241-L265 | train | Print metrics if interval is over | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/callbacks.py | TrainIntervalLogger.on_step_end | def on_step_end(self, step, logs):
""" Update progression bar at the end of each step """
if self.info_names is None:
self.info_names = logs['info'].keys()
values = [('reward', logs['reward'])]
if KERAS_VERSION > '2.1.3':
self.progbar.update((self.step % self.inte... | python | def on_step_end(self, step, logs):
""" Update progression bar at the end of each step """
if self.info_names is None:
self.info_names = logs['info'].keys()
values = [('reward', logs['reward'])]
if KERAS_VERSION > '2.1.3':
self.progbar.update((self.step % self.inte... | [
"def",
"on_step_end",
"(",
"self",
",",
"step",
",",
"logs",
")",
":",
"if",
"self",
".",
"info_names",
"is",
"None",
":",
"self",
".",
"info_names",
"=",
"logs",
"[",
"'info'",
"]",
".",
"keys",
"(",
")",
"values",
"=",
"[",
"(",
"'reward'",
",",
... | Update progression bar at the end of each step | [
"Update",
"progression",
"bar",
"at",
"the",
"end",
"of",
"each",
"step"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/callbacks.py#L267-L279 | train | Update progression bar at the end of each step | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/callbacks.py | FileLogger.on_episode_begin | def on_episode_begin(self, episode, logs):
""" Initialize metrics at the beginning of each episode """
assert episode not in self.metrics
assert episode not in self.starts
self.metrics[episode] = []
self.starts[episode] = timeit.default_timer() | python | def on_episode_begin(self, episode, logs):
""" Initialize metrics at the beginning of each episode """
assert episode not in self.metrics
assert episode not in self.starts
self.metrics[episode] = []
self.starts[episode] = timeit.default_timer() | [
"def",
"on_episode_begin",
"(",
"self",
",",
"episode",
",",
"logs",
")",
":",
"assert",
"episode",
"not",
"in",
"self",
".",
"metrics",
"assert",
"episode",
"not",
"in",
"self",
".",
"starts",
"self",
".",
"metrics",
"[",
"episode",
"]",
"=",
"[",
"]"... | Initialize metrics at the beginning of each episode | [
"Initialize",
"metrics",
"at",
"the",
"beginning",
"of",
"each",
"episode"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/callbacks.py#L305-L310 | train | Initialize metrics at the beginning of each episode | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/callbacks.py | FileLogger.on_episode_end | def on_episode_end(self, episode, logs):
""" Compute and print metrics at the end of each episode """
duration = timeit.default_timer() - self.starts[episode]
metrics = self.metrics[episode]
if np.isnan(metrics).all():
mean_metrics = np.array([np.nan for _ in self.metrics_n... | python | def on_episode_end(self, episode, logs):
""" Compute and print metrics at the end of each episode """
duration = timeit.default_timer() - self.starts[episode]
metrics = self.metrics[episode]
if np.isnan(metrics).all():
mean_metrics = np.array([np.nan for _ in self.metrics_n... | [
"def",
"on_episode_end",
"(",
"self",
",",
"episode",
",",
"logs",
")",
":",
"duration",
"=",
"timeit",
".",
"default_timer",
"(",
")",
"-",
"self",
".",
"starts",
"[",
"episode",
"]",
"metrics",
"=",
"self",
".",
"metrics",
"[",
"episode",
"]",
"if",
... | Compute and print metrics at the end of each episode | [
"Compute",
"and",
"print",
"metrics",
"at",
"the",
"end",
"of",
"each",
"episode"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/callbacks.py#L312-L336 | train | Compute and print metrics at the end of each episode | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/callbacks.py | FileLogger.save_data | def save_data(self):
""" Save metrics in a json file """
if len(self.data.keys()) == 0:
return
# Sort everything by episode.
assert 'episode' in self.data
sorted_indexes = np.argsort(self.data['episode'])
sorted_data = {}
for key, values in self.data.... | python | def save_data(self):
""" Save metrics in a json file """
if len(self.data.keys()) == 0:
return
# Sort everything by episode.
assert 'episode' in self.data
sorted_indexes = np.argsort(self.data['episode'])
sorted_data = {}
for key, values in self.data.... | [
"def",
"save_data",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"data",
".",
"keys",
"(",
")",
")",
"==",
"0",
":",
"return",
"# Sort everything by episode.",
"assert",
"'episode'",
"in",
"self",
".",
"data",
"sorted_indexes",
"=",
"np",
".",
... | Save metrics in a json file | [
"Save",
"metrics",
"in",
"a",
"json",
"file"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/callbacks.py#L342-L360 | train | Save metrics in a json file. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/callbacks.py | ModelIntervalCheckpoint.on_step_end | def on_step_end(self, step, logs={}):
""" Save weights at interval steps during training """
self.total_steps += 1
if self.total_steps % self.interval != 0:
# Nothing to do.
return
filepath = self.filepath.format(step=self.total_steps, **logs)
if self.ver... | python | def on_step_end(self, step, logs={}):
""" Save weights at interval steps during training """
self.total_steps += 1
if self.total_steps % self.interval != 0:
# Nothing to do.
return
filepath = self.filepath.format(step=self.total_steps, **logs)
if self.ver... | [
"def",
"on_step_end",
"(",
"self",
",",
"step",
",",
"logs",
"=",
"{",
"}",
")",
":",
"self",
".",
"total_steps",
"+=",
"1",
"if",
"self",
".",
"total_steps",
"%",
"self",
".",
"interval",
"!=",
"0",
":",
"# Nothing to do.",
"return",
"filepath",
"=",
... | Save weights at interval steps during training | [
"Save",
"weights",
"at",
"interval",
"steps",
"during",
"training"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/callbacks.py#L377-L387 | train | Save weights at interval steps during training | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/memory.py | sample_batch_indexes | def sample_batch_indexes(low, high, size):
"""Return a sample of (size) unique elements between low and high
# Argument
low (int): The minimum value for our samples
high (int): The maximum value for our samples
size (int): The number of samples to pick
# Returns... | python | def sample_batch_indexes(low, high, size):
"""Return a sample of (size) unique elements between low and high
# Argument
low (int): The minimum value for our samples
high (int): The maximum value for our samples
size (int): The number of samples to pick
# Returns... | [
"def",
"sample_batch_indexes",
"(",
"low",
",",
"high",
",",
"size",
")",
":",
"if",
"high",
"-",
"low",
">=",
"size",
":",
"# We have enough data. Draw without replacement, that is each index is unique in the",
"# batch. We cannot use `np.random.choice` here because it is horrib... | Return a sample of (size) unique elements between low and high
# Argument
low (int): The minimum value for our samples
high (int): The maximum value for our samples
size (int): The number of samples to pick
# Returns
A list of samples of length size, wit... | [
"Return",
"a",
"sample",
"of",
"(",
"size",
")",
"unique",
"elements",
"between",
"low",
"and",
"high"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/memory.py#L14-L42 | train | Return a random batch of size unique elements between low and high. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/memory.py | zeroed_observation | def zeroed_observation(observation):
"""Return an array of zeros with same shape as given observation
# Argument
observation (list): List of observation
# Return
A np.ndarray of zeros with observation.shape
"""
if hasattr(observation, 'shape'):
return np.zeros(observati... | python | def zeroed_observation(observation):
"""Return an array of zeros with same shape as given observation
# Argument
observation (list): List of observation
# Return
A np.ndarray of zeros with observation.shape
"""
if hasattr(observation, 'shape'):
return np.zeros(observati... | [
"def",
"zeroed_observation",
"(",
"observation",
")",
":",
"if",
"hasattr",
"(",
"observation",
",",
"'shape'",
")",
":",
"return",
"np",
".",
"zeros",
"(",
"observation",
".",
"shape",
")",
"elif",
"hasattr",
"(",
"observation",
",",
"'__iter__'",
")",
":... | Return an array of zeros with same shape as given observation
# Argument
observation (list): List of observation
# Return
A np.ndarray of zeros with observation.shape | [
"Return",
"an",
"array",
"of",
"zeros",
"with",
"same",
"shape",
"as",
"given",
"observation"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/memory.py#L85-L102 | train | Return an array of zeros with same shape as given observation | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/memory.py | Memory.get_recent_state | def get_recent_state(self, current_observation):
"""Return list of last observations
# Argument
current_observation (object): Last observation
# Returns
A list of the last observations
"""
# This code is slightly complicated by the fact that subsequent o... | python | def get_recent_state(self, current_observation):
"""Return list of last observations
# Argument
current_observation (object): Last observation
# Returns
A list of the last observations
"""
# This code is slightly complicated by the fact that subsequent o... | [
"def",
"get_recent_state",
"(",
"self",
",",
"current_observation",
")",
":",
"# This code is slightly complicated by the fact that subsequent observations might be",
"# from different episodes. We ensure that an experience never spans multiple episodes.",
"# This is probably not that important ... | Return list of last observations
# Argument
current_observation (object): Last observation
# Returns
A list of the last observations | [
"Return",
"list",
"of",
"last",
"observations"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/memory.py#L120-L144 | train | Return the state of the recent episode. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/memory.py | SequentialMemory.sample | def sample(self, batch_size, batch_idxs=None):
"""Return a randomized batch of experiences
# Argument
batch_size (int): Size of the all batch
batch_idxs (int): Indexes to extract
# Returns
A list of experiences randomly selected
"""
# It is no... | python | def sample(self, batch_size, batch_idxs=None):
"""Return a randomized batch of experiences
# Argument
batch_size (int): Size of the all batch
batch_idxs (int): Indexes to extract
# Returns
A list of experiences randomly selected
"""
# It is no... | [
"def",
"sample",
"(",
"self",
",",
"batch_size",
",",
"batch_idxs",
"=",
"None",
")",
":",
"# It is not possible to tell whether the first state in the memory is terminal, because it",
"# would require access to the \"terminal\" flag associated to the previous state. As a result",
"# we ... | Return a randomized batch of experiences
# Argument
batch_size (int): Size of the all batch
batch_idxs (int): Indexes to extract
# Returns
A list of experiences randomly selected | [
"Return",
"a",
"randomized",
"batch",
"of",
"experiences"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/memory.py#L171-L239 | train | Return a randomized batch of experiences from the memory. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/memory.py | SequentialMemory.append | def append(self, observation, action, reward, terminal, training=True):
"""Append an observation to the memory
# Argument
observation (dict): Observation returned by environment
action (int): Action taken to obtain this observation
reward (float): Reward obtained by ... | python | def append(self, observation, action, reward, terminal, training=True):
"""Append an observation to the memory
# Argument
observation (dict): Observation returned by environment
action (int): Action taken to obtain this observation
reward (float): Reward obtained by ... | [
"def",
"append",
"(",
"self",
",",
"observation",
",",
"action",
",",
"reward",
",",
"terminal",
",",
"training",
"=",
"True",
")",
":",
"super",
"(",
"SequentialMemory",
",",
"self",
")",
".",
"append",
"(",
"observation",
",",
"action",
",",
"reward",
... | Append an observation to the memory
# Argument
observation (dict): Observation returned by environment
action (int): Action taken to obtain this observation
reward (float): Reward obtained by taking this action
terminal (boolean): Is the state terminal | [
"Append",
"an",
"observation",
"to",
"the",
"memory"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/memory.py#L241-L258 | train | Append an observation to the memory. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/memory.py | SequentialMemory.get_config | def get_config(self):
"""Return configurations of SequentialMemory
# Returns
Dict of config
"""
config = super(SequentialMemory, self).get_config()
config['limit'] = self.limit
return config | python | def get_config(self):
"""Return configurations of SequentialMemory
# Returns
Dict of config
"""
config = super(SequentialMemory, self).get_config()
config['limit'] = self.limit
return config | [
"def",
"get_config",
"(",
"self",
")",
":",
"config",
"=",
"super",
"(",
"SequentialMemory",
",",
"self",
")",
".",
"get_config",
"(",
")",
"config",
"[",
"'limit'",
"]",
"=",
"self",
".",
"limit",
"return",
"config"
] | Return configurations of SequentialMemory
# Returns
Dict of config | [
"Return",
"configurations",
"of",
"SequentialMemory"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/memory.py#L269-L277 | train | Returns configurations of SequentialMemory
Dict | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/memory.py | EpisodeParameterMemory.sample | def sample(self, batch_size, batch_idxs=None):
"""Return a randomized batch of params and rewards
# Argument
batch_size (int): Size of the all batch
batch_idxs (int): Indexes to extract
# Returns
A list of params randomly selected and a list of associated rew... | python | def sample(self, batch_size, batch_idxs=None):
"""Return a randomized batch of params and rewards
# Argument
batch_size (int): Size of the all batch
batch_idxs (int): Indexes to extract
# Returns
A list of params randomly selected and a list of associated rew... | [
"def",
"sample",
"(",
"self",
",",
"batch_size",
",",
"batch_idxs",
"=",
"None",
")",
":",
"if",
"batch_idxs",
"is",
"None",
":",
"batch_idxs",
"=",
"sample_batch_indexes",
"(",
"0",
",",
"self",
".",
"nb_entries",
",",
"size",
"=",
"batch_size",
")",
"a... | Return a randomized batch of params and rewards
# Argument
batch_size (int): Size of the all batch
batch_idxs (int): Indexes to extract
# Returns
A list of params randomly selected and a list of associated rewards | [
"Return",
"a",
"randomized",
"batch",
"of",
"params",
"and",
"rewards"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/memory.py#L289-L307 | train | Return a randomized batch of params and rewards from the current state of the cluster. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/memory.py | EpisodeParameterMemory.append | def append(self, observation, action, reward, terminal, training=True):
"""Append a reward to the memory
# Argument
observation (dict): Observation returned by environment
action (int): Action taken to obtain this observation
reward (float): Reward obtained by taking... | python | def append(self, observation, action, reward, terminal, training=True):
"""Append a reward to the memory
# Argument
observation (dict): Observation returned by environment
action (int): Action taken to obtain this observation
reward (float): Reward obtained by taking... | [
"def",
"append",
"(",
"self",
",",
"observation",
",",
"action",
",",
"reward",
",",
"terminal",
",",
"training",
"=",
"True",
")",
":",
"super",
"(",
"EpisodeParameterMemory",
",",
"self",
")",
".",
"append",
"(",
"observation",
",",
"action",
",",
"rew... | Append a reward to the memory
# Argument
observation (dict): Observation returned by environment
action (int): Action taken to obtain this observation
reward (float): Reward obtained by taking this action
terminal (boolean): Is the state terminal | [
"Append",
"a",
"reward",
"to",
"the",
"memory"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/memory.py#L309-L320 | train | Append a reward to the memory | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/memory.py | EpisodeParameterMemory.finalize_episode | def finalize_episode(self, params):
"""Closes the current episode, sums up rewards and stores the parameters
# Argument
params (object): Parameters associated with the episode to be stored and then retrieved back in sample()
"""
total_reward = sum(self.intermediate_rewards)
... | python | def finalize_episode(self, params):
"""Closes the current episode, sums up rewards and stores the parameters
# Argument
params (object): Parameters associated with the episode to be stored and then retrieved back in sample()
"""
total_reward = sum(self.intermediate_rewards)
... | [
"def",
"finalize_episode",
"(",
"self",
",",
"params",
")",
":",
"total_reward",
"=",
"sum",
"(",
"self",
".",
"intermediate_rewards",
")",
"self",
".",
"total_rewards",
".",
"append",
"(",
"total_reward",
")",
"self",
".",
"params",
".",
"append",
"(",
"p... | Closes the current episode, sums up rewards and stores the parameters
# Argument
params (object): Parameters associated with the episode to be stored and then retrieved back in sample() | [
"Closes",
"the",
"current",
"episode",
"sums",
"up",
"rewards",
"and",
"stores",
"the",
"parameters"
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/memory.py#L322-L331 | train | Closes the current episode sums up rewards and stores the parameters | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
keras-rl/keras-rl | rl/common/cmd_util.py | make_gym_env | def make_gym_env(env_id, num_env=2, seed=123, wrapper_kwargs=None, start_index=0):
"""
Create a wrapped, SubprocVecEnv for Gym Environments.
"""
if wrapper_kwargs is None:
wrapper_kwargs = {}
def make_env(rank): # pylint: disable=C0111
def _thunk():
env = gym.make(env_id... | python | def make_gym_env(env_id, num_env=2, seed=123, wrapper_kwargs=None, start_index=0):
"""
Create a wrapped, SubprocVecEnv for Gym Environments.
"""
if wrapper_kwargs is None:
wrapper_kwargs = {}
def make_env(rank): # pylint: disable=C0111
def _thunk():
env = gym.make(env_id... | [
"def",
"make_gym_env",
"(",
"env_id",
",",
"num_env",
"=",
"2",
",",
"seed",
"=",
"123",
",",
"wrapper_kwargs",
"=",
"None",
",",
"start_index",
"=",
"0",
")",
":",
"if",
"wrapper_kwargs",
"is",
"None",
":",
"wrapper_kwargs",
"=",
"{",
"}",
"def",
"mak... | Create a wrapped, SubprocVecEnv for Gym Environments. | [
"Create",
"a",
"wrapped",
"SubprocVecEnv",
"for",
"Gym",
"Environments",
"."
] | e6efb0d8297ec38d704a3110b5d6ed74d09a05e3 | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/common/cmd_util.py#L7-L22 | train | Create a wrapped Gym Environments. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
awslabs/aws-sam-cli | samcli/commands/local/cli_common/options.py | invoke_common_options | def invoke_common_options(f):
"""
Common CLI options shared by "local invoke" and "local start-api" commands
:param f: Callback passed by Click
"""
invoke_options = [
template_click_option(),
click.option('--env-vars', '-n',
type=click.Path(exists=True),
... | python | def invoke_common_options(f):
"""
Common CLI options shared by "local invoke" and "local start-api" commands
:param f: Callback passed by Click
"""
invoke_options = [
template_click_option(),
click.option('--env-vars', '-n',
type=click.Path(exists=True),
... | [
"def",
"invoke_common_options",
"(",
"f",
")",
":",
"invoke_options",
"=",
"[",
"template_click_option",
"(",
")",
",",
"click",
".",
"option",
"(",
"'--env-vars'",
",",
"'-n'",
",",
"type",
"=",
"click",
".",
"Path",
"(",
"exists",
"=",
"True",
")",
","... | Common CLI options shared by "local invoke" and "local start-api" commands
:param f: Callback passed by Click | [
"Common",
"CLI",
"options",
"shared",
"by",
"local",
"invoke",
"and",
"local",
"start",
"-",
"api",
"commands"
] | c05af5e7378c6f05f7d82ad3f0bca17204177db6 | https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/cli_common/options.py#L73-L130 | train | Common CLI options shared by local invoke and local start - api commands | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
awslabs/aws-sam-cli | samcli/commands/_utils/options.py | get_or_default_template_file_name | def get_or_default_template_file_name(ctx, param, provided_value, include_build):
"""
Default value for the template file name option is more complex than what Click can handle.
This method either returns user provided file name or one of the two default options (template.yaml/template.yml)
depending on... | python | def get_or_default_template_file_name(ctx, param, provided_value, include_build):
"""
Default value for the template file name option is more complex than what Click can handle.
This method either returns user provided file name or one of the two default options (template.yaml/template.yml)
depending on... | [
"def",
"get_or_default_template_file_name",
"(",
"ctx",
",",
"param",
",",
"provided_value",
",",
"include_build",
")",
":",
"search_paths",
"=",
"[",
"\"template.yaml\"",
",",
"\"template.yml\"",
",",
"]",
"if",
"include_build",
":",
"search_paths",
".",
"insert",
... | Default value for the template file name option is more complex than what Click can handle.
This method either returns user provided file name or one of the two default options (template.yaml/template.yml)
depending on the file that exists
:param ctx: Click Context
:param param: Param name
:param p... | [
"Default",
"value",
"for",
"the",
"template",
"file",
"name",
"option",
"is",
"more",
"complex",
"than",
"what",
"Click",
"can",
"handle",
".",
"This",
"method",
"either",
"returns",
"user",
"provided",
"file",
"name",
"or",
"one",
"of",
"the",
"two",
"def... | c05af5e7378c6f05f7d82ad3f0bca17204177db6 | https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/_utils/options.py#L18-L50 | train | This method returns the user provided file name or default value for the SAM Template file name. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
awslabs/aws-sam-cli | samcli/commands/_utils/options.py | template_click_option | def template_click_option(include_build=True):
"""
Click Option for template option
"""
return click.option('--template', '-t',
default=_TEMPLATE_OPTION_DEFAULT_VALUE,
type=click.Path(),
envvar="SAM_TEMPLATE_FILE",
... | python | def template_click_option(include_build=True):
"""
Click Option for template option
"""
return click.option('--template', '-t',
default=_TEMPLATE_OPTION_DEFAULT_VALUE,
type=click.Path(),
envvar="SAM_TEMPLATE_FILE",
... | [
"def",
"template_click_option",
"(",
"include_build",
"=",
"True",
")",
":",
"return",
"click",
".",
"option",
"(",
"'--template'",
",",
"'-t'",
",",
"default",
"=",
"_TEMPLATE_OPTION_DEFAULT_VALUE",
",",
"type",
"=",
"click",
".",
"Path",
"(",
")",
",",
"en... | Click Option for template option | [
"Click",
"Option",
"for",
"template",
"option"
] | c05af5e7378c6f05f7d82ad3f0bca17204177db6 | https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/_utils/options.py#L73-L83 | train | Click Option for template option | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
awslabs/aws-sam-cli | samcli/lib/utils/tar.py | create_tarball | def create_tarball(tar_paths):
"""
Context Manger that creates the tarball of the Docker Context to use for building the image
Parameters
----------
tar_paths dict(str, str)
Key representing a full path to the file or directory and the Value representing the path within the tarball
Yie... | python | def create_tarball(tar_paths):
"""
Context Manger that creates the tarball of the Docker Context to use for building the image
Parameters
----------
tar_paths dict(str, str)
Key representing a full path to the file or directory and the Value representing the path within the tarball
Yie... | [
"def",
"create_tarball",
"(",
"tar_paths",
")",
":",
"tarballfile",
"=",
"TemporaryFile",
"(",
")",
"with",
"tarfile",
".",
"open",
"(",
"fileobj",
"=",
"tarballfile",
",",
"mode",
"=",
"'w'",
")",
"as",
"archive",
":",
"for",
"path_on_system",
",",
"path_... | Context Manger that creates the tarball of the Docker Context to use for building the image
Parameters
----------
tar_paths dict(str, str)
Key representing a full path to the file or directory and the Value representing the path within the tarball
Yields
------
The tarball file | [
"Context",
"Manger",
"that",
"creates",
"the",
"tarball",
"of",
"the",
"Docker",
"Context",
"to",
"use",
"for",
"building",
"the",
"image"
] | c05af5e7378c6f05f7d82ad3f0bca17204177db6 | https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/utils/tar.py#L11-L37 | train | Context Manger that creates a tarball of the Docker Context | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
awslabs/aws-sam-cli | samcli/commands/local/lib/local_lambda_service.py | LocalLambdaService.start | def start(self):
"""
Creates and starts the Local Lambda Invoke service. This method will block until the service is stopped
manually using an interrupt. After the service is started, callers can make HTTP requests to the endpoint
to invoke the Lambda function and receive a response.
... | python | def start(self):
"""
Creates and starts the Local Lambda Invoke service. This method will block until the service is stopped
manually using an interrupt. After the service is started, callers can make HTTP requests to the endpoint
to invoke the Lambda function and receive a response.
... | [
"def",
"start",
"(",
"self",
")",
":",
"# We care about passing only stderr to the Service and not stdout because stdout from Docker container",
"# contains the response to the API which is sent out as HTTP response. Only stderr needs to be printed",
"# to the console or a log file. stderr from Dock... | Creates and starts the Local Lambda Invoke service. This method will block until the service is stopped
manually using an interrupt. After the service is started, callers can make HTTP requests to the endpoint
to invoke the Lambda function and receive a response.
NOTE: This is a blocking call t... | [
"Creates",
"and",
"starts",
"the",
"Local",
"Lambda",
"Invoke",
"service",
".",
"This",
"method",
"will",
"block",
"until",
"the",
"service",
"is",
"stopped",
"manually",
"using",
"an",
"interrupt",
".",
"After",
"the",
"service",
"is",
"started",
"callers",
... | c05af5e7378c6f05f7d82ad3f0bca17204177db6 | https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/local_lambda_service.py#L35-L58 | train | Starts the Local Lambda Invoke service. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
awslabs/aws-sam-cli | samcli/commands/local/lib/sam_function_provider.py | SamFunctionProvider._extract_functions | def _extract_functions(resources):
"""
Extracts and returns function information from the given dictionary of SAM/CloudFormation resources. This
method supports functions defined with AWS::Serverless::Function and AWS::Lambda::Function
:param dict resources: Dictionary of SAM/CloudForma... | python | def _extract_functions(resources):
"""
Extracts and returns function information from the given dictionary of SAM/CloudFormation resources. This
method supports functions defined with AWS::Serverless::Function and AWS::Lambda::Function
:param dict resources: Dictionary of SAM/CloudForma... | [
"def",
"_extract_functions",
"(",
"resources",
")",
":",
"result",
"=",
"{",
"}",
"for",
"name",
",",
"resource",
"in",
"resources",
".",
"items",
"(",
")",
":",
"resource_type",
"=",
"resource",
".",
"get",
"(",
"\"Type\"",
")",
"resource_properties",
"="... | Extracts and returns function information from the given dictionary of SAM/CloudFormation resources. This
method supports functions defined with AWS::Serverless::Function and AWS::Lambda::Function
:param dict resources: Dictionary of SAM/CloudFormation resources
:return dict(string : samcli.com... | [
"Extracts",
"and",
"returns",
"function",
"information",
"from",
"the",
"given",
"dictionary",
"of",
"SAM",
"/",
"CloudFormation",
"resources",
".",
"This",
"method",
"supports",
"functions",
"defined",
"with",
"AWS",
"::",
"Serverless",
"::",
"Function",
"and",
... | c05af5e7378c6f05f7d82ad3f0bca17204177db6 | https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_function_provider.py#L81-L108 | train | Extracts and returns function information from the given dictionary of SAM and CloudFormation resources. This method supports functions defined with AWS Serverless and AWS Lambda functions. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
awslabs/aws-sam-cli | samcli/commands/local/lib/sam_function_provider.py | SamFunctionProvider._convert_sam_function_resource | def _convert_sam_function_resource(name, resource_properties, layers):
"""
Converts a AWS::Serverless::Function resource to a Function configuration usable by the provider.
:param string name: LogicalID of the resource NOTE: This is *not* the function name because not all functions
... | python | def _convert_sam_function_resource(name, resource_properties, layers):
"""
Converts a AWS::Serverless::Function resource to a Function configuration usable by the provider.
:param string name: LogicalID of the resource NOTE: This is *not* the function name because not all functions
... | [
"def",
"_convert_sam_function_resource",
"(",
"name",
",",
"resource_properties",
",",
"layers",
")",
":",
"codeuri",
"=",
"SamFunctionProvider",
".",
"_extract_sam_function_codeuri",
"(",
"name",
",",
"resource_properties",
",",
"\"CodeUri\"",
")",
"LOG",
".",
"debug... | Converts a AWS::Serverless::Function resource to a Function configuration usable by the provider.
:param string name: LogicalID of the resource NOTE: This is *not* the function name because not all functions
declare a name
:param dict resource_properties: Properties of this resource
... | [
"Converts",
"a",
"AWS",
"::",
"Serverless",
"::",
"Function",
"resource",
"to",
"a",
"Function",
"configuration",
"usable",
"by",
"the",
"provider",
"."
] | c05af5e7378c6f05f7d82ad3f0bca17204177db6 | https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_function_provider.py#L111-L135 | train | Converts a AWS Serverless function resource to a Function configuration usable by the provider. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.