-
Notifications
You must be signed in to change notification settings - Fork 8
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
Update of Repo from Python2 to Python3 & Implementation of metadata use via CSV file #12
Conversation
Switched the httplib (Python2) library to http.client (Python3). Updated all references in DownloadRunner.py to http.client.
Switched import statement from cStringIO (module in Python2) to io.StringIO (Python3 upgrade). All references to cString.StringIO have been replaced with StringIO.
Remove 'urllib2' import statement. Modified urllib import to contain 'requests' module. All instances of 'urllib.openurl' and 'urllib2.openurl' replaced with 'request.openurl'
Python3 replaces Python2s 'cString.StringIO' with 'io.BytesIO'. Corrected this mistake now.
download_single_metadata_xml() download_single_pano()
Added docstrings for the following functions: * generate_gsv_urls() * download_single_gsv() * download_all_gsv_images()
Added comments to lines that are commented out in the code. These are code blocks that were previously used for the XML metadata for Google Street View. As this is no longer accessible, we now rely on the input csv file which contains the metadata and do not need these lines. They have been kept in for the Project Sidewalk team to decide if they should be maintained or removed.
Updated print statements for logging to have a consistent format across the three possible image size settings. Added in the check to see if the pano id had been visited previously.
Three changes: * Updated 'warn' (deprecated) to 'warning'. * Made sample file paths that match DownloadRunner.py. * Set the marking of the image centre with a red dot to False in run statement.
Function was not used in code, deleted.
Function was not used in code.
@ThatOneGoat
Can you reverse this bit? We are still able to download the XML and depth data right now, so I'd like to keep trying to do this as long as we can.
Similarly, some of the deleted code is probably for the XML/depth data. We should make sure to retain anything related to those. Feel free to ask me about specific functions as you go along. |
@ThatOneGoat here are the changes I've made to the API:
Here's a full before/after for the output of the API.
After:
|
Substantial update of the sidewalk-panorama-tools repository. High-level overview and more detailed breakdown will be given below.
1.0 What Has Changed - Two underlying core changes:
2.0 Why These Changes
2.1 Python2 to Python3
As of 01/01/2020 Python2 has been depreciated. No more support or improvements are offered for Python2 so an upgrade to Python3 was advisable. Further to this, a lot of the modules this repository was dependent on were no longer supported/compatible with Python2, so an upgrade was also required for this reason.
2.2 Data Endpoint Download to CSV File With Metadata
Google removed the data endpoint that allowed the download of image metadata, including the depth data, all of which was required for the cropping tool. A workaround for this is to replace direct metadata download with a CSV file which contains all the required information. For further information on this, see Depth data endpoint removed, need to get metadata elsewhere #8 .
3.0 How & Where These Changes Were Implemented
3.1 DownloadRunner.py
3.1.1 Updates to Code to Cover Section 2.2
3.1.2 Additional New Features
3.1.3 Unused/Obsolete Code Requiring Review by Project Sidewalk - Refactor Task
Below are core functions that were left in the script, but were either unused, or commented out. I have not deleted these in case the group wishes to keep them, so the ultimate refactor decision rests with The Project Sidewalk Group.
3.2 CropRunner.py
3.2.1 Updates to Code to Cover Section 2.2
3.2.2 Additional New Features
No new or additional features were added for this script.
3.2.3 Unused/Obsolete Code Requiring Review by Project Sidewalk - Refactor Task
Below are core functions that were left in the script, but were either unused, or commented out. I have not deleted these in case the group wishes to keep them, so the ultimate refactor decision rests with The Project Sidewalk Group.
3.3 config.py
A new additional configuration file. Allows the user set how many threads to use in asyncio (for I/O tasks) and set proxies if required. Also provides browser headers to be passed with the requests.
3.4 README.md
Updated to reflect the changes made to the code base and it's operation. There are some placeholders where the Project Sidewalk Group will need to update based on the csv file with metadata they provide to the public, and where it will be accessed from. References in README are:
3.5 Legacy Code/Scrips
The below scrips were also updated, but only to make them Python3 compatible. There are no new features added, and the functionality remains the same:
4.0 Testing
DownloadRunner.py
andCropRunner.py
and these both executed successfully and as expected.5.0 COMMENTS
I have provided a sample csv with the required metadata in the repo - sidewalk-panorama-tools/metadata/sample_csv-metadata-seattle.csv . Project Sidewalk group will need to decide what metadata they want to make publicly available with the repo, and where the full file should be stored to enable correct functionality of the codebase.