[Feature request] Allow `Scientist::Experiment` classes to *not* be default Scientist experiment class
- 主要语言
- Ruby
- 星标
- 7.8k
- 派生
- 505
- PR 合并指标
- 30 天内没有已合并 PR
描述
I'm wondering what the original inspiration for making any class that `include`s the module the default experiment, [code here](https://github.com/github/scientist/blob/303c1f4ff98786b702507ed0c4f8cfdeb5fc7138/lib/scientist/experiment.rb#L13). Is it possible to create a class that `include`s the `Scientist::Experiment` module and **not** make it the default scientist experiment?
Looking [here](https://github.com/github/scientist#making-science-useful) 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 via `Scientist::Experiment.set_default`. This `set_default` call is is skipped if you include `Scientist::Experiment` in a module.
The reason I ask is because recently we ran into an issue with our Rails app:
1. We had a class that was running `Scientist` via `include` `Scientist` with the default experiment, but was **not** publishing anything, *oops*.
2. We created a new class for that `include`d `Scientist::Experiment`, but since our tests don't eager load our classes, it was a flaky test and not surfaced during our build.
3. When running in production, we eager loaded and overrode the default experiment and then surfaced issues.
So a few questions I was wondering:
1. Why default experiment, this seems a little aggressive IMO?
2. Can we actually find a way to either make default the normal behavior and have a way to pass a flag to override it?
3. 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 🤔
4. 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.
贡献指南
调研方向
从 lib/scientist/experiment.rb 中链接的包含逻辑以及 README 的“Making science useful”部分开始。在定义期望的语义之前,先审查未解决的问题和当前的默认选择行为。完成的标准是:有一种经过协商并测试过的方法,可以避免被包含的 experiment 类成为默认类,并更新所有需要的文档。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- ruby
- 领域
- backend
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100