Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Run build
- name: Install requirements
run: |
pip install -r requirements.txt

- name: Run build
run: |
python build.py

- name: Test built package
Expand Down
13 changes: 12 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import shutil
import subprocess
import sys
from time import perf_counter
from urllib.request import urlopen, HTTPError

from jinja2 import Environment, select_autoescape, FileSystemLoader
Expand All @@ -23,6 +24,8 @@
print(f"Triggering the generation of Python package for openMINDS, from the {args.branch} branch")
print("*******************************************************************************")

start_time = perf_counter()

# Step 0 - read code for additional methods
additional_methods = {}
with open("pipeline/src/additional_methods/by_name.py.txt") as fp:
Expand All @@ -35,6 +38,7 @@
instance_loader = InstanceLoader()
if os.path.exists("target"):
shutil.rmtree("target")
print(f"Cloned {args.branch} branch of central repository ({perf_counter() - start_time} s)")

# Step 2 - load instances
instances = {}
Expand All @@ -45,6 +49,7 @@
with open(instance_path) as fp:
instance_data = json.load(fp)
instances[version][instance_data["@type"]].append(instance_data)
print(f"Loaded instances ({perf_counter() - start_time} s)")

python_modules = defaultdict(list)

Expand Down Expand Up @@ -86,6 +91,9 @@
parent_path = ".".join(parts[:-1])
python_modules[parent_path].append((parts[-1], class_name))

print(f"Processed schemas ({perf_counter() - start_time} s)")


# Step 5 - create additional files, e.g. __init__.py
openminds_modules = defaultdict(set)
for path in sorted(python_modules):
Expand Down Expand Up @@ -151,5 +159,8 @@
with open("target/codemeta.json", "w") as fp:
json.dump(codemeta, fp, indent=2)

print(f"Generated additional files ({perf_counter() - start_time} s)")

# Step 6 - run formatter
subprocess.call([sys.executable, "-m", "black", "--quiet", "target"])
subprocess.call(["ruff", "format", "--quiet", "target"])
print(f"Formatted all files ({perf_counter() - start_time} s)")
4 changes: 2 additions & 2 deletions pipeline/src/pyproject_template.toml.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dev = [
"setuptools",
"wheel",
"sphinx",
"black",
"ruff",
"twine"
]

Expand All @@ -51,5 +51,5 @@ include = ["openminds*"]
]
build-backend = "setuptools.build_meta"

[tool.black]
[tool.ruff]
line-length = 119
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
gitpython
jinja2
black
ruff