Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8153892
created a concoredocker.java - equivalent of concoredocker.py
harshal-rembhotkar Mar 31, 2024
652a5e8
Created a Dockerfile : file supports java language
harshal-rembhotkar Apr 11, 2024
40124c3
Rename Dockerfile to Dockerfile.java
harshal-rembhotkar Apr 11, 2024
4cf78aa
Merge pull request #116 from Harshal-Rembhotkar/feature-dockerfile
pradeeban May 5, 2024
ba0c63f
Warning While Running The Flask Server Fixed
saksham-gera Jan 31, 2025
33aff40
Removed unused CGI test import, because it is deprecated, we can use …
saksham-gera Jan 31, 2025
b7ee152
Solved Download Function Error, by correctly handling the response of…
saksham-gera Jan 31, 2025
34b7dab
Merge pull request #118 from saksham-gera/dev
pradeeban Feb 4, 2025
12e68cf
Fixed Space Issues In The Directory And A path warning while making n…
saksham-gera Feb 4, 2025
9bb8a89
Merge pull request #121 from saksham-gera/dev
pradeeban Feb 10, 2025
0798c7e
Fixing White Space In Directory Causing Failure In Study Creation
saksham-gera Feb 17, 2025
c397c7c
Removed Some Unused Variables From mkconcore.py
saksham-gera Feb 17, 2025
e199b32
Merge pull request #129 from saksham-gera/dev
pradeeban Feb 18, 2025
54664e3
Updated:Dockerfile
harshal-rembhotkar Feb 25, 2025
aa42f51
modify:Draft.yaml
harshal-rembhotkar Feb 25, 2025
e10b90c
Merge branch 'ControlCore-Project:dev' into dev
harshal-rembhotkar Feb 25, 2025
511f5b5
Merge pull request #134 from harshal-rembhotkar/feat/dockerfile
pradeeban Feb 26, 2025
c95d9df
Update draft-pdf.yml
pradeeban Feb 26, 2025
8d6481e
Fixing Issue #124 , Implemented Logging for debugging in mkconcore.py
saksham-gera Feb 26, 2025
ac124d7
Merge pull request #138 from saksham-gera/dev
pradeeban Feb 26, 2025
b5e10a3
Fixing Issue #135
saksham-gera Mar 1, 2025
7637d8d
Merge pull request #140 from saksham-gera/dev
pradeeban Mar 2, 2025
96fe4fb
Fixing Issue #137 partially for concore.py and concoredocker.py
saksham-gera Mar 3, 2025
c51d270
Merge pull request #141 from saksham-gera/dev
pradeeban Mar 4, 2025
0851731
Adding concoredocker.hpp as per concoredocker.py
saksham-gera Mar 6, 2025
9d2d922
Merge pull request #143 from saksham-gera/dev
pradeeban Mar 6, 2025
2fc2c17
Migrated kong with cassandra to docker with postgres in DOCKER-README.md
saksham-gera Mar 9, 2025
f79567c
Made necessary changes in docker-compose to migrate from kong with ca…
saksham-gera Mar 9, 2025
f7e4646
Fixing issue #145 & #146
saksham-gera Mar 9, 2025
c8cd06e
Merge pull request #148 from saksham-gera/dev
pradeeban Mar 9, 2025
2df10f9
Merge pull request #149 from saksham-gera/sslAndARMSupport
pradeeban Mar 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/draft-pdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ jobs:
name: Paper Draft
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Build draft PDF
uses: openjournals/openjournals-draft-action@master
with:
journal: joss
# This should be the path to the paper within your repo.
paper-path: paper.md
- name: Upload
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4

with:
name: paper
# This is the output path where Pandoc will write the compiled
Expand Down
14 changes: 14 additions & 0 deletions Dockerfile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM openjdk:17-jdk-alpine

WORKDIR /app

# Only copy the JAR if it exists
COPY ./target/concore-0.0.1-SNAPSHOT.jar /app/concore.jar || true

# Ensure the JAR file is executable if present
RUN [ -f /app/concore.jar ] && chmod +x /app/concore.jar || true

EXPOSE 3000

# Run Java app only if the JAR exists, otherwise do nothing
CMD ["/bin/sh", "-c", "if [ -f /app/concore.jar ]; then java -jar /app/concore.jar; else echo 'No Java application found, exiting'; fi"]
122 changes: 73 additions & 49 deletions concore.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,24 @@
with open("concorekill.bat","w") as fpid:
fpid.write("taskkill /F /PID "+str(os.getpid())+"\n")

try:
iport = literal_eval(open("concore.iport").read())
except:
iport = dict()
try:
oport = literal_eval(open("concore.oport").read())
except:
oport = dict()

def safe_literal_eval(filename, defaultValue):
try:
with open(filename, "r") as file:
return literal_eval(file.read())
except (FileNotFoundError, SyntaxError, ValueError, Exception) as e:
print(f"Error reading {filename}: {e}")
return defaultValue

iport = safe_literal_eval("concore.iport", {})
oport = safe_literal_eval("concore.oport", {})

s = ''
olds = ''
delay = 1
retrycount = 0
inpath = "./in" #must be rel path for local
outpath = "./out"
simtime = 0

#9/21/22
try:
Expand All @@ -46,70 +48,92 @@
except:
params = dict()
#9/30/22
def tryparam(n,i):
try:
return params[n]
except:
return i
def tryparam(n, i):
return params.get(n, i)


#9/12/21
def default_maxtime(default):
global maxtime
try:
maxtime = literal_eval(open(inpath+"1/concore.maxtime").read())
except:
maxtime = default
maxtime = safe_literal_eval(os.path.join(inpath + "1", "concore.maxtime"), default)

default_maxtime(100)

def unchanged():
global olds,s
if olds==s:
global olds, s
if olds == s:
s = ''
return True
else:
olds = s
return False
olds = s
return False

def read(port, name, initstr):
global s,simtime,retrycount
global s, simtime, retrycount
max_retries=5
time.sleep(delay)
file_path = os.path.join(inpath+str(port), name)

try:
infile = open(inpath+str(port)+"/"+name);
ins = infile.read()
infile.close()
except:
with open(file_path, "r") as infile:
ins = infile.read()
except FileNotFoundError:
print(f"File {file_path} not found, using default value.")
ins = initstr
while len(ins)==0:
except Exception as e:
print(f"Error reading {file_path}: {e}")
return initstr

attempts = 0
while len(ins) == 0 and attempts < max_retries:
time.sleep(delay)
infile = open(inpath+str(port)+"/"+name);
ins = infile.read()
infile.close()
try:
with open(file_path, "r") as infile:
ins = infile.read()
except Exception as e:
print(f"Retry {attempts + 1}: Error reading {file_path} - {e}")
attempts += 1
retrycount += 1

if len(ins) == 0:
print(f"Max retries reached for {file_path}, using default value.")
return initstr

s += ins
inval = literal_eval(ins)
simtime = max(simtime,inval[0])
return inval[1:]
try:
inval = literal_eval(ins)
simtime = max(simtime, inval[0])
return inval[1:]
except Exception as e:
print(f"Error parsing {ins}: {e}")
return initstr


def write(port, name, val, delta=0):
global outpath,simtime
if isinstance(val,str):
time.sleep(2*delay)
elif isinstance(val,list)==False:
print("mywrite must have list or str")
quit()
global simtime
file_path = os.path.join(outpath+str(port), name)

if isinstance(val, str):
time.sleep(2 * delay)
elif not isinstance(val, list):
print("write must have list or str")
return

try:
with open(outpath+str(port)+"/"+name,"w") as outfile:
if isinstance(val,list):
outfile.write(str([simtime+delta]+val))
with open(file_path, "w") as outfile:
if isinstance(val, list):
outfile.write(str([simtime + delta] + val))
simtime += delta
else:
outfile.write(val)
except:
print("skipping"+outpath+str(port)+"/"+name);
except Exception as e:
print(f"Error writing to {file_path}: {e}")

def initval(simtime_val):
global simtime
val = literal_eval(simtime_val)
simtime = val[0]
return val[1:]
try:
val = literal_eval(simtime_val)
simtime = val[0]
return val[1:]
except Exception as e:
print(f"Error parsing simtime_val: {e}")
return []
131 changes: 130 additions & 1 deletion concoredocker.hpp
Original file line number Diff line number Diff line change
@@ -1 +1,130 @@
// concoredocker.hpp -- this C++ include file will be the equivalent of concoredocker.py
#ifndef CONCORE_HPP
#define CONCORE_HPP

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>
#include <chrono>
#include <thread>
#include <filesystem>
#include <stdexcept>
#include <regex>

class Concore {
public:
std::unordered_map<std::string, std::string> iport;
std::unordered_map<std::string, std::string> oport;
std::string s, olds;
int delay = 1;
int retrycount = 0;
std::string inpath = "/in";
std::string outpath = "/out";
int simtime = 0;
int maxtime = 100;
std::unordered_map<std::string, std::string> params;

Concore() {
iport = safe_literal_eval("concore.iport", {});
oport = safe_literal_eval("concore.oport", {});
default_maxtime(100);
load_params();
}

std::unordered_map<std::string, std::string> safe_literal_eval(const std::string& filename, std::unordered_map<std::string, std::string> defaultValue) {
std::ifstream file(filename);
if (!file) {
std::cerr << "Error reading " << filename << "\n";
return defaultValue;
}
return defaultValue;
}

void load_params() {
std::ifstream file(inpath + "/1/concore.params");
if (!file) return;
std::stringstream buffer;
buffer << file.rdbuf();
std::string sparams = buffer.str();

if (!sparams.empty() && sparams[0] == '"') {
sparams = sparams.substr(1, sparams.find('"') - 1);
}

if (!sparams.empty() && sparams[0] != '{') {
sparams = "{'" + std::regex_replace(std::regex_replace(std::regex_replace(sparams, std::regex(","), ", '"), std::regex("="), "':"), std::regex(" "), "") + "}";
}
}

std::string tryparam(const std::string& n, const std::string& i) {
return params.count(n) ? params[n] : i;
}

void default_maxtime(int defaultValue) {
maxtime = defaultValue;
std::ifstream file(inpath + "/1/concore.maxtime");
if (file) {
file >> maxtime;
}
}

bool unchanged() {
if (olds == s) {
s.clear();
return true;
}
olds = s;
return false;
}

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

if (!infile) {
std::cerr << "File " << file_path << " not found, using default value.\n";
return {initstr};
}
std::getline(infile, ins);

int attempts = 0, max_retries = 5;
while (ins.empty() && attempts < max_retries) {
std::this_thread::sleep_for(std::chrono::seconds(delay));
infile.open(file_path);
if (infile) std::getline(infile, ins);
attempts++;
retrycount++;
}

if (ins.empty()) {
std::cerr << "Max retries reached for " << file_path << ", using default value.\n";
return {initstr};
}

s += ins;
return {ins};
}

void write(int port, const std::string& name, const std::vector<std::string>& val, int delta = 0) {
std::string file_path = outpath + std::to_string(port) + "/" + name;
std::ofstream outfile(file_path);
if (!outfile) {
std::cerr << "Error writing to " << file_path << "\n";
return;
}
if (!val.empty()) {
outfile << "[" << simtime + delta << ", ";
for (size_t i = 0; i < val.size(); ++i) {
outfile << val[i] << (i + 1 < val.size() ? ", " : "");
}
outfile << "]";
simtime += delta;
}
}
};

#endif
Loading