mapillary / mapillary-python-sdk

A Python 3 library built on the Mapillary API v4 to facilitate retrieving and working with Mapillary data.
MIT License
39 stars 15 forks source link

[Feature] Utilities for extracing fields, filtering pipeline #43

Closed Rubix982 closed 3 years ago

Rubix982 commented 3 years ago

[Feature] Utilities for extracting fields, filtering pipeline)

Pull Request Type

Purpose

To simply the filtering purpose, and for users who might want to extract only certain fields from a GeoJSON. I ran into a problem when testing requirement#2 where I just wanted to check the final id property across all features in a GeoJSON and did not need everything else, so I came up to write a simple function that does it for me.

I noticed that the DRY principle was being violated with the filtering ideas. As we go on in the requirements, there are fields that are common across requirements, and can be also common with future requirements, that we would have to write the same code for over and over again - what if can automate that?

A pipeline does just that. It passes the data to the first filter it has received, then that output of that gets passed to the 2nd filter, then the output of the 2nd filter gets passed as the input to the 3rd filter.

Why?

The most important change that this PR introduces is the filtering pipeline which lets us reorganize, add, remove filters as simple objects, future demonstration will be worked on. This means if a filtering mechanism breaks or if we want to add a new one, it will be a simple addition, and then any future user or potential developer can just reuse this pipeline component

Feedback required over

Feedback required when

Whenever feasible

Mentions

from mapillary.utils.filter import pipeline.
pipeline(...)
Rubix982 commented 3 years ago

For the above commits,

CC: @OmarMuhammedAli review please

Rubix982 commented 3 years ago

Amazing work, @Rubix982 !!!!! I really enjoyed reviewing this PR. Can you share some resources that inspired you to apply the design decisions you used here?

Just the DRY principle suggested by someone called "Omar". I think you know him :wink: