MCPcopy Create free account
hub / github.com/pytorch/pytorch / run

Function run

scripts/release_notes/namespace_check.py:49–92  ·  view source on GitHub ↗
(args, submod)

Source from the content-addressed store, hash-verified

47
48
49def run(args, submod):
50 print(f"## Processing torch.{submod}")
51 prev_filename = f"prev_data_{submod}.json"
52 new_filename = f"new_data_{submod}.json"
53
54 if args.prev_version:
55 content = get_content(submod)
56 with open(prev_filename, "w") as f:
57 json.dump(content, f)
58 print("Data saved for previous version.")
59 elif args.new_version:
60 content = get_content(submod)
61 with open(new_filename, "w") as f:
62 json.dump(content, f)
63 print("Data saved for new version.")
64 else:
65 assert args.compare
66 if not path.exists(prev_filename):
67 raise RuntimeError("Previous version data not collected")
68
69 if not path.exists(new_filename):
70 raise RuntimeError("New version data not collected")
71
72 with open(prev_filename, "r") as f:
73 prev_content = set(json.load(f))
74
75 with open(new_filename, "r") as f:
76 new_content = set(json.load(f))
77
78 if not args.show_all:
79 prev_content = namespace_filter(prev_content)
80 new_content = namespace_filter(new_content)
81
82 if new_content == prev_content:
83 print("Nothing changed.")
84 print("")
85 else:
86 print("Things that were added:")
87 print(new_content - prev_content)
88 print("")
89
90 print("Things that were removed:")
91 print(prev_content - new_content)
92 print("")
93
94
95def main():

Callers 1

mainFunction · 0.70

Calls 4

get_contentFunction · 0.85
namespace_filterFunction · 0.85
dumpMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected