Hi folks, I’d like to share some configuration acr...
# announcements
b
Hi folks, I’d like to share some configuration across a handful of solids. What’s the best way to do this? Conceptually, creating a new resource would fit; however, it seems a bit like overkill to me, since the desired configuration is very simple (a list of integer IDs).
s
i've just put the shared config schema dictionary in a top-level constant and referenced it in the definition of each solid
b
Thanks, Steve - Do you still have to specify the config values in multiple places in the YAML with this approach?
s
you can extend it with additional values for each one with the splat operator, e.g.
Copy code
SHARED_SCHEMA = {
  'foo': StringSource,
}

@solid(config_schema={
  **SHARED_SCHEMA,
  'bar': IntSource,
})
def foobar(self): ...
unfortunately, yes, i don't know of any way to avoid needing to repeat the values in the run config
b
Thanks, Steve. Avoiding duplicating the values in the run config is what I’d like to avoid if possible. Since it could lead to some unexpected edge-cases and errors. Perhaps creating a resource or config-loader solid is the simplest approach here 😕
s
Hey @Ben Torvaney - I believe that creating a resource is best approach for what you're trying to do. Do you have an idea in mind of what it would look like to make this simpler?
b
Thanks, Sandy. I don’t really have a clear idea, no. One option could be to enable application of config to multiple solids:
Copy code
solids:
  # ...:
  custom:
    solids:
      - my_solid_a
      - my_solid_n
    config:
      some_config_ids:
        - 12
        - 90
        - 42
But I have to say, I’m not convinced this is a great idea… My hesitance towards resources is that it has additional flexibility that I don’t think would ever be used. Perhaps that’s more of an aesthetic concern than a practical or conceptual one?
c
I had to do something similar, the most straightforward solution i could find was a resource that returned a class/dataclass containing the “global” config values
1
m
there is also
configured
, if these values rarely change
s
yeah, for static values loaded from environment variables i've been using
configured