-
Notifications
You must be signed in to change notification settings - Fork 7
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
Exclusions: "all_missing" #359
Comments
It looks like we will also need to add >>> ds.exclude('disposition in [0] or all_missing(bix_MY_ecommerce_unaided_recode)')`
ValueError: unknown method "all_missing", valid methods are: [bin, all, duplicates, selected, not_selected, any] |
@jjdelc can you advise on the place of expressions.py: CRUNCH_FUNC_MAP = {
'valid': 'is_valid',
'missing': 'all_missing',
'bin': 'bin',
'selected': 'selected',
'not_selected': 'not_selected',
}
CRUNCH_METHOD_MAP = {
'any': 'any',
'all': 'all',
'duplicates': 'duplicates',
'bin': 'bin',
'selected': 'selected',
'not_selected': 'not_selected',
'all_missing': 'all_missing'
} >>> conn.ds.get_exclusion()
u'disposition in [0] or missing(bix_MY_ecommerce_unaided_recode)'
>>> conn.ds.exclude('disposition in [0] or bix_MY_ecommerce_unaided_recode.all_missing()')
>>> conn.ds.get_exclusion()
u'disposition in [0] or bix_MY_ecommerce_unaided_recode.all_missing()'
|
This looks like a translation problem. Looking at the logic used to transform, there seems to be a nomenclature problem. The The I'm not sure of what would be the syntax that feels more natural to you, but depending on your choise of i'd recommend avoid renaming the functions in a map, as this could cause collisions in the future if we grow more functions on zz9 that are already used in scrunch. |
Just to clarify, the above @jjdelc do you mean |
I think this function has been around for a while. The fix for this would be in 2 part:
|
In the original example we set the exclusion using scrunch in the same way we always have, so nothing seems to be different on our side with this. It is definitely new behavior for this to throw an error: >>> ds.exclude('disposition in [0] or missing(bix_MY_ecommerce_unaided_recode)')`
>>> ds.get_exclusion()
...
Exception: Unknown function "all_missing"
|
It looks like this problem of going back and forth happens within scrunch. But overall we should avoid translating functions because we could cause conflicts as the Crunch API grows more functions that may collide with some of Scrunch translations. |
Being able to translate filter payloads back to scrunch syntax is actually a very important feature because it allows us to save a filter to re-apply later. An example of a situation where we might want to do this is described for https://github.com/Crunch-io/scrunch/wiki/User-Reference#derive_weight Of course, it's also just important for human users to be able to make sense of an existing filter. |
Sorry, with translating I meant to have function names differ from Scrunch and the Crunch API. If we have a function called |
Right, I get it now. This came up in a conversation I had with Fernando yesterday as well and I think we all agree on this point. Making a switch to Crunch-native function names across the board for scrunch's expression syntax is something we can cope with on our side if you want to move in that direction. |
We could raise a deprecation warning if the translations are used. And have some compatibility if needed temporarily, but I think we should move forward avoiding changing function names. |
we were translating the function |
Careful about changing function names as there may be a bunch of scripts that use it. Do you have a PR to look at the change? |
Based on the docs I know above we agreed to disallow non-canon function names but in the case of |
So what should we do ? I think we should change the parser to use strict names for all_missing, is_missing. Cut a release with a warning that missing is no longer supported. |
After having a conversation with Jamie this is what I think we should do:
|
Can we support all of the logical functions here: https://docs.crunch.io/object-reference/object-reference.html?highlight=all_missing#logic-functions And with regard to the shorthand |
Agreed to @xbito's comment. The support for the other functions should be dealt with in another ticket. Since I suppose some syntax choices need to be made. |
that's not gonna work, we use a dictionary to map srunch functions to Crunch functions and viceversa. I can't have 2 keys or 2 values mapping to My proposal is to either:
The rest of the functions would need to be addressed on a new ticket as mentioned by Jj |
In that case I guess the request here is not to use a dict as-is, but to wrap this with a function that can, in the case of missing, differentiate between the required |
That is going to be a lot more work and if we are going to start supporting variable context analysis then we should plan how to do it. For the context of this ticket we simply translate the JSON that comes from Crunch into a human-friendly form. Making the parser aware of the type of variables it's translating is a whole new world. |
@xbito The code to deal with expressions is here: https://github.com/Crunch-io/scrunch/blob/master/scrunch/expressions.py. mappings happen here: https://github.com/Crunch-io/scrunch/blob/master/scrunch/expressions.py#L59 This function The function And finally |
On
184bfcef7f8f4331b229c0e7606db425
:Has the Crunch API exposed the
missing
function with a new name @jjdelc ?If so, it looks like
scrunch.expressions.CRUNCH_FUNC_MAP
may be out of date.The text was updated successfully, but these errors were encountered: