Using flag values as a resource definition

I have a few parameters to my training script that point to files, e.g. to a pretrained model for transfer learning. If I use a relative path, I need to include the file in my resources section of the guild.yml file, or if I use an absolute path things work, but since the file isn’t copied into the run directory, it’s not saved if I want to be able to reproduce an experiment later with the same inputs.

I’d be nice to be able to do something like:

test.py:

import argparse
from   os.path import exists

parser = argparse.ArgumentParser()
parser.add_argument('--resource', type=str)

if __name__ == '__main__':    
    args = parser.parse_args()

    if not exists(args.resource):
        raise FileNotFoundError()
    
    print('Success!')

guild.yml

test:
    main: test
    flags-import: all
    requires:
        - ${resource}

command:

guild run -y resource=data/resource.txt

But this doesn’t work (guild.util.UndefinedReferenceError: resource), and if it did, seems to have the problem that you need to somehow specify a target-path as well unless your flag specified file is in the same directory as the guildfile.

Am I missing a technique that solves this problem, or is it something for a feature request?

Thanks!

-Chris