NatLabRockies / NatLabRockies/reView

Fix capacity title for unpacking bespoke layouts

Open
#61 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
8
Forks
12
PR merge metrics
No merged PRs in 30d

Description

Bug Description
Cannot unpack bespoke turbine layouts for the newest supply curve tables because of the capacity field name change.

Full Traceback

[2024-10-17 09:44:23,458] ERROR in app: Exception on /_dash-update-component [POST]
Traceback (most recent call last):
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/pandas/core/indexes/base.py", line 3805, in get_loc
    return self._engine.get_loc(casted_key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "index.pyx", line 167, in pandas._libs.index.IndexEngine.get_loc
  File "index.pyx", line 196, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 7081, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 7089, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'capacity'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/dash/dash.py", line 1373, in dispatch
    ctx.run(
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/dash/_callback.py", line 465, in add_context
    output_value = _invoke_callback(func, *func_args, **func_kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/dash/_callback.py", line 40, in _invoke_callback
    return func(*args, **kwargs)  # %% callback invoked %%
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/github/reView/reView/utils/classes.py", line 181, in _callback_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/github/reView/reView/pages/rev/controller/callbacks.py", line 1109, in figure_map
    df = unpacker.unpack_turbines()
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/github/reView/reView/utils/bespoke.py", line 156, in unpack_turbines
    new_rows = self.unpack_row(row)
               ^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/github/reView/reView/utils/bespoke.py", line 121, in unpack_row
    turbine_capacity_mw = row[capacity_col] / len(xs)
                          ~~~^^^^^^^^^^^^^^
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/pandas/core/series.py", line 1121, in __getitem__
    return self._get_value(key)
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/pandas/core/series.py", line 1237, in _get_value
    loc = self.index.get_loc(label)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/pandas/core/indexes/base.py", line 3812, in get_loc
    raise KeyError(key) from err
KeyError: 'capacity'
reView (ERROR) - [app.py:838] : Exception on /_dash-update-component [POST]
Traceback (most recent call last):
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/pandas/core/indexes/base.py", line 3805, in get_loc
    return self._engine.get_loc(casted_key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "index.pyx", line 167, in pandas._libs.index.IndexEngine.get_loc
  File "index.pyx", line 196, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 7081, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 7089, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'capacity'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/dash/dash.py", line 1373, in dispatch
    ctx.run(
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/dash/_callback.py", line 465, in add_context
    output_value = _invoke_callback(func, *func_args, **func_kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/dash/_callback.py", line 40, in _invoke_callback
    return func(*args, **kwargs)  # %% callback invoked %%
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/github/reView/reView/utils/classes.py", line 181, in _callback_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/github/reView/reView/pages/rev/controller/callbacks.py", line 1109, in figure_map
    df = unpacker.unpack_turbines()
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/github/reView/reView/utils/bespoke.py", line 156, in unpack_turbines
    new_rows = self.unpack_row(row)
               ^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/github/reView/reView/utils/bespoke.py", line 121, in unpack_row
    turbine_capacity_mw = row[capacity_col] / len(xs)
                          ~~~^^^^^^^^^^^^^^
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/pandas/core/series.py", line 1121, in __getitem__
    return self._get_value(key)
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/pandas/core/series.py", line 1237, in _get_value
    loc = self.index.get_loc(label)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/twillia2/anaconda3/envs/review/lib/python3.12/site-packages/pandas/core/indexes/base.py", line 3812, in get_loc
    raise KeyError(key) from err
KeyError: 'capacity'

Charge code
[GDOP.12495.31.01.01] reV Maintenance

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in reView/utils/bespoke.py at unpack_row and trace its caller from reView/pages/rev/controller/callbacks.py:1109, figure_map. Reproduce the KeyError with the newest supply curve tables and inspect how the capacity column is selected. Done means bespoke turbine layouts unpack without the missing-capacity-field error.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python
Domain
data
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.