Spaces:
Running
Running
Update networkx_ops to new API.
Browse files- server/main.py +1 -1
- server/networkx_ops.py +10 -3
server/main.py
CHANGED
@@ -6,7 +6,7 @@ from . import workspace
|
|
6 |
# Which boxes are available is currently configured here.
|
7 |
# This is not the final solution.
|
8 |
from . import lynxkite_ops
|
9 |
-
|
10 |
# from . import pytorch_model_ops
|
11 |
from . import lynxscribe_ops
|
12 |
from . import llm_ops
|
|
|
6 |
# Which boxes are available is currently configured here.
|
7 |
# This is not the final solution.
|
8 |
from . import lynxkite_ops
|
9 |
+
from . import networkx_ops
|
10 |
# from . import pytorch_model_ops
|
11 |
from . import lynxscribe_ops
|
12 |
from . import llm_ops
|
server/networkx_ops.py
CHANGED
@@ -25,7 +25,7 @@ def register_networkx(env: str):
|
|
25 |
for (name, func) in nx.__dict__.items():
|
26 |
if hasattr(func, 'graphs'):
|
27 |
sig = inspect.signature(func)
|
28 |
-
inputs = {k: nx.Graph for k in func.graphs}
|
29 |
params = {
|
30 |
name: ops.Parameter.basic(
|
31 |
name, str(param.default)
|
@@ -33,14 +33,21 @@ def register_networkx(env: str):
|
|
33 |
else None,
|
34 |
param.annotation)
|
35 |
for name, param in sig.parameters.items()
|
36 |
-
if name not in ['G', 'backend', 'backend_kwargs']}
|
37 |
for p in params.values():
|
38 |
if not p.type:
|
39 |
# Guess the type based on the name.
|
40 |
if len(p.name) == 1:
|
41 |
p.type = int
|
42 |
name = "NX › " + name.replace('_', ' ').title()
|
43 |
-
op = ops.Op(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
ops.CATALOGS[env][name] = op
|
45 |
|
46 |
register_networkx('LynxKite')
|
|
|
25 |
for (name, func) in nx.__dict__.items():
|
26 |
if hasattr(func, 'graphs'):
|
27 |
sig = inspect.signature(func)
|
28 |
+
inputs = {k: ops.Input(name=k, type=nx.Graph) for k in func.graphs}
|
29 |
params = {
|
30 |
name: ops.Parameter.basic(
|
31 |
name, str(param.default)
|
|
|
33 |
else None,
|
34 |
param.annotation)
|
35 |
for name, param in sig.parameters.items()
|
36 |
+
if name not in ['G', 'backend', 'backend_kwargs', 'create_using']}
|
37 |
for p in params.values():
|
38 |
if not p.type:
|
39 |
# Guess the type based on the name.
|
40 |
if len(p.name) == 1:
|
41 |
p.type = int
|
42 |
name = "NX › " + name.replace('_', ' ').title()
|
43 |
+
op = ops.Op(
|
44 |
+
func=wrapped(name, func),
|
45 |
+
name=name,
|
46 |
+
params=params,
|
47 |
+
inputs=inputs,
|
48 |
+
outputs={'output': ops.Output(name='output', type=nx.Graph)},
|
49 |
+
type='basic',
|
50 |
+
)
|
51 |
ops.CATALOGS[env][name] = op
|
52 |
|
53 |
register_networkx('LynxKite')
|