[Feature request] Allow Scientist::Experiment
classes to *not* be default Scientist experiment class #162
Description
I'm wondering what the original inspiration for making any class that include
s the module the default experiment, code here. Is it possible to create a class that include
s the Scientist::Experiment
module and not make it the default scientist experiment?
Looking here it doesn't seem like it is possible.
From docs as well:
When
Scientist::Experiment
is included in a class, it automatically sets it as the default implementation viaScientist::Experiment.set_default
. Thisset_default
call is is skipped if you includeScientist::Experiment
in a module.
The reason I ask is because recently we ran into an issue with our Rails app:
- We had a class that was running
Scientist
viainclude
Scientist
with the default experiment, but was not publishing anything, oops. - We created a new class for that
include
dScientist::Experiment
, but since our tests don't eager load our classes, it was a flaky test and not surfaced during our build. - When running in production, we eager loaded and overrode the default experiment and then surfaced issues.
So a few questions I was wondering:
- Why default experiment, this seems a little aggressive IMO?
- Can we actually find a way to either make default the normal behavior and have a way to pass a flag to override it?
- Or is it that the way we were using it was wrong, and that the intention is to actually just
include Scientist
and override the default methods for that class? If so, the only reason I held back from doing so is better separation of responsibilities. It was going to look a bit messy to clog up one class's specs with experiment specs and I'd rather separate the two easily 🤔 - Relating to point 3, is it the case that by the current implementation we can't be running multiple experiments at once?
I looked into it a bit myself, but it doesn't seem like there is a reasonably clean way. Although I think we can add a class method (something like):
class Foo
include Scientist::Experiment
default_scientist_experiment(false) # new
end
What do y'all think? If so - I can try to take a stab at it.