|
5 | 5 | import shutil |
6 | 6 | import subprocess |
7 | 7 | import sys |
| 8 | +from time import perf_counter |
8 | 9 | from urllib.request import urlopen, HTTPError |
9 | 10 |
|
10 | 11 | from jinja2 import Environment, select_autoescape, FileSystemLoader |
|
23 | 24 | print(f"Triggering the generation of Python package for openMINDS, from the {args.branch} branch") |
24 | 25 | print("*******************************************************************************") |
25 | 26 |
|
| 27 | +start_time = perf_counter() |
| 28 | + |
26 | 29 | # Step 0 - read code for additional methods |
27 | 30 | additional_methods = {} |
28 | 31 | with open("pipeline/src/additional_methods/by_name.py.txt") as fp: |
|
35 | 38 | instance_loader = InstanceLoader() |
36 | 39 | if os.path.exists("target"): |
37 | 40 | shutil.rmtree("target") |
| 41 | +print(f"Cloned {args.branch} branch of central repository ({perf_counter() - start_time} s)") |
38 | 42 |
|
39 | 43 | # Step 2 - load instances |
40 | 44 | instances = {} |
|
45 | 49 | with open(instance_path) as fp: |
46 | 50 | instance_data = json.load(fp) |
47 | 51 | instances[version][instance_data["@type"]].append(instance_data) |
| 52 | +print(f"Loaded instances ({perf_counter() - start_time} s)") |
48 | 53 |
|
49 | 54 | python_modules = defaultdict(list) |
50 | 55 |
|
|
86 | 91 | parent_path = ".".join(parts[:-1]) |
87 | 92 | python_modules[parent_path].append((parts[-1], class_name)) |
88 | 93 |
|
| 94 | +print(f"Processed schemas ({perf_counter() - start_time} s)") |
| 95 | + |
| 96 | + |
89 | 97 | # Step 5 - create additional files, e.g. __init__.py |
90 | 98 | openminds_modules = defaultdict(set) |
91 | 99 | for path in sorted(python_modules): |
|
151 | 159 | with open("target/codemeta.json", "w") as fp: |
152 | 160 | json.dump(codemeta, fp, indent=2) |
153 | 161 |
|
| 162 | +print(f"Generated additional files ({perf_counter() - start_time} s)") |
| 163 | + |
154 | 164 | # Step 6 - run formatter |
155 | | -subprocess.call([sys.executable, "-m", "black", "--quiet", "target"]) |
| 165 | +subprocess.call(["ruff", "format", "--quiet", "target"]) |
| 166 | +print(f"Formatted all files ({perf_counter() - start_time} s)") |
0 commit comments