Repository navigation
Description
Description
The README wire format lists nested arrays, tuples, strings and booleans as supported payload types, and names Julia among the implementations that parse this shared format. The Julia safe_parse_list only handles a flat list of numbers. It splits the payload on commas and calls tryparse(Float64, ...) on each token, so anything else raises an ArgumentError.
concore_read does not catch that error. When a peer writes one of these payloads, the Julia node stops with an exception instead of falling back to initstr. Python and C++ (since #460 for #389) parse these payloads, and on a parse failure both fall back to the default value instead of stopping.
Steps to reproduce
On dev (8f3e444), with CONCORE pointing at the checkout:
mkdir -p repro/out1 && cd repro
cat > writer.py <<'EOF'
import sys
sys.path.insert(0, sys.argv[1])
import concore
concore.delay = 0
concore.simtime = 5.0
concore.outpath = "./out"
concore.write(1, "ym", [[1.0, 2.0], 3.0])
EOF
cat > reader.jl <<'EOF'
include(joinpath(ARGS[1], "concore.jl"))
using .Concore
Concore.delay = 0.0
Concore.inpath = "./out"
ym = concore_read(1, "ym", "[0.0, 0.0, 0.0]")
println("ym = ", ym)
EOF
python writer.py "$CONCORE"
cat out1/ym # [5.0, [1.0, 2.0], 3.0]
julia reader.jl "$CONCORE"Expected behavior
The Julia node reads the value. C++ returns [1, 2, 3] for this file, and Python returns [[1.0, 2.0], 3.0]. If the payload really cannot be parsed, the read should fall back to initstr, the same as in the other runtimes.
Actual behavior
ERROR: LoadError: ArgumentError: safe_parse_list: cannot parse '[1.0' as Float64 (position 2 in '[5.0, [1.0, 2.0], 3.0]')
Stacktrace:
[1] safe_parse_list(str::String)
@ Main.Concore concore.jl:536
[2] concore_read(port::Int64, name::String, initstr::String)
@ Main.Concore concore.jl:712
The process exits with status 1.
Other payloads
The same Python writer, read back by the Julia and C++ nodes:
Payload passed to concore.write |
File contents | Julia concore_read |
C++ read |
|---|---|---|---|
[1.0, 2.0] |
[5.0, 1.0, 2.0] |
[1.0, 2.0] |
[1, 2] |
[[1.0, 2.0], 3.0] |
[5.0, [1.0, 2.0], 3.0] |
throws | [1, 2, 3] |
[1.0, (2.0, 3.0)] |
[5.0, 1.0, (2.0, 3.0)] |
throws | [1, 2, 3] |
['ok', 1.0] |
[5.0, 'ok', 1.0] |
throws | [1] |
'ok' |
ok |
throws | falls back to initstr |
Python only turns a top-level tuple into a list (#605), so a tuple nested inside a list is written as-is, as in the third row.
safe_parse_list also throws on these inputs, all of which ast.literal_eval accepts:
| Input | ast.literal_eval |
Julia |
|---|---|---|
(5.0, 1.0, 2.0) |
tuple | throws |
[5.0, 'a,b', 1.0] |
list | throws |
[5.0, 1.0,] |
list | throws |
[] |
empty list | throws |
The initval cases in tests/protocol_fixtures/python_phase1_cases.json fail as well:
| Case | Expected | Julia |
|---|---|---|
initval/valid_list_sets_simtime: [12.5, "a", 3] |
simtime 12.5, payload ["a", 3] |
throws, simtime unchanged |
initval/invalid_input_returns_empty_and_preserves_simtime: not_a_list |
[], simtime unchanged |
throws |
Julia is not listed in cross_runtime_matrix.phase2.json, so these cases are not tracked for it.
Cause
safe_parse_listsplits the inner text on,and parses each token as aFloat64. Brackets, parentheses and quoted strings are not tokenized.- In
concore_read, the call tosafe_parse_list(ins)is outside anytry, so a parse error propagates out of the read. - The ZMQ path,
_zmq_read, already catches parse errors and returnsinitval(initstr). File-based and ZMQ reads in Julia therefore behave differently for the same payload. - For comparison, C++
parselist_doubleparses the full literal and flattens it to numbers. Pythonreadreturns the default withlast_read_status = "PARSE_ERROR"when parsing fails.
concoredocker.jl has the same code and the same behavior.
Proposed fix
- Replace the comma split in
safe_parse_listwith a small recursive parser for the subset of Python literals that the other runtimes accept: numbers (including exponent notation),True/False/None, single- and double-quoted strings, nested[...]and(...), and trailing commas. Keep the existingnp.float64(...)/np.array(...)handling. - Keep the return type
Vector{Float64}and flatten in the same way as C++flatten_numeric: numbers kept, booleans become1.0/0.0, strings skipped, and nested lists and tuples flattened in order. Existing Julia nodes need no changes. - In
concore_readandinitval, fall back toinitstr(or returnFloat64[]and leavesimtimeunchanged, per the fixture) when the payload cannot be parsed, matching the ZMQ path, Python and C++. - Apply the same changes to
concoredocker.jl. - Tests: update the
@test_throwscases intests/julia/test_parser.jlwhose expected behavior changes (for example[]), add parser cases for each payload type above, add a Python-to-Julia interop test with a nested payload, and run theinitvalprotocol fixtures against Julia.
Questions
- Is flattening (the C++ behavior) the preferred result for Julia, or should
concore_readreturn structured values the way Python does? Flattening keeps the current API. Structured values would be a breaking change for existing Julia nodes. - Should
safe_parse_listitself still throw on malformed input such as[1.0, abc], with onlyconcore_readandinitvalfalling back? Keeping the public parser strict seems useful for callers who want the error. - Should a fallback emit a
@warn? Julia currently logs nothing on the read path.
I'd like to work on this once the approach is agreed.
Related
- C++ and Verilog
parser/literal_evalreject valid concore data types that Python accepts #389 / Fix C++ literal parser to match Python concore wire format #460: the same gap in the C++ parser, fixed by adding a Python-compatible literal parser. - Julia: list values in concore.params get cut off ("[1.0" instead of the list) #670 / fix(julia): keep list values when loading concore.params #671: fix(julia): keep list values when loading concore.params #671 makes Julia
load_params!parse list values withsafe_parse_list, so list parameters will depend on the same parser.
Environment
- concore
devat 8f3e444 - Julia 1.10.12 and 1.13.1 (same result on both)
- Python 3.11.17
- Linux x86_64
Activity
github-actions commentedon Nov 23, 2026
👋 Welcome to the CONTROL-CORE Project, @Saswatsusmoy! Thank you for opening your first issue in concore.
We appreciate your contribution to the organization and will review it as soon as possible.
Before we get started, please check out these resources: