mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[export] Add test to enforce consistency between synced thrift and generated thrift from schema.py (#141989)
Summary: In this diff we implement a way to ensure the internal thrift schema from cfgr (configerator/structs/caffe2/torch/export/schema.thrift) and the schema in OSS (torch/_export/serde/schema.thrift) are in sync, by adding a unittest to reflect on the type names and fields from each schema and compare them field by field. When we detect new fields/types from torch/_export/serde/schema.thrift, there'll be a test failure on the trunk and the error message hints people to add the missing field/type to the thrift schema from cfgr, so that they are always in sync in practice. Test Plan: buck test mode/opt caffe2/test:test_export -- -r test_thrift_schema_in_sync Differential Revision: D66716834 Pull Request resolved: https://github.com/pytorch/pytorch/pull/141989 Approved by: https://github.com/yiming0416
This commit is contained in:
committed by
PyTorch MergeBot
parent
bab15df40a
commit
1a7da6e7e9
@ -58,7 +58,7 @@ if __name__ == "__main__":
|
||||
first_line = (
|
||||
"@" + "generated by " + os.path.basename(__file__).rsplit(".", 1)[0] + ".py"
|
||||
)
|
||||
checksum = f"checksum<<{commit.checksum_result}>>"
|
||||
checksum = f"checksum<<{commit.checksum_next}>>"
|
||||
yaml_header = "# " + first_line
|
||||
yaml_header += "\n# " + checksum
|
||||
yaml_payload = dump(commit.result, Dumper=Dumper, sort_keys=False)
|
||||
@ -73,7 +73,7 @@ if __name__ == "__main__":
|
||||
yaml_content = yaml_header + "\n" + yaml_payload
|
||||
|
||||
thrift_schema = "// " + first_line
|
||||
thrift_schema += "\n// " + checksum
|
||||
thrift_schema += f"\n// checksum<<{commit.thrift_checksum_next}>>"
|
||||
thrift_schema += "\n" + commit.thrift_schema
|
||||
|
||||
if args.dry_run:
|
||||
|
Reference in New Issue
Block a user