I’m working on creating API to allow scripts to add Policy to butler output repositories. (in DM-7777)
The ‘new’ butler API allows a repository-arguments structure to be passed to butler when loading input repositories and when creating output repositories. I’m thinking of adding a parameter to that structure that accepts a dict (or Butler.Policy instance, which extends dict) for that purpose. The new policy would get written into the repository, used while the repository is getting used as an output, and loaded when the repository is loaded as an input.
Setting the in-repository policy should only be allowed on output repositories (input repositories should not be modified, generally speaking).
The only API change would be adding a keyword to lsst.daf.persistence.RepositoryArgs:
class RepositoryArgs(object):
def __init__(..., policy=None):
...
so that then a policy can be created in a script e.g.:
newPolicy = {
'datasets': {
'testDataset': {
'python': 'lsst.daf.persistence.test.TestObject',
'template': 'basic/id%(id)s.pickle',
'storage': 'PickleStorage'
}
}
}
and passed to butler:
repoArgs = lsst.daf.persistence.RepositoryArgs(root='path/to/output/repo', policy=newPolicy)
butler = lsst.daf.persistence.butler(inputs='path/to/inputs', outputs=repoArgs)
People that are interested in adding policy to repositories - does this work for you? Do you have other ideas, or requirements that I’ve overlooked?