-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_predictive_maintenance.sh
More file actions
executable file
·140 lines (117 loc) · 3.84 KB
/
run_predictive_maintenance.sh
File metadata and controls
executable file
·140 lines (117 loc) · 3.84 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
# Predictive Maintenance Runner
# ------------------------------
echo "========================================"
echo "RPA Predictive Maintenance"
echo "========================================"
# Activate conda environment using the correct path
echo "Activating conda environment..."
source /opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh && conda activate agent_f1_env
# Check if environment activated successfully
if [[ "$CONDA_DEFAULT_ENV" != "agent_f1_env" ]]; then
echo "Warning: Failed to activate agent_f1_env conda environment."
echo "Trying to activate windsurf-mcp environment instead..."
source /opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh && conda activate windsurf-mcp
if [[ "$CONDA_DEFAULT_ENV" != "windsurf-mcp" ]]; then
echo "Error: Failed to activate any required conda environment."
exit 1
fi
fi
echo "Environment activated successfully: $CONDA_DEFAULT_ENV"
# Create necessary directories
mkdir -p output/maintenance
mkdir -p logs
# Progress indicators
show_progress() {
echo -e "\nud83dudd34 Quality: 85%"
echo "ud83dudfe2 Speed: 60%"
echo "ud83dudd35 Time: 70%"
echo "ud83dudfe1 Progress: $1%\n"
}
# Check dependencies
echo "Checking dependencies..."
py_deps=("pandas" "numpy" "matplotlib")
missing_deps=0
for dep in "${py_deps[@]}"; do
if ! python -c "import $dep" &> /dev/null; then
echo "Warning: Python package '$dep' not found."
missing_deps=1
fi
done
if [ $missing_deps -eq 1 ]; then
echo "Installing missing dependencies..."
conda install -y -c conda-forge pip pandas numpy matplotlib
pip install scikit-learn
fi
show_progress 20
# Parse command line arguments
DAYS=7
LOGS_DIR="/Users/yacinebenhamou/Desktop/logs"
OUTPUT_DIR="/Users/yacinebenhamou/Desktop/output/maintenance"
VERBOSE=false
while [[ $# -gt 0 ]]; do
case $1 in
--days)
DAYS="$2"
shift 2
;;
--logs-dir)
LOGS_DIR="$2"
shift 2
;;
--output-dir)
OUTPUT_DIR="$2"
shift 2
;;
--verbose)
VERBOSE=true
shift
;;
--help)
echo "Usage: $0 [options]"
echo "Options:"
echo " --days N Number of days to analyze (default: 7)"
echo " --logs-dir DIR Directory containing log files"
echo " --output-dir DIR Directory for output files"
echo " --verbose Enable verbose output"
echo " --help Show this help message"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
show_progress 40
# Set up logging level
LOGGING_ARGS=""
if [ "$VERBOSE" = true ]; then
LOGGING_ARGS="--log-level DEBUG"
echo "Verbose logging enabled"
fi
# Run the predictive maintenance module
echo -e "\nRunning predictive maintenance check for the last $DAYS days..."
echo "Logs directory: $LOGS_DIR"
echo "Output directory: $OUTPUT_DIR"
show_progress 60
python /Users/yacinebenhamou/Desktop/predictive_maintenance.py \
--days "$DAYS" \
--logs-dir "$LOGS_DIR" \
--output-dir "$OUTPUT_DIR" \
$LOGGING_ARGS
RESULT=$?
show_progress 100
if [ $RESULT -eq 0 ]; then
echo -e "\n========================================"
echo "Predictive Maintenance Check Completed"
echo "========================================"
echo "Check the generated report for detailed results and recommendations."
else
echo -e "\n========================================"
echo "Predictive Maintenance Check Failed"
echo "========================================"
echo "Check logs/predictive_maintenance.log for details"
fi
exit $RESULT