Allow OTB dotted parameters in kwargs
Right now it is not possible to pass composed keys without using a dict e.g. {"map.code.espg": ...}
.
One possible workaround would be to replace any kwarg with "_" by ".", thus allowing to pass keys like map_code_epsg=...
Activity
-
Newest first Oldest first
-
Show all activity Show comments only Show history only
- Cresson Remi added feature label
added feature label
- Cresson Remi assigned to @vidlb
assigned to @vidlb
By Vincent Delbar on 2023-01-24T15:03:16 (imported from GitLab)
- Cresson Remi changed the description
changed the description
By Vincent Delbar on 2023-01-24T15:03:39 (imported from GitLab)
- Cresson Remi changed title from Allow parameter with dots to be passed as kwargs to Accept any parameter as kwarg, even if it contains dots
changed title from Allow parameter with dots to be passed as kwargs to Accept any parameter as kwarg, even if it contains dots
By Vincent Delbar on 2023-01-24T15:08:08 (imported from GitLab)
- Cresson Remi changed the description
changed the description
By Vincent Delbar on 2023-01-24T15:08:22 (imported from GitLab)
- Cresson Remi changed the description
changed the description
By Vincent Delbar on 2023-01-24T15:08:32 (imported from GitLab)
- Author Owner
@remicress any thought about this one ? I believe it can be done with a single line commit
By Vincent Delbar on 2023-02-03T10:30:05 (imported from GitLab)
- Author Owner
I don't like the idea that classes attributes are named after OTB application parameters.
I know its nitpicking but suppose you develop a C++ OTB application with a parameter named "name", then you could not use the feature.
By Rémi Cresson on 2023-02-03T20:40:51 (imported from GitLab)
Collapse replies - Author Owner
Ow yes I just realized you were talking about
save_objects
, we left it for now, what should we do with it ?By Vincent Delbar on 2023-02-03T20:40:50 (imported from GitLab)
- Author Owner
Yeah I am not a big fan of this, I prefer accessing with
app[key]
. Also thissetattr
thing might be dangerous, and is opaque.I am in favor to remove it, but what do you think?
By Rémi Cresson on 2023-02-04T19:40:16 (imported from GitLab)
Edited by Cresson Remi - Author Owner
Ok just saw #75 / #76
By Rémi Cresson on 2023-02-04T19:45:28 (imported from GitLab)
- Author Owner
We already removed this feature with your previous MR !I'm not talking about class attributes but App init keyword arguments.By Vincent Delbar on 2023-02-03T20:41:29 (imported from GitLab)
Edited by Cresson Remi - Author Owner
Here is a draft of the proposed change :
def set_parameters(self, *args, **kwargs): ... parameters = kwargs parameters.update(self.__parse_args(args)) # Going through all arguments for key, obj in parameters.items(): if "_" in key: key = key.replace("_", ".") if key not in self.parameters_keys: raise KeyError( f"{self.name}: parameter '{key}' was not recognized. Available keys are {self.parameters_keys}" )
So it is a +2 lines commit
By Vincent Delbar on 2023-02-03T10:59:28 (imported from GitLab)
Edited by Cresson Remi - Author Owner
aah sorry
yes, ok!
By Rémi Cresson on 2023-02-03T11:00:21 (imported from GitLab)
- Author Owner
It should work perfectly, can you confirm no OTB param key containing "_" exists ? I believe it is always single word, or separated with a dot.
By Vincent Delbar on 2023-02-03T11:01:48 (imported from GitLab)
- Author Owner
yes, I confirm you can't use "_" char in parameters names in OTB Applications!
By Rémi Cresson on 2023-02-03T11:03:33 (imported from GitLab)
1 - Author Owner
I'll see which is best : may be it's better to do it either in
save_objects
or__set_param
, anyway it must also appear in App.parameters, so during init would be more appropriate.By Vincent Delbar on 2023-02-05T15:49:26 (imported from GitLab)
Edited by Cresson Remi - Cresson Remi created branch
65-accept-any-parameter-as-kwarg-even-if-it-contains-dots
to address this issuecreated branch
65-accept-any-parameter-as-kwarg-even-if-it-contains-dots
to address this issueBy Vincent Delbar on 2023-05-24T08:37:18 (imported from GitLab)
- Cresson Remi changed title from Accept any parameter as kwarg, even if it contains dots to Allow OTB dotted parameters in kwargs
changed title from Accept any parameter as kwarg, even if it contains dots to Allow OTB dotted parameters in kwargs
By Vincent Delbar on 2023-05-24T08:39:40 (imported from GitLab)
- Cresson Remi created branch
65-allow-otb-dotted-parameters-in-kwargs
to address this issuecreated branch
65-allow-otb-dotted-parameters-in-kwargs
to address this issueBy Vincent Delbar on 2023-05-24T08:40:15 (imported from GitLab)