Skip to content

Commit

Permalink
remove symlinks and update scripts with paths relative to its own fol…
Browse files Browse the repository at this point in the history
…der instead of cwd
  • Loading branch information
1yefuwang1 committed Sep 5, 2024
1 parent 625866f commit 1de75f5
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 23 deletions.
1 change: 0 additions & 1 deletion aca-host/app

This file was deleted.

8 changes: 4 additions & 4 deletions aca-host/azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,22 @@ hooks:
preprovision:
windows:
shell: pwsh
run: ./scripts/auth_init.ps1
run: ../scripts/auth_init.ps1
interactive: true
continueOnError: false
posix:
shell: sh
run: ./scripts/auth_init.sh
run: ../scripts/auth_init.sh
interactive: true
continueOnError: false
postprovision:
windows:
shell: pwsh
run: ./scripts/auth_update.ps1;./scripts/prepdocs.ps1
run: ../scripts/auth_update.ps1; ../scripts/prepdocs.ps1
interactive: true
continueOnError: false
posix:
shell: sh
run: ./scripts/auth_update.sh;./scripts/prepdocs.sh
run: ../scripts/auth_update.sh; ../scripts/prepdocs.sh
interactive: true
continueOnError: false
1 change: 0 additions & 1 deletion aca-host/data

This file was deleted.

1 change: 0 additions & 1 deletion aca-host/scripts

This file was deleted.

9 changes: 7 additions & 2 deletions scripts/adlsgen2setup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/sh

. ./scripts/loadenv.sh
# Get the project root of the current script
project_root="$(cd "$(dirname $(dirname $0))" && pwd)"
script_dir="$project_root/scripts"
data_dir="$project_root/data"

. $script_dir/loadenv.sh

if [ -n "$AZURE_ADLS_GEN2_STORAGE_ACCOUNT" ]; then
echo 'AZURE_ADLS_GEN2_STORAGE_ACCOUNT must be set to continue'
Expand All @@ -9,4 +14,4 @@ fi

echo 'Running "adlsgen2setup.py"'

./.venv/bin/python ./scripts/adlsgen2setup.py './data/*' --data-access-control './scripts/sampleacls.json' --storage-account "$AZURE_ADLS_GEN2_STORAGE_ACCOUNT" -v
./.venv/bin/python $script_dir/adlsgen2setup.py "$data_dir/*" --data-access-control "$script_dir/sampleacls.json" --storage-account "$AZURE_ADLS_GEN2_STORAGE_ACCOUNT" -v
11 changes: 8 additions & 3 deletions scripts/auth_init.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/bin/sh

# Get the project root of the current script
project_root="$(cd "$(dirname $(dirname $0))" && pwd)"
script_dir="$project_root/scripts"
data_dir="$project_root/data"

echo "Checking if authentication should be setup..."

. ./scripts/load_azd_env.sh
. $script_dir/load_azd_env.sh

if [ -z "$AZURE_USE_AUTHENTICATION" ]; then
echo "AZURE_USE_AUTHENTICATION is not set, skipping authentication setup."
Expand All @@ -11,6 +16,6 @@ fi

echo "AZURE_USE_AUTHENTICATION is set, proceeding with authentication setup..."

. ./scripts/load_python_env.sh
. $script_dir/load_python_env.sh

./.venv/bin/python ./scripts/auth_init.py
./.venv/bin/python $script_dir/auth_init.py
10 changes: 7 additions & 3 deletions scripts/auth_update.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#!/bin/sh

. ./scripts/load_azd_env.sh
# Get the project root of the current script
project_root="$(cd "$(dirname $(dirname $0))" && pwd)"
script_dir="$project_root/scripts"

. $script_dir/load_azd_env.sh

if [ -z "$AZURE_USE_AUTHENTICATION" ]; then
exit 0
fi

. ./scripts/load_python_env.sh
. $script_dir/load_python_env.sh

./.venv/bin/python ./scripts/auth_update.py
./.venv/bin/python $script_dir/auth_update.py
8 changes: 6 additions & 2 deletions scripts/load_python_env.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#!/bin/sh
#!/bin/sh

# Get the project root of the current script
project_root="$(cd "$(dirname $(dirname $0))" && pwd)"
app_dir="$project_root/app"

echo 'Creating Python virtual environment "app/backend/.venv"...'
python3 -m venv .venv

echo 'Installing dependencies from "requirements.txt" into virtual environment (in quiet mode)...'
.venv/bin/python -m pip --quiet --disable-pip-version-check install -r app/backend/requirements.txt
.venv/bin/python -m pip --quiet --disable-pip-version-check install -r $app_dir/backend/requirements.txt
8 changes: 6 additions & 2 deletions scripts/loadenv.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/sh

. ./scripts/load_azd_env.sh
# Get the project root of the current script
project_root="$(cd "$(dirname $(dirname $0))" && pwd)"
script_dir="$project_root/scripts"

. ./scripts/load_python_env.sh
. $script_dir/load_azd_env.sh

. $script_dir/load_python_env.sh
8 changes: 6 additions & 2 deletions scripts/manageacl.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/sh

. ./scripts/loadenv.sh
# Get the project root of the current script
project_root="$(cd "$(dirname $(dirname $0))" && pwd)"
script_dir="$project_root/scripts"

. $script_dir/loadenv.sh

echo "Running manageacl.py. Arguments to script: $@"
./.venv/bin/python ./scripts/manageacl.py --search-service "$AZURE_SEARCH_SERVICE" --index "$AZURE_SEARCH_INDEX" $@
./.venv/bin/python $script_dir/manageacl.py --search-service "$AZURE_SEARCH_SERVICE" --index "$AZURE_SEARCH_INDEX" $@
10 changes: 8 additions & 2 deletions scripts/prepdocs.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/sh

. ./scripts/loadenv.sh
# Get the project root of the current script
project_root="$(cd "$(dirname $(dirname $0))" && pwd)"
script_dir="$project_root/scripts"
data_dir="$project_root/data"

. $script_dir/loadenv.sh

echo 'Running "prepdocs.py"'

Expand Down Expand Up @@ -74,7 +79,8 @@ if [ $# -gt 0 ]; then
additionalArgs="$@"
fi

./.venv/bin/python ./app/backend/prepdocs.py './data/*' --verbose \

./.venv/bin/python $app_dir/backend/prepdocs.py "$data_dir/*" --verbose \
--subscriptionid $AZURE_SUBSCRIPTION_ID \
--storageaccount "$AZURE_STORAGE_ACCOUNT" --container "$AZURE_STORAGE_CONTAINER" --storageresourcegroup $AZURE_STORAGE_RESOURCE_GROUP \
--searchservice "$AZURE_SEARCH_SERVICE" --index "$AZURE_SEARCH_INDEX" \
Expand Down

0 comments on commit 1de75f5

Please sign in to comment.