Skip to content

Commit c30867e

Browse files
committed
[RMS] Add check for the correct conda environment
1 parent fc9d125 commit c30867e

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ env:
5555
# RMS branch to use for ReactionMechanismSimulator installation
5656
RMS_BRANCH: for_rmg
5757
# Use standard RMS installation mode for install_rms.sh
58-
RMS_MODE: standard
58+
RMS_MODE: CI
5959
# julia parallel pre-compilation leads to race conditions and hangs, so we limit it to run in serial
6060
JULIA_NUM_PRECOMPILE_TASKS: 1
6161

install_rms.sh

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,25 @@ echo "Julia 1.10 binary path: $julia_path"
3939

4040
# Get current conda environment name
4141
current_env=$(conda info --envs | grep '\*' | awk '{print $1}')
42-
echo "Current conda environment: $current_env"
42+
43+
# Ask the user to confirm RMS is being installed in the correct
44+
# conda environemnt. Skip if this is run under CI.
45+
if [ "$RMS_MODE" != "CI" ]; then
46+
echo " Please confirm that you want to install RMS into the current conda environment: '$current_env'"
47+
echo " If this is not correct, abort and activate the correct environment before rerunning."
48+
read -p "Proceed with installation in '$current_env'? (y/N): " confirm
49+
case "$confirm" in
50+
[yY][eE][sS]|[yY])
51+
echo "✅ Proceeding with installation in '$current_env'"
52+
;;
53+
*)
54+
echo "❌ Aborted. Please activate the correct conda environment and try again."
55+
exit 1
56+
;;
57+
esac
58+
else
59+
echo "Current conda environment: $current_env"
60+
fi
4361

4462
# Set environment variables for the current environment, for future uses
4563
# https://juliapy.github.io/PythonCall.jl/stable/pythoncall/#If-you-already-have-Python-and-required-Python-packages-installed
@@ -89,14 +107,22 @@ if [ "$RMS_MODE" = "dev" ]; then
89107
echo "Using local RMS path: $RMS_PATH"
90108
fi
91109

92-
if [ "$RMS_MODE" = "standard" ]; then
110+
if [ "$RMS_MODE" = "standard" ] || [ "$RMS_MODE" = "CI" ]; then
93111
echo "Installing RMS from branch: $RMS_BRANCH"
94112
julia << EOF || echo "RMS standard install error - continuing anyway ¯\\_(ツ)_/¯"
95113
using Pkg
96114
Pkg.activate(ENV["PYTHON_JULIAPKG_PROJECT"])
97115
Pkg.add(Pkg.PackageSpec(name="ReactionMechanismSimulator", url="https://github.com/ReactionMechanismGenerator/ReactionMechanismSimulator.jl.git", rev="$RMS_BRANCH"))
98116
Pkg.instantiate()
99-
using ReactionMechanismSimulator
117+
try
118+
@info "Loading RMS"
119+
using ReactionMechanismSimulator
120+
@info "RMS loaded successfully!"
121+
catch err
122+
@error "Failed to load RMS" exception=err
123+
Base.show_backtrace(stderr, catch_backtrace())
124+
exit(1)
125+
end
100126
EOF
101127
elif [ "$RMS_MODE" = "dev" ]; then
102128
echo "Installing RMS in developer mode from path: $RMS_PATH"
@@ -105,12 +131,26 @@ elif [ "$RMS_MODE" = "dev" ]; then
105131
Pkg.activate(ENV["PYTHON_JULIAPKG_PROJECT"])
106132
Pkg.develop(path="$RMS_PATH")
107133
Pkg.instantiate()
108-
using ReactionMechanismSimulator
134+
try
135+
@info "Loading RMS"
136+
using ReactionMechanismSimulator
137+
@info "RMS loaded successfully!"
138+
catch err
139+
@error "Failed to load RMS" exception=err
140+
Base.show_backtrace(stderr, catch_backtrace())
141+
exit(1)
142+
end
109143
EOF
110144
else
111145
echo "Unknown RMS_MODE: $RMS_MODE. Must be either 'standard' or 'dev'."
112146
exit 1
113147
fi
114148

149+
julia_status=$?
150+
if [ $julia_status -ne 0 ]; then
151+
echo "RMS installation failed!"
152+
exit $status
153+
fi
154+
115155
echo "Checking if ReactionMechanismSimulator is installed in the current conda environment for Python usage..."
116156
python -c "from juliacall import Main; import sys; sys.exit(0 if Main.seval('Base.identify_package(\"ReactionMechanismSimulator\") !== nothing') and print('ReactionMechanismSimulator is installed in $current_env') is None else 1)"

0 commit comments

Comments
 (0)