gorlins / salted

A demo implementation of a "Salted Graph" workflow
Other
14 stars 10 forks source link

Version as a Parameter? #1

Open pford221 opened 5 years ago

pford221 commented 5 years ago

Hey,

Cool idea. I was wondering if you thought it made sense to change the dunder __version__ to a version parameter so that it can be passed in via the command line?

Also, I don't know if it's possible, but I would love to be able to produce a string representation of the code in task.run() such that a new salt is created if any of the code in the run method changes. Any ideas on that?

gorlins commented 5 years ago

re: version, i wouldn't remove the dunder so much as just use a parameter that impacts the ending salt. the __version__ is meant as a scorched-earth 'force everything to rerun'. Eg for a modeling task:

class Train(Task):
    PARAMS = {
        'exp_1': {'alpha': 0.1, ...},  # Do not change - create a new key for new results
    }

    model_params = Parameter(default='exp_1')

    def run(self):
        model = SomeModel(**self.PARAMS[self.model_params]).fit(data)
        ...

re: hashing run, it's a really neat idea that I suspect fails in practice. The run method itself can be very sensitive to non-meaningful changes like adding comments or logging. Additionally, the method itself will not necessarily know about meaningful changes in external code it calls. In the past, the closest I've come to automatically generating a meaningful 'signature' of a function is by passing a signatory input value to the function (eg an array from 0 to 10, or some example text) and hashing the result.