fermitools / declad

BSD 3-Clause "New" or "Revised" License
1 stars 2 forks source link

Plugin for path/template fields #16

Closed marcmengel closed 4 months ago

marcmengel commented 5 months ago

Currently the fields available for rel_path_pattern in the config are metadata fields and one or two custom values ('sha256hash', 'md5hash', 'scope' etc.) But sometimes the desired directory structure is more complicated, i.e. a certain component has one value for production users, but a different one for regular users; or there is a directory based on the month/day/year of the file creation date, phase of the moon, etc.

The idea here is to let folks add in their custom/experiment.py file a method that returns extra names and values that can be used in the rel_path_pattern; something like:

def rel_path_extras(metadata):
     return { 'fn.sum_a_b' : metadata['fn.a'] + metadata['fn.b'],  'NAME': metadata['name'].upper() }

Then they can use:

rel_path_pattern: "%(fn.sum_a_b)s/%(NAME)s"

This routine could be more complicated, look things up in external databases, etc. if needed.

marcmengel commented 4 months ago

This is now implemented in #22. One can add a method to their experiment/site-specific custom module to provide extra path template components, based on metadata, etc.

marcmengel commented 4 months ago

And in #27 , this now is usable for dataset name expansion as well