Skip to content

Commit 22d0936

Browse files
authored
Merge branch 'dev' into refactor/consolidate-pidmayuresh-378
2 parents b27755a + 97a38f6 commit 22d0936

20 files changed

Lines changed: 450 additions & 180 deletions

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
# Python
1+
# Python bytecode/cache
22
__pycache__/
3+
*.pyc
4+
*.pyo
5+
*.pyd
36
*.py[cod]
47
*.class
58
*.so
69
.Python
10+
11+
# Virtual environments
712
venv/
813
env/
914
ENV/
15+
.env/
16+
.venv/
1017

1118
# IDE
1219
.vscode/

0mq/funbody.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import concore
22
import time
3+
import sys
34
from osparc_control import CommandManifest
45
from osparc_control import CommandParameter
56
from osparc_control import CommandType
@@ -58,7 +59,7 @@
5859
request_id=command.request_id, payload=ym)
5960
else:
6061
print("undefined action"+str(command.action))
61-
quit()
62+
sys.exit(1)
6263
#concore.write(concore.oport['Y1'],"ym",ym)
6364
print("funbody u="+str(u)+" ym="+str(ym)+" time="+str(concore.simtime))
6465
paired_transmitter.stop_background_sync()

concore.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ class Concore{
503503
outfile<<val[i]<<',';
504504
outfile<<val[val.size()-1]<<']';
505505
outfile.close();
506-
simtime += delta;
506+
// simtime must not be mutated here (issue #385).
507507
}
508508
else{
509509
throw 505;
@@ -559,7 +559,7 @@ class Concore{
559559
outfile<<val[val.size()-1]<<']';
560560
std::string result = outfile.str();
561561
std::strncpy(sharedData_create, result.c_str(), 256 - 1);
562-
simtime += delta;
562+
// simtime must not be mutated here (issue #385).
563563
}
564564
else{
565565
throw 505;

concore.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@ def write(port_identifier, name, val, delta=0):
382382
# Prepend simtime to match file-based write behavior
383383
payload = [simtime + delta] + zmq_val
384384
zmq_p.send_json_with_retry(payload)
385-
simtime += delta
385+
# simtime must not be mutated here.
386+
# Mutation breaks cross-language determinism (see issue #385).
386387
else:
387388
zmq_p.send_json_with_retry(zmq_val)
388389
except zmq.error.ZMQError as e:
@@ -413,7 +414,8 @@ def write(port_identifier, name, val, delta=0):
413414
val_converted = convert_numpy_to_python(val)
414415
data_to_write = [simtime + delta] + val_converted
415416
outfile.write(str(data_to_write))
416-
simtime += delta
417+
# simtime must not be mutated here.
418+
# Mutation breaks cross-language determinism (see issue #385).
417419
else:
418420
outfile.write(val)
419421
except Exception as e:

concore.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ module concore;
296296
end
297297
$fdisplay(fout,"]");
298298
$fclose(fout);
299-
simtime = simtime + delta;
299+
// simtime must not be mutated here (issue #385).
300300
end
301301
endtask
302302

concore_cli/commands/validate.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,14 @@ def finalize():
117117
warnings.append(f"Node {node_id} has no label")
118118
except Exception as e:
119119
warnings.append(f"Error parsing node: {str(e)}")
120-
120+
121+
# duplicate labels cause silent corruption in mkconcore.py
122+
seen = set()
123+
for label in node_labels:
124+
if label in seen:
125+
errors.append(f"Duplicate node label: '{label}'")
126+
seen.add(label)
127+
121128
node_ids = {node.get('id') for node in nodes if node.get('id')}
122129
for edge in edges:
123130
source = edge.get('source')

concore_write.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function concore_write(port, name, val, delta)
55
outstr = cat(2,"[",num2str(concore.simtime+delta),num2str(val,",%e"),"]");
66
fprintf(output1,'%s',outstr);
77
fclose(output1);
8-
concore.simtime = concore.simtime + delta;
8+
% simtime must not be mutated here (issue #385).
99
catch exc
1010
disp(['skipping ' concore.outpath num2str(port) '/' name]);
1111
end

concoredocker.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class Concore {
138138

139139
std::vector<std::string> read(int port, const std::string& name, const std::string& initstr) {
140140
std::this_thread::sleep_for(std::chrono::seconds(delay));
141-
std::string file_path = inpath + std::to_string(port) + "/" + name;
141+
std::string file_path = inpath + "/" + std::to_string(port) + "/" + name;
142142
std::ifstream infile(file_path);
143143
std::string ins;
144144

@@ -151,6 +151,7 @@ class Concore {
151151
int attempts = 0, max_retries = 5;
152152
while (ins.empty() && attempts < max_retries) {
153153
std::this_thread::sleep_for(std::chrono::seconds(delay));
154+
infile.close();
154155
infile.open(file_path);
155156
if (infile) std::getline(infile, ins);
156157
attempts++;
@@ -175,7 +176,7 @@ class Concore {
175176
}
176177

177178
void write(int port, const std::string& name, const std::vector<std::string>& val, int delta = 0) {
178-
std::string file_path = outpath + std::to_string(port) + "/" + name;
179+
std::string file_path = outpath + "/" + std::to_string(port) + "/" + name;
179180
std::ofstream outfile(file_path);
180181
if (!outfile) {
181182
std::cerr << "Error writing to " << file_path << "\n";

0 commit comments

Comments
 (0)