Skip to content

Commit 4af813e

Browse files
Refactored config path retrieval, removed deprecated files, and impro… (#211)
2 parents fa257b3 + 96ea556 commit 4af813e

37 files changed

Lines changed: 1536 additions & 1375 deletions

CODE/Logicytics.py

Lines changed: 278 additions & 199 deletions
Large diffs are not rendered by default.

CODE/VulnScan/tools/_test_gpu_acceleration.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,20 @@
66
exit(1)
77

88

9-
def check_gpu():
9+
def check_gpu() -> str:
1010
"""Check if CUDA is available and print the device information.
1111
1212
This function attempts to detect CUDA capability and prints whether
1313
GPU acceleration is available, along with the device name if applicable.
1414
"""
1515
try:
1616
if torch.cuda.is_available():
17-
print(f"CUDA is available. Using GPU: {torch.cuda.get_device_name(0)}")
17+
return f"CUDA is available. Using GPU: {torch.cuda.get_device_name(0)}"
1818
else:
19-
print("CUDA is not available. Using CPU.")
19+
return "CUDA is not available. Using CPU."
2020
except RuntimeError as err:
21-
print(f"Error initializing CUDA: {err}")
21+
return f"Error initializing CUDA: {err}"
2222

2323

2424
if __name__ == '__main__':
25-
check_gpu()
26-
else:
27-
raise ImportError("This training script is meant to be run directly "
28-
"and cannot be imported. Please execute it as a standalone script.")
25+
print(check_gpu())

CODE/VulnScan/v2-deprecated/_generate_data.py

Lines changed: 0 additions & 110 deletions
This file was deleted.

CODE/VulnScan/v3/_train.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@
1919
from sklearn.tree import DecisionTreeClassifier
2020
from torch.utils.data import Dataset, DataLoader
2121

22-
# NN seems to be the best choice for this task
23-
2422
# Set up logging
2523
from logicytics import Log, DEBUG
2624

25+
# NN seems to be the best choice for this task
26+
2727
logger = Log(
2828
{"log_level": DEBUG,
2929
"filename": "../../../ACCESS/LOGS/VulnScan_Train.log",
3030
"colorlog_fmt_parameters":
3131
"%(log_color)s%(levelname)-8s%(reset)s %(yellow)s%(asctime)s %(blue)s%(message)s",
3232
}
3333
)
34+
vectorizer = None
3435

3536

3637
# Dataset Class for PyTorch models
@@ -361,7 +362,8 @@ def validate_data():
361362
logger.error("CUDA must be a boolean")
362363
exit(1)
363364

364-
allowed_models = ["NeuralNetwork", "LogReg", "RandomForest", "ExtraTrees", "GBM", "XGBoost", "DecisionTree", "NaiveBayes"]
365+
allowed_models = ["NeuralNetwork", "LogReg", "RandomForest", "ExtraTrees", "GBM", "XGBoost", "DecisionTree",
366+
"NaiveBayes"]
365367
if MODEL_NAME not in allowed_models:
366368
logger.error(f"MODEL_NAME must be one of: {', '.join(allowed_models)}")
367369
exit(1)

0 commit comments

Comments
 (0)