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

Load and karel-ized imported modules, reload code on 'Run Program' #3

Merged
merged 4 commits into from
Jul 10, 2021

Conversation

sdspikes
Copy link
Contributor

@sdspikes sdspikes commented Jul 8, 2021

I would like to use this within replit for a course I'm teaching this fall, but don't like that the student has to stop and run the program every time they update the code, since the "Run Program" button intuitively seems like it should reload the code.

I also wanted to be able to abstract away the main file with the

if __name__ == "__main__":
  run_karel_program()

so that it feels more like the Karel environment used for Code in Place and CodeHS.

If you don't want these changes, that's fine, but I figured I'd send a PR in case you do :)

@sdspikes
Copy link
Contributor Author

sdspikes commented Jul 8, 2021

@TylerYep it doesn't look like I can add anyone as a reviewer, so tagging you instead.

@codecov
Copy link

codecov bot commented Jul 10, 2021

Codecov Report

Merging #3 (1418560) into main (2e78eba) will decrease coverage by 0.34%.
The diff coverage is 10.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main       #3      +/-   ##
==========================================
- Coverage   35.30%   34.95%   -0.35%     
==========================================
  Files          10       10              
  Lines        1337     1356      +19     
==========================================
+ Hits          472      474       +2     
- Misses        865      882      +17     
Impacted Files Coverage Δ
stanfordkarel/style_checker.py 32.43% <0.00%> (-0.45%) ⬇️
stanfordkarel/karel_application.py 18.66% <10.52%> (-0.72%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2e78eba...1418560. Read the comment docs.

@TylerYep
Copy link
Owner

Thank you for the contribution! I tested it out and it works really well.

For my own understanding, could you explain what additional code in stanfordkarel/karel_application.py is doing? It looks like this is adding support for importing code outside of the current file?

An example would help me a lot here - I can eventually add it as a test case too.

@sdspikes
Copy link
Contributor Author

Sure, I'll give an example in the context I'm trying to use it, in the replit environment: https://replit.com/join/cqbytqnnos-sarahspikes

I want the student to be able to interact with just the collect_newspaper_karel.py file and not have to think/know about the __main__ etc part.

@TylerYep
Copy link
Owner

Makes sense, thanks!

@TylerYep TylerYep merged commit ac733a1 into TylerYep:main Jul 10, 2021
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.

2 participants