Upload parsing_utils.py with huggingface_hub
Browse files- parsing_utils.py +6 -9
parsing_utils.py
CHANGED
|
@@ -209,23 +209,20 @@ def separate_inside_and_outside_square_brackets(s: str) -> Tuple[str, any]:
|
|
| 209 |
if start == -1 or end == -1 or start > end:
|
| 210 |
raise ValueError("Illegal structure: unmatched square brackets.")
|
| 211 |
|
| 212 |
-
after = s[end + 1 :]
|
| 213 |
-
|
| 214 |
-
# Check for text after the closing bracket
|
| 215 |
-
if len(after.strip()) != 0:
|
| 216 |
-
raise ValueError(
|
| 217 |
-
"Illegal structure: text follows after the closing square bracket."
|
| 218 |
-
)
|
| 219 |
-
|
| 220 |
instring = s.strip()
|
| 221 |
orig_instring = instring
|
| 222 |
if "[" not in instring:
|
| 223 |
# no alternative values to artifact: consider the whole input string as an artifact name
|
| 224 |
return (instring, None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
# parse to identify artifact name and alternative values to artifact's arguments
|
| 226 |
(query, instring) = consume_query(instring)
|
| 227 |
if len(instring) > 0:
|
| 228 |
raise ValueError(
|
| 229 |
-
f"malformed end of query: excessive text following the ] that closes the overwrites in: {orig_instring}"
|
| 230 |
)
|
| 231 |
return query
|
|
|
|
| 209 |
if start == -1 or end == -1 or start > end:
|
| 210 |
raise ValueError("Illegal structure: unmatched square brackets.")
|
| 211 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
instring = s.strip()
|
| 213 |
orig_instring = instring
|
| 214 |
if "[" not in instring:
|
| 215 |
# no alternative values to artifact: consider the whole input string as an artifact name
|
| 216 |
return (instring, None)
|
| 217 |
+
if ("=" in instring and instring.find("=") < instring.find("[")) or (
|
| 218 |
+
"," in instring and instring.find(",") < instring.find("[")
|
| 219 |
+
):
|
| 220 |
+
# this could also constitute just overwrites for recipe's args, as conceived by fetch_artifact
|
| 221 |
+
return (instring, None)
|
| 222 |
# parse to identify artifact name and alternative values to artifact's arguments
|
| 223 |
(query, instring) = consume_query(instring)
|
| 224 |
if len(instring) > 0:
|
| 225 |
raise ValueError(
|
| 226 |
+
f"malformed end of query: excessive text following the ] that closes the overwrites in: '{orig_instring}'"
|
| 227 |
)
|
| 228 |
return query
|