PropertyTaxProject/ptap

Front End (Collecting Info)

erhla opened this issue · 14 comments

erhla commented

Breaking out Detroit and turning this into a MVP for Cook County Single Family.

Flask App to collect & serve information for Cook County SF.

Page 1

  • Input address (street address, direction, name, city, unit number) OR input pin
  • Send to flask---expect back either data for page 2 or an error

Page 2

  • Present characteristics of target property
  • Present characteristics of comparable properties with option to delete or include/exclude (can be literally deleting from the page or checking box to include individual rows)
  • (Possible) Show and update on selection the 'contention value' which is the mean assessed value of selected comparable properties

Page 3

Placeholder to collect information on homeowner like permission/name/contact info/etc

I started working on the frontend and have an MVP for page 1. There should be instructions for running the server in the README.md under ptap_site. Let me know if I should add more clarification/installation instructions.

I've attached some screenshots of the site.
Currently, the information shown in the screenshots is the only information that I'm collecting on page 1. Are there any fields I need to add or remove?

Currently, I'm just returning a dictionary, but I can convert this to a data frame if that would be easier.

Screenshot from 2020-07-03 21-56-55
Screenshot from 2020-07-03 21-56-59

erhla commented

This looks great and was able to install. We should add an optional field for unit, and I'll check the data to come up with the suggested format (e.g. 2E, #2E, etc). Yes---feel free to use dictionaries for this page. Probably makes sense for all the pages, but we will see later. I'll work on making some example data today.

erhla commented

I'm going to work on the flask post request to serve characteristics & comparables.

Do you have a sense of what the best data structure would be?

I was thinking something like this:

{
target_property : {characteristics},
comparable_properties: {[{char_1}, {char_2}, {char_3}]}
}

Something like that would work well. I just wrote the frontend script for processing the comparables yesterday and this is the format that it currently works for.

{
target_property: {square_feet: 1234, bedrooms: 2},
comparable_properties: [{square_feet: 1231, bedrooms: 2}, {square_feet: 1423, bedrooms: 2}]
}

where each property is represented by a dict with the keys being the characteristic name with each word separated with an underscore and comparable properties is a list of properties.

Additionally, I'm not sure if this already exists, but it would be nice if each property had a field that serves as a unique identifier.

erhla commented

Perfect. I just updated the column names and this datatype with a true example: 386dc98

PIN will always be a unique id.

Sounds good, could you add the cooksf.csv to git? It seems to be missing from the repo

erhla commented

Oops! Just added it.

Were you able to get the program running? When I try to test the API I get the error

Traceback (most recent call last):
  File "/home/austin/Documents/Computer Science/projects/ptap_all/ptap/ptap_site/api/venv/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 2646, in get_loc
    return self._engine.get_loc(key)
  File "pandas/_libs/index.pyx", line 111, in pandas._libs.index.IndexEngine.get_loc
    
  File "pandas/_libs/index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc
    
  File "pandas/_libs/hashtable_class_helper.pxi", line 1619, in pandas._libs.hashtable.PyObjectHashTable.get_item
    
  File "pandas/_libs/hashtable_class_helper.pxi", line 1627, in pandas._libs.hashtable.PyObjectHashTable.get_item
    
KeyError: 'Longitude'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/austin/Documents/Computer Science/projects/ptap_all/ptap/ptap_site/api/venv/lib/python3.6/site-packages/werkzeug/serving.py", line 323, in run_wsgi
    execute(self.server.app)
  File "/home/austin/Documents/Computer Science/projects/ptap_all/ptap/ptap_site/api/venv/lib/python3.6/site-packages/werkzeug/serving.py", line 312, in execute
    application_iter = app(environ, start_response)
  File "/home/austin/Documents/Computer Science/projects/ptap_all/ptap/ptap_site/api/venv/lib/python3.6/site-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/austin/Documents/Computer Science/projects/ptap_all/ptap/ptap_site/api/venv/lib/python3.6/site-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/home/austin/Documents/Computer Science/projects/ptap_all/ptap/ptap_site/api/venv/lib/python3.6/site-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/austin/Documents/Computer Science/projects/ptap_all/ptap/ptap_site/api/venv/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/austin/Documents/Computer Science/projects/ptap_all/ptap/ptap_site/api/venv/lib/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/austin/Documents/Computer Science/projects/ptap_all/ptap/ptap_site/api/venv/lib/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/austin/Documents/Computer Science/projects/ptap_all/ptap/ptap_site/api/venv/lib/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/austin/Documents/Computer Science/projects/ptap_all/ptap/ptap_site/api/venv/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/austin/Documents/Computer Science/projects/ptap_all/ptap/ptap_site/api/venv/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/austin/Documents/Computer Science/projects/ptap_all/ptap/ptap_site/api/venv/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/austin/Documents/Computer Science/projects/ptap_all/ptap/ptap_site/api/api.py", line 17, in handle_form
    response_dict = get_comps(form_data) # this is the data to send back
  File "/home/austin/Documents/Computer Science/projects/ptap_all/ptap/ptap_site/api/api.py", line 36, in get_comps
    data_json = process_one_pin(form_data, cook_sf)
  File "/home/austin/Documents/Computer Science/projects/ptap_all/ptap/ptap_site/api/cook_sf.py", line 58, in process_one_pin
    new_targ, cur_comps = comps_cook_sf(targ, cook_sf, multiplier)
  File "/home/austin/Documents/Computer Science/projects/ptap_all/ptap/ptap_site/api/cook_sf.py", line 44, in comps_cook_sf
    new = filter_on(new, 'Distance', (targ['Longitude'].values[0], targ['Latitude'].values[0]), distance_filter)
  File "/home/austin/Documents/Computer Science/projects/ptap_all/ptap/ptap_site/api/venv/lib/python3.6/site-packages/pandas/core/frame.py", line 2800, in __getitem__
    indexer = self.columns.get_loc(key)
  File "/home/austin/Documents/Computer Science/projects/ptap_all/ptap/ptap_site/api/venv/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 2648, in get_loc
    return self._engine.get_loc(self._maybe_cast_indexer(key))
  File "pandas/_libs/index.pyx", line 111, in pandas._libs.index.IndexEngine.get_loc
    
  File "pandas/_libs/index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc
    
  File "pandas/_libs/hashtable_class_helper.pxi", line 1619, in pandas._libs.hashtable.PyObjectHashTable.get_item
    
  File "pandas/_libs/hashtable_class_helper.pxi", line 1627, in pandas._libs.hashtable.PyObjectHashTable.get_item
    
KeyError: 'Longitude'
erhla commented

Deleted too many columns trying to avoid the github file size limit. Should work now.

erhla commented

I didn't format the output of get_comps into a proper json. I'm going to fix it in a few.

erhla commented

Note that my most recent commit assumes you have R (with packages knitr, kableExtra, tidyverse, rmarkdown installed) and latex. If you are getting errors here, we could split off generating the attachments from the api and simply write the output from the api to a file and process it separately.

erhla commented

Closing this issue for now to regroup in an MVP issue.