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
Tickets/DM-16797 #72
Tickets/DM-16797 #72
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the decorator isn't doing what you want it to do; otherwise looks fine.
python/lsst/pipe/base/config.py
Outdated
optional=True, | ||
doc=("Templated name of string, used to set name " | ||
"field according to a shared substring at " | ||
"configuration time")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe change "configuration time" to "when formatTemplateNames
is called", to be a bit clearer.
python/lsst/pipe/base/config.py
Outdated
@@ -284,6 +295,15 @@ class ResourceConfig(pexConfig.Config): | |||
doc="Minimal number of cores needed by task.") | |||
|
|||
|
|||
def _templateNameStorageDecorator(func): | |||
storedParamsDict = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this variable ends up effectively being a class attribute, by virtue of being a local variable in a closure defined at class scope. I think what you want is a new instance attribute, which I think you can do by just dropping the decorator and doing something like the following in formatTemplateNames
directly:
if not hasattr(self, "_storedParamsDict"):
self._storedParamsDict = {}
self._storedParamsDict.update(templateParamsDict)
templateParamsDict.update(self._storedParamsDict)
A completely different (and possibly cleaner approach) would be to use Formatter.parse to skip substitution for fields that don't actually have the parameters given in a particular call.
python/lsst/pipe/base/config.py
Outdated
@@ -294,6 +314,12 @@ class PipelineTaskConfig(pexConfig.Config): | |||
quantum = pexConfig.ConfigField(dtype=QuantumConfig, | |||
doc="configuration for PipelineTask quantum") | |||
|
|||
@_templateNameStorageDecorator | |||
def formatTemplateNames(self, templateParamDict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend renaming this to substituteDatasetNames
for consistency with the command-line argument.
Add the ability to specify a templated string which may be used to format the name of PipelineTask Config fields.
8d788b1
to
bd0dee3
Compare
No description provided.