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

Dependencies #73

Draft
wants to merge 28 commits into
base: master
Choose a base branch
from
Draft

Dependencies #73

wants to merge 28 commits into from

Conversation

zmoon
Copy link
Contributor

@zmoon zmoon commented Dec 20, 2021

Closes #71 and also should speed up the RTD build

  • cartopy and dask.array now optional
  • user-facing methods that need them raise exception if they are not importable
  • create exception type (MissingDependency)? to raise and change the tests to xfail on this instead of skip
  • notes about ffmpeg requirement in the docs
  • minimal pip requirements for RTD
  • update Conda recipe, which currently includes cartopy and dask-core ?

and comment the extras that aren't currently used in the tests
consistent with the conda-forge recipe
`ipython` is needed to syntax highlight the examples
in the nbsphinx nb parsing

I don't recall getting these last time I built the docs,
but whatever...

The images need to have a unique alt.
I was getting:
  WARNING: Duplicate substitution definition name: "image0"

Note: using the filename as the alt in the markdown
causes this warning:
  WARNING: Undefined substitution referenced: "movie_fast.gif"
(and also the image is not shown)
if already have ffmpeg, don't need it
if don't, can easily install with conda or other method
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@zmoon
Copy link
Contributor Author

zmoon commented Dec 20, 2021

@jbusecke can you give this an initial look when you get a chance?

@codecov
Copy link

codecov bot commented Dec 20, 2021

Codecov Report

Merging #73 (9dd742c) into master (f69ed6d) will increase coverage by 3.03%.
The diff coverage is 97.91%.

@@            Coverage Diff             @@
##           master      #73      +/-   ##
==========================================
+ Coverage   78.52%   81.56%   +3.03%     
==========================================
  Files           3        4       +1     
  Lines         326      358      +32     
  Branches       61       63       +2     
==========================================
+ Hits          256      292      +36     
+ Misses         46       43       -3     
+ Partials       24       23       -1     
Flag Coverage Δ
unittests 81.00% <95.83%> (+2.78%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
xmovie/core.py 85.57% <92.30%> (+0.44%) ⬆️
xmovie/_util.py 100.00% <100.00%> (ø)
xmovie/presets.py 74.63% <100.00%> (+4.87%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f69ed6d...9dd742c. Read the comment docs.

@zmoon zmoon mentioned this pull request Jan 12, 2022
1 task
Copy link
Owner

@jbusecke jbusecke left a comment

Choose a reason for hiding this comment

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

Amazing start @zmoon. I briefly checked the changes, and think you are on a good track.
It was a bit hard to review this with the mix of formatting only changes, perhaps we should enforce the code formatting a bit more strictly in another PR?

I will definitely need to go over this one more time in more detail, but I made some suggestions that might help streamline the code. Let me know what you think

docs/index.rst Show resolved Hide resolved
xmovie/core.py Show resolved Hide resolved
@@ -72,6 +68,9 @@ def _base_plot(ax, base_data, timestamp, framedim, plotmethod=None, **kwargs):

# projections utilities and hacks
def _smooth_boundary_NearsidePerspective(projection):
import cartopy.crs as ccrs
Copy link
Owner

Choose a reason for hiding this comment

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

I am not sure this is the best way to do this. Could we define a decorator that checks if cartopy is available, and raises an error if not. Similar to what xarray is doing for their tests: https://github.com/pydata/xarray/blob/95bb9ae4233c16639682a532c14b26a3ea2728f3/xarray/tests/__init__.py#L43-L66
I might be missing something here, but this will not result in a nice error message for the user AFAIKT

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did put such a message in the user-facing functions, e.g. here. But I like the decorator idea, to reduce duplication of code like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jbusecke I had a go at the decorator, let me know what you think.

xmovie/presets.py Show resolved Hide resolved
xmovie/test/test_core.py Outdated Show resolved Hide resolved
@zmoon
Copy link
Contributor Author

zmoon commented Mar 17, 2022

@jbusecke thanks much for the suggestions. I will update the tests to use the xarray-style _importorskip function. And in the code base I will try a @requires/@needs decorator that can take a module name or list of module names to check for. I have seen the like in a few projects but can't remember where right now...

It was a bit hard to review this with the mix of formatting only changes, perhaps we should enforce the code formatting a bit more strictly in another PR?

Sorry about that; we could introduce a pre-commit config in another PR?

@jbusecke
Copy link
Owner

Sorry about that; we could introduce a pre-commit config in another PR?

That would be best I think. And no worries! I should have set this up earlier anyways. The growing pains of converting a pet project into a community maintainable package are real!

@zmoon
Copy link
Contributor Author

zmoon commented Mar 28, 2022

Also we need to decide if we want to use the new pip requirements file I made for RTD, or stick with your mamba-forge solution that is currently working.

@zmoon zmoon mentioned this pull request Mar 28, 2022
@zmoon
Copy link
Contributor Author

zmoon commented May 3, 2022

@jbusecke there are still some things to resolve, but I think this is ready for another look

@jbusecke
Copy link
Owner

jbusecke commented May 3, 2022

Could you run pre-commit locally and rebase on the latest main? I would hope some of the formatting diffs would go away. Then Ill def go through it in more detail. Thanks for your patience on this.

zmoon added 2 commits May 3, 2022 16:47
before attempting merge with the already-formatted master
@jbusecke jbusecke self-assigned this Jun 28, 2022
@zmoon
Copy link
Contributor Author

zmoon commented Jul 31, 2022

I tried to test for the xmovie.core module-level warning about tqdm like this

# Separate file
import warnings

import pytest

from . import has_tqdm


def test_tqdm_message_on_import():
    if has_tqdm:
        with warnings.catch_warnings():
            warnings.simplefilter("error")
            import xmovie
    else:
        with pytest.warns(UserWarning, match="^Optional dependency `tqdm` not found."):
            import xmovie

but it seems like it get emitted before where I am trying to catch.

@zmoon zmoon requested a review from jbusecke August 1, 2022 15:00
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.

Lighten requirements?
2 participants