Skip to content

Commit d737a7e

Browse files
authored
Merge branch 'dev' into fix/zmq-simtime-framing-382
2 parents 454acd8 + 327116d commit d737a7e

12 files changed

Lines changed: 93 additions & 36 deletions

File tree

concore.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ class Concore{
279279
*/
280280
vector<double> parser(string f){
281281
vector<double> temp;
282+
if(f.empty()) return temp;
282283
string value = "";
283284

284285
//Changing last bracket to comma to use comma as a delimiter
@@ -370,6 +371,10 @@ class Concore{
370371
s += ins;
371372

372373
vector<double> inval = parser(ins);
374+
if(inval.empty())
375+
inval = parser(initstr);
376+
if(inval.empty())
377+
return inval;
373378
simtime = simtime > inval[0] ? simtime : inval[0];
374379

375380
//returning a string with data excluding simtime
@@ -432,6 +437,10 @@ class Concore{
432437
s += ins;
433438

434439
vector<double> inval = parser(ins);
440+
if(inval.empty())
441+
inval = parser(initstr);
442+
if(inval.empty())
443+
return inval;
435444
simtime = simtime > inval[0] ? simtime : inval[0];
436445

437446
//returning a string with data excluding simtime
@@ -494,6 +503,7 @@ class Concore{
494503
outfile<<val[i]<<',';
495504
outfile<<val[val.size()-1]<<']';
496505
outfile.close();
506+
simtime += delta;
497507
}
498508
else{
499509
throw 505;
@@ -549,6 +559,7 @@ class Concore{
549559
outfile<<val[val.size()-1]<<']';
550560
std::string result = outfile.str();
551561
std::strncpy(sharedData_create, result.c_str(), 256 - 1);
562+
simtime += delta;
552563
}
553564
else{
554565
throw 505;

concore.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ module concore;
296296
end
297297
$fdisplay(fout,"]");
298298
$fclose(fout);
299+
simtime = simtime + delta;
299300
end
300301
endtask
301302

concore_write.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +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;
89
catch exc
910
disp(['skipping ' concore.outpath num2str(port) '/' name]);
1011
end

concoredocker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static void main(String[] args) {
6262
} else if (!sparams.isEmpty()) {
6363
// Fallback: convert key=value,key=value format to dict
6464
System.out.println("converting sparams: " + sparams);
65-
sparams = "{'" + sparams.replaceAll(",", ",'").replaceAll("=", "':").replaceAll(" ", "") + "}";
65+
sparams = "{'" + sparams.replaceAll(";", ",'").replaceAll("=", "':").replaceAll(" ", "") + "}";
6666
System.out.println("converted sparams: " + sparams);
6767
try {
6868
Object parsed = literalEval(sparams);

concoredocker.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ def write(port_identifier, name, val, delta=0):
283283
try:
284284
zmq_val = convert_numpy_to_python(val)
285285
if isinstance(zmq_val, list):
286+
# Prepend simtime to match file-based write behavior
286287
payload = [simtime + delta] + zmq_val
287288
zmq_p.send_json_with_retry(payload)
288289
simtime += delta
@@ -292,7 +293,8 @@ def write(port_identifier, name, val, delta=0):
292293
logging.error(f"ZMQ write error on port {port_identifier} (name: {name}): {e}")
293294
except Exception as e:
294295
logging.error(f"Unexpected error during ZMQ write on port {port_identifier} (name: {name}): {e}")
295-
296+
return
297+
296298
try:
297299
file_port_num = int(port_identifier)
298300
file_path = os.path.join(outpath, str(file_port_num), name)

demo/cwrap.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
except:
5959
init_simtime_ym = "[0.0, 0.0, 0.0]"
6060

61-
print(apikey)
6261
print(yuyu)
6362
print(name1+'='+init_simtime_u)
6463
print(name2+'='+init_simtime_ym)
@@ -83,7 +82,7 @@
8382
u = concore.read(1,name1,init_simtime_u)
8483
f = {'file1': open(concore.inpath+'1/'+name1, 'rb')}
8584
print("CW: before post u="+str(u))
86-
print('http://www.controlcore.org/pm/'+yuyu+apikey+'&fetch='+name2)
85+
print('http://www.controlcore.org/pm/'+yuyu+'<APIKEY_HIDDEN>'+'&fetch='+name2)
8786
r = requests.post('http://www.controlcore.org/pm/'+yuyu+apikey+'&fetch='+name2, files=f,timeout=timeout_max)
8887
if r.status_code!=200:
8988
print("bad POST request "+str(r.status_code))

demo/pwrap.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
except:
6262
init_simtime_ym = "[0.0, 0.0, 0.0]"
6363

64-
print(apikey)
6564
print(yuyu)
6665
print(name1+'='+init_simtime_u)
6766
print(name2+'='+init_simtime_ym)

mkconcore.py

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ def _resolve_concore_path():
137137
return os.getcwd()
138138
return SCRIPT_DIR
139139

140+
if len(sys.argv) < 4:
141+
print("usage: py mkconcore.py file.graphml sourcedir outdir [type]")
142+
print(" type must be posix (macos or ubuntu), windows, or docker")
143+
sys.exit(1)
144+
140145
GRAPHML_FILE = sys.argv[1]
141146
TRIMMED_LOGS = True
142147
CONCOREPATH = _resolve_concore_path()
@@ -202,11 +207,7 @@ def _resolve_concore_path():
202207
logging.error(f"{sourcedir} does not exist")
203208
quit()
204209

205-
if len(sys.argv) < 4:
206-
logging.error("usage: py mkconcore.py file.graphml sourcedir outdir [type]")
207-
logging.error(" type must be posix (macos or ubuntu), windows, or docker")
208-
quit()
209-
elif len(sys.argv) == 4:
210+
if len(sys.argv) == 4:
210211
prefixedgenode = outdir+"_" #nodes and edges prefixed with outdir_ only in case no type specified 3/24/21
211212
concoretype = "docker"
212213
else:
@@ -706,7 +707,7 @@ def cleanup_script_files():
706707
for node in nodes_dict:
707708
containername,sourcecode = nodes_dict[node].split(':')
708709
if len(sourcecode)!=0 and sourcecode.find(".")!=-1: #3/28/21
709-
dockername,langext = sourcecode.split(".")
710+
dockername,langext = sourcecode.rsplit(".", 1)
710711
dockerfile_path = os.path.join(outdir, "src", f"Dockerfile.{dockername}")
711712
if not os.path.exists(dockerfile_path): # 3/30/21
712713
try:
@@ -750,7 +751,7 @@ def cleanup_script_files():
750751
for node in nodes_dict:
751752
containername,sourcecode = nodes_dict[node].split(':')
752753
if len(sourcecode)!=0 and sourcecode.find(".")!=-1: #3/28/21
753-
dockername,langext = sourcecode.split(".")
754+
dockername,langext = sourcecode.rsplit(".", 1)
754755
fbuild.write("mkdir docker-"+dockername+"\n")
755756
fbuild.write("cd docker-"+dockername+"\n")
756757
fbuild.write("cp ../src/Dockerfile."+dockername+" Dockerfile\n")
@@ -788,7 +789,7 @@ def cleanup_script_files():
788789
# Use safe_container
789790
frun.write(DOCKEREXE+' run --name='+safe_container+volswr[i]+volsro[i]+" "+DOCKEREPO+"/docker-"+shlex.quote(sourcecode)+"&\n")
790791
else:
791-
dockername,langext = sourcecode.split(".")
792+
dockername,langext = sourcecode.rsplit(".", 1)
792793
logging.debug(f"Generating Docker run command for {dockername}: {DOCKEREXE} run --name={containername+volswr[i]+volsro[i]} docker-{dockername}")
793794
# Use safe_container
794795
frun.write(DOCKEREXE+' run --name='+safe_container+volswr[i]+volsro[i]+" docker-"+shlex.quote(dockername)+"&\n")
@@ -800,8 +801,8 @@ def cleanup_script_files():
800801
for node in nodes_dict:
801802
containername,sourcecode = nodes_dict[node].split(':')
802803
if len(sourcecode)!=0:
803-
#dockername,langext = sourcecode.split(".")
804-
dockername = sourcecode.split(".")[0] # 3/28/21
804+
#dockername,langext = sourcecode.rsplit(".", 1)
805+
dockername = sourcecode.rsplit(".", 1)[0] # 3/28/21
805806
safe_container = shlex.quote(containername)
806807
fstop.write(DOCKEREXE+' stop '+safe_container+"\n")
807808
fstop.write(DOCKEREXE+' rm '+safe_container+"\n")
@@ -813,7 +814,7 @@ def cleanup_script_files():
813814
for node in nodes_dict:
814815
containername,sourcecode = nodes_dict[node].split(':')
815816
if len(sourcecode)!=0:
816-
dockername = sourcecode.split(".")[0] #3/28/21
817+
dockername = sourcecode.rsplit(".", 1)[0] #3/28/21
817818
writeedges = volswr[i]
818819
while writeedges.find(":") != -1:
819820
#scape volume path using shlex.quote for Docker commands (defense-in-depth)
@@ -833,7 +834,7 @@ def cleanup_script_files():
833834
for node in nodes_dict:
834835
containername,sourcecode = nodes_dict[node].split(':')
835836
if len(sourcecode)!=0:
836-
dockername = sourcecode.split(".")[0] #3/28/21
837+
dockername = sourcecode.rsplit(".", 1)[0] #3/28/21
837838
writeedges = volswr[i]
838839
while writeedges.find(":") != -1:
839840
fmaxtime.write(' -v ')
@@ -850,7 +851,7 @@ def cleanup_script_files():
850851
for node in nodes_dict:
851852
containername,sourcecode = nodes_dict[node].split(':')
852853
if len(sourcecode)!=0:
853-
dockername = sourcecode.split(".")[0] #3/28/21
854+
dockername = sourcecode.rsplit(".", 1)[0] #3/28/21
854855
writeedges = volswr[i]
855856
while writeedges.find(":") != -1:
856857
fmaxtime.write('sudo docker cp concore.maxtime concore:/')
@@ -876,7 +877,7 @@ def cleanup_script_files():
876877
for node in nodes_dict:
877878
containername,sourcecode = nodes_dict[node].split(':')
878879
if len(sourcecode)!=0:
879-
dockername = sourcecode.split(".")[0] #3/28/21
880+
dockername = sourcecode.rsplit(".", 1)[0] #3/28/21
880881
writeedges = volswr[i]
881882
while writeedges.find(":") != -1:
882883
fparams.write(' -v ')
@@ -893,7 +894,7 @@ def cleanup_script_files():
893894
for node in nodes_dict:
894895
containername,sourcecode = nodes_dict[node].split(':')
895896
if len(sourcecode)!=0:
896-
dockername = sourcecode.split(".")[0] #3/28/21
897+
dockername = sourcecode.rsplit(".", 1)[0] #3/28/21
897898
writeedges = volswr[i]
898899
while writeedges.find(":") != -1:
899900
fparams.write('sudo docker cp concore.params concore:/')
@@ -918,7 +919,7 @@ def cleanup_script_files():
918919
for node in nodes_dict:
919920
containername,sourcecode = nodes_dict[node].split(':')
920921
if len(sourcecode)!=0:
921-
dockername = sourcecode.split(".")[0] #3/28/21
922+
dockername = sourcecode.rsplit(".", 1)[0] #3/28/21
922923
writeedges = volswr[i]
923924
while writeedges.find(":") != -1:
924925
funlock.write(' -v ')
@@ -935,7 +936,7 @@ def cleanup_script_files():
935936
for node in nodes_dict:
936937
containername,sourcecode = nodes_dict[node].split(':')
937938
if len(sourcecode)!=0:
938-
dockername = sourcecode.split(".")[0] #3/28/21
939+
dockername = sourcecode.rsplit(".", 1)[0] #3/28/21
939940
writeedges = volswr[i]
940941
while writeedges.find(":") != -1:
941942
funlock.write('sudo docker cp ~/concore.apikey concore:/')
@@ -955,7 +956,7 @@ def cleanup_script_files():
955956
for node in nodes_dict:
956957
containername,sourcecode = nodes_dict[node].split(':')
957958
if len(sourcecode)!=0 and sourcecode.find(".")!=-1: #3/28/21
958-
dockername,langext = sourcecode.split(".")
959+
dockername,langext = sourcecode.rsplit(".", 1)
959960
# safe_container added to debug line (POSIX)
960961
safe_container = shlex.quote(containername)
961962
safe_image = shlex.quote("docker-" + dockername) # escape docker image name
@@ -984,7 +985,7 @@ def cleanup_script_files():
984985
if sourcecode.find(".")==-1:
985986
logging.error("cannot pull container "+sourcecode+" with control core type "+concoretype) #3/28/21
986987
quit()
987-
dockername,langext = sourcecode.split(".")
988+
dockername,langext = sourcecode.rsplit(".", 1)
988989
fbuild.write('mkdir '+containername+"\n")
989990
source_subdir = os.path.dirname(sourcecode).replace("\\", "/")
990991
if source_subdir:
@@ -1041,7 +1042,7 @@ def cleanup_script_files():
10411042
containername,sourcecode = edges_dict[edges][0].split(':')
10421043
outcount[nodes_num[edges_dict[edges][0]]] += 1
10431044
if len(sourcecode)!=0:
1044-
dockername,langext = sourcecode.split(".")
1045+
dockername,langext = sourcecode.rsplit(".", 1)
10451046
fbuild.write('cd '+containername+"\n")
10461047
if concoretype=="windows":
10471048
fbuild.write("mklink /J out"+str(outcount[nodes_num[edges_dict[edges][0]]])+" ..\\"+str(edges)+"\n")
@@ -1054,7 +1055,7 @@ def cleanup_script_files():
10541055
for node in nodes_dict:
10551056
containername,sourcecode = nodes_dict[node].split(':')
10561057
if len(sourcecode)!=0:
1057-
dockername,langext = sourcecode.split(".")
1058+
dockername,langext = sourcecode.rsplit(".", 1)
10581059
fbuild.write('cd '+containername+"\n")
10591060
for pair in indir[i]:
10601061
volname,dirname = pair.split(':/')
@@ -1075,7 +1076,7 @@ def cleanup_script_files():
10751076
for node in nodes_dict:
10761077
containername,sourcecode = nodes_dict[node].split(':')
10771078
if len(sourcecode)!=0:
1078-
dockername,langext = sourcecode.split(".")
1079+
dockername,langext = sourcecode.rsplit(".", 1)
10791080
if not (langext in ["py","m","sh","cpp","v"]): # 6/22/21
10801081
logging.error(f"Extension .{langext} is unsupported")
10811082
quit()
@@ -1191,7 +1192,7 @@ def cleanup_script_files():
11911192
for node in nodes_dict:
11921193
containername,sourcecode = nodes_dict[node].split(':')
11931194
if len(sourcecode)!=0:
1194-
dockername = sourcecode.split(".")[0] # 3/28/21
1195+
dockername = sourcecode.rsplit(".", 1)[0] # 3/28/21
11951196
if concoretype=="windows":
11961197
q_container = f'"{containername}"'
11971198
fstop.write('cmd /C '+q_container+"\\concorekill\n")
@@ -1209,7 +1210,7 @@ def cleanup_script_files():
12091210
for node in nodes_dict:
12101211
containername,sourcecode = nodes_dict[node].split(':')
12111212
if len(sourcecode)!=0:
1212-
dockername = sourcecode.split(".")[0] #3/28/21
1213+
dockername = sourcecode.rsplit(".", 1)[0] #3/28/21
12131214
writeedges = volswr[i]
12141215
while writeedges.find(":") != -1:
12151216
path_part = writeedges.split(":")[0].split("-v")[1].strip()
@@ -1229,7 +1230,7 @@ def cleanup_script_files():
12291230
for node in nodes_dict:
12301231
containername,sourcecode = nodes_dict[node].split(':')
12311232
if len(sourcecode)!=0:
1232-
dockername = sourcecode.split(".")[0] #3/28/21
1233+
dockername = sourcecode.rsplit(".", 1)[0] #3/28/21
12331234
writeedges = volswr[i]
12341235
while writeedges.find(":") != -1:
12351236
path_part = writeedges.split(":")[0].split("-v")[1].strip()
@@ -1247,7 +1248,7 @@ def cleanup_script_files():
12471248
for node in nodes_dict:
12481249
containername,sourcecode = nodes_dict[node].split(':')
12491250
if len(sourcecode)!=0:
1250-
dockername = sourcecode.split(".")[0] #3/28/21
1251+
dockername = sourcecode.rsplit(".", 1)[0] #3/28/21
12511252
writeedges = volswr[i]
12521253
while writeedges.find(":") != -1:
12531254
path_part = writeedges.split(":")[0].split("-v")[1].strip()
@@ -1265,7 +1266,7 @@ def cleanup_script_files():
12651266
for node in nodes_dict:
12661267
containername,sourcecode = nodes_dict[node].split(':')
12671268
if len(sourcecode)!=0:
1268-
dockername = sourcecode.split(".")[0] #3/28/21
1269+
dockername = sourcecode.rsplit(".", 1)[0] #3/28/21
12691270
writeedges = volswr[i]
12701271
while writeedges.find(":") != -1:
12711272
path_part = writeedges.split(":")[0].split("-v")[1].strip()

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ name = "concore"
77
version = "1.0.0"
88
description = "Concore workflow management CLI"
99
readme = "README.md"
10-
requires-python = ">=3.8"
10+
requires-python = ">=3.9"
1111
license = {text = "MIT"}
1212
dependencies = [
1313
"click>=8.0.0",
1414
"rich>=10.0.0",
1515
"beautifulsoup4>=4.9.0",
1616
"lxml>=4.6.0",
1717
"psutil>=5.8.0",
18+
"numpy>=1.19.0",
19+
"pyzmq>=22.0.0",
20+
"scipy>=1.5.0",
21+
"matplotlib>=3.3.0",
1822
]
1923

2024
[project.optional-dependencies]

ratc/cwrap.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
except:
5959
init_simtime_ym = "[0.0, 0.0, 0.0]"
6060

61-
print(apikey)
6261
print(yuyu)
6362
print(name1+'='+init_simtime_u)
6463
print(name2+'='+init_simtime_ym)
@@ -83,7 +82,7 @@
8382
u = concore.read(1,name1,init_simtime_u)
8483
f = {'file1': open(concore.inpath+'1/'+name1, 'rb')}
8584
print("CW: before post u="+str(u))
86-
print('http://www.controlcore.org/pm/'+yuyu+apikey+'&fetch='+name2)
85+
print('http://www.controlcore.org/pm/'+yuyu+'<APIKEY_HIDDEN>'+'&fetch='+name2)
8786
r = requests.post('http://www.controlcore.org/pm/'+yuyu+apikey+'&fetch='+name2, files=f,timeout=timeout_max)
8887
if r.status_code!=200:
8988
print("bad POST request "+str(r.status_code))

0 commit comments

Comments
 (0)