orion
orion copied to clipboard
Support passing objects or callables to build_experiment in addition to strings/configurations
It would be nice to be able to pass objects to build_experiment rather than strings or dictionaries:
- it would make it a lot easier to create/debug new algorithms, since they wouldnt need to be registered and then created with the arguments.
- it would be a lot cleaner from an API standpoint to be able to pass a Space object directly, since you can tell programmatically what the different dimensions are (e.g. with code completion), but you have to go to the docs to know what strings to pass for the priors/dimension types.
- passing storage dict as
storage={"type": "legacy", ...
is unintuitive to me, personally. Would be a lot cleaner to pass juststorage=PickledDB("database.pkl")
Passing objects isnt necessarily always feasible (e.g. algorithms need to be instantiated on each worker, etc).
In such a case, we should allow passing the factory function, or type of object directly:
algorithm=MyAlgorithm,
, or algorithm=functools.partial(MyAlgorithm, my_arg=123)
To support this we'll need to make sure these objects have a configuration property that can be used to save them in DB, which is already available for most of them.
We could:
- run the callable, and then extract its configuration, or (perhaps better):
- Save the callable itself (pickled or otherwise) in the db?
I'd be in favor of first option, saving the configuration. It exposes the configuration in the DB so it is queryable and it simplifies the handling of the DB for backward compatibility.