Skip to content

Commit 0ffda4e

Browse files
committed
fixing changes that accidentally got committed
1 parent 9b4cfd1 commit 0ffda4e

File tree

3 files changed

+189
-13
lines changed

3 files changed

+189
-13
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
.install_firewheel_docker: &install_firewheel_docker
3232
- python -m pip install $PIP_ARGS -U build setuptools pip
3333
- python -m build
34-
- python -m pip install -e .[dev,mcs]
34+
- python -m pip install -e .[dev]
3535

3636
.install_firewheel: &install_firewheel
3737
- sudo killall minimega # Make sure minimega is not running

install.sh

Lines changed: 187 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,120 @@ function err() {
5959
echo "[$(date -u +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
6060
}
6161

62+
#######################################
63+
# Set up the default directory for output
64+
# and ensure it has the correct permissions.
65+
# Arguments:
66+
# None
67+
# Globals:
68+
# DEFAULT_OUTPUT_DIR
69+
# FIREWHEEL_GROUP
70+
#######################################
71+
function setup_dirs() {
72+
if ! mkdir -p "${DEFAULT_OUTPUT_DIR}"; then
73+
err "FIREWHEEL failed to create default output directory: \"${DEFAULT_OUTPUT_DIR}\". Aborting."
74+
exit 1
75+
fi
76+
77+
if ! chgrp "${FIREWHEEL_GROUP}" "${DEFAULT_OUTPUT_DIR}"; then
78+
err "FIREWHEEL failed to alter group ownership of default output directory: \"${DEFAULT_OUTPUT_DIR}\". Aborting."
79+
exit 1
80+
fi
81+
82+
if ! chmod -R g=u "${DEFAULT_OUTPUT_DIR}"; then
83+
err "FIREWHEEL failed to permissions of default output directory: \"${DEFAULT_OUTPUT_DIR}\". Aborting."
84+
exit 1
85+
fi
86+
}
87+
88+
#######################################
89+
# Clone a few of the most common Model Component Repositories (base, linux, vyos).
90+
# There is some error handling to ensure group permissions are set and
91+
# that the repositories are cloned correctly.
92+
# Arguments:
93+
# None
94+
# Globals:
95+
# FIREWHEEL_GROUP
96+
# MC_BRANCH
97+
# MC_DIR
98+
# MC_REPO_GROUP
99+
#######################################
100+
function clone_repos() {
101+
if ! mkdir -p "${MC_DIR}"; then
102+
err "FIREWHEEL failed to create model component directory: \"${MC_DIR}\". Aborting."
103+
exit 1
104+
fi
105+
106+
if ! chgrp -R "${FIREWHEEL_GROUP}" "${MC_DIR}"; then
107+
err "FIREWHEEL failed to alter group ownership of model component directory: \"${MC_DIR}\". Aborting."
108+
exit 1
109+
fi
110+
111+
if ! chmod -R g=u "${MC_DIR}"; then
112+
err "FIREWHEEL failed to permissions of model component directory: \"${MC_DIR}\". Aborting."
113+
exit 1
114+
fi
115+
116+
pushd "${MC_DIR}"
117+
118+
local fail_count=1
119+
local max_attempts=5
120+
if [[ ! -d "base" ]]; then
121+
fail_count=1
122+
until (( fail_count > max_attempts )) || git clone $GIT_CLONE_OPTS "${MC_REPO_GROUP}/firewheel_repo_base.git" --branch "${MC_BRANCH}"; do
123+
fail_count=$((fail_count+1))
124+
rate_mod=$((2**(fail_count)))
125+
r_sleep=$((RANDOM % rate_mod))
126+
err "Failed to clone $fail_count out of $max_attempts times. Sleeping for ${r_sleep} to rate limit."
127+
sleep ${r_sleep}
128+
done
129+
130+
if (( fail_count > max_attempts )); then
131+
err "FIREWHEEL failed to clone required git repository: \"${MC_REPO_GROUP}/firewheel_repo_base.git\". Aborting."
132+
exit 1
133+
fi
134+
else
135+
err "Directory \"${MC_REPO_GROUP}/firewheel_repo_base\" already exists. Skipping git clone."
136+
fi
137+
138+
if [[ ! -d "linux" ]]; then
139+
fail_count=1
140+
until (( fail_count > max_attempts )) || git clone $GIT_CLONE_OPTS "${MC_REPO_GROUP}/firewheel_repo_linux.git" --branch "${MC_BRANCH}"; do
141+
fail_count=$((fail_count+1))
142+
rate_mod=$((2**(fail_count)))
143+
r_sleep=$((RANDOM % rate_mod))
144+
err "Failed to clone $fail_count out of $max_attempts times. Sleeping for ${r_sleep} to rate limit."
145+
sleep ${r_sleep}
146+
done
147+
148+
if (( fail_count > max_attempts )); then
149+
err "FIREWHEEL failed to clone required git repository: \"${MC_REPO_GROUP}/firewheel_repo_linux.git\". Aborting."
150+
exit 1
151+
fi
152+
else
153+
err "Directory \"${MC_REPO_GROUP}/firewheel_repo_linux\" already exists. Skipping git clone."
154+
fi
155+
156+
if [[ ! -d "vyos" ]]; then
157+
fail_count=1
158+
until (( fail_count > max_attempts )) || git clone $GIT_CLONE_OPTS "${MC_REPO_GROUP}/firewheel_repo_vyos.git" --branch "${MC_BRANCH}"; do
159+
fail_count=$((fail_count+1))
160+
rate_mod=$((2**(fail_count)))
161+
r_sleep=$((RANDOM % rate_mod))
162+
err "Failed to clone $fail_count out of $max_attempts times. Sleeping for ${r_sleep} to rate limit."
163+
sleep ${r_sleep}
164+
done
165+
166+
if (( fail_count > max_attempts )); then
167+
err "FIREWHEEL failed to clone required git repository: \"${MC_REPO_GROUP}/firewheel_repo_vyos.git\". Aborting."
168+
exit 1
169+
fi
170+
else
171+
err "Directory \"${MC_REPO_GROUP}/firewheel_repo_vyos\" already exists. Skipping git clone."
172+
fi
173+
174+
popd
175+
}
62176

63177
#######################################
64178
# Check for the installation of minimega
@@ -80,6 +194,49 @@ function check_deps() {
80194
fi
81195
}
82196

197+
#######################################
198+
# Basic setup for upgrading the virtual envionment tools and
199+
# building the FIREWHEEL whl file.
200+
# Arguments:
201+
# None
202+
# Globals:
203+
# PIP_ARGS
204+
# PYTHON_BIN
205+
#######################################
206+
function install_firewheel_generic() {
207+
if ! ${PYTHON_BIN} -m pip install ${PIP_ARGS} build; then
208+
err "FIREWHEEL setup failed to pip install 'build'."
209+
err "Consult the pip error logs, and verify network connectivity. Aborting."
210+
exit 1
211+
fi
212+
213+
if ! ${PYTHON_BIN} -m build; then
214+
err "FIREWHEEL setup failed to build the source distribution and wheel."
215+
err "Consult the error logs, and verify network connectivity. Aborting."
216+
exit 1
217+
fi
218+
219+
}
220+
221+
#######################################
222+
# Installing the FIREWHEEL package with standard dependencies.
223+
# Arguments:
224+
# None
225+
# Globals:
226+
# FIREWHEEL_ROOT
227+
# PIP_ARGS
228+
# PYTHON_BIN
229+
#######################################
230+
function install_firewheel() {
231+
pushd "${FIREWHEEL_ROOT_DIR}"
232+
${PYTHON_BIN} -m pip install ${PIP_ARGS} firewheel
233+
if [ ! $? -eq 0 ];
234+
then
235+
install_firewheel_generic
236+
${PYTHON_BIN} -m pip install ${PIP_ARGS} --prefer-binary ./dist/firewheel-2.6.0.tar.gz
237+
fi
238+
popd
239+
}
83240

84241
#######################################
85242
# Installing the FIREWHEEL package with development dependencies.
@@ -91,13 +248,22 @@ function check_deps() {
91248
# PYTHON_BIN
92249
#######################################
93250
function install_firewheel_development() {
94-
local mc_dir="${MC_DIR}_packages"
95-
# Install the development version of FIREWHEEL
96-
${PYTHON_BIN} -m pip install ${PIP_ARGS} -e ${FIREWHEEL_ROOT_DIR}/[dev]
97-
# Essential MCs (base, linux, vyos, etc.) were cloned; install them in development mode too
98-
${PYTHON_BIN} -m pip install ${PIP_ARGS} -e ${mc_dir}/firewheel_repo_base
99-
${PYTHON_BIN} -m pip install ${PIP_ARGS} -e ${mc_dir}/firewheel_repo_linux
100-
${PYTHON_BIN} -m pip install ${PIP_ARGS} -e ${mc_dir}/firewheel_repo_vyos
251+
pushd "${FIREWHEEL_ROOT_DIR}"
252+
install_firewheel_generic
253+
254+
# Install the development version.
255+
if [[ $1 -eq 1 ]]; then
256+
then
257+
# In this case, we do not use the "dev" optional dependencies as
258+
# the user is using the source code version of these model components, rather
259+
# than the Python package installed repositories.
260+
${PYTHON_BIN} -m pip install ${PIP_ARGS} pre-commit tox
261+
${PYTHON_BIN} -m pip install ${PIP_ARGS} -e .[format,docs]
262+
263+
else
264+
${PYTHON_BIN} -m pip install ${PIP_ARGS} -e .[dev]
265+
fi
266+
popd
101267
}
102268

103269
#######################################
@@ -175,11 +341,13 @@ function post_install() {
175341
#######################################
176342
function usage() {
177343
echo -e "Useful script to install FIREWHEEL and ensure proper system configuration.\n"
178-
echo "usage: install.sh [-h | --help] [-d | --development] [-s | --static]"
344+
echo "usage: install.sh [-h | --help] [-d | --development] [-nc | --no-clone] [-s | --static]"
179345
echo -e "\n\nOptional Arguments:"
180346
echo " -h, --help Show this help message and exit"
181347
echo " -d, --development Install FIREWHEEL in development mode, an 'editable' installation"
182348
echo " including all development dependencies."
349+
echo " -nc, --no-clone Prevents the install script from cloning/installing any model component"
350+
echo " repositories."
183351
echo " -s, --static Does not check if necessary system services are running (e.g., minimega)."
184352
}
185353

@@ -188,11 +356,14 @@ function usage() {
188356
#######################################
189357
function main() {
190358
local dev=0
359+
local clone=1
191360
local static=0
192361
while [[ "$1" != "" ]]; do
193362
case $1 in
194363
-d | --development ) shift
195364
dev=1 ;;
365+
-nc | --no-clone ) shift
366+
clone=0 ;;
196367
-s | --static ) shift
197368
static=1 ;;
198369
-h | --help ) usage
@@ -206,12 +377,17 @@ function main() {
206377
echo "${fw_str} Checking dependencies."
207378
check_deps
208379
echo "${fw_str} Setting up temporary directory."
380+
setup_dirs
381+
if [[ $clone -eq 1 ]]; then
382+
echo "${fw_str} Cloning model component repositories."
383+
clone_repos
384+
fi
209385
if [[ $dev -eq 1 ]]; then
210386
echo "${fw_str} Installing FIREWHEEL in development mode."
211-
install_firewheel_development
387+
install_firewheel_development $clone
212388
else
213-
echo "${fw_str} Installing FIREWHEEL with standard (non-development) dependencies."
214-
${PYTHON_BIN} -m pip install ${PIP_ARGS} firewheel[mcs]
389+
echo "${fw_str} Installing FIREWHEEL without development dependencies."
390+
install_firewheel
215391
fi
216392
echo "${fw_str} Setting configuration options."
217393
init_firewheel $static

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ docs = [
9797
"sphinx-design",
9898
]
9999
dev = [
100-
"firewheel[format,docs]",
100+
"firewheel[mcs,format,docs]",
101101
"pre-commit",
102102
"tox~=4.0",
103103
]

0 commit comments

Comments
 (0)