vaccine_availability icon indicating copy to clipboard operation
vaccine_availability copied to clipboard

Pincode based distance and Enhancements for Streamlit App

Open manujosephv opened this issue 4 years ago • 7 comments

key changes:

  1. Added pin code based distance as another column
  2. made some changes in the streamlit app - some performance and some the way it is displayed
  3. filtered out centers with all slots as zero
  4. made email trigger to mail that there is no slot, instead of not sending any email at all.

manujosephv avatar May 03 '21 01:05 manujosephv

image

love this @manujosephv

this fixes #11, as age is logical.

aahnik avatar May 07 '21 14:05 aahnik

but getting

error-screenshot
👉 full traceback
File "/home/aahnik/Desktop/vaccine_availability/.venv/lib/python3.9/site-packages/streamlit/script_runner.py", line 337, in _run_script
    exec(code, module.__dict__)
File "/home/aahnik/Desktop/vaccine_availability/streamlit_app.py", line 77, in <module>
    main()
File "/home/aahnik/Desktop/vaccine_availability/streamlit_app.py", line 53, in main
    df = cached_availability(next_n_days, district_ids, min_age_limit, pincode_search, free_paid)
File "/home/aahnik/Desktop/vaccine_availability/.venv/lib/python3.9/site-packages/streamlit/caching.py", line 573, in wrapped_func
    return get_or_create_cached_value()
File "/home/aahnik/Desktop/vaccine_availability/.venv/lib/python3.9/site-packages/streamlit/caching.py", line 557, in get_or_create_cached_value
    return_value = func(*args, **kwargs)
File "/home/aahnik/Desktop/vaccine_availability/streamlit_app.py", line 10, in cached_availability
    df= get_availability(next_n_days, district_ids, min_age_limit, pincode_search)
File "/home/aahnik/Desktop/vaccine_availability/availability.py", line 51, in get_availability
    data = get_data(URL)
File "/home/aahnik/Desktop/vaccine_availability/.venv/lib/python3.9/site-packages/cachetools/func.py", line 66, in wrapper
    v = func(*args, **kwargs)
File "/home/aahnik/Desktop/vaccine_availability/.venv/lib/python3.9/site-packages/decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
File "/home/aahnik/Desktop/vaccine_availability/.venv/lib/python3.9/site-packages/retry/api.py", line 73, in retry_decorator
    return __retry_internal(partial(f, *args, **kwargs), exceptions, tries, delay, max_delay, backoff, jitter,
File "/home/aahnik/Desktop/vaccine_availability/.venv/lib/python3.9/site-packages/retry/api.py", line 33, in __retry_internal
    return f()
File "/home/aahnik/Desktop/vaccine_availability/availability.py", line 37, in get_data
    data = json.loads(response.text)['centers']
File "/usr/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None

aahnik avatar May 07 '21 14:05 aahnik

@bhavsarpratik have resolved the merge conflicts. And fixed the api pull issue. It is now working

manujosephv avatar May 08 '21 01:05 manujosephv

on more investigation... the requests are going through from my local, but not from the Github Action. Not sure why

manujosephv avatar May 08 '21 02:05 manujosephv

hi @manujosephv, the JSON decode error is resolved after the changes. thanks!

image

46 is greater than 45, so it should show all slots with min age 45 ... right ?

it shows nothing,

image

but if I do this,

image

then slots are shown.

image

aahnik avatar May 08 '21 03:05 aahnik

without the "show full slots" being checked, nothing is being shown ever

image

aahnik avatar May 08 '21 03:05 aahnik

hi @manujosephv, it would be more logical to have a download pdf button.

df.to_html() # will give HTML of the dataframe

import pdfkit as pdf

# pip install pdfkit
# sudo apt install wkhtmltopdf

pdf.from_file("/path/to/html.html","/path/to/pdf.pdf")

the user of this app will be common human, and csv is for machines to read. if a programmer wants data, they will take from the official API, not after downloading csv from this app.

aahnik avatar May 08 '21 03:05 aahnik