-
Notifications
You must be signed in to change notification settings - Fork 4
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
Automatically parse missing as None in clickify_parameters? #329
Comments
A related question is how to UNSET a value from the CLI when it has a default but you want it evaluated to None. Is there a way to do that? One use case I have run into is when you want to use the FLAG column by default but ignore it some of the time (eg. spectral line imaging) |
Would |
Yeah |
Well this issue is really in the domain of CLIs, as far as I'm concerned. So let's think of what makes sense from a CLI point of view. A If this is not a common use case, it might be simpler to explicitly check for a |
It is not that common and I have indeed gone with the latter option but that only works for string inputs. I was just wondering is there is a cleaner way to do this eg. something like I think it makes sense for clickify_parameters to evaluate unset parameters to
|
I can get this working like so but I am not sure if it will have unintended consequences elsewhere. Also not sure if this makes sense for positional arguments. What do you think @o-smirnov ? |
Random question, but does click let you do something like |
Nope. I get eg. |
In principle, parameters without a specified default are supposed to be caught here: https://github.com/caracal-pipeline/stimela/blob/master/scabha/schema_utils.py#L276. The idea is that the click option is then created without a I think we should just hash out the desired logic (maybe on Tuesday) and write it down clearly so we can test against it. Here I'll just list the subtle aspects of the problem:
|
Did you see what I did here? stimela/scabha/schema_utils.py Line 277 in f5b8c35
Is that what you meant? I now just have this policy in the the config.yaml eg.
This was an attempt at defining parameters in a single place. I agree that it's not best practice but the alternative is a lot more work and has proven to be more error prone given the number of rapidly evolving workers I am attempting to maintain. There is an obvious downside to this viz. the function doc string is not informative and has to be viewed by running the CLI command with |
Ah yes. I think this is the right thing to do!
Yeah I hear you... it's a pain keeping the YaML and the Python signature in sync with this many parameters. Well, I suppose we can just proclaim the YaML cab definition to be part of the function documentation and leave it at that? |
Yeah, good idea. Let me see if I can render that to the docstring without breaking something elsewhere. Thanks for the suggestion.
Actually, I think my logic was flawed there (I missed the stimela/scabha/schema_utils.py Line 190 in 1c6a973
the default policies will get overwritten by whatever is in |
Good catch, I think this genuinely a bug! The corresponding cab invocation logic has something more sophisticated than a simple merge, see here: https://github.com/caracal-pipeline/stimela/blob/master/stimela/kitchen/cab.py#L168 I guess the solution is to use that same logic here. |
I had a go in the |
So the issue was that the stimela/scabha/schema_utils.py Line 128 in 95e4f3f
and similarly for |
When defining inputs to be parsed by
clickify_parameters
such asthis will get parsed as an UNSET value. In pfb I get around this like so and I now realise you can also get around this by making parameters optional with no default (eg.
Optional[int]
above) but should it perhaps be the default behaviour?The text was updated successfully, but these errors were encountered: