gigl.common.omegaconf_resolvers#
OmegaConf custom resolvers for GiGL.
This module contains custom OmegaConf resolvers that can be used in YAML configuration files to provide dynamic values during configuration loading.
Attributes#
Functions#
| Resolver that returns the current git hash. | |
| 
 | Resolver that creates a string representing the current time (with optional offset) using strftime. | 
| Register all custom OmegaConf resolvers. | 
Module Contents#
- gigl.common.omegaconf_resolvers.git_hash_resolver()[source]#
- Resolver that returns the current git hash. - This resolver returns the current git hash if one is available. Takes no arguments and returns the git hash as a string. - Returns:
- Current git hash as a string, or empty string if not available. 
- Return type:
- str 
 - Example - In YAML config: - `yaml model_version: "model_${git_hash}" experiment_id: "exp_${git_hash}_${now:%Y%m%d}" `
- gigl.common.omegaconf_resolvers.now_resolver(*args)[source]#
- Resolver that creates a string representing the current time (with optional offset) using strftime. - This resolver supports both time formatting and time offsets with explicit named parameters that are compatible with OmegaConf’s resolver parameter limitations. - Parameters:
- *args (str) – - Variable arguments where: - First argument (optional): datetime.datetime compatible strftime format string. - If not provided, defaults to “%Y%m%d_%H%M%S” - Subsequent arguments: datetime.timedelta compatible time offset specifications in format “unit±value” where:
- unit can be: days, seconds, minutes, hours, weeks 
- ± can be + or - (+ can be omitted for positive values) 
- Examples: “days+1”, “hours-2”, “minutes30”, “seconds-15” 
 
 
 
- Returns:
- Current time (with optional offset) formatted as a string. 
- Return type:
- str 
 - Example - In YAML config: ```yaml name: “exp_${now:%Y%m%d_%H%M%S}” start_time: “${now:%Y-%m-%d %H:%M:%S}” log_file: “logs/run_${now:%H-%M-%S}.log” timestamp: “${now:}” # Uses default format short_date: “${now:%m-%d}” - tomorrow: “${now:%Y-%m-%d, days+1}” yesterday: “${now:%Y-%m-%d, days-1}” tomorrow_plus_5_hours_30_min_15_sec: “${now:%Y-%m-%d %H:%M:%S,hours+5,days+1,minutes+30,seconds+15}” next_week: “${now:%Y-%m-%d, weeks+1}” multiple_args: “${now:%Y%m%d, days-15}:${now:%Y%m%d, days-1}” - This would resolve to something like: ```yaml name: “exp_20231215_143022” start_time: “2023-12-15 14:30:22” log_file: “logs/run_14-30-22.log” timestamp: “20231215_143022” short_date: “12-15” - tomorrow: “2023-12-16” yesterday: “2023-12-14” tomorrow_plus_5_hours_30_min_15_sec: “2023-12-16 20:00:37” next_week: “2023-12-22” multiple_args: “20231201:20231214” ``` 
