ipython / ipython/traitlets

Nested configurables

Đang mở
#421 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
653
Fork
217
Merge trung bình
2 ngày 21 giờ
Pull request đã merge (30 ngày)
2

Mô tả

We're looking to use traitlets to enforce type checking in the configuration of a coastal ocean model thetis (github.com/thetisproject/thetis).

Right now, we have a tree of configuration options. For example:
```
ModelOptions:
turbulence_model = "some_value"
turbulence_model_options = TurbulenceModelOptions
```

Right now, we just use nested dictionaries for this.

It seems like one would like to have a `Configurable` with traits that are themselves `Configurable` objects:

right now we use:

```python
class TurbulenceModelOptions(Configurable):
pass

class GLSOptions(TurbulenceModelOptions):
use_hyperviscosity = Bool()

class SmagorinskyOptions(TurbulenceModelOptions):
background_viscosity = Float()

class ModelOptions(Configurable):
turbulence_model = Enum(["gls", "smagorinsky"])
turbulence_model_options = Instance(TurbulenceModelOptions)
```

But generating (for example) rST doesn't recurse into the trait values, so the presentation of the options isn't right.

Are we doing this wrong? Is there some more obvious way of glueing together such a hierarchy?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.