The flexibility that can be seen below can be exploited on these contexts:
In [2]:
from fito import as_operation, SpecField, PrimitiveField, Operation
from time import sleep
class DatabaseConnection(Operation):
host = PrimitiveField(pos=0)
def __repr__(self): return "connection(db://{})".format(self.host)
@as_operation(database=SpecField, experiment_config=SpecField)
def run_experiment(database, experiment_config):
sleep(0.25)
@as_operation()
def experiment_1(alpha=0.5, beta=10):
return alpha + beta / 2
It's __repr__ is descent
In [4]:
run = run_experiment(DatabaseConnection('localhost'), experiment_1(alpha=10))
print run
Json serializable:
In [5]:
print run.json.dumps()
My beloved yaml-serializable
In [6]:
print run.yaml.dumps()
And of course, parseable :)
In [7]:
print Operation.from_yaml(run.yaml.dumps()).yaml.dumps()