Skip to content

Commit

Permalink
FEAT-#1831: Apply black and fix flake8 issues
Browse files Browse the repository at this point in the history
Signed-off-by: Vasilij Litvinov <vasilij.n.litvinov@intel.com>
  • Loading branch information
vnlitvinov committed Jul 28, 2020
1 parent e374be7 commit 9e5b082
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
5 changes: 0 additions & 5 deletions modin/experimental/cloud/rpyc_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# governing permissions and limitations under the License.

import types
import time
import threading
import collections
import os

Expand All @@ -39,9 +37,6 @@ def _tuplize(arg):
_TRACE_RPYC = os.environ.get("MODIN_TRACE_RPYC", "").title() == "True"





class WrappingConnection(rpyc.Connection):
def __init__(self, *a, **kw):
super().__init__(*a, **kw)
Expand Down
39 changes: 26 additions & 13 deletions modin/experimental/cloud/tracing/parse_rpyc_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def get_syncs(items):
if i["kind"] == "recv" and i["msg"] == "MSG_REPLY":
try:
pairs.append((sends[i["seq"]], i))
responses[i['seq']] = i
responses[i["seq"]] = i
except KeyError:
pass
getattrs = [p for p in pairs if p[0].get("req", "") == "HANDLE_GETATTR"]
Expand Down Expand Up @@ -110,7 +110,7 @@ def from_getattr_send(i, s=True):

def from_getattr_recv(i, s=True):
if not i:
return ''
return ""
args = eval(i["args"])
return _unbox(args)

Expand All @@ -130,20 +130,23 @@ def _unwrap_obj(obj, remote):
obj = f"{obj.replace('[local]', '[remote]')}.{attr}"
return obj


def _stringify(obj):
if not isinstance(obj, str):
return str(obj)
if '[local]' in obj or '[remote]' in obj:
if "[local]" in obj or "[remote]" in obj:
return obj
return repr(obj)


def _format_args(args, kw):
fargs = ", ".join(_stringify(x) for x in args)
fkw = ", ".join(f"{k}={_stringify(v)}" for (k, v) in kw)
if fargs and fkw:
fargs += ", "
return f"({fargs}{fkw})"


def from_callattr_send(i, s=True, remote=None):
_, args = eval(i["args"])
obj, name, args, kw = _unbox(args)
Expand All @@ -162,25 +165,27 @@ def from_call_send(i, s=True, remote=None):
return re.sub(r"\(cls=\d+:inst=", "(inst:", res)
return obj, args, kw


def _parse_msg(m, s=False, **kw):
if m['kind'] == 'send':
if m.get('req') == 'HANDLE_GETATTR':
if m["kind"] == "send":
if m.get("req") == "HANDLE_GETATTR":
return from_getattr_send(m, s, **kw)
if m.get('req') in ('HANDLE_HASH', 'HANDLE_STR'):
if m.get("req") in ("HANDLE_HASH", "HANDLE_STR"):
return from_hash_send(m, s, **kw)
if m.get('req') == 'HANDLE_CALLATTR':
if m.get("req") == "HANDLE_CALLATTR":
return from_callattr_send(m, s, **kw)
if m.get('req') == 'HANDLE_CALL':
if m.get("req") == "HANDLE_CALL":
return from_call_send(m, s, **kw)
return str(m)
return from_getattr_recv(m, s, **kw)


remote = {}
for gsend, grecv in pairs:
got, sent = _parse_msg(grecv, False), _parse_msg(gsend, False)
if isinstance(got, str):
remote[got] = sent
#remote[from_getattr_recv(grecv, False)] = from_getattr_send(gsend, False)
# remote[from_getattr_recv(grecv, False)] = from_getattr_send(gsend, False)

print(f"total time getattrs={sum(x[1]['timing'] for x in getattrs)}")

Expand All @@ -194,19 +199,27 @@ def _parse_msg(m, s=False, **kw):
print("\n\n----[ hash ]----")
for i in syncs:
if i.get("req", "") == "HANDLE_HASH" and i["kind"] == "send":
print(from_hash_send(i), '-->', from_getattr_recv(responses.get(i['seq'])))
print(from_hash_send(i), "-->", from_getattr_recv(responses.get(i["seq"])))

print("\n\n----[ str ]----")
for i in syncs:
if i.get("req", "") == "HANDLE_STR" and i["kind"] == "send":
print(from_hash_send(i), '-->', from_getattr_recv(responses.get(i['seq'])))
print(from_hash_send(i), "-->", from_getattr_recv(responses.get(i["seq"])))

print("\n\n----[ callattr ]----")
for i in syncs:
if i.get("req", "") == "HANDLE_CALLATTR" and i["kind"] == "send":
print(from_callattr_send(i, remote=remote), '-->', from_getattr_recv(responses.get(i['seq'])))
print(
from_callattr_send(i, remote=remote),
"-->",
from_getattr_recv(responses.get(i["seq"])),
)

print("\n\n----[ call ]----")
for i in syncs:
if i.get("req", "") == "HANDLE_CALL" and i["kind"] == "send":
print(from_call_send(i, remote=remote), '-->', from_getattr_recv(responses.get(i['seq'])))
print(
from_call_send(i, remote=remote),
"-->",
from_getattr_recv(responses.get(i["seq"])),
)

0 comments on commit 9e5b082

Please sign in to comment.