tronikos / opower

A Python library for getting historical and forecasted usage/cost from utilities that use opower.com such as PG&E
Apache License 2.0
66 stars 59 forks source link

demo.py --aggregate_type is failing #28

Closed akoebbe closed 1 year ago

akoebbe commented 1 year ago

When using --aggregate_type hour on demo.py, I'm getting the following error:

demo.py: error: argument --aggregate_type: invalid choice: 'hour' (choose from <AggregateType.BILL: 'bill'>, <AggregateType.DAY: 'day'>, <AggregateType.HOUR: 'hour'>)

I get the general reason for the error, but I'm not sure how best to fix it. In the mean time, I've just been replacing the default in demo.py, line 36, as needed.

   parser.add_argument(
        "--aggregate_type",
        help="How to aggregate historical data. Defaults to day",
        choices=list(AggregateType),
        default=AggregateType.HOUR, # <-- Was AggregateType.DAY
tronikos commented 1 year ago

Strange. Works for me. I'm under Windows 10, Powershell, Python 3.11 If I type an invalid one I get a different error than yours:

> python src/demo.py --aggregate_type foo
usage: demo.py [-h] [--utility {atlanticcityelectric,bge,comed,coned,delmarva,evergy,peco,pepco,pge,pse}] [--username USERNAME] [--password PASSWORD] [--mfa_secret MFA_SECRET] [--aggregate_type {bill,day,hour}] [--start_date START_DATE] [--end_date END_DATE]
               [--usage_only] [-v]
demo.py: error: argument --aggregate_type: invalid AggregateType value: 'foo'
akoebbe commented 1 year ago

Huh. That is really strange. I'll do some poking around to see if there is something up on my end. FWIW I'm in a Python venv with the following version on Linux (Fedora 38).

Python 3.11.4 (main, Jun  7 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)] on linux
akoebbe commented 1 year ago

Well now I'm questioning everything. Now it's working and I have no idea what's different. It's possible that I did a pip install . before working on the quarter_hour implementation and I'm wondering if I had a bugged library before. Oh well. I'll close this issue and reopen it if it pops back up.