mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-11-10 20:47:09 +01:00
All 44 directories now probe: 38 runnable, 5 no-code, 1 blocked (ENUME needs
MATLAB or Octave, neither of which is on this machine).
The runners are stubs over one shared scripts/course_lib.sh rather than 44
copies of the logic, for the same reason the gates live in ~/utils. A stub
passes its kind as ARGUMENTS -- course_main --kind python --entry ... -- "$@"
-- rather than setting globals, because globals a linter cannot see being read
mean SC2034 on every one of them, and the only cure would be 44 disables.
Fixed along the way:
- Generating the stubs overwrote Programming/PSD/run.sh, the original
coursework runner. Restored, and given a --probe early exit instead so it
is otherwise untouched: it installs packages with sudo and starts Kafka,
which is exactly what a probe must not trigger.
- The probe guard only recognised runners containing the literal --probe, so
the new stubs (which delegate to the library) all read unprobed. It now
also accepts delegation to course_lib.sh.
- Blocked probes reported "unknown" because _require_any prints the tool it
found, so probes redirected its stdout -- swallowing the failure reason
too. Split into _probe_any, and ENUME now says exactly what it needs.
- shellcheck runs with -x so it follows the sourced library; without it every
stub reports SC1091 and the only alternative is a per-file disable. The
library itself carries `# shellcheck shell=bash` because it has no shebang
on purpose -- it is sourced, never executed.
Then EADS was actually run, and three of its six C++ files did not compile:
- lab3.cpp: copyDictionary was declared taking Dictionary* but its body used
Node members, and the copy constructor called copyTree(), which does not
exist. The copy also dropped key and balanceFactor. Now compiles AND runs,
printing its AVL tests.
- MidTerm/task2.cpp: a const mismatch between declaration and definition, a
stray semicolon before a function body, findNode calling a Tree method on
a treeNode*, and a while loop that never advanced. sumNodeSub also had no
base case -- unreachable before, because the const mismatch meant its body
was never compiled.
These compiled years ago because older GCC did not diagnose uninstantiated
template bodies. Fragments with no main() are now type-checked with -c rather
than linked, since two of these files are exam answers, not programs.
Binaries go to a gitignored build/ -- an extensionless executable dropped next
to its source is not something .gitignore catches by name.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172dj34FDpao6wsix8ZuCzE
114 lines
3.4 KiB
Bash
Executable File
114 lines
3.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# --probe: report whether this can run here WITHOUT running it, per the
|
|
# contract in ../../run.sh. This script is the original coursework runner and
|
|
# is deliberately left otherwise untouched, so the probe is a early exit
|
|
# rather than a rewrite -- it installs packages with sudo and starts Kafka,
|
|
# which is exactly what a probe must never trigger.
|
|
if [[ "${1:-}" == "--probe" ]]; then
|
|
for tool in python mvn java; do
|
|
if ! command -v "$tool" > /dev/null 2>&1; then
|
|
echo "needs $tool"
|
|
exit 78
|
|
fi
|
|
done
|
|
echo "starts the Kafka/Flink stack (installs packages with sudo)"
|
|
exit 0
|
|
fi
|
|
|
|
# Function to run a script in the background and save its PID
|
|
run_script() {
|
|
python "$1" &
|
|
echo $!
|
|
}
|
|
|
|
# Function to install Kafka
|
|
install_kafka() {
|
|
if ! command -v kafka-server-start &> /dev/null; then
|
|
echo "Kafka is not installed. Installing Kafka..."
|
|
sudo pacman -Syu --noconfirm
|
|
sudo pacman -S --noconfirm kafka
|
|
else
|
|
echo "Kafka is already installed."
|
|
fi
|
|
}
|
|
|
|
# Function to install Flink using yay
|
|
install_flink() {
|
|
if ! command -v flink &> /dev/null; then
|
|
echo "Flink is not installed. Installing Flink..."
|
|
if ! command -v yay &> /dev/null; then
|
|
echo "yay is not installed. Installing yay..."
|
|
sudo pacman -S --noconfirm git
|
|
git clone https://aur.archlinux.org/yay.git
|
|
( cd yay && makepkg -si --noconfirm )
|
|
rm -rf yay
|
|
fi
|
|
yay -S --noconfirm apache-flink
|
|
else
|
|
echo "Flink is already installed."
|
|
fi
|
|
}
|
|
|
|
# Ensure Kafka and Flink are installed
|
|
#install_kafka
|
|
#install_flink
|
|
|
|
# Ensure Kafka and Flink services are running
|
|
echo "Starting Kafka and Flink services..."
|
|
sudo systemctl start kafka
|
|
start-cluster.sh
|
|
|
|
# Give some time for Kafka and Flink to start
|
|
sleep 1
|
|
|
|
# Start the Kafka producer (Transaction Simulator)
|
|
echo "Starting transaction simulator..."
|
|
producer_pid=$(run_script './kafka/generate_and_send.py')
|
|
echo "Started transaction simulator with PID $producer_pid"
|
|
|
|
# Give some time for the producer to start and produce initial transactions
|
|
sleep 1
|
|
|
|
# Start the Kafka consumer for testing
|
|
echo "Starting Kafka consumer for testing..."
|
|
consumer_pid=$(run_script './kafka/kafka_consumer.py')
|
|
echo "Started Kafka consumer for testing with PID $consumer_pid"
|
|
|
|
# Give some time for the consumer to read initial transactions
|
|
sleep 1
|
|
|
|
# Start the Flink job (Anomaly Detector)
|
|
echo "Starting Flink anomaly detector..."
|
|
flink_pid=$(run_script './flink/anomaly_detector.py')
|
|
echo "Started Flink anomaly detector with PID $flink_pid"
|
|
|
|
# Give some time for the Flink job to start processing
|
|
sleep 1
|
|
|
|
# Start the Flask application (Alarm Reader and Visualizer)
|
|
echo "Starting Flask alarm reader..."
|
|
flask_pid=$(run_script './webinterface/webinterface.py')
|
|
echo "Started Flask alarm reader with PID $flask_pid"
|
|
|
|
# Function to handle script termination
|
|
terminate_scripts() {
|
|
echo "Shutting down..."
|
|
kill "$producer_pid"
|
|
kill "$consumer_pid"
|
|
kill "$flink_pid"
|
|
kill "$flask_pid"
|
|
echo "All processes terminated."
|
|
# Optionally stop Kafka and Flink services
|
|
sudo systemctl stop kafka
|
|
sudo systemctl stop flink
|
|
}
|
|
|
|
# Trap SIGINT (Ctrl+C) to terminate all subprocesses
|
|
trap terminate_scripts SIGINT
|
|
|
|
# Keep the main script running to allow all subprocesses to continue executing
|
|
while true; do
|
|
sleep 1
|
|
done
|