Changeset View
Changeset View
Standalone View
Standalone View
docs/content/concepts/solids-pipelines/composite-solids.mdx
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | |||||
### Configuration Mapping | ### Configuration Mapping | ||||
Composite solids can also define a config schema. When a composite solid defines a config schema, it must also define a `config_mapping_fn` to map the composite solids config to the wrapped solids' config. | Composite solids can also define a config schema. When a composite solid defines a config schema, it must also define a `config_mapping_fn` to map the composite solids config to the wrapped solids' config. | ||||
```python file=/concepts/solids_pipelines/composite_solids.py startafter=start_composite_mapping_marker endbefore=end_composite_mapping_marker | ```python file=/concepts/solids_pipelines/composite_solids.py startafter=start_composite_mapping_marker endbefore=end_composite_mapping_marker | ||||
def config_mapping_fn(config): | def config_mapping_fn(config): | ||||
x = config["x"] | x = config["x"] | ||||
return {"add_n": {"config": {"n": x}}, "multiply_by_m": {"config": {"m": x}}} | return { | ||||
"add_n": {"config": {"n": x}}, | |||||
"multiply_by_m": {"config": {"m": x}}, | |||||
} | |||||
@composite_solid( | @composite_solid( | ||||
config_fn=config_mapping_fn, | config_fn=config_mapping_fn, | ||||
config_schema={"x": int}, | config_schema={"x": int}, | ||||
input_defs=[InputDefinition("number", int)], | input_defs=[InputDefinition("number", int)], | ||||
) | ) | ||||
def add_x_multiply_by_x(number): | def add_x_multiply_by_x(number): | ||||
return multiply_by_m(add_n(number)) | return multiply_by_m(add_n(number)) | ||||
``` | ``` | ||||
In this example, the composite solid has only one field in the config schema: `x`. The config mapping function takes config provided to the composite solid and maps it to the wrapped solids. | In this example, the composite solid has only one field in the config schema: `x`. The config mapping function takes config provided to the composite solid and maps it to the wrapped solids. |