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 delete functionality #359

Merged
merged 3 commits into from
Dec 15, 2020
Merged

Fix delete functionality #359

merged 3 commits into from
Dec 15, 2020

Conversation

jenhagg
Copy link
Collaborator

@jenhagg jenhagg commented Dec 15, 2020

Purpose

Fix error when deleting data, and handle clearing local data correctly.

What the code is doing

The self.path_config attribute needs to be set in the base class since we don't actually call the Delete constructor. Also, data is now cached in the same tree structure as the server, so changed the glob to match that.

I removed the implementation in DataAccess since that will fail when glob matches are directories instead of files, and didn't feel a strong need for it but I can put it back if people are using it.

Testing

Shell session testing the glob change

In [1]: from powersimdata.utility import server_setup

In [2]: import glob, os

In [3]: glob.glob(os.path.join(server_setup.LOCAL_DIR, "data", "**", "1714123_*"))
Out[3]: []

In [4]: glob.glob(os.path.join(server_setup.LOCAL_DIR, "data", "**", "1714_*"))
Out[4]:
['/Users/jonhagg/ScenarioData/data/input/1714_ct.pkl',
 '/Users/jonhagg/ScenarioData/data/input/1714_grid.mat',
 '/Users/jonhagg/ScenarioData/data/output/1714_AVERAGED_CONG.pkl',
 '/Users/jonhagg/ScenarioData/data/output/1714_PF.pkl']

In [5]: glob.glob(os.path.join(server_setup.LOCAL_DIR, "foo", "**", "1714_*"))
Out[5]: []

Separate session testing the delete state:

In [1]: from powersimdata.scenario.scenario import Scenario

In [2]: scenario = Scenario('1714')
Failed to download ScenarioList.csv from server
Falling back to local cache...
Failed to download ExecuteList.csv from server
Falling back to local cache...
SCENARIO: test | jon1

--> State
analyze
--> Loading grid
Loading bus
Loading plant
Loading heat_rate_curve
Loading gencost_before
Loading gencost_after
Loading branch
Loading sub
Loading bus2sub
--> Loading ct

In [3]: from powersimdata.scenario.delete import Delete

In [4]: scenario.change(Delete)
State switching: analyze --> delete

In [5]: scenario.state.path_config
Out[5]: <powersimdata.utility.server_setup.PathConfig at 0x1041aab80>

Time estimate

5 min

@jenhagg jenhagg self-assigned this Dec 15, 2020
@jenhagg jenhagg added the bug Something isn't working label Dec 15, 2020
@jenhagg jenhagg added this to the Hello Darkness My Old Friend milestone Dec 15, 2020
@@ -14,7 +14,6 @@ class Delete(State):

def __init__(self, scenario):
super().__init__(scenario)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the class is not instantiated, I guess we could just remove the __init__, no?

Copy link
Collaborator

@rouille rouille left a comment

Choose a reason for hiding this comment

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

This has been successfully tested. Thanks

@jenhagg jenhagg merged commit 29c15d5 into develop Dec 15, 2020
@jenhagg jenhagg deleted the jon/delete branch December 15, 2020 18:41
@ahurli ahurli mentioned this pull request Mar 11, 2021
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.

2 participants