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

Make estimate-area and rasterio/GDAL optional #149

Merged
merged 8 commits into from
Mar 14, 2022
Merged

Make estimate-area and rasterio/GDAL optional #149

merged 8 commits into from
Mar 14, 2022

Conversation

johnk1
Copy link
Contributor

@johnk1 johnk1 commented Mar 3, 2022

fixes #147

This makes estimate-area an optional command. This command depends on rasterio w/GDAL, which is not as easily installed on arm64 Macs. So, this PR enables a simple installation for most uses while still keeping this command available.

testing

This shows the basic installation without estimate-area. We see the command fails with an exception.

$ pyenv activate env1
$ pip install mapbox-tilesets==1.7.3a1
    Collecting mapbox-tilesets==1.7.3a1
    Downloading mapbox_tilesets-1.7.3a1-py3-none-any.whl (15 kB)
    ...

$ tilesets --version
    1.7.3a1

$ tilesets list <account>
  ... list of tilesets

$ tilesets estimate-area valid.ldgeojson  -p 10m
    Traceback (most recent call last):
    File "/Users/johnklancer/.pyenv/versions/fresh/bin/tilesets", line 8, in <module>
        sys.exit(cli())
    File "/Users/johnklancer/.pyenv/versions/3.9.10/envs/fresh/lib/python3.9/site-packages/click/core.py", line 829, in __call__
        return self.main(*args, **kwargs)
    File "/Users/johnklancer/.pyenv/versions/3.9.10/envs/fresh/lib/python3.9/site-packages/click/core.py", line 782, in main
        rv = self.invoke(ctx)
    File "/Users/johnklancer/.pyenv/versions/3.9.10/envs/fresh/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
    File "/Users/johnklancer/.pyenv/versions/3.9.10/envs/fresh/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
        return ctx.invoke(self.callback, **ctx.params)
    File "/Users/johnklancer/.pyenv/versions/3.9.10/envs/fresh/lib/python3.9/site-packages/click/core.py", line 610, in invoke
        return callback(*args, **kwargs)
    File "/Users/johnklancer/.pyenv/versions/3.9.10/envs/fresh/lib/python3.9/site-packages/mapbox_tilesets/scripts/cli.py", line 756, in estimate_area
        filter_features = utils.load_module("supermercado.super_utils").filter_features
    File "/Users/johnklancer/.pyenv/versions/3.9.10/envs/fresh/lib/python3.9/site-packages/mapbox_tilesets/utils.py", line 18, in load_module
        raise ValueError(
    ValueError: Couldn't find supermercado.super_utils. Check installation steps in the readme for help.

This test shows the full installation including estimate-area. Testing on an M1 with brew install gdal already run.

$ pyenv activate env2
$ pip install 'mapbox-tilesets[estimate-area]'==1.7.3a1
Collecting mapbox-tilesets[estimate-area]==1.7.3a1
    ...
$ tilesets estimate-area valid.ldgeojson  -p 10m
{"km2": "382565", "precision": "10m", "pricing_docs": "For more information, visit https://www.mapbox.com/pricing/#tilesets"}

After review

Once this is merged, I will bump the version to 1.7.3, tag, and verify it's published.

@@ -16,4 +17,5 @@ deploy:
password: $PYPI_PASSWORD
distributions: "sdist bdist_wheel"
on:
python: 3.7
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Travis' default dist action w/pypi fails with an error on python 3.6 now, so I changed this to publish with 3.7

@@ -1,6 +1,7 @@
boto3==1.9.99
Click==7.1.2
cligj==0.5.0
numpy==1.19.5
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a direct dependency but came in via supermercado

@johnk1 johnk1 marked this pull request as draft March 3, 2022 21:53
@johnk1 johnk1 marked this pull request as ready for review March 3, 2022 21:54
Copy link

@AnwarBaroudi AnwarBaroudi left a comment

Choose a reason for hiding this comment

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

LGTM!

mapbox_tilesets/utils.py Show resolved Hide resolved
Copy link
Contributor

@dnomadb dnomadb left a comment

Choose a reason for hiding this comment

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

This looks / works great @johnk1. One suggestion -- add the link for installation to the estimate-area docstring. Something like:

tilesets estimate-area --help
Usage: tilesets estimate-area [OPTIONS] FEATURES...

  Estimate area of features with a precision level. Requires extra installation steps: see https://github.com/mapbox/tilesets-cli/blob/master/README.md.

@@ -70,7 +70,7 @@ Releases to PyPi are handled via TravisCI and GitHub tags. Once changes have bee
All tests are runnable with pytest. pytest is not installed by default and can be installed with the pip test extras

```shell
pip install -e .[test]
pip install -e '.[test]'
Copy link
Contributor

Choose a reason for hiding this comment

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

Do the tests require [estimate-area] as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, [test] includes supermercado already

@johnk1 johnk1 requested a review from dnomadb March 14, 2022 19:01
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.

Install error on macOS Monterrey
3 participants