Skip to content

Move data and modules around#245

Merged
rouille merged 9 commits intodevelopfrom
ben/organize
Aug 4, 2020
Merged

Move data and modules around#245
rouille merged 9 commits intodevelopfrom
ben/organize

Conversation

@rouille
Copy link
Copy Markdown
Collaborator

@rouille rouille commented Aug 3, 2020

Purpose

Rename/move modules and move data as listed in #244.

What is the code doing?

There are only two modules that I have tweaked:

  • powersimdata.data_access.scenario_list module where I added an argument to the _execute_and_check_err method to raise an explicit error message if the command fails.
  • powersimdata.network.usa_tamu.usa_tamu_model module where I modified the path to the data in the _set_data_loc method.
    Otherwise I created some __init__ module along with modifying various import statements and existing __init__ modules.

Where to look

The only module that is not covered by the tests is powersimdata.data_access.scenario_list. Make sure everything looks good there.

Time estimate

15 minutes.

raise IOError(
"Failed to delete entry in %s on server" % const.SCENARIO_LIST
)
raise IOError(err_message)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for fixing this!

Copy link
Copy Markdown
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.

We want to synchronize corresponding changes to PostREISE, etc?

@rouille
Copy link
Copy Markdown
Collaborator Author

rouille commented Aug 3, 2020

We want to synchronize corresponding changes to PostREISE, etc?

In fact, there is nothing in PostREISE that needs to be changed. I thought the constants module was used in PostREISE but it is never imported. The ScenarioInfo class that uses the constants module is used in PostREISE. All tests pass in PostREISE with this branch of PowerSimData checked out.:

[~/CEM/PostREISE] (develop) brdo$ pipenv sync
Creating a virtualenv for this project…
Pipfile: /Users/brdo/CEM/PostREISE/Pipfile
Using /usr/local/bin/python3 (3.8.3) to create virtualenv…
⠸ Creating virtual environment...created virtual environment CPython3.8.3.final.0-64 in 3213ms
  creator CPython3Posix(dest=/Users/brdo/.local/share/virtualenvs/PostREISE-2SBrWDwC, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=/Users/brdo/Library/Application Support/virtualenv/seed-app-data/v1.0.1)
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

✔ Successfully created virtual environment! 
Virtualenv location: /Users/brdo/.local/share/virtualenvs/PostREISE-2SBrWDwC
Installing dependencies from Pipfile.lock (60d44d)…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 39/39 — 00:00:49
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
All dependencies are now up-to-date!
[~/CEM/PostREISE] (develop) brdo$ pipenv shell
Launching subshell in virtual environment…
[~/CEM/PostREISE] (develop) brdo$  . /Users/brdo/.local/share/virtualenvs/PostREISE-2SBrWDwC/bin/activate
(PostREISE) [~/CEM/PostREISE] (develop) brdo$ pytest .
===================================================================== test session starts ======================================================================
platform darwin -- Python 3.8.3, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: /Users/brdo/CEM/PostREISE
collected 129 items                                                                                                                                            

postreise/analyze/generation/tests/test_binding.py ....................                                                                                  [ 15%]
postreise/analyze/generation/tests/test_capacity_value.py ......................                                                                         [ 32%]
postreise/analyze/generation/tests/test_carbon.py ....                                                                                                   [ 35%]
postreise/analyze/generation/tests/test_curtailment.py .................                                                                                 [ 48%]
postreise/analyze/generation/tests/test_summarize.py ...                                                                                                 [ 51%]
postreise/analyze/tests/test_helpers.py ....                                                                                                             [ 54%]
postreise/analyze/transmission/tests/test_congestion_surplus.py ...                                                                                      [ 56%]
postreise/analyze/transmission/tests/test_mwmiles.py ....                                                                                                [ 59%]
postreise/analyze/transmission/tests/test_statelines.py .....                                                                                            [ 63%]
postreise/plot/multi/tests/test_plot_bar.py ..........                                                                                                   [ 71%]
postreise/plot/multi/tests/test_plot_helpers.py ...............                                                                                          [ 82%]
postreise/plot/multi/tests/test_plot_pie.py ....                                                                                                         [ 86%]
postreise/plot/multi/tests/test_plot_shortfall.py .........                                                                                              [ 93%]
postreise/plot/tests/test_plot_shadowprice.py .........                                                                                                  [100%]

===================================================================== 129 passed in 18.69s =====================================================================
(PostREISE) [~/CEM/PostREISE] (develop) brdo$ 

@jenhagg
Copy link
Copy Markdown
Collaborator

jenhagg commented Aug 3, 2020

Ha, awesome. I got an error with local branch in PostREISE but seems that's the only thing affected. All good from my side.

@rouille rouille linked an issue Aug 3, 2020 that may be closed by this pull request
9 tasks
@rouille rouille modified the milestones: A New Hope, Oppressive Sun Aug 3, 2020
@rouille
Copy link
Copy Markdown
Collaborator Author

rouille commented Aug 4, 2020

Just realize I forgot to update the path to the data in the setup.py file.

Comment thread powersimdata/scenario/execute.py Outdated
self.ct = ct

self.TMP_DIR = "%s/scenario_%s" % (const.EXECUTE_DIR, scenario_info["id"])
self.TMP_DIR = "%s/scenario_%s" % (
Copy link
Copy Markdown
Contributor

@danielolsen danielolsen Aug 4, 2020

Choose a reason for hiding this comment

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

Do you think it would be cleaner to do this with posixpath.join?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Contributor

@danielolsen danielolsen left a comment

Choose a reason for hiding this comment

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

Looks good.

raise IOError(err_message[0].strip())

err_message = "Failed to generate id for new scenario"
stdout = self._execute_and_check_err(command, err_message)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Where is 'command' defined? Should it be 'script' instead?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

good catch

Comment thread powersimdata/design/scenario_info.py
:raises ValueError: if model or engine does not exist.
"""

def __init__(self, interconnect, source="usa_tamu", engine="REISE"):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we change the default engine into 'REISE.jl' some time.

Copy link
Copy Markdown
Contributor

@danielolsen danielolsen Aug 4, 2020

Choose a reason for hiding this comment

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

We changed the default when creating a scenario in #229. I am not sure there is a point in having a default here, since all entries in the ScenarioList should be appropriately tagged.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

A Grid object does not have access to the ScenarioList file. And we need to know the engine to appropriately read the *_grid.mat files. This optional argument is kind of transparent because it is handled in the _set_ct_and_grid method of the Analyze class

Copy link
Copy Markdown
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.

Thanks for taking care of this tedious work. I think the reorganization makes the package structure and naming more reasonable.

@rouille rouille merged commit 00848fd into develop Aug 4, 2020
@rouille rouille deleted the ben/organize branch August 4, 2020 22:14
@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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reorganize package

4 participants