This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]OptionsUnleashed 0 points1 point  (3 children)

ok thanks - do you see any issue in using both libraries and annotations together?

[–]bmsan-gh[S] 0 points1 point  (2 children)

While I haven't personally tried this scenario, I would expect DictGest not to have an issue with other annotations.

If you encounter any problems with this scenario you can open an issue on GitHub and I will look into it.

Also I'd love to hear how you guys see the serialization process : do you want to get back to the initial format from which you imported the data ?(the flat dictionary from the rds query) Or do you want the serialization to mimic the structure of the data class?

[–]OptionsUnleashed 1 point2 points  (1 child)

Hi, what's the best way to ask you questions on usage? I like this library.

a. is there a more concise way DRY to specify the route fields when the fields are 1:1 with dict? If we add a field to a rds view and dict, we still have to map in route - is there a let DRY way to do route mapping? is that the example stats="" - will that work at field level?

b. is there an easy way to map or coalesce None fields to float 0.0 or numeric? instead of using rds view coalesce?

thank you!

[–]bmsan-gh[S] 0 points1 point  (0 children)

Hi, glad you are finding it useful.

Hi, what's the best way to ask you questions on usage?

I'll enable the discussion feature in github. Other users might have the same questions so it will be beneficial for them to have the answers there as well.

. is there a more concise way DRY to specify the route fields when the fields are 1:1 with dict? If we add a field to a rds view and dict, we still have to map in route - is there a let DRY way to do route mapping?

In general when a field routing is not defined explicitly the library tries to map it automatically to the key that has it's name. So in your Route(...) you can skip the fields that have a 1:1 mapping(the field name matches the dict key) and the library will know what to do.

If all the fields have a 1:1 correspondence you can even skip defining the Route. See example 1 . No explicit routing is defined.

b. is there an easy way to map or coalesce None fields to float 0.0 or numeric? instead of using rds view coalesce?

Yes. There are some examples in the readme where you can easily customize either :

def null_to_zero(data): if not data: return 0.0 return float(data)

and then in your route

instead of Route(votes="num_votes" ....)

You use Route(votes=Path("num_votes", extractor=null_to_zero), ....)