Skip to content

Commit 444fcac

Browse files
authored
Merge pull request #437 from MEDomics-UdeS/scalability
V1.5.0 merge
2 parents 7ed271c + 5899a0b commit 444fcac

File tree

25 files changed

+914
-97
lines changed

25 files changed

+914
-97
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.github/workflows/automaticBuilding.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
VERSION: ${{ steps.get-tag.outputs.VERSION }}
8080

8181
build-linux-ubuntu:
82-
runs-on: ubuntu-22.04
82+
runs-on: ubuntu-20.04
8383

8484
steps:
8585
- name: Checkout code

.github/workflows/automaticBuildingLinux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ permissions:
77
contents: write
88
jobs:
99
build-linux-ubuntu:
10-
runs-on: ubuntu-22.04
10+
runs-on: ubuntu-20.04
1111

1212
steps:
1313
- name: Checkout code

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ dmypy.json
142142
# submodules
143143
/flask_server/submodules/MEDimage/*
144144
/flask_server/submodules/MEDprofiles/*
145+
pythonCode/submodules/MEDimage/*
146+
pythonCode/submodules/MEDprofiles/*
147+
148+
# Go executables
149+
go_server/main
150+
go_server/main.exe
145151

146152
# custom gitignore
147153
tmp

build/.DS_Store

-2 KB
Binary file not shown.

go_server/blueprints/learning/learning.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ var prePath = "learning"
1010
// AddHandleFunc adds the specific module handle function to the server
1111
func AddHandleFunc() {
1212
Utils.CreateHandleFunc(prePath+"/run_experiment/", handleRunExperiment)
13+
Utils.CreateHandleFunc(prePath+"/get_file_content/", handleGetFileContent)
14+
Utils.CreateHandleFunc(prePath+"/save_file_content/", handleSaveFileContent)
1315
Utils.CreateHandleFunc(prePath+"/progress/", handleProgress)
1416
}
1517

@@ -25,6 +27,30 @@ func handleRunExperiment(jsonConfig string, id string) (string, error) {
2527
return response, nil
2628
}
2729

30+
// handleGetFileContent handles the request to run an experiment
31+
// It returns the response from the python script
32+
func handleGetFileContent(jsonConfig string, id string) (string, error) {
33+
log.Println("Running script get_file_content...", id)
34+
response, err := Utils.StartPythonScripts(jsonConfig, "../pythonCode/modules/learning/get_file_content.py", id)
35+
Utils.RemoveIdFromScripts(id)
36+
if err != nil {
37+
return "", err
38+
}
39+
return response, nil
40+
}
41+
42+
// handleSaveFileContent handles the request to run an experiment
43+
// It returns the response from the python script
44+
func handleSaveFileContent(jsonConfig string, id string) (string, error) {
45+
log.Println("Running script save_file_content...", id)
46+
response, err := Utils.StartPythonScripts(jsonConfig, "../pythonCode/modules/learning/save_file_content.py", id)
47+
Utils.RemoveIdFromScripts(id)
48+
if err != nil {
49+
return "", err
50+
}
51+
return response, nil
52+
}
53+
2854
// handleProgress handles the request to get the progress of the experiment
2955
// It returns the progress of the experiment
3056
func handleProgress(jsonConfig string, id string) (string, error) {

go_server/main

-709 KB
Binary file not shown.

main/utils/pythonEnv.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export function getBundledPythonEnvironment() {
187187
}
188188

189189
export async function installRequiredPythonPackages(mainWindow) {
190-
let requirementsFileName = process.platform === "darwin" ? "requirements_mac.txt" : "requirements.txt"
190+
let requirementsFileName = "merged_requirements.txt"
191191
if (process.env.NODE_ENV === "production") {
192192
installPythonPackage(mainWindow, pythonExecutablePath, null, path.join(process.cwd(), "resources", "pythonEnv", requirementsFileName))
193193
} else {
@@ -208,6 +208,12 @@ function comparePythonInstalledPackages(pythonPackages, requirements) {
208208
if (pythonPackage.name === requirementName && pythonPackage.version === requirementVersion) {
209209
found = true
210210
break
211+
} else if (pythonPackage.name.replace('-', '_') === requirementName && pythonPackage.version === requirementVersion) {
212+
found = true
213+
break
214+
} else if (pythonPackage.name.replace('_', '-') === requirementName && pythonPackage.version === requirementVersion) {
215+
found = true
216+
break
211217
}
212218
}
213219
if (!found) {
@@ -360,9 +366,9 @@ export async function installBundledPythonExecutable(mainWindow) {
360366

361367
// Install the required python packages
362368
if (process.env.NODE_ENV === "production") {
363-
installPythonPackage(mainWindow, pythonExecutablePath, null, path.join(process.cwd(), "resources", "pythonEnv", "requirements.txt"))
369+
installPythonPackage(mainWindow, pythonExecutablePath, null, path.join(process.cwd(), "resources", "pythonEnv", "merged_requirements.txt"))
364370
} else {
365-
installPythonPackage(mainWindow, pythonExecutablePath, null, path.join(process.cwd(), "pythonEnv", "requirements.txt"))
371+
installPythonPackage(mainWindow, pythonExecutablePath, null, path.join(process.cwd(), "pythonEnv", "merged_requirements.txt"))
366372
}
367373
let removeCommand = `rm ${outputFileName}`
368374
let removePromise = exec(removeCommand, { shell: "powershell.exe" })
@@ -429,9 +435,9 @@ export async function installBundledPythonExecutable(mainWindow) {
429435
console.log("process.resourcesPath: ", process.resourcesPath)
430436
// Install the required python packages
431437
if (process.env.NODE_ENV === "production") {
432-
installPythonPackage(mainWindow, pythonExecutablePath, null, path.join(process.resourcesPath, "pythonEnv", "requirements.txt"))
438+
installPythonPackage(mainWindow, pythonExecutablePath, null, path.join(process.resourcesPath, "pythonEnv", "merged_requirements.txt"))
433439
} else {
434-
installPythonPackage(mainWindow, pythonExecutablePath, null, path.join(process.cwd(), "pythonEnv", "requirements.txt"))
440+
installPythonPackage(mainWindow, pythonExecutablePath, null, path.join(process.cwd(), "pythonEnv", "merged_requirements.txt"))
435441
}
436442
}
437443
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"private": true,
33
"name": "medomicslab-application",
44
"description": "MEDomicsLab application",
5-
"version": "1.0.0",
5+
"version": "1.5.0",
66
"author": "MEDomicsLab Team",
77
"main": "app/background.js",
88
"build": {
@@ -114,7 +114,7 @@
114114
"primeicons": "^7.0.0",
115115
"primereact": "^9.6.2",
116116
"prismjs": "^1.29.0",
117-
"react-ace": "^10.1.0",
117+
"react-ace": "^14.0.1",
118118
"react-bootstrap-icons": "^1.10.3",
119119
"react-bootstrap-sidebar-menu": "^2.0.3",
120120
"react-complex-tree": "^2.2.2",
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import json
2+
import os
3+
import sys
4+
from pathlib import Path
5+
6+
sys.path.append(
7+
str(Path(os.path.dirname(os.path.abspath(__file__))).parent.parent))
8+
9+
from med_libs.GoExecutionScript import GoExecutionScript, parse_arguments
10+
from med_libs.server_utils import go_print
11+
12+
json_params_dict, id_ = parse_arguments()
13+
go_print("running script.py:" + id_)
14+
15+
16+
17+
class GoExecScriptMerge(GoExecutionScript):
18+
"""
19+
This class is used to execute the merge script
20+
21+
Args:
22+
json_params: The input json params
23+
_id: The id of the page that made the request if any
24+
"""
25+
26+
def __init__(self, json_params: dict, _id: str = None):
27+
super().__init__(json_params, _id)
28+
self.results = {"data": "nothing to return"}
29+
30+
def _custom_process(self, json_config: dict) -> dict:
31+
"""
32+
This function reads the content of a file
33+
34+
Args:
35+
json_config: The input json params
36+
"""
37+
go_print(json.dumps(json_config, indent=4))
38+
39+
try:
40+
# Set local variables
41+
file_path = json_config["filePath"]
42+
43+
# Check if the file exists
44+
if not os.path.exists(file_path):
45+
return {"error": "File not found"}
46+
47+
# Read the file content
48+
with open(file_path, "r") as file:
49+
content = file.read()
50+
51+
# Detect the file extension
52+
prog_lang = os.path.splitext(file_path)[1].lower().replace(".", "")
53+
if prog_lang == "py" or prog_lang == "ipynb":
54+
prog_lang = "python"
55+
elif prog_lang == "md":
56+
prog_lang = "markdown"
57+
elif prog_lang == "txt":
58+
prog_lang = "text"
59+
60+
# Return the file content and extension
61+
return {
62+
"content": content,
63+
"language": prog_lang
64+
}
65+
66+
except Exception as e:
67+
return {"error": str(e)}
68+
69+
script = GoExecScriptMerge(json_params_dict, id_)
70+
script.start()

0 commit comments

Comments
 (0)