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

Python map import scripts refactor #109

Closed
wants to merge 15 commits into from
Closed

Conversation

Conengmo
Copy link

@Conengmo Conengmo commented Jul 1, 2018

Hi guys,

I'm working on figuring out how Barefoot really works underneath. While I was looking through the Python scripts that import map data, I figured they could use some work. I wanted to show my work in progress to maybe get some comments if and how this could be merged in main stream Barefoot when finished.

What I'm working on:

  • Mainly making it DRY
  • Making it Python 3 compatible
  • Improve readability
  • Keep functionality the same

I know this will be hard to review because the changes are so large. But know that I'm not changing functionality in this PR.

@Conengmo
Copy link
Author

Conengmo commented Jul 2, 2018

I touched all the Python code and finished a first refactoring. It can be better, but it is functional now.

@smattheis
Copy link

Thanks for refactoring and the PR!

@jongiddy Would you mind having a look on the changes? You're much better in Python than me. I have looked through it, e.g., if conditions, test execution, etc., and it seems all okay (not bypassing any test) and the CI system checked it with perfect results, i.e., also the result of the sample data looks the same as before.

@Conengmo Have you used some code style configuration? If so, could you include that in the repo in order to have the same style with future edits? Further, is the PR still WIP?

@Conengmo
Copy link
Author

Conengmo commented Jul 4, 2018

Good to hear you want to consider this PR. I follow regular PEP8, the default style guide for Python:

https://www.python.org/dev/peps/pep-0008/

Is there a line width you want to stick to in this project? I tried to keep most at 80 characters, but allowed for lines to go to 100 characters. Personally I like 100.

If you want to consider merging this, I'll take this weekend to polish it a bit more before dropping the WIP. Let me know if you have any comments or requests!

@smattheis
Copy link

In the Java code style, we use a line width of 100 characters. PEP8 is perfect and can be integrated into the Travis CI configuration. Thanks!

@Conengmo
Copy link
Author

Conengmo commented Jul 5, 2018

Does Travis also do code style reviews? Another project I work on uses Travis for testing and Stickler for automated code style review:

https://stickler-ci.com/

It should be functionally the same under the assumptions.
So it's same as in ways2bfmap
The plural methods are going to be deprecated
@Conengmo
Copy link
Author

Conengmo commented Jul 8, 2018

Alright I finished cleaning up. The Travis test passed, so that's nice. I hope you guys like it, let me know if you have any further requests or suggestions.

@Conengmo Conengmo changed the title WIP: Python map import scripts refactor Python map import scripts refactor Jul 8, 2018
Copy link
Contributor

@jongiddy jongiddy left a comment

Choose a reason for hiding this comment

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

This is a very nice clean-up of the Python code. I have tested the new code by creating a database from the same OSM file using master and this branch. They appear to create the same database.

The Python code could definitely do with more automated tests so we are more comfortable with such major refactorings.

This change will also make it easier to add a pep8 test to the CI, now that the code is fairly PEP8 clean (with an adjustment to max line size of 100).

Thanks for doing this. It has been on my mind as a TODO for some time.

@Conengmo
Copy link
Author

Conengmo commented Aug 1, 2018

Glad you like it. I agree on adding more tests, and also a good idea to add a pep8 check to Travis. But that's something for a new PR I reckon. I'll leave this PR as is so it won't have to be reviewed again.

@thomhubers
Copy link

So since it's approved and everyone's happy. Can this be merged?

@Conengmo Conengmo closed this by deleting the head repository Jun 16, 2024
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

4 participants