-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathml_pipeline.groovy
75 lines (63 loc) · 2.28 KB
/
ml_pipeline.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
pipeline {
agent any
environment {
BASE_PATH = "/home/ubuntu/feature_testing/Automation_for_Malware_Detection_process"
SCRIPT_PATH = "${BASE_PATH}/main.py"
}
stages {
stage('Set Latest Paths') {
steps {
script {
// Find latest model file
def modelFile = sh(
script: """
ls ${BASE_PATH}/utilities/model/cnn_*.h5 2>/dev/null | grep -E 'cnn_[0-9]{4}-[0-9]{2}-[0-9]{2}\\.h5' | sort -t'_' -k2 -r | head -n 1
""",
returnStdout: true
).trim()
if (!modelFile) {
error("No model files matching the pattern 'cnn_YYYY-MM-DD.h5' found!")
}
env.MODEL_PATH = modelFile
// Print the latest model path for verification
echo "Latest MODEL_PATH: ${env.MODEL_PATH}"
// Find latest dataset file
env.DATASET_PATH = sh(
script: "ls -t ${BASE_PATH}/dataset/*.csv | head -n1",
returnStdout: true
).trim()
// Print paths for verification
echo "Latest MODEL_PATH: ${env.MODEL_PATH}"
echo "Latest DATASET_PATH: ${env.DATASET_PATH}"
}
}
}
stage('Load Dataset') {
steps {
sh '''
#!/bin/bash
. ${BASE_PATH}/venv/bin/activate
python3 ${SCRIPT_PATH} -d ${DATASET_PATH} --summarize
'''
}
}
stage('Visualize Dataset') {
steps {
sh '''
#!/bin/bash
. ${BASE_PATH}/venv/bin/activate
python ${SCRIPT_PATH} -d ${DATASET_PATH} --visualize
'''
}
}
stage('Retrain Model') {
steps {
sh '''
#!/bin/bash
. ${BASE_PATH}/venv/bin/activate
python3 ${SCRIPT_PATH} -m ${MODEL_PATH} -r ${DATASET_PATH}
'''
}
}
}
}