From 83a6050c5e2690ce3182af4f2d39fa42f60a7394 Mon Sep 17 00:00:00 2001 From: Grieve Date: Fri, 13 Dec 2024 11:32:08 +0800 Subject: [PATCH] chore: merge just commands (#982) --- .github/workflows/ibis-ci.yml | 2 -- .github/workflows/stable-release.yml | 2 +- ibis-server/Dockerfile | 7 +++++-- ibis-server/README.md | 2 +- ibis-server/docs/development.md | 26 ++++++++++++++++++++------ ibis-server/justfile | 12 +++++------- wren-core-py/justfile | 7 +++++-- 7 files changed, 37 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ibis-ci.yml b/.github/workflows/ibis-ci.yml index 239f964cf..8c7e35ec8 100644 --- a/.github/workflows/ibis-ci.yml +++ b/.github/workflows/ibis-ci.yml @@ -64,8 +64,6 @@ jobs: - name: Install dependencies run: | just install - just install-core - just update-core - name: Run tests env: WREN_ENGINE_ENDPOINT: http://localhost:8080 diff --git a/.github/workflows/stable-release.yml b/.github/workflows/stable-release.yml index 817e9122a..cfd9433a0 100644 --- a/.github/workflows/stable-release.yml +++ b/.github/workflows/stable-release.yml @@ -155,7 +155,7 @@ jobs: labels: ${{ steps.meta.outputs.labels }} context: ./ibis-server build-args: | - RUST_PROFILE=--release + ENV=prod build-contexts: | wren-core-py=./wren-core-py wren-core=./wren-core diff --git a/ibis-server/Dockerfile b/ibis-server/Dockerfile index 757d3240a..2b96a8849 100644 --- a/ibis-server/Dockerfile +++ b/ibis-server/Dockerfile @@ -1,5 +1,9 @@ FROM python:3.11-buster AS builder -ARG RUST_PROFILE + +ARG ENV +ENV ENV=$ENV + + # libpq-dev is required for psycopg2 RUN apt-get update && apt-get -y install libpq-dev @@ -30,7 +34,6 @@ COPY --from=wren-core . /wren-core WORKDIR /app COPY . . RUN just install --without dev -RUN just install-core $RUST_PROFILE FROM python:3.11-slim-buster AS runtime diff --git a/ibis-server/README.md b/ibis-server/README.md index ea7afc581..1d4c6d8b3 100644 --- a/ibis-server/README.md +++ b/ibis-server/README.md @@ -71,7 +71,7 @@ vim .env ``` Install the dependencies ```bash -just install && just install-core +just install ``` Run the server ```bash diff --git a/ibis-server/docs/development.md b/ibis-server/docs/development.md index 71a056a39..1b186f338 100644 --- a/ibis-server/docs/development.md +++ b/ibis-server/docs/development.md @@ -1,8 +1,9 @@ # Development -This document describes the process for running this application on your local computer. +This document describes the process for running this application on your local computer. ## Getting started + This application is powered by Python and Rust! :sparkles: :snake: :gear: :sparkles: It runs on macOS, Windows, and Linux environments. @@ -12,63 +13,76 @@ You'll need `Python 3.11` to run the application. To install Python, [download t You'll also need `Rust` and `Cargo`. To install them, follow the instructions on the [Rust installation page](https://www.rust-lang.org/tools/install). Next, install the following tools: + - [poetry](https://github.com/python-poetry/poetry) - [casey/just](https://github.com/casey/just) - [pre-commit](https://pre-commit.com) - [taplo](https://github.com/tamasfe/taplo) After installing these tools, run: + ```shell just pre-commit-install ``` -This installs the pre-commit hooks. +This installs the pre-commit hooks. ## Start the server + To get the application running: + 1. Execute `just install` to install the dependencies -2. Execute `just install-core` to Install the core. If you modify the core, you can update it by `just update-core`. +2. If you modified the core, you can install it into python venv by `just install-core`. 3. Create a `.env` file and fill in the required environment variables (see [Environment Variables](#Environment-Variables)) To start the server: + - Execute `just run` to start the server - Execute `just dev` to start the server in development mode (auto-reloads on code changes) - The default port is `8000`. You can change it by running `just port=8001 run` or `just port=8001 dev` ### Docker + - Build the image: `just docker-build` - Run the container: `just docker-run` ### Run the testing + - Prepare the Java Engine server (see [Java Engine Example](../../example/README.md)) - Use the `.env` file to set the `WREN_ENGINE_ENDPOINT` environment variable to change the endpoint of the Java Engine server. ``` WREN_ENGINE_ENDPOINT=http://localhost:8080 ``` More information about the environment variables can be found in the [Environment Variables](#Environment-Variables) section. -- Run specific data source test using [pytest marker](https://docs.pytest.org/en/stable/example/markers.html). There are some markers for different data sources. See the list in [pyproject.toml](../pyproject.toml). +- Run specific data source test using [pytest marker](https://docs.pytest.org/en/stable/example/markers.html). There are some markers for different data sources. See the list + in [pyproject.toml](../pyproject.toml). ``` just test postgres ``` ### Environment Variables -- `WREN_ENGINE_ENDPOINT`: The endpoint of the Wren Java engine +- `WREN_ENGINE_ENDPOINT`: The endpoint of the Wren Java engine ## How to add new data source -Please see [How to Add a New Data Source](how-to-add-data-source.md) for more information. +Please see [How to Add a New Data Source](how-to-add-data-source.md) for more information. ## Troubleshooting + ### No driver for MS SQL Server + If you want to run tests related to MS SQL Server, you may need to install the `Microsoft ODBC 18 driver`. \ You can follow the instructions to install the driver: + - [Microsoft ODBC driver for SQL Server (Linux)](https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server). - [Microsoft ODBC driver for SQL Server (macOS)](https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos). - [Microsoft ODBC driver for SQL Server (Windows)](https://learn.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server). ### [ODBC Driver 18 for SQL Server]SSL Provider: [error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:self signed certificate] + If you encounter this error, you can add the `TrustServerCertificate` parameter to the connection string. + ```json { "connectionInfo": { diff --git a/ibis-server/justfile b/ibis-server/justfile index ebbab49aa..93ae82314 100644 --- a/ibis-server/justfile +++ b/ibis-server/justfile @@ -1,21 +1,19 @@ default: @just --list --unsorted -build-core *args: - cd ../wren-core-py && just install && just build {{ args }} +build-core: + cd ../wren-core-py && just install && just build core-wheel-path := "../wren-core-py/target/wheels/wren_core_py-*.whl" -install-core *args: - just build-core {{ args }} +install-core: + just build-core # Using pip install to avoid adding wheel to pyproject.toml - poetry run pip install {{ core-wheel-path }} - -update-core: build-core poetry run pip install --force-reinstall {{ core-wheel-path }} install *args: poetry install {{ args }} + just install-core pre-commit-install: poetry run pre-commit install diff --git a/wren-core-py/justfile b/wren-core-py/justfile index b92ce90ee..b5cfc038e 100644 --- a/wren-core-py/justfile +++ b/wren-core-py/justfile @@ -4,8 +4,11 @@ default: install: poetry install --no-root -build *args: - poetry run maturin build {{ args }} +env := env("ENV", "dev") +release_flag := if env == "prod" { "--release" } else { "" } + +build: + poetry run maturin build {{ release_flag }} develop: poetry run maturin develop