Closed MikeDacre closed 7 years ago
This can be done with a three layer decorator:
>>> class Job:
...
... def __init__(self, command, args, kwds, profile):
... self.command = command
... self.args = args
... self.kwds = kwds
... self.profile = profile
...
... def submit(self):
... self.command(*self.args, **self.kwds)
...
... def __repr__(self):
... return "Im a Job, and my name is {0}".format(self.profile)
...
>>> def make_job(profile=None):
... def deco(func):
... def wrapper(*args, **kwds):
... job = Job(func, args, kwds, profile)
... return job
... return wrapper
... return deco
...
>>> @make_job(profile='bob')
... def hi(instr):
... print('Hi {0}!'.format(instr))
...
>>> j = hi('vincent')
>>> j
Im a Job, and my name is bob
>>> j.submit()
Hi vincent!
This will allow people to make any random function a job.
Now implemented and functional in 0.6.2
Closing as done in 0.6.2
I want folks to be able to add a simple decorator to a function to make it submit to the cluster when called.