Production request YAML format should limit request name length
The DB enforces a shorter limit on the request name than the production request YAML format does. This ends up resulting in an error like:
Execution failed.: ( 1406: Data too long for column 'RequestName' at row 1 ))"
(The rest is purely for my reference.)
This happened with some analyis productiosn which were fixed by applying this to the automatically generated name:
def commonprefix(m):
"Given a list of pathnames, returns the longest common leading component"
if not m: return ''
s1 = min(m)
s2 = max(m)
for i, c in enumerate(s1):
if c != s2[i]:
return s1[:i]
return s1
def transform(name):
a, b, c = name.split("#")
parts = c.split(", ")
prefix = commonprefix(parts)
c = [x[len(prefix):] for x in parts[:-1]]
c.append(parts[-1])
return"#".join([a, b, ", ".join(c)])
print(*[x["name"] for x in to_submit], sep="\n")
for xxx in to_submit:
xxx["name"] = transform(xxx["name"])