Skip to content

Commit 759d523

Browse files
committed
Prevent ops gateway initialization on import
The SciJava Ops gateway should only be initialized if the ops_gateway.py file is run as a script. The module should be importable without creating the gateway.
1 parent bbedba2 commit 759d523

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

scijava-ops-tutorial/scripts/ops_gateway.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,5 @@ def _find_op_names(env: "scijava.OpEnvironment") -> set:
225225
"""
226226
return {str(name) for info in env.infos() for name in info.names()}
227227

228-
ops = init(endpoints)
228+
if __name__ == "__main__":
229+
ops = init(endpoints)

0 commit comments

Comments
 (0)