Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
Add simple scripts for checking if generated code changed. (pytorch#1…
Browse files Browse the repository at this point in the history
…2835)

Summary:
This is designed to make it easier to see how your codegen changes affected actual generated code.

Limitations:
A) This is NOT robust; if new directories are added that include generated files, they need to be added to tools/generated_dirs.txt.  Note that subdirectories of the list are not included.

B) This is particular to my workflow which I don't claim is generally applicable.  Ideally we would have a script that pumped out a diff that could be attached to PRs.

C) Only works on OSS and definitely won't work on windows.

How to use:
1) python setup.py ...
2) tools/git_add_generated_dirs
3) Edit codegen
4) python setup.py ...
4) git diff to see changes
5) If satisfied: tools/git_reset_generated_dirs, commit, etc.
   If not satisfied: Go to 3)
Pull Request resolved: pytorch#12835

Reviewed By: ezyang

Differential Revision: D10452255

Pulled By: gchanan

fbshipit-source-id: 294fc74d41d1b840c7a26d20e05efd0aff154635
  • Loading branch information
gchanan authored and facebook-github-bot committed Oct 22, 2018
1 parent 01227f3 commit 25f4b3e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tools/generated_dirs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
torch/csrc/autograd/generated/
torch/csrc/jit/generated/
build/aten/src/ATen
13 changes: 13 additions & 0 deletions tools/git_add_generated_dirs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

# HOW TO USE:
# 1) python setup.py ...
# 2) tools/git_add_generated_dirs
# 3) Edit codegen
# 4) python setup.py ...
# 5) git diff to see changes
# 6) If satisfied: tools/git_reset_generated_dirs, commit, etc.
# If not satisfied: Go to 3)

BASEDIR=$(dirname "$0")
(< $BASEDIR/generated_dirs.txt xargs -i find {} -type f) | xargs git add -f
13 changes: 13 additions & 0 deletions tools/git_reset_generated_dirs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

# HOW TO USE:
# 1) python setup.py ...
# 2) tools/git_add_generated_dirs
# 3) Edit codegen
# 4) python setup.py ...
# 5) git diff to see changes
# 6) If satisfied: tools/git_reset_generated_dirs, commit, etc.
# If not satisfied: Go to 3)

BASEDIR=$(dirname "$0")
(< $BASEDIR/generated_dirs.txt xargs -i find {} -type f) | xargs git reset HEAD

0 comments on commit 25f4b3e

Please sign in to comment.