Skip to content

Commit

Permalink
add windows dev setup
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobweiss2305 committed May 7, 2024
1 parent 1302da0 commit 5de5f48
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 28 deletions.
21 changes: 14 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,24 @@ Please follow the [fork and pull request](https://docs.github.com/en/get-started
## Development setup

1. Clone the repository.
2. Create a virtual environment using the `./scripts/create_venv.sh` script. This will:
- Create a `phienv` virtual environment in the current directory.
- Install the required packages.
- Install the `phidata` package in editable mode.
3. Activate the virtual environment using `source phienv/bin/activate`.
2. Create a virtual environment:
- For Unix, use `./scripts/create_venv.sh`.
- For Windows, use `.\scripts\create_venv_win.bat`.
- This setup will:
- Create a `phienv` virtual environment in the current directory.
- Install the required packages.
- Install the `phidata` package in editable mode.
3. Activate the virtual environment:
- On Unix: `source phienv/bin/activate`
- On Windows: `phienv\Scripts\activate`

## Formatting and validation

We provide a `./scripts/format.sh` script that runs `ruff`, `mypy` and `pytest`.
Ensure your code meets our quality standards by running the appropriate formatting and validation script before submitting a pull request:
- For Unix: `./scripts/format.sh`
- For Windows: `.\scripts\format.bat`
These scripts will perform code formatting with `ruff`, static type checks with `mypy`, and run unit tests with `pytest`.

Please run this script before submitting a pull request.

## Adding a new Vector Database

Expand Down
25 changes: 25 additions & 0 deletions scripts/_utils.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@echo off
:: Collection of helper functions to import in other scripts

:: Function to pause the script until a key is pressed
:space_to_continue
echo Press any key to continue...
pause > nul
goto :eof

:: Function to print a horizontal line
:print_horizontal_line
echo ------------------------------------------------------------
goto :eof

:: Function to print a heading with horizontal lines
:print_heading
call :print_horizontal_line
echo -*- %~1
call :print_horizontal_line
goto :eof

:: Function to print a status message
:print_status
echo -*- %~1
goto :eof
39 changes: 39 additions & 0 deletions scripts/create_venv_win.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@echo off
setlocal

set "CURR_DIR=%~dp0"
set "REPO_ROOT=%~dp0.."
set "VENV_DIR=%REPO_ROOT%\phienv"

call "%CURR_DIR%_utils.bat"

echo phidata dev setup
echo Creating venv: %VENV_DIR%

echo Removing existing venv: %VENV_DIR%
rd /s /q "%VENV_DIR%"

echo Creating python3 venv: %VENV_DIR%
python -m venv "%VENV_DIR%"

echo Upgrading pip to the latest version
call "%VENV_DIR%\Scripts\python.exe" -m pip install --upgrade pip
if %ERRORLEVEL% neq 0 (
echo Failed to upgrade pip. Please run the script as Administrator or check your network connection.
exit /b %ERRORLEVEL%
)

echo Installing base python packages
call "%VENV_DIR%\Scripts\pip" install pip-tools twine build
if %ERRORLEVEL% neq 0 (
echo Failed to install required packages. Attempting to retry installation...
call "%VENV_DIR%\Scripts\pip" install pip-tools twine build
)

:: Install workspace
call "%VENV_DIR%\Scripts\activate"
call "%CURR_DIR%install.bat"

echo Activate using: call %VENV_DIR%\Scripts\activate

endlocal
45 changes: 45 additions & 0 deletions scripts/format.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@echo off

:: Formats phidata

:: Usage:
:: .\scripts\format.bat

set "CURR_DIR=%~dp0"
set "REPO_ROOT=%~dp0.."

:: Ensure that _utils.bat is correctly located and called
call "%CURR_DIR%\_utils.bat"

:main
call :print_heading "Formatting phidata"

call :print_heading "Running: ruff format %REPO_ROOT%"
call "%REPO_ROOT%\phienv\Scripts\ruff" format "%REPO_ROOT%"
if %ERRORLEVEL% neq 0 (
echo Failed to format with ruff.
goto :eof
)

call :print_heading "Running: ruff check %REPO_ROOT%"
call "%REPO_ROOT%\phienv\Scripts\ruff" check "%REPO_ROOT%"
if %ERRORLEVEL% neq 0 (
echo Failed ruff check.
goto :eof
)

call :print_heading "Running: mypy %REPO_ROOT%"
call "%REPO_ROOT%\phienv\Scripts\mypy" "%REPO_ROOT%"
if %ERRORLEVEL% neq 0 (
echo Failed mypy check.
goto :eof
)

call :print_heading "Running: pytest %REPO_ROOT%"
call "%REPO_ROOT%\phienv\Scripts\pytest" "%REPO_ROOT%"
if %ERRORLEVEL% neq 0 (
echo Failed pytest.
goto :eof
)

goto :eof
19 changes: 19 additions & 0 deletions scripts/install.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@echo off
:: Install phidata
:: Usage:
:: .\scripts\install.bat

set "CURR_DIR=%~dp0"
set "REPO_ROOT=%~dp0.."
call "%CURR_DIR%_utils.bat"

:main
call :print_heading "Installing phidata"

call :print_heading "Installing requirements.txt"
call "%REPO_ROOT%\phienv\Scripts\pip" install --no-deps -r "%REPO_ROOT%\requirements.txt"

call :print_heading "Installing phidata with [dev] extras"
call "%REPO_ROOT%\phienv\Scripts\pip" install --editable "%REPO_ROOT%[dev]"

goto :eof
35 changes: 14 additions & 21 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
#!/bin/bash
@echo off
:: Install phidata
:: Usage:
:: .\scripts\install.bat

############################################################################
#
# Install phidata
# Usage:
# ./scripts/install.sh
#
############################################################################
set "CURR_DIR=%~dp0"
set "REPO_ROOT=%~dp0.."
call "%CURR_DIR%_utils.bat"

CURR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$( dirname ${CURR_DIR} )"
source ${CURR_DIR}/_utils.sh
:main
call :print_heading "Installing phidata"

main() {
print_heading "Installing phidata"
call :print_heading "Installing requirements.txt"
call "%REPO_ROOT%\phienv\Scripts\pip" install --no-deps -r "%REPO_ROOT%\requirements.txt"

print_heading "Installing requirements.txt"
pip install --no-deps \
-r ${REPO_ROOT}/requirements.txt
call :print_heading "Installing phidata with [dev] extras"
call "%REPO_ROOT%\phienv\Scripts\pip" install --editable "%REPO_ROOT%[dev]"

print_heading "Installing phidata with [dev] extras"
pip install --editable "${REPO_ROOT}[dev]"
}

main "$@"
goto :eof

0 comments on commit 5de5f48

Please sign in to comment.