Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid Exception when calling get_load_shed on a Scenario without load shed #624

Merged
merged 1 commit into from
Apr 27, 2022

Conversation

danielolsen
Copy link
Contributor

Pull Request doc

Purpose

Fix a bug, where calling Scenario.get_load_shed() on a Scenario without any load shed throws an Exception.

>>> from powersimdata import Scenario
>>> Scenario(3497).get_load_shed()
[...truncated...]
No infeasibilities, constructing DataFrame
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\DanielOlsen\repos\bes\PowerSimData\powersimdata\scenario\analyze.py", line 199, in get_load_shed
    filepath = os.path.join(server_setup.LOCAL_DIR, output_dir, filename)
  File "C:\Python39\lib\ntpath.py", line 117, in join
    genericpath._check_arg_types('join', path, *paths)
  File "C:\Python39\lib\genericpath.py", line 152, in _check_arg_types
    raise TypeError(f'{funcname}() argument must be str, bytes, or '
TypeError: join() argument must be str, bytes, or os.PathLike object, not 'tuple'

This bug seems to have been introduced in commit 5665083 within #475.

What the code is doing

Since output_dir is a tuple of strings, rather than a single string, we need to unpack it before feeding to os.path.join.

Testing

The same example above no longer throws an Exception.

Time estimate

5 minutes.

@danielolsen danielolsen added the bug Something isn't working label Apr 27, 2022
@danielolsen danielolsen self-assigned this Apr 27, 2022
Copy link
Collaborator

@BainanXia BainanXia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

Copy link
Collaborator

@jenhagg jenhagg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@danielolsen danielolsen merged commit 8b28ba6 into develop Apr 27, 2022
@danielolsen danielolsen deleted the daniel/missing_load_shed branch April 27, 2022 21:12
@jenhagg jenhagg mentioned this pull request May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants