diff --git a/concore_cli/commands/validate.py b/concore_cli/commands/validate.py
index ffb6a89..2cbefc7 100644
--- a/concore_cli/commands/validate.py
+++ b/concore_cli/commands/validate.py
@@ -48,8 +48,6 @@ def _classify_message(message, bucket_name):
return {"error_type": "invalid_node_label_format"}
if message.startswith("Node '") and message.endswith("has invalid format"):
return {"error_type": "invalid_node_label_format"}
- if message.startswith("Node '") and message.endswith("has no filename"):
- return {"error_type": "missing_node_filename"}
if message.startswith("Node '") and message.endswith("has unusual file extension"):
return {"error_type": "unusual_file_extension"}
if message.startswith("Missing source file:"):
@@ -257,29 +255,39 @@ def finalize():
warnings.append(f"Node '{label}' has invalid format")
else:
nodeId_part, filename = parts
- source_nodes[filename] = node_id
- if not filename:
- errors.append(f"Node '{label}' has no filename")
- elif (
- exec_type in ("posix", "windows")
- and "." not in filename
- ):
- errors.append(
- f"Node '{label}' is a pulled container (no file "
- f"extension); pulled containers need --type docker, "
- f"not {exec_type}"
- )
- elif not any(
- filename.endswith(ext)
- for ext in [".py", ".cpp", ".m", ".v", ".java", ".jl"]
- ):
- warnings.append(
- f"Node '{label}' has unusual file extension"
- )
- elif source_root.exists():
- file_path = source_root / filename
- if not file_path.exists():
- errors.append(f"Missing source file: {filename}")
+ # A node with no filename ('IN:' / 'OUT:') is a
+ # port-only input/output source: nothing to check.
+ if filename:
+ source_nodes[filename] = node_id
+ if (
+ exec_type in ("posix", "windows")
+ and "." not in filename
+ ):
+ errors.append(
+ f"Node '{label}' is a pulled container (no file "
+ f"extension); pulled containers need --type docker, "
+ f"not {exec_type}"
+ )
+ elif not any(
+ filename.endswith(ext)
+ for ext in [
+ ".py",
+ ".cpp",
+ ".m",
+ ".v",
+ ".java",
+ ".jl",
+ ]
+ ):
+ warnings.append(
+ f"Node '{label}' has unusual file extension"
+ )
+ elif source_root.exists():
+ file_path = source_root / filename
+ if not file_path.exists():
+ errors.append(
+ f"Missing source file: {filename}"
+ )
else:
warnings.append(f"Node {node_id} has no label")
except Exception as e:
diff --git a/mkconcore.py b/mkconcore.py
index a1014d2..5804f77 100644
--- a/mkconcore.py
+++ b/mkconcore.py
@@ -359,7 +359,9 @@ def cleanup_script_files():
if ':' in node_label:
container_part, source_part = node_label.split(':', 1)
safe_name(container_part, f"Node container name '{container_part}'")
- source_part = safe_relpath(source_part, f"Node source file '{source_part}'")
+ # A node may have no source file (port endpoints such as 'IN:' / 'OUT:').
+ if source_part:
+ source_part = safe_relpath(source_part, f"Node source file '{source_part}'")
node_label = f"{container_part}:{source_part}"
else:
safe_name(node_label, f"Node label '{node_label}'")
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 32d55f4..68122f0 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -1145,16 +1145,22 @@ def test_validate_and_inspect_julia_node(self):
(src_dir / "ctrl.jl").write_text("# julia controller")
# validate passes with no unusual file extension warning
- val_res = self.runner.invoke(cli, ["validate", "workflow.graphml", "--format", "json"])
+ val_res = self.runner.invoke(
+ cli, ["validate", "workflow.graphml", "--format", "json"]
+ )
self.assertEqual(val_res.exit_code, 0)
val_payload = json.loads(val_res.output)
self.assertTrue(val_payload["valid"])
self.assertEqual(val_payload["summary"]["error_count"], 0)
warning_messages = [w["message"] for w in val_payload["warnings"]]
- self.assertFalse(any("unusual file extension" in m for m in warning_messages))
+ self.assertFalse(
+ any("unusual file extension" in m for m in warning_messages)
+ )
# inspect reports Julia language
- insp_res = self.runner.invoke(cli, ["inspect", "workflow.graphml", "--json"])
+ insp_res = self.runner.invoke(
+ cli, ["inspect", "workflow.graphml", "--json"]
+ )
self.assertEqual(insp_res.exit_code, 0)
insp_payload = json.loads(insp_res.output)
self.assertEqual(insp_payload["nodes"]["by_language"].get("julia"), 1)
diff --git a/tests/test_graph.py b/tests/test_graph.py
index b26859c..581ff64 100644
--- a/tests/test_graph.py
+++ b/tests/test_graph.py
@@ -96,22 +96,28 @@ def test_validate_broken_edges(self):
self.assertIn("Validation failed", result.output)
self.assertIn("Edge references non-existent target node", result.output)
- def test_validate_node_missing_filename(self):
+ def test_validate_port_only_node_is_valid(self):
content = """
- n0:
+ IN:
+
+ OUT:
+
+
+ 0x1000_a
+
"""
- filepath = self.create_graph_file("bad_node.graphml", content)
+ filepath = self.create_graph_file("port_only.graphml", content)
result = self.runner.invoke(cli, ["validate", filepath])
- self.assertIn("Validation failed", result.output)
- self.assertIn("has no filename", result.output)
+ self.assertNotIn("has no filename", result.output)
+ self.assertNotIn("Validation failed", result.output)
def test_validate_unsafe_node_label(self):
content = """
diff --git a/tests/test_port_only_nodes.py b/tests/test_port_only_nodes.py
new file mode 100644
index 0000000..5d13fe5
--- /dev/null
+++ b/tests/test_port_only_nodes.py
@@ -0,0 +1,70 @@
+"""Nodes with no source file ("IN:", "OUT:") must not stop a study from building.
+
+Port-only nodes are used by the distributed / ZMQ and measurement workflows
+in this repository. mkconcore.py used to reject them while validating node
+labels ("Node source file '' cannot be empty"), although the rest of the
+generator handles a node without a source file.
+"""
+
+import re
+import subprocess
+import sys
+from pathlib import Path
+
+import pytest
+
+REPO_ROOT = Path(__file__).resolve().parent.parent
+LABEL_RE = re.compile(r"]*>([^<]*)")
+
+
+def _has_port_only_node(graphml):
+ text = graphml.read_text(errors="ignore")
+ for label in LABEL_RE.findall(text):
+ label = re.sub(r"\s+", " ", label)
+ if ":" in label and not label.split(":", 1)[1].strip():
+ return True
+ return False
+
+
+PORT_ONLY_WORKFLOWS = sorted(
+ p for p in REPO_ROOT.rglob("*.graphml") if _has_port_only_node(p)
+)
+
+
+def test_port_only_workflows_were_found():
+ assert PORT_ONLY_WORKFLOWS, "no workflow with a port-only node found"
+
+
+@pytest.mark.parametrize("build_type", ["posix", "windows", "docker"])
+@pytest.mark.parametrize(
+ "workflow",
+ PORT_ONLY_WORKFLOWS,
+ ids=[str(p.relative_to(REPO_ROOT)) for p in PORT_ONLY_WORKFLOWS],
+)
+def test_workflow_with_port_only_node_builds(tmp_path, workflow, build_type):
+ # mkconcore refuses nodes whose source file is missing, and not every
+ # bundled workflow ships its node scripts, so give each node an empty file.
+ src = tmp_path / "src"
+ src.mkdir()
+ for label in LABEL_RE.findall(workflow.read_text(errors="ignore")):
+ label = re.sub(r"\s+", " ", label)
+ if ":" in label:
+ name = label.split(":", 1)[1].strip()
+ if name:
+ (src / name).parent.mkdir(parents=True, exist_ok=True)
+ (src / name).write_text("")
+ result = subprocess.run(
+ [
+ sys.executable,
+ str(REPO_ROOT / "mkconcore.py"),
+ str(workflow),
+ str(src),
+ str(tmp_path / "study"),
+ build_type,
+ ],
+ capture_output=True,
+ text=True,
+ cwd=str(REPO_ROOT),
+ timeout=120,
+ )
+ assert result.returncode == 0, result.stdout + result.stderr