Comments (4)
Per chat w @sgillies:
- Write validation logic in SDK
- Write click callbacks in CLI (which leverage the validation logic in the SDK)
- Simple functions instead of stateful methods (keep it testable)
I'm still stuck on exactly how the implementation is going to look, it could take one of several forms but I'm currently leaning towards:
mapbox.validate
module exposing a bunch of functions with the signaturef(val) -> val
and raise aValueError
if anything was wrong.mapboxcli.validate
module with a bunch of wrapper functions that call ^ and reraiseclick.BadParameter
. These would be click callbacks and take the signaturef(ctx, param, val) -> val
The validation modules could even handle the geojson feature validation and normalization.
from mapbox-cli-py.
@sgillies, I created validation
branches in both the sdk and cli. Started off with geocoding, let's review this before I go ahead with the other services:
In the CLI:
957694d
In the SDK:
mapbox/mapbox-sdk-py@b235003
from mapbox-cli-py.
Agreed that we shouldn't repeat ourselves. How about this (a restatement of our conclusions from yesterday plus some new thoughts):
SDK
- In the SDK we are committed to preventing requests that will fail 💯 because of invalid arguments (image sizes, travel modes, geocoding datasets)
- Let's validate them using functions in a
validation
module, not with in-line code. - Raise SDK-specific exceptions that derive from
ValueError
(orKeyError
for, say, travel modes).
CLI
- We're committed 💯 to sparing CLI users from reading tracebacks.
- The CLI takes responsibility for validating: input/output file paths and the few other things that aren't a concern of the SDK
- Otherwise, rely on the SDK, re-raising its errors as you suggest above.
- We could reserve the option to write validiating Click callbacks using methods from the SDK's validation module if we have a future need.
from mapbox-cli-py.
👍 I'll work on implementing this soon.
rely on the SDK, re-raising its errors ...
write validiating Click callbacks using methods from the SDK's validation module if we have a future need
I realized that writing click callbacks means testing everything twice (once on arg parsing, once when you run it). I think just catching SDK exceptions is sufficient and DRY (as long as we have a consistent exception to look out for)
from mapbox-cli-py.
Related Issues (20)
- Seems to be an off-by-one error in mapbox staticimage HOT 4
- Tileset info incorrect when uploading data files in parallel HOT 2
- Update Directions CLI HOT 5
- python MapboxDeprecationWarning: The distance module will be removed in the next version. Use the matrix module instead. "Use the matrix module instead.", MapboxDeprecationWarning) HOT 3
- Add mapbox-matrix HOT 2
- Homebrew tap: error & fix HOT 1
- 0.8.0 release
- address Homebrew formula warning HOT 1
- TypeError: request() got an unexpected keyword argument 'json'
- Remove deprecated Distance API
- Remove surface command HOT 1
- Gracefully error when tileset name not specified HOT 2
- Usage of `datasets create-tileset` HOT 1
- Retreiving tilesets HOT 1
- pip install --user mapboxcli doesn't actually install properly on debian 10 (buster) HOT 1
- Update mapbox dependency to support Python 3.9
- error while installing using homebrew HOT 9
- Install Fails on Windows
- Latest version on pypi is no longer installing properly
- Is this project abandoned?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapbox-cli-py.