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

Cut new version #30

Merged
merged 18 commits into from Apr 26, 2021
Merged

Cut new version #30

merged 18 commits into from Apr 26, 2021

Conversation

jomey
Copy link
Collaborator

@jomey jomey commented Apr 23, 2021

I would like to cut a new version for the library as I:

  • Changed the API on to load HRRR data
  • Removed the forecast_flag option when loading data on get_saved_data
  • Renamed the output_dir parameter to input_dir on get_saved_data
  • Removed HRRR class.
  • Removed the utility method for get HRRR file names.
  • Cleaned up some tests.

Can we make this 0.7?
I would need guidance on how you usually cut a new release.

Then I can follow up with SMRF to either pin the version to below the suggested new one or change the one call we do from SMRF.

Update 20210424

Got carried a way a bit and changed a few more things.

  • FileLoader now takes the file_dir and 'file_type as initialize arguments
  • Renamed parameter the config_file to config
  • Turned down the log level in tests.
    See more explanations in the commit message for each change.

This option was dropped in SMRF with PR#205
This deprecates the HRRR class, which was broken up into the data.hrrr
structure in a previous commit. The class was kept around for backwards
compatibility and this change will also include a version bump.
The file contained had dependencies that were not met in this repository
and usage with this library has changes since.
@jomey jomey requested a review from scotthavens April 23, 2021 15:39
The method has moved to the FileHandler.
@scotthavens
Copy link
Contributor

Right now, this requires a manual push to pypi. I want to move this to Github actions and add the deployment piece to it. Then creating a release would publish to pypi. I can get to that next week, WFR isn't too complicated for testing and deployment.

@@ -10,8 +10,7 @@ class RMETestCase(unittest.TestCase):
"""
Base class for all unit tests using the RME data
"""
test_dir = Path(__file__).parent
basin_dir = test_dir.joinpath('RME')
basin_dir = Path(__file__).parent
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain moving this file? It seems to go against how SMRF/AWSM are setup to test with basins. Just trying to think of how the format fits with the other tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I moved this in here because I see this as the next improvement over how SMRF/AWSM does it and would also like to see this change propagate to there. If you look at the class, it basically describes the structure of the basin dir test data and is all you need in order to use the data in tests.

It also clearly separates test data from test logic, moving it in there.

Last argument I see is that the test_dir property was removed and this was never used anywhere else, showing that moving the class into the folder is the better place to keep it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does seem to be cleaner if we move that route. Then in SMRF, the RME/Lakes would be under their presepective directories.

The one major downside I see is discoverability for that class. You pretty much have to know that it's there, as in the SMRF case, it'll be buried a few directories down.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can see this downside addressed with documentation. Currently we have a need for that as a whole, on how they are set up, what parts tests what, or when it is appropriate to updated the gold files.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes to documentation. But it's way easier to just code.

weather_forecast_retrieval/data/hrrr/file_loader.py Outdated Show resolved Hide resolved
weather_forecast_retrieval/data/hrrr/file_loader.py Outdated Show resolved Hide resolved
Rename parameter in method to `file_dir` from `output_dir` and add as
class property. The current implementation utilized the 'output_dir'
property from the base class, which is parsing the `output_dir` value
from a config file. However, calling this method should not overwrite
this property.
The start and end date are already initialized in the ConfigFile base
class.
There were two separate places where the dataframe was read and data
manipulated. This combines them into one method.
if key == 'cloud_factor':
dataframe['cloud_factor'] = 1 - dataframe['cloud_factor'] / 100

return metadata, dataframe
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved this into the convert_to_dataframes method. Seems a better place and consolidates any dataframe logic.

@@ -26,10 +26,8 @@ def __init__(self, config_file=None, external_logger=None):
__name__, config_file=config_file, external_logger=external_logger
)

self.start_date = None
self.end_date = None
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unnecessary double initialization. Already happening in the parent base class.

@@ -3,7 +3,7 @@

import pandas as pd

from tests.RME_test_case import RMETestCase
from tests.RME import RMETestCase
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see this as a readability improvement and another argument for moving the class into the folder.

@jomey jomey requested a review from scotthavens April 23, 2021 20:54
Move the basic parameters for file type and file directory to the
initializer. This separates the type of data from the `get_saved_data`
method, where filters for the data are given with parameters.
Rename the `config_file` parameter and rename to config to support
either a .ini style file or a dictionary.
Consolidate the log messages by using the same logger.
There is no need to record an initialization entry in the log when using
an external logger. This also combines the logic for creating a logger
and then recording the above mentioned entry.
No version of less than 3.5 is supported by this library anymore.
@@ -10,8 +10,7 @@ class RMETestCase(unittest.TestCase):
"""
Base class for all unit tests using the RME data
"""
test_dir = Path(__file__).parent
basin_dir = test_dir.joinpath('RME')
basin_dir = Path(__file__).parent
Copy link
Contributor

Choose a reason for hiding this comment

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

Does seem to be cleaner if we move that route. Then in SMRF, the RME/Lakes would be under their presepective directories.

The one major downside I see is discoverability for that class. You pretty much have to know that it's there, as in the SMRF case, it'll be buried a few directories down.

@scotthavens
Copy link
Contributor

I will be working on the new release over the next couple of days. I'll also be moving to setuptools_scm to keep track of the versions.

@scotthavens scotthavens merged commit 949df46 into USDA-ARS-NWRC:main Apr 26, 2021
@scotthavens
Copy link
Contributor

v0.7.0 is up!

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.

None yet

2 participants