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

Added importTester #1

Closed
wants to merge 3 commits into from

Conversation

Projects
None yet
2 participants
@JoshuaRM
Copy link

commented Mar 15, 2019

This PR contains additions to the pull_request.py as well as an additional script importTester.py.

This PR introduces the testing of relative and absolute imports in the keras and tests directories. The message sent to the user has been edited to now receive an additional parameter (additions) which is the import testing. The message adds the first 10 files with errors for both absolute and relative (20 total), and specifies how many remain eg. 10/56. This is done by cloning the users repo, parsing the files, then deleting the cloned repo.

Please let me know if you have any questions or concerns.

@gabrieldemarmiesse
Copy link
Owner

left a comment

Thanks for the PR and sorry for the delay. I added some comments. Can you check it out? Thanks.

absKeys = list(additions['absolute'].keys())[:10]
relKeys = list(additions['relative'].keys())[:10]

absolute = "The following files should not contain relative imports\n"

This comment has been minimized.

Copy link
@gabrieldemarmiesse

gabrieldemarmiesse Mar 25, 2019

Owner

Actually, I'm not certain, but I believe that it's not possible to use relative imports in test files. Meaning that there is quite some code which wouldn't be needed. Could you verify this? Thanks.

absolute = "The following files should not contain relative imports\n"
for file in range(len(absKeys)):
absolute += absKeys[file] + "\n"
absolute += ("\nThis is " + str(file+1) + " out of " + len(additions['absolute']) + " files with relative imports to be changed\n")

This comment has been minimized.

Copy link
@gabrieldemarmiesse

gabrieldemarmiesse Mar 25, 2019

Owner

prefer f-string formatting when possible. The docker image used is with python 3.7 so we're safe.

@@ -0,0 +1,122 @@
import os

This comment has been minimized.

Copy link
@gabrieldemarmiesse

gabrieldemarmiesse Mar 25, 2019

Owner

python files should have names with uppercases. See PEP8.


return errs

def checkImports(dirPath, style):

This comment has been minimized.

Copy link
@gabrieldemarmiesse

gabrieldemarmiesse Mar 25, 2019

Owner

This function name does not follow PEP8. See https://www.python.org/dev/peps/pep-0008/

@JoshuaRM

This comment has been minimized.

Copy link
Author

commented Mar 28, 2019

@gabrieldemarmiesse
I have made the changes requested above, as well as made some changes I believe to be beneficial. The output of this now displays 10 files in a details/summary markdown format, with the specific errors listed within the dropdown.


os.system(cmd)

absoluteOnly = import_tester.check_imports("./" + repo_id + "/keras")

This comment has been minimized.

Copy link
@gabrieldemarmiesse

gabrieldemarmiesse Apr 1, 2019

Owner

The current bot actually runs only keras-contrib. So I believe that this will fail as there is no ./keras directory in keras-contrib.

@gabrieldemarmiesse

This comment has been minimized.

Copy link
Owner

commented Apr 1, 2019

@JoshuaRM I'm going to be less and less active in the future on keras-team/keras, because I currently use tf.keras and I don't really want to maintain a package that I don't use. Going forward I believe that the best solution for you is to fork this repo, add your modification and make a bot account of your own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.