Skip to content

Commit 1a8c661

Browse files
committed
Add package-level set_error_handling() to fairgraph.openminds
1 parent a0f78e4 commit 1a8c661

3 files changed

Lines changed: 23 additions & 13 deletions

File tree

builder/update_openminds.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,8 +943,13 @@ def main(openminds_root, ignore=[]):
943943
)
944944

945945
init_file_path = os.path.join("..", "fairgraph", "openminds", "__init__.py")
946+
sorted_modules = sorted(openminds_modules)
946947
with open(init_file_path, "w") as fp:
947-
fp.write(f"from . import ({', '.join(sorted(openminds_modules))})\n")
948+
fp.write(f"from . import ({', '.join(sorted_modules)})\n\n\n")
949+
fp.write("def set_error_handling(value):\n")
950+
fp.write(' """Set error handling for all openMINDS classes, across every submodule."""\n')
951+
fp.write(f" for module in ({', '.join(sorted_modules)}):\n")
952+
fp.write(" module.set_error_handling(value)\n")
948953

949954
# Format with Black
950955
subprocess.call([sys.executable, "-m", "black", "--quiet", target_path])

fairgraph/__init__.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,4 @@
4747

4848
def set_error_handling(value):
4949
"""Set error handling globally for all modules"""
50-
for module in (
51-
openminds.chemicals,
52-
openminds.computation,
53-
openminds.controlled_terms,
54-
openminds.core,
55-
openminds.ephys,
56-
openminds.publications,
57-
openminds.sands,
58-
openminds.specimen_prep,
59-
openminds.stimulation,
60-
):
61-
module.set_error_handling(value)
50+
openminds.set_error_handling(value)

fairgraph/openminds/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
11
from . import chemicals, computation, controlled_terms, core, ephys, publications, sands, specimen_prep, stimulation
2+
3+
4+
def set_error_handling(value):
5+
"""Set error handling for all openMINDS classes, across every submodule."""
6+
for module in (
7+
chemicals,
8+
computation,
9+
controlled_terms,
10+
core,
11+
ephys,
12+
publications,
13+
sands,
14+
specimen_prep,
15+
stimulation,
16+
):
17+
module.set_error_handling(value)

0 commit comments

Comments
 (0)