diff --git a/concore_cli/README.md b/concore_cli/README.md
index 78f98b1..96825f2 100644
--- a/concore_cli/README.md
+++ b/concore_cli/README.md
@@ -83,6 +83,7 @@ Validates a GraphML workflow file before running.
**Options:**
- `-s, --source
` - Source directory to verify file references exist
+- `-t, --type ` - Also check the workflow can be built for this execution type (`windows`, `posix` or `docker`). Pulled containers (a node label with no file extension, such as `CZ:cpymat`) are only valid with `docker`
Checks:
- Valid XML structure
diff --git a/concore_cli/cli.py b/concore_cli/cli.py
index dc8fca3..a916c0b 100644
--- a/concore_cli/cli.py
+++ b/concore_cli/cli.py
@@ -111,7 +111,15 @@ def build(workflow_file, source, output, type, auto_build, compose, zmq):
type=click.Choice(["text", "json"]),
help="Validation output format",
)
-def validate(workflow_file, source, output_format):
+@click.option(
+ "--type",
+ "-t",
+ "exec_type",
+ default=None,
+ type=click.Choice(["windows", "posix", "docker"]),
+ help="Also check the workflow can be built for this execution type",
+)
+def validate(workflow_file, source, output_format, exec_type):
"""Validate a workflow file"""
try:
ok = validate_workflow(
@@ -119,6 +127,7 @@ def validate(workflow_file, source, output_format):
source,
console,
output_format=output_format,
+ exec_type=exec_type,
)
if not ok:
sys.exit(1)
diff --git a/concore_cli/commands/validate.py b/concore_cli/commands/validate.py
index c8972d7..0268757 100644
--- a/concore_cli/commands/validate.py
+++ b/concore_cli/commands/validate.py
@@ -132,7 +132,9 @@ def _build_payload(workflow_path, source_root, errors, warnings, info, source_no
}
-def validate_workflow(workflow_file, source_dir, console, output_format="text"):
+def validate_workflow(
+ workflow_file, source_dir, console, output_format="text", exec_type=None
+):
workflow_path = Path(workflow_file)
source_root = resolve_source_dir(workflow_path, source_dir)
@@ -256,6 +258,15 @@ def finalize():
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"]
diff --git a/tests/test_validate_exec_type.py b/tests/test_validate_exec_type.py
new file mode 100644
index 0000000..d6c7be5
--- /dev/null
+++ b/tests/test_validate_exec_type.py
@@ -0,0 +1,48 @@
+import pytest
+from click.testing import CliRunner
+
+from concore_cli.cli import cli
+
+GRAPH = """
+
+
+ CZ:{first}
+ PZ:pm.py
+
+
+"""
+
+
+def _validate(tmp_path, first, *extra):
+ src = tmp_path / "src"
+ src.mkdir(exist_ok=True)
+ (src / "pm.py").write_text("x\n")
+ if "." in first:
+ (src / first).write_text("x\n")
+ wf = tmp_path / "wf.graphml"
+ wf.write_text(GRAPH.format(first=first), encoding="utf-8")
+ return CliRunner().invoke(cli, ["validate", str(wf), "--source", str(src), *extra])
+
+
+@pytest.mark.parametrize("exec_type", ["posix", "windows"])
+def test_pulled_container_is_an_error_for_posix_and_windows(tmp_path, exec_type):
+ result = _validate(tmp_path, "cpymat", "--type", exec_type)
+ assert result.exit_code == 1
+ assert "pulled container" in result.output
+ assert f"not {exec_type}" in result.output
+
+
+def test_pulled_container_is_fine_for_docker(tmp_path):
+ result = _validate(tmp_path, "cpymat", "--type", "docker")
+ assert "pulled container" not in result.output
+
+
+def test_without_type_nothing_changes(tmp_path):
+ result = _validate(tmp_path, "cpymat")
+ assert "pulled container" not in result.output
+
+
+def test_regular_source_files_pass_with_a_type(tmp_path):
+ result = _validate(tmp_path, "controller.py", "--type", "posix")
+ assert result.exit_code == 0, result.output
+ assert "pulled container" not in result.output