diff --git a/concore_cli/commands/build.py b/concore_cli/commands/build.py index 83c2056..86fe0bc 100644 --- a/concore_cli/commands/build.py +++ b/concore_cli/commands/build.py @@ -138,6 +138,7 @@ def _write_docker_compose(output_path, console, zmq_mode=False): compose_lines.append("volumes:") for v in sorted(named_volumes): compose_lines.append(f" {v}:") + compose_lines.append(f" name: {_yaml_quote(v)}") compose_lines.append("") compose_lines.append("networks:") diff --git a/concoredocker.py b/concoredocker.py index 7388f9a..47f52ca 100644 --- a/concoredocker.py +++ b/concoredocker.py @@ -36,7 +36,7 @@ simtime = 0 def _port_path(base, port_num): - return os.path.join(base, str(port_num)) + return base + str(port_num) concore_params_file = os.path.join(_port_path(inpath, 1), "concore.params") concore_maxtime_file = os.path.join(_port_path(inpath, 1), "concore.maxtime") diff --git a/demo/sampleJ.graphml b/demo/sampleJ.graphml new file mode 100644 index 0000000..27a89ae --- /dev/null +++ b/demo/sampleJ.graphml @@ -0,0 +1,53 @@ + + + + + + + + + + + + CZ:controller_jl.jl + + + + + + + + + + + PZ:pm.py + + + + + + + + + + CU + + + + + + + + + + + + PYM + + + + + + + + diff --git a/tests/test_compose_generation.py b/tests/test_compose_generation.py index ba57ce5..81ef087 100644 --- a/tests/test_compose_generation.py +++ b/tests/test_compose_generation.py @@ -27,6 +27,13 @@ def test_compose_has_network_section(tmp_path): assert "networks:" in content +def test_compose_preserves_named_volume(tmp_path): + (tmp_path / "run").write_text("docker run --name node1 -v CU:/out1 concore/py &") + path = _write_docker_compose(tmp_path, Console(quiet=True)) + content = path.read_text() + assert " CU:\n name: 'CU'" in content + + def test_compose_depends_on_second_service(tmp_path): _fake_run_script( tmp_path, diff --git a/tests/test_concoredocker.py b/tests/test_concoredocker.py index 2d8d8fa..15ff939 100644 --- a/tests/test_concoredocker.py +++ b/tests/test_concoredocker.py @@ -44,6 +44,14 @@ def test_returns_default_for_bad_syntax(self, temp_dir): assert result == "fallback" +class TestDockerPaths: + def test_port_path_matches_docker_mounts(self): + from concoredocker import _port_path + + assert _port_path("/in", 1) == "/in1" + assert _port_path("/out", 2) == "/out2" + + class TestUnchanged: def test_returns_true_when_unchanged(self): import concoredocker @@ -89,9 +97,10 @@ def test_writes_list_with_simtime(self, temp_dir): import concoredocker old_outpath = concoredocker.outpath - outdir = os.path.join(temp_dir, "1") + outpath = os.path.join(temp_dir, "out") + outdir = outpath + "1" os.makedirs(outdir) - concoredocker.outpath = temp_dir + concoredocker.outpath = outpath concoredocker.simtime = 5.0 concoredocker.write(1, "testfile", [1.0, 2.0], delta=0) @@ -105,9 +114,10 @@ def test_writes_with_delta(self, temp_dir): import concoredocker old_outpath = concoredocker.outpath - outdir = os.path.join(temp_dir, "1") + outpath = os.path.join(temp_dir, "out") + outdir = outpath + "1" os.makedirs(outdir) - concoredocker.outpath = temp_dir + concoredocker.outpath = outpath concoredocker.simtime = 10.0 concoredocker.write(1, "testfile", [3.0], delta=2) @@ -126,9 +136,10 @@ def test_reads_and_parses_data(self, temp_dir): old_inpath = concoredocker.inpath old_delay = concoredocker.delay - indir = os.path.join(temp_dir, "1") + inpath = os.path.join(temp_dir, "in") + indir = inpath + "1" os.makedirs(indir) - concoredocker.inpath = temp_dir + concoredocker.inpath = inpath concoredocker.delay = 0.001 with open(os.path.join(indir, "data"), "w") as f: @@ -149,9 +160,10 @@ def test_returns_default_when_file_missing(self, temp_dir): old_inpath = concoredocker.inpath old_delay = concoredocker.delay - indir = os.path.join(temp_dir, "1") + inpath = os.path.join(temp_dir, "in") + indir = inpath + "1" os.makedirs(indir) - concoredocker.inpath = temp_dir + concoredocker.inpath = inpath concoredocker.delay = 0.001 concoredocker.s = ""