You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary:
Lets allow aliases for a runopt. This will give downstream users to have multiple ways of accessing the same runopt.
1. Modify add() to accept this and add a new optional aliases List[str] that will store this.
2. Modify resolve() to check if a different alias is already used in cfg i.e if the "run_as" and "Run_As" are aliases for the same one, we dont allow for both to be present in the cfg.
Differential Revision: D84157870
Returns the primary key and aliases for the given cfg_key.
1180
+
"""
1181
+
ifisinstance(cfg_key, str):
1182
+
returncfg_key, []
1183
+
1184
+
iflen(cfg_key) ==0:
1185
+
raiseValueError("cfg_key must be a non-empty list")
1186
+
primary_key=None
1187
+
aliases=list[RunOptAlias]()
1188
+
fornameincfg_key:
1189
+
ifisinstance(name, RunOptAlias):
1190
+
aliases.append(name)
1191
+
else:
1192
+
ifprimary_keyisnotNone:
1193
+
raiseValueError(
1194
+
f"cfg_key must contain a single primary key. Given more than one primary keys: {primary_key}, {name}. If one of them is an alias please use RunOptAlias type instead of str. "
1195
+
)
1196
+
primary_key=name
1197
+
ifprimary_keyisNoneorprimary_key=="":
1198
+
raiseValueError(
1199
+
"Missing cfg_key. Please provide one other than the aliases."
1200
+
)
1201
+
returnprimary_key, aliases
1202
+
1146
1203
defadd(
1147
1204
self,
1148
-
cfg_key: str,
1205
+
cfg_key: str|list[str],
1149
1206
type_: Type[CfgVal],
1150
1207
help: str,
1151
1208
default: CfgVal=None,
@@ -1156,6 +1213,7 @@ def add(
1156
1213
value (if any). If the ``default`` is not specified then this option
0 commit comments