Basic Usage
While the primary use case for nshconfig
is in machine learning projects, it can be used in any Python project where you need to store configurations in a fully typed manner.
Here’s a basic example:
import nshconfig as C
class MyConfig(C.Config):
field1: int
field2: str
field3: C.AllowMissing[float] = C.MISSING
config = MyConfig.draft()
config.field1 = 42
config.field2 = "hello"
final_config = config.finalize()
print(final_config)
This example demonstrates:
Creating a configuration class
Using draft mode for configuration creation
Setting configuration values
Finalizing the configuration
For more advanced features, check out the Features section.