Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OK Debugger: Python Tutor Tracing #301

Merged
merged 19 commits into from
Jan 7, 2020
Merged

OK Debugger: Python Tutor Tracing #301

merged 19 commits into from
Jan 7, 2020

Conversation

Sumukh
Copy link
Member

@Sumukh Sumukh commented May 7, 2017

This PR brings in a debugger into OK (with the help of a slightly modified version of @pgbovine's Python Tutor)

Usage:

  • Doctests: python3 ok -q q1 --trace
  • Ok Tests: python3 ok -q q1 --trace --suite 3

ok-tracer-demo

I haven't really tried this on projects yet.

@Sumukh
Copy link
Member Author

Sumukh commented May 7, 2017

Update: It works for project too but there's a little bit of work to do in hiding irrelevant information.

image

Copy link
Member Author

@Sumukh Sumukh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall comment: Some of this exporting code could probably be refactored out but there's nothing else that will use this code right now so I won't.

client/api/assignment.py Outdated Show resolved Hide resolved
modules = {k.replace('.py', '').replace('/', '.'): v for k,v in messages['file_contents'].items()}
data = generate_trace.run_logger(test_script, setup, modules) or "{}"
messages['tracing']['end-trace'] = get_time()
messages['tracing']['trace-len'] = len(json.loads(data).get('trace', [])) # includes the code since data is a str
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the trace gets huge - we probably don't want to be loading/dumping all over the place - but this should be fine.

return

test = tests[0]
data = test.get_code()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably test that your test case has a get_code attr (since it's not actually part of the test base model) - we might want to add it there - (and just have it return {} - or throw an exception and catch it here)

if data:
messages['tracing']['start-server'] = get_time()
# Open Python Tutor Browser Window with this trace
server.run_server(data)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--trace-print should just print the contents of the trace - we should probably have it accept a file argument to dump to instead of stdout (since a bunch of other stuff gets printed to stdout too)

cc: @epai (just fyi - it could make your life easier later)

@epai epai self-assigned this May 21, 2017
@epai epai added this to the 1.13 milestone Jul 7, 2017
@Sumukh
Copy link
Member Author

Sumukh commented Sep 11, 2017

@epai - Ping on merging this? I don't think any of my comments are blockers.

@kavigupta
Copy link
Contributor

I think I can work on merging this, it looks like a useful feature! @epai @Sumukh any objections?

@Sumukh
Copy link
Member Author

Sumukh commented Nov 25, 2019

No objections on my end, I'd suggest giving a quick trial run

@kavigupta
Copy link
Contributor

kavigupta commented Nov 27, 2019

Some tasks before merge:

  • this shows everything in the global frame even irrelevant things.
  • there were some issues with the old version of pythontutor, and this seems to use that? @rahularya50 can you elaborate?

@kavigupta
Copy link
Contributor

@Sumukh can you take a look at my changes? I removed unused global variables, using the ast_scope module I've been developing for the last month or so (https://github.com/kavigupta/ast_scope)

@Sumukh
Copy link
Member Author

Sumukh commented Dec 22, 2019 via email

requirements.txt Outdated Show resolved Hide resolved
@Sumukh
Copy link
Member Author

Sumukh commented Jan 6, 2020

@kavigupta Your changes overall looks good to me. I'm a bit concerned about what including networkx does to the ok client bundle size but maybe the impact is smaller than I would imagine

@kavigupta
Copy link
Contributor

oh wow it goes from 2.0MB to 6.4MB.

I think I'll change ast_scope to remove the networkx dependency, we're really only using it for a DFS

@kavigupta
Copy link
Contributor

kavigupta commented Jan 7, 2020

@Sumukh removed the dependency on networkx. It's now 2.1MB instead of 6.4MB.

for neighbor in graph.neighbors(node):
helper(neighbor)
helper(node)
return seen
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who said you'll never have to write a DFS in the real world ;)

@Sumukh
Copy link
Member Author

Sumukh commented Jan 7, 2020

Nice! I haven't really tried the actual result yet but feel free to merge & deploy!

@kavigupta
Copy link
Contributor

ok sounds good!

@kavigupta kavigupta merged commit fc10869 into master Jan 7, 2020
@kavigupta kavigupta deleted the python_tutor branch January 7, 2020 08:50
@mehrdadn
Copy link
Contributor

@kavigupta I think this broke OkPy. Did you forget to add the new dependencies to pip requirement (or elsewhere)? I'm getting errors about urllib3 being missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants