rjurney / Agile_Data_Code_2

Code for Agile Data Science 2.0, O'Reilly 2017, Second Edition
http://bit.ly/agile_data_science
MIT License
456 stars 307 forks source link

Broken code #44

Closed jaluecht closed 6 years ago

jaluecht commented 7 years ago

I just purchased this book and have been following the examples closely. I have come across several items in which the code was incorrect and needed to be debugged and changed. My most recent example is the web code in chapter 4.

The flights template binds the display_nav macro with four parameters that are required by display_nav. The actual macro signature only includes three parameters - query being the odd man out.

Another issue I came across was the mongo queries - you code in the on_time_performance files has the mongo query keys surrounded by single quotes. The queries did not work for me unless I changes the single to double quotes. You also cast the flight number to an integer - this did not work unless I removed the int function in the query.

Am I mistaken? Are these actual issues? I find it hard to believe that anyone is able to make this code work following the book.

I AM using the vagrant image and the code that came with the image itself which does seem to match the GitHub repository for this book.

rjurney commented 7 years ago

@jaluecht Thanks for these bug reports!

Chapter 4 example fixed in https://github.com/rjurney/Agile_Data_Code_2/commit/b5e48dc3c976dcd9ccdecae2a7152720154bb807

@jaluecht Can you be more specific about the code in the mongo queries? I don't have enough information to find the bug. Which chapter?

bennwei commented 7 years ago

Hi Russell, I found it on the controller for chapter 4 and 5, I have to remove this "int" on the "flight-num" to get the code work properly. I am also using the Vagrant image.

@app.route("/on_time_performance") def on_time_performance():

carrier = request.args.get('Carrier') flight_date = request.args.get('FlightDate') flight_num = request.args.get('FlightNum')

flight = client.agile_data_science.on_time_performance.find_one({ 'Carrier': carrier, 'FlightDate': flight_date, 'FlightNum': int(flight_num)
})

return render_template('flight.html', flight=flight)

rjurney commented 6 years ago

Thanks for the fix! I'll get it in... https://github.com/rjurney/Agile_Data_Code_2/commit/69d641686b83a3d1d00aea6bd15b847e3a50eb84

Fixed! Thanks!