Follow pureconfig not json load/loads #16
-
With load and loads, we can only load from string config or file config. However, if we have a config tree, we would have to call fromString
fromFile
fromConfig Why would we want a
In the above example, we wouldn't know or care about the dataclasses of the user so we couldn't build the nested dataclass config parsing. We would just want to call by key their tree and send it to their code for them to handle. In the orchestration code, we would read in the file config and then pass config trees to the user code. config = load()
framework = config[framework] # but want to parse this into a dataclass but we have a config tree
call_user_code(config[user_code_1]) # same idea here Or maybe just do load and loadOrThrow and behind the scenes we determine from string, from file, from config tree. https://pureconfig.github.io/docs/loading-a-config.html Here is an example from some pipeline code in Scala I have. I get the config from as key in the larger config from the framework and I parse a config object since it is no long a string or a file. object DeequDataFlow extends ConfigurableInstance {
case class RulesTable(query: String)
case class InstanceConfig(
inputSource: InputType,
metricsRepoPath: Option[String],
tags: Option[Map[String, String]],
checkLevel: String,
description: String,
dqQuery: RulesTable
)
override def createFromConfig(conf: Config): DeequDataFlow =
new DeequDataFlow(pureconfig.ConfigSource.fromConfig(conf).loadOrThrow[InstanceConfig])
} @zifeo thoughts? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 9 replies
-
@dwsmith1983 thanks for the proposal. The load/loads comes from usual json/parsing library in python. I would favour having a new a generic method |
Beta Was this translation helpful? Give feedback.
-
@zifeo how do you want to approach refactoring to allow for from |
Beta Was this translation helpful? Give feedback.
-
@zifeo can you create a dev branch I can have access to? This way we can collaborate on a branch without needing to PR to main and work out the code there. |
Beta Was this translation helpful? Give feedback.
-
@zifeo I created secondary methods for load and loads (from_file, from_string) and updated __parse to from_config and gave path="" as a default param to make usage easy; that is, the user can skip it when parsing a config. I added deprecation warnings for load and loads. How should we roll it out? In pieces or all at once?
Any thoughts of changes from the small changes so far? Do we need that path parameter in __parse (now from_config)? |
Beta Was this translation helpful? Give feedback.
-
@zifeo this should be done I believe with your update--at lest most of it. |
Beta Was this translation helpful? Give feedback.
@zifeo this should be done I believe with your update--at lest most of it.