Skip to content

Commit

Permalink
moving from using pip module to submodules (#668)
Browse files Browse the repository at this point in the history
* moving from using pip module to submodules

* using a conditional so script doesn't error out if file doesn't exist
  • Loading branch information
modernNeo authored Oct 27, 2024
1 parent c0e6d39 commit 585b272
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 32 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,3 @@ logs/

.idea/

wall_e/wall_e_models
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "wall_e_models"]
path = .wall_e_models
url = https://github.com/CSSS/wall_e_models.git
22 changes: 3 additions & 19 deletions .run_walle.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ def create_argument_parser():
choices=[DatabaseType.sqlite3.value, DatabaseType.postgreSQL.value],
help="indicates whether you want to use sqlite3 or postgres for the database type."
)
parser_obj.add_argument(
"--wall_e_models_location", action='store', default=None,
help="used to specify the absolute path to the wall_e_models", metavar="/path/to/wall_e_model/repo"
)
parser_obj.add_argument(
"--launch_wall_e", action='store', default=None, choices=['true', 'false'], help="script will run wall_e."
)
Expand Down Expand Up @@ -84,7 +80,6 @@ def pull_variable_from_command_line_arguments(argparser):
:return: (
the dockerized_wall_e command-line flag
the database type command-line flag
the wall_e_models location
the launch_wall_e command-line flag
the install_requirements command-line flag
the setup_database command-line flag
Expand All @@ -97,7 +92,7 @@ def pull_variable_from_command_line_arguments(argparser):
database_type = DatabaseType.postgreSQL.value
return (
convert_command_line_argument_to_menu_format(argparser.dockerized_wall_e), database_type,
argparser.wall_e_models_location, convert_command_line_argument_to_menu_format(argparser.launch_wall_e),
convert_command_line_argument_to_menu_format(argparser.launch_wall_e),
convert_command_line_argument_to_menu_format(argparser.install_requirements),
convert_command_line_argument_to_menu_format(argparser.setup_database)

Expand Down Expand Up @@ -280,7 +275,7 @@ def take_user_input_for_string_variable(message, description=None, default_value

(
basic_config__DOCKERIZED_CMD_LINE_ARGUMENT, database_config__TYPE_CMD_LINE_ARGUMENT,
WALL_E_MODEL_PATH_CMD_LINE_ARGUMENT, LAUNCH_WALL_E_CMD_LINE_ARGUMENT, INSTALL_REQUIREMENTS_CMD_LINE_ARGUMENT,
LAUNCH_WALL_E_CMD_LINE_ARGUMENT, INSTALL_REQUIREMENTS_CMD_LINE_ARGUMENT,
SETUP_DATABASE_CMD_LINE_ARGUMENT
) = pull_variable_from_command_line_arguments(args)

Expand Down Expand Up @@ -329,16 +324,6 @@ def take_user_input_for_string_variable(message, description=None, default_value
print("Feel free to add that feature in or revert to using db.sqlite3")
exit(1)

WALL_E_MODEL_PATH = WALL_E_MODEL_PATH_CMD_LINE_ARGUMENT
while WALL_E_MODEL_PATH is None or not os.path.exists(WALL_E_MODEL_PATH):
WALL_E_MODEL_PATH = get_string_variables(
"Please specify the relative/absolute path for the wall_e_model in the form /path/to/wall_e_model/repo",
"WALL_E_MODEL_PATH",
command_line_argument=WALL_E_MODEL_PATH, overwrite_env=overwrite_env_file,
default_value=WALL_E_MODEL_PATH
)
if WALL_E_MODEL_PATH is not None and not os.path.exists(WALL_E_MODEL_PATH):
print(f"path {WALL_E_MODEL_PATH} does not exist")
LAUNCH_WALL_E = get_boolean_variable(
"Do you you want this script to launch wall_e? [the alternative is to use PyCharm]", "LAUNCH_WALL_E",
command_line_argument=LAUNCH_WALL_E_CMD_LINE_ARGUMENT, overwrite_env=overwrite_env_file
Expand Down Expand Up @@ -396,7 +381,7 @@ def take_user_input_for_string_variable(message, description=None, default_value

essential_variables_are_null = check_for_null_variables(
basic_config__TOKEN=basic_config__TOKEN, basic_config__GUILD_ID=basic_config__GUILD_ID,
basic_config__DOCKERIZED=basic_config__DOCKERIZED, WALL_E_MODEL_PATH=WALL_E_MODEL_PATH
basic_config__DOCKERIZED=basic_config__DOCKERIZED
)
if essential_variables_are_null[0]:
raise Exception(f"necessary variable {essential_variables_are_null[1]} is None")
Expand Down Expand Up @@ -447,7 +432,6 @@ def take_user_input_for_string_variable(message, description=None, default_value
with open(RUN_ENV_FILE_LOCATION, "w") as f:
f.seek(0)
f.write(f"""LAUNCH_WALL_E='{LAUNCH_WALL_E}'
WALL_E_MODEL_PATH='{WALL_E_MODEL_PATH}'
POSTGRES_PASSWORD='postgres_passwd'
ORIGIN_IMAGE='sfucsssorg/wall_e'
HELP_SELECTED='0'
Expand Down
1 change: 1 addition & 0 deletions .wall_e_models
Submodule .wall_e_models added at ff6526
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ COPY CI/validate_and_deploy/2_deploy/create-database.ddl .

COPY CI/validate_and_deploy/2_deploy/server_scripts/wait-for-postgres.sh .

COPY CI/validate_and_deploy/2_deploy/server_scripts/wall_e_models_requirement.txt .

RUN apk add --no-cache tzdata # https://github.com/docker-library/postgres/issues/220

CMD ["./wait-for-postgres.sh", "db", "python", "./main.py" ]
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ if [[ "${basic_config__ENVIRONMENT}" == "TEST" ]]; then
--set=WALL_E_DB_PASSWORD="${database_config__WALL_E_DB_PASSWORD}" \
--set=WALL_E_DB_DBNAME="${database_config__WALL_E_DB_DBNAME}" \
-h "$host" -U "postgres" -f "${HOME_DIR}"/create-database.ddl
python3 -m pip install -r ../CI/validate_and_deploy/2_deploy/server_scripts/wall_e_models_requirement.txt
python3 django_manage.py migrate
wget https://dev.sfucsss.org/wall_e/fixtures/banrecords.json
wget https://dev.sfucsss.org/wall_e/fixtures/commandstats.json
Expand All @@ -45,7 +44,6 @@ if [[ "${basic_config__ENVIRONMENT}" == "TEST" ]]; then
rm -r /wall_e || true
fi

python3 -m pip install -r wall_e_models_requirement.txt
python3 django_manage.py migrate

exec $cmd
Expand Down

This file was deleted.

12 changes: 5 additions & 7 deletions run_walle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ fi

# need to delete and re-create so that the if statement that tries to detected if the
# help menu was invoked can work correctly
cat ./CI/validate_and_deploy/2_deploy/user_scripts/run_wall_e.env | grep -v HELP_SELECTED > ./CI/validate_and_deploy/2_deploy/user_scripts/run_wall_e.env.2
mv ./CI/validate_and_deploy/2_deploy/user_scripts/run_wall_e.env.2 ./CI/validate_and_deploy/2_deploy/user_scripts/run_wall_e.env
if [ -f "CI/validate_and_deploy/2_deploy/user_scripts/run_wall_e.env" ]; then
cat ./CI/validate_and_deploy/2_deploy/user_scripts/run_wall_e.env | grep -v HELP_SELECTED > ./CI/validate_and_deploy/2_deploy/user_scripts/run_wall_e.env.2
mv ./CI/validate_and_deploy/2_deploy/user_scripts/run_wall_e.env.2 ./CI/validate_and_deploy/2_deploy/user_scripts/run_wall_e.env
fi

./.run_walle.py $@

Expand Down Expand Up @@ -42,11 +44,7 @@ else
python3 -m pip install -r layer-2-requirements.txt
rm layer-1-requirements.txt layer-2-requirements.txt
python3 -m pip install -r requirements.txt
python3 -m pip install -r ../CI/validate_and_deploy/2_deploy/server_scripts/wall_e_models_requirement.txt
python3 -m pip uninstall -y wall_e_models
fi
if [ ! -f 'wall_e_models' ]; then
ln -sn "${WALL_E_MODEL_PATH}/wall_e_models" wall_e_models || true
python3 -m pip install -r ../.wall_e_models/requirements.txt
fi

if [[ "${SETUP_DATABASE}" == "True" ]]; then
Expand Down
1 change: 1 addition & 0 deletions wall_e/wall_e_models

0 comments on commit 585b272

Please sign in to comment.