From 347bdad7a6264e5a5c0cf5483fda99024242dbe0 Mon Sep 17 00:00:00 2001 From: aaronburtle <93220300+aaronburtle@users.noreply.github.com> Date: Fri, 12 Jul 2024 13:52:03 -0700 Subject: [PATCH] Add SQL Server 2022 workflow contained on runner VM with Python (#118) * pthon installation * configure python for MLS * add python client install and tests * add env variable passwords * add some doc links use most recent python install version * whitspace/format * add logging for python installation * add passive for python install * try remove previous python installs * using python-setup * new strategy for Python installation * use github native python path * add explicit user and pw * add explicit user and pw * add explicit user and pw * add explicit user and pw * add explicit user and pw * update some names continueOnError --- .github/workflows/SQL2022.yml | 50 ++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/.github/workflows/SQL2022.yml b/.github/workflows/SQL2022.yml index 7046d4e..e3895ed 100644 --- a/.github/workflows/SQL2022.yml +++ b/.github/workflows/SQL2022.yml @@ -96,6 +96,7 @@ jobs: USE AirlineTestDB; ALTER AUTHORIZATION ON SCHEMA::[db_owner] TO [AirlineUserdbowner]" + # https://learn.microsoft.com/sql/machine-learning/install/sql-machine-learning-services-windows-install-sql-2022?view=sql-server-ver16#setup-r-support - name: Install R for MLS run: | curl -L -o R-4.2.0-win.exe https://cloud.r-project.org/bin/windows/base/old/4.2.0/R-4.2.0-win.exe @@ -110,6 +111,26 @@ jobs: - name: Configure the R runtime installed for MLS with SQL Server run: C:\MLS\R\library\RevoScaleR\rxLibs\x64\RegisterRext.exe /configure /rhome:"C:\MLS\R" /instance:"MSSQLSERVER" + - name: Set up Python ${{ env.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ env.python-version }} + + - name: Install revoscalepy and dependencies + working-directory: ${{ env.Python3_ROOT_DIR }} + run: | + python -m pip install -t "${{ env.Python3_ROOT_DIR }}\Lib\site-packages" dill numpy==1.22.0 pandas patsy python-dateutil + python -m pip install -t "${{ env.Python3_ROOT_DIR }}\Lib\site-packages" https://aka.ms/sqlml/python3.10/windows/revoscalepy-10.0.1-py3-none-any.whl + + - name: Grant READ/EXECUTE access to installed libraries + run: | + icacls "${{ env.Python3_ROOT_DIR }}\Lib\site-packages" /grant "NT Service\MSSQLLAUNCHPAD":(OI)(CI)RX /T + icacls "${{ env.Python3_ROOT_DIR }}\Lib\site-packages" /grant *S-1-15-2-1:(OI)(CI)RX /T + + - name: Configure the Python runtime installed for MLS with SQL Server + working-directory: ${{ env.Python3_ROOT_DIR }}\Lib\site-packages\revoscalepy\rxLibs + run: .\RegisterRext.exe /configure /pythonhome:"${{ env.Python3_ROOT_DIR }}" /instance:"MSSQLSERVER" + - name: Enable External Scripts run: sqlcmd -S localhost -U SA -P %dbPassword% -Q "EXEC sp_configure 'external scripts enabled', 1;" @@ -122,7 +143,7 @@ jobs: timeout /t 5 /nobreak net start "MSSQLSERVER" - - name: Execute SPEES for R + - name: Execute sp_execute_external_script for R run: sqlcmd -S localhost -U SA -P %dbPassword% -l 5 -Q " EXEC sp_execute_external_script @language =N'R', @script=N' @@ -131,6 +152,12 @@ jobs: @input_data_1 =N'SELECT 1 AS hello' WITH RESULT SETS (([hello] int not null));" + - name: Execute sp_execute_external_script for Python + run: sqlcmd -S localhost -U SA -P %dbPassword% -l 5 -Q " + EXEC sp_execute_external_script @language =N'Python', + @script=N'OutputDataSet = InputDataSet;', + @input_data_1 =N'SELECT 1 AS hello' WITH RESULT SETS (([hello] int not null));" + - name: Set up R ${{ env.r-version }} Runtime uses: r-lib/actions/setup-r@v2 with: @@ -154,3 +181,24 @@ jobs: env: PASSWORD_AIRLINE_USER: "${{ env.dbPassword }}" PASSWORD_AIRLINE_USER_DBOWNER: "${{ env.dbPassword }}" + + - name: Install Python dependencies + working-directory: ./Python + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest + pip install -r requirements.txt + + - name: Build Python Package + working-directory: ./Python + run: ./buildandinstall.cmd + + - name: Run pytest + working-directory: ./Python/tests + run: | + pytest + env: + USER: "AirlineUserdbowner" + PASSWORD: "${{ env.dbPassword }}" + PASSWORD_AIRLINE_USER: "${{ env.dbPassword }}" + continue-on-error: true