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

Feature/smhi class to match 0.2.0 #115

Merged
merged 71 commits into from
May 22, 2024
Merged

Conversation

docNord
Copy link
Collaborator

@docNord docNord commented Apr 6, 2024

Naive update of parent class to new structure. To be updated later. Ambition here is simply to support 0.2.0 release.

  • Restructure base code to new format
  • Fix superstructure (find station from gps and place name, interpolation etc)
  • Test functionality
  • Re-write tests
  • Update documentation

@docNord docNord added documentation Improvements or additions to documentation enhancement New feature or request labels Apr 6, 2024
@docNord docNord added this to the 0.2.0 milestone Apr 6, 2024
@docNord docNord self-assigned this Apr 6, 2024
Copy link
Collaborator

@mgcth mgcth left a comment

Choose a reason for hiding this comment

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

A simplification.

src/smhi/smhi.py Outdated Show resolved Hide resolved
src/smhi/smhi.py Outdated Show resolved Hide resolved
@docNord
Copy link
Collaborator Author

docNord commented Apr 7, 2024

I am not in a position to fix the unit tests without support.

@mgcth
Copy link
Collaborator

mgcth commented Apr 7, 2024

I hate mutating an object's state. I'd rather a method called get_ returns something and not also mutated an object's internal state.

I'd also write the unit tests in a way that will be easier for us when updating the code in the future. That is, as little patching as possible and assert calls and stuff. The important underlying stuff has been tested and we can assume it'll run fine. I know this isn't strictly a unit test, but they are too brittle to upkeep for our small organisation. Define some input data at some defined interface and some output data your module should produce, mock requests.get, the Metobs modules or so, and let the code run. Call that the unit test of the module. In the integration test, we can actually call the API and run through.

I've simplified it a bit in 57c3e05. I'd probably add a separate method called get_data_by_city (and also allow for interpolation) or so and refactor some of the code in get_data so it can be reused.

@mgcth
Copy link
Collaborator

mgcth commented Apr 7, 2024

I still think you should refactor the _interpolate method in c4dfcca.

src/smhi/smhi.py Outdated Show resolved Hide resolved
src/smhi/smhi.py Outdated Show resolved Hide resolved
src/smhi/smhi.py Outdated Show resolved Hide resolved
@docNord
Copy link
Collaborator Author

docNord commented Apr 11, 2024

Sorry @mgcth, didn't realize until now that you had also commited here. I will look into your work and update. Agree we shouldn't mutate the object.

Copy link
Collaborator

@mgcth mgcth left a comment

Choose a reason for hiding this comment

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

Great job, looks better!

At this point, I'd focus on docs and one or two tests of the whole SMHI object (call them integration, but without calling the API).

tests/unit/test_unit_smhi.py Show resolved Hide resolved
This was linked to issues May 5, 2024
@docNord
Copy link
Collaborator Author

docNord commented May 5, 2024

Thanks for the input. I will try to get an integration test going and sort out the remaining stuff to the extent that I can.

@docNord
Copy link
Collaborator Author

docNord commented May 5, 2024

@mgcth it seems your fix to use IntEnum changed the order of the list so that default is now "corrected-archive" again, was that deliberate?

@mgcth
Copy link
Collaborator

mgcth commented May 5, 2024

@mgcth it seems your fix to use IntEnum changed the order of the list so that default is now "corrected-archive" again, was that deliberate?

Yes. Do you prefer it the other way around?

@docNord
Copy link
Collaborator Author

docNord commented May 5, 2024

@mgcth it seems your fix to use IntEnum changed the order of the list so that default is now "corrected-archive" again, was that deliberate?

@mgcth it seems your fix to use IntEnum changed the order of the list so that default is now "corrected-archive" again, was that deliberate?

Yes. Do you prefer it the other way around?

Not at all - I thought you wanted it the other way around after that discussion we had earlier, but I have absolutely no opinion on the matter. I will continue with this way of working, seems good to me. 👍

@docNord docNord requested a review from mgcth May 18, 2024 14:48
@docNord
Copy link
Collaborator Author

docNord commented May 20, 2024

Ping @mgcth

Copy link
Collaborator

@mgcth mgcth 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. Just minor comments from the phone. Fix them and I'll approve tomorrow when I have a computer at hand.

docs/index.md Outdated Show resolved Hide resolved
docs/smhi-example.md Outdated Show resolved Hide resolved
docs/smhi-example.md Outdated Show resolved Hide resolved
docs/smhi-example.md Outdated Show resolved Hide resolved
docs/smhi-example.md Outdated Show resolved Hide resolved
tests/integration/test_integration_smhi.py Outdated Show resolved Hide resolved
tests/integration/test_integration_smhi.py Show resolved Hide resolved
Copy link
Collaborator

@mgcth mgcth left a comment

Choose a reason for hiding this comment

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

Great job! 🚀

@docNord
Copy link
Collaborator Author

docNord commented May 22, 2024

I don't know if I managed to get the figure in the build properly @mgcth, could you have a look please? Other than that, I am quite happy.

@mgcth mgcth merged commit 3b7dc36 into main May 22, 2024
12 checks passed
@mgcth mgcth deleted the feature/smhi-class-to-match-0.2.0 branch May 22, 2024 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test coverage for smhi Add functionality to smhi client
2 participants