orion icon indicating copy to clipboard operation
orion copied to clipboard

Support passing objects or callables to build_experiment in addition to strings/configurations

Open lebrice opened this issue 2 years ago • 3 comments

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 just storage=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)

lebrice avatar Mar 24 '22 14:03 lebrice

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.

bouthilx avatar Mar 24 '22 14:03 bouthilx

We could:

  • run the callable, and then extract its configuration, or (perhaps better):
  • Save the callable itself (pickled or otherwise) in the db?

lebrice avatar Mar 24 '22 14:03 lebrice

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.

bouthilx avatar Mar 24 '22 16:03 bouthilx