@@ -12,23 +12,25 @@ automatic file I/O by extension.
1212
1313.. code-block :: python
1414
15+ import importlib.resources as r
1516 from versioning import Config
1617
17- cfg = Config(" project_config.yaml" )
18+ # Load the bundled example config
19+ path = str (r.files(" versioning" ) / " data" / " example_config.yaml" )
20+ cfg = Config(path)
1821
19- # Retrieve settings
20- cfg.get(" project_name" )
22+ # Retrieve settings (top-level and nested)
23+ cfg.get(" a" ) # 'foo'
24+ cfg.get(" group_c" , " e" ) # False
2125
22- # Build paths (versioned or not)
23- cfg.get_dir_path(" results" ) # ~/data/results/v1
24- cfg.get_file_path(" raw" , " input" ) # ~/data/raw/records.csv
26+ # Build paths (versioned and non-versioned directories)
27+ cfg.get_dir_path(" raw_data" ) # PosixPath('.../raw_data')
28+ cfg.get_dir_path(" prepared_data" ) # PosixPath('.../prepared_data/v1')
29+ cfg.get_file_path(" raw_data" , " a" ) # PosixPath('.../raw_data/example_input_file.csv')
2530
26- # Read and write by extension
27- df = cfg.read(" raw" , " input" )
28- cfg.write(df.head(10 ), " results" , " output" )
29-
30- # Override the version at runtime
31- cfg_v2 = Config(" project_config.yaml" , versions = {" results" : " v2" })
31+ # Override the version at runtime — all path lookups update automatically
32+ cfg_v2 = Config(path, versions = {" prepared_data" : " v2" })
33+ cfg_v2.get_dir_path(" prepared_data" ) # PosixPath('.../prepared_data/v2')
3234
3335 .. toctree ::
3436 :maxdepth: 1
0 commit comments