Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web GUI for tvb-recon #68

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
48025f4
Adding home page
PUNITBATRA May 16, 2020
57d67b7
minor update
PUNITBATRA May 16, 2020
9f90af3
minor fix
PUNITBATRA May 20, 2020
fca8b92
Added input page for multiple patients
PUNITBATRA May 28, 2020
c6ddb25
gui for adding data processing type
PUNITBATRA May 31, 2020
fab5a87
update server.js for creating dir dynamically
PUNITBATRA Jun 3, 2020
06b72a4
adding initial configuration page
PUNITBATRA Jun 9, 2020
7952b97
adding updated config page
PUNITBATRA Jun 12, 2020
692e521
minor update
PUNITBATRA Jun 12, 2020
d2b0abd
updated path of the .properties file
PUNITBATRA Jun 12, 2020
cdf4291
refactoring some files
PUNITBATRA Jun 22, 2020
17b0373
update run_Sequentially.py and server.js
PUNITBATRA Jun 26, 2020
462fa6b
Dockerfiles according to condor image
PUNITBATRA Jul 30, 2020
c219ae1
adding workflow & hardcoded joblist component and some minor update
PUNITBATRA Aug 13, 2020
a71a8bb
final changes in joblist and workflowlist component
PUNITBATRA Aug 14, 2020
4e4af6b
initial readme for web GUI
PUNITBATRA Aug 17, 2020
6694211
Update README.md
PUNITBATRA Aug 17, 2020
f1c2bb8
minor update
PUNITBATRA Aug 17, 2020
adff004
minor update in readme images
PUNITBATRA Aug 18, 2020
af8db95
updated readme as suggested
PUNITBATRA Aug 21, 2020
331cf80
updated readme as suggested
PUNITBATRA Aug 21, 2020
34d8edf
Update README.md
PUNITBATRA Aug 21, 2020
d7c730b
adding slider in home page
PUNITBATRA Aug 21, 2020
27416c1
added config props info
PUNITBATRA Aug 22, 2020
be62030
parses the node and edges on server dynamically
PUNITBATRA Aug 31, 2020
193de3d
Final readme update
PUNITBATRA Aug 31, 2020
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
Prev Previous commit
Next Next commit
refactoring some files
  • Loading branch information
PUNITBATRA committed Jun 22, 2020
commit cdf4291a5efcb76e853a0608bfd93d741349b8a1
88 changes: 35 additions & 53 deletions pegasus/run_sequentially.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
import sys
from enum import Enum
from string import Template
from configobj import ConfigObj

config = ConfigObj()

config = ConfigObj('/home/punit/github/GSOC/tvb-recon/web/TVB_patients/TVB1/configs/patient_flow.properties')
print(config['parcelation.atlas'])

PATH_TO_INPUT_SUBJ_FOLDERS = "/home/submitter/data"
PATH_TO_SUBJ_CONFIG_FOLDERS = "/home/submitter/data"
Expand All @@ -16,7 +22,6 @@

SUBJECTS_TO_BE_PROCESSED = [24]

ATLASES = ["default", "a2009s"]

OS = "LINUX"

Expand All @@ -29,7 +34,6 @@

class configs(Enum):
ENVIRON_CONFIGS = "environment_config.sh"
PATIENT_PROPS = "patient_flow.properties"
PEGASUS_PROPS = "pegasus.properties"
SITES = "sites.xml"
RC = "rc.txt"
Expand All @@ -46,14 +50,6 @@ def create_config_files_for_subj(current_subject, current_atlas):
with open(subj_pegasus_props_path, "w+") as subj_pegasus_props_file:
subj_pegasus_props_file.write(pegasus_props)

default_patient_props_path = os.path.join(PATH_TO_DEFAULT_PEGASUS_CONFIGURATION, configs.PATIENT_PROPS.value)
with open(default_patient_props_path) as default_patient_props_file:
template = Template(default_patient_props_file.read())
patient_props = template.substitute(subject=current_subject, atlas=current_atlas, os=OS)
subj_patient_props = os.path.join(current_dir, configs.PATIENT_PROPS.value)
with open(subj_patient_props, "w+") as subj_patient_props_file:
subj_patient_props_file.write(patient_props)

default_environ_config_path = os.path.join(PATH_TO_DEFAULT_PEGASUS_CONFIGURATION, configs.ENVIRON_CONFIGS.value)
with open(default_environ_config_path) as default_environ_config_file:
template = Template(default_environ_config_file.read())
Expand Down Expand Up @@ -88,25 +84,7 @@ def create_config_files_for_subj(current_subject, current_atlas):
print("Configuration files for subject %s are ready!" % current_subject)


def prepare_config_for_new_atlas(current_dir, current_atlas):
atlas_exists_in_config = False
atlas_config_name = "parcelation.atlas"
atlas_config = atlas_config_name + "=" + current_atlas + "\n"

current_patient_props_path = os.path.join(current_dir, configs.PATIENT_PROPS.value)
with open(current_patient_props_path, "r") as current_patient_props_file:
text = current_patient_props_file.readlines()
for idx, line in enumerate(text):
if line.startswith(atlas_config_name):
text[idx] = atlas_config
atlas_exists_in_config = True
break
if not atlas_exists_in_config:
text.insert(len(text), atlas_config)
print "Configured atlas %s for patient inside folder %s" % (current_atlas, current_dir)
os.remove(current_patient_props_path)
with open(current_patient_props_path, "w") as new_patient_props_file:
new_patient_props_file.writelines(text)


def get_currently_running_job_ids():
Expand Down Expand Up @@ -161,41 +139,45 @@ def get_specified_submit_folder(current_dir):
print "Starting to process the subject: %s" % current_subject

current_dir = os.path.join(PATH_TO_SUBJ_CONFIG_FOLDERS, current_subject, "configs")
for atlas in ATLASES:
if not os.path.exists(current_dir):
os.mkdir(current_dir)
print "Folder %s has been created..." % current_dir
if not os.path.exists(current_dir):
os.mkdir(current_dir)
print "Folder %s has been created..." % current_dir

create_config_files_for_subj(current_subject, atlas)
create_config_files_for_subj(current_subject, atlas)

else:
prepare_config_for_new_atlas(current_dir, atlas)

elif os.path.exists(current_dir):
print "Files are adding in the existing configs Folder"

create_config_files_for_subj(current_subject, atlas)
else:
prepare_config_for_new_atlas(current_dir, atlas)

existent_job_ids = get_currently_running_job_ids()
existent_job_ids = get_currently_running_job_ids()

print "Starting pegasus run for subject: " + current_subject + "with atlas: " + atlas
current_dax_dir = os.path.join(current_dir, "dax")
p = subprocess.call(["sh", "main_pegasus.sh", current_dir, current_dax_dir])
print "Starting pegasus run for subject: " + current_subject + "with atlas: " + atlas
current_dax_dir = os.path.join(current_dir, "dax")
p = subprocess.call(["sh", "main_pegasus.sh", current_dir, current_dax_dir])

new_job_ids = get_currently_running_job_ids()
new_job_ids = get_currently_running_job_ids()

for job in existent_job_ids:
new_job_ids.remove(job)
for job in existent_job_ids:
new_job_ids.remove(job)

current_job_id = new_job_ids[0]
print "The job that has been started has the id: %s" % current_job_id
current_job_id = new_job_ids[0]
print "The job that has been started has the id: %s" % current_job_id

submit_dir = os.path.join(get_specified_submit_folder(current_dir), getpass.getuser(), "pegasus",
submit_dir = os.path.join(get_specified_submit_folder(current_dir), getpass.getuser(), "pegasus",
"TVB-PIPELINE", PREFIX_JOB_ID + current_job_id)

print("Starting to monitor the submit folder: %s ..." % submit_dir)
print("Starting to monitor the submit folder: %s ..." % submit_dir)

while True:
if MONITORED_FILE in os.listdir(submit_dir):
break
else:
print("Checked at %s and %s file was not generated yet!" % (
while True:
if MONITORED_FILE in os.listdir(submit_dir):
break
else:
print("Checked at %s and %s file was not generated yet!" % (
str(time.strftime("%a, %d %b %Y %H:%M:%S", time.gmtime())), MONITORED_FILE))
time.sleep(600)
time.sleep(600)

print("The run has finished for job with id: %s" % current_job_id)
print("The run has finished for job with id: %s" % current_job_id)
5 changes: 5 additions & 0 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"font-awesome": "^4.7.0",
"multer": "^1.4.2",
"nodemon": "^2.0.4",
"properties-file": "^1.0.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-router": "^5.2.0",
Expand Down
35 changes: 27 additions & 8 deletions web/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ app.use(cors())
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({extended: true}));
app.use(express.json())
var parser = require("properties-file");

//For Patient 1
var storage = multer.diskStorage({
Expand All @@ -20,7 +21,7 @@ var storage = multer.diskStorage({
}
})

var upload1 = multer({ storage: storage }).single('file')
var upload1 = multer({ storage: storage }).array('file')

app.get('/',function(req,res){
return res.send('Hello Server')
Expand Down Expand Up @@ -52,7 +53,7 @@ var storage = multer.diskStorage({
}
})

var upload2 = multer({ storage: storage }).single('file')
var upload2 = multer({ storage: storage }).array('file')

app.post('/upload2',function(req, res) {

Expand Down Expand Up @@ -82,7 +83,7 @@ var storage = multer.diskStorage({
}
})

var upload3 = multer({ storage: storage }).single('file')
var upload3 = multer({ storage: storage }).array('file')

app.post('/upload3',function(req, res) {

Expand Down Expand Up @@ -112,7 +113,7 @@ filename: function (req, file, cb) {
}
})

var upload4 = multer({ storage: storage }).single('file')
var upload4 = multer({ storage: storage }).array('file')

app.post('/upload4',function(req, res) {

Expand Down Expand Up @@ -153,7 +154,7 @@ app.post("/input1",function(req,res){
"decim.factor":req.body.label4,
os:"LINUX"
}
fs.writeFile(file1,JSON.stringify(data,null,2) ,'utf-8',
fs.writeFile(file1,parser.stringify(data) ,'utf-8',
(err) => {
if(err) {
return console.log(err);
Expand Down Expand Up @@ -185,7 +186,7 @@ app.post("/input2",function(req,res){
"decim.factor":req.body.label4,
os:"LINUX"
}
fs.writeFile(file2,JSON.stringify(data,null,2) ,'utf-8',
fs.writeFile(file2,parser.stringify(data) ,'utf-8',
(err) => {
if(err) {
return console.log(err);
Expand Down Expand Up @@ -217,7 +218,7 @@ app.post("/input3",function(req,res){
"decim.factor":req.body.label4,
os:"LINUX"
}
fs.writeFile(file3,JSON.stringify(data,null,2) ,'utf-8',
fs.writeFile(file3,parser.stringify(data) ,'utf-8',
(err) => {
if(err) {
return console.log(err);
Expand Down Expand Up @@ -249,13 +250,31 @@ app.post("/input4",function(req,res){
"decim.factor":req.body.label4,
os:"LINUX"
}
fs.writeFile(file4,JSON.stringify(data,null,2) ,'utf-8',
fs.writeFile(file4,parser.stringify(data) ,'utf-8',
(err) => {
if(err) {
return console.log(err);
}
})
})


//Start docker
const { exec } = require("child_process");
const { cwd } = require('process');
app.post("/start",function(req,res){
exec("sudo docker run -it -v "+ (cwd())+"/TVB_patients/:/home/submitter/data thevirtualbrain/tvb-recon /bin/bash", (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
})
})
app.listen(8000, function() {
console.log('App running on port 8000');
});
2 changes: 1 addition & 1 deletion web/src/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from "react";
import { BrowserRouter as Router,Switch,Route } from "react-router-dom";
import Home from "./components/Home/Home";
import Input from './components/Input/Patient';
import Input from './components/Input/Input';
import Configuration from './components/Configuration/Configuration'
import WorkflowList from './components/WorkflowList/WorkflowList';
import NewWorkflow from './components/NewWorkflow/NewWorkflow';
Expand Down
24 changes: 13 additions & 11 deletions web/src/components/Configuration/Configuration.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import React, { Component } from 'react';
import Header from '../Home/Header/Header';
import Configuration1 from './Configuration1';
import Configuration2 from './Configuration2';
import Configuration3 from './Configuration3';
import Configuration4 from './Configuration4';
import InputConfiguration from './InputConfiguration'
import Slider from "react-slick";
import "slick-carousel/slick/slick.css";
import "slick-carousel/slick/slick-theme.css";
import './Configuration.css'
import './Configuration.css';
import axios from 'axios'
class Configuration extends Component{

handleClick=()=>{
alert("Docker started on server")
axios.post('http:https://localhost:8000/start')

}
render(){
const settings = {
dots: true,
Expand All @@ -22,12 +24,12 @@ class Configuration extends Component{
<div>
<Header/>
<Slider {...settings}>
<Configuration1/>
<Configuration2/>
<Configuration3/>
<Configuration4/>
<InputConfiguration no="1"/>
<InputConfiguration no="2"/>
<InputConfiguration no="3"/>
<InputConfiguration no="4"/>
</Slider>
<button type="submit" className="proceed_btn" onClick={this.handleClick}>Click Here To Proceed >>></button>
<button className="proceed_btn" onClick={this.handleClick}>Start the Docker Container</button>


</div>
Expand Down
Loading