Check the list of schemas are the same on the given keys.
(schemas, keys, name)
| 213 | |
| 214 | |
| 215 | def check_all_same_schema_for_keys(schemas, keys, name): |
| 216 | """Check the list of schemas are the same on the given keys.""" |
| 217 | if len(schemas) == 0: |
| 218 | return |
| 219 | |
| 220 | head = None |
| 221 | keys = set(keys) |
| 222 | for i, schema in enumerate(schemas): |
| 223 | if not keys.issubset(schema.keys()): |
| 224 | raise DGLError( |
| 225 | "Expect all graphs to have keys {} on {}, " |
| 226 | "but graph {} got keys {}.".format(keys, name, i, schema.keys()) |
| 227 | ) |
| 228 | |
| 229 | if head is None: |
| 230 | head = {k: schema[k] for k in keys} |
| 231 | else: |
| 232 | target = {k: schema[k] for k in keys} |
| 233 | if target != head: |
| 234 | raise DGLError( |
| 235 | "Expect all graphs to have the same schema for keys {} on {}, " |
| 236 | "but graph {} got \n\t{}\n which is different from\n\t{}.".format( |
| 237 | keys, name, i, target, head |
| 238 | ) |
| 239 | ) |
| 240 | |
| 241 | |
| 242 | def check_valid_idtype(idtype): |