Mitchell
Mitchell

Reputation: 1

How to allow a user to specify behaviors in a config file?

For a Python program I'm writing, I am using TOML configuration files. Essentially, I want the user to be able to specify different options nested within a field with the least hassle and most flexibility for the user manually writing the TOML file. In nodes.toml, I have tables that each define a node of a DAG, and each node has a field for input variables. When the user first adds/defines a variable, they need to specify which of several different ways the variable should be loaded (including more options than are shown here):

[node_name]
other_attribute = "other_value" # just to show that there are other attributes in this table
inputs.var1 = "my_hard-coded_value" # hard-coded value (any type)
inputs.var2.__load__ = "path/to/var1.toml" # load a variable from toml
inputs.var3 = "custom.variable.loading.syntax" # treat strings with periods in its own way
inputs.var4 = "?" # treat this in its own way

I am wondering if this nested method is the right way to allow the user to specify which way the var1 input variable should be loaded? Meaning, is there a simpler, i.e. less nested, way to structure this config file?

I've tried structuring the toml as shown above, but the process of writing the attributes feels a bit cumbersome.

Upvotes: 0

Views: 11

Answers (0)

Related Questions