Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H-3614: Introduce chonky PDF Embeddings #5673

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ blocks/**/.env
.env.local
.env.*.local

# Generated credentials from google-github-actions/auth
gha-creds-*.json

# macOS directory file
**/.DS_Store

Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ jobs:
fail-fast: false
if: needs.setup.outputs.unit-tests != '{"package":[],"include":[]}'
runs-on: ubuntu-24.04
permissions:
# Required to fetch an OIDC token, used to auth with Google Cloud Platform for @rust/chonky tests
id-token: "write"
# Maintain permission to read repo contents
contents: "read"
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand Down Expand Up @@ -148,6 +153,15 @@ jobs:
rm -rf $temp_dir
echo "PDFIUM_DYNAMIC_LIB_PATH=$(pwd)/${{ matrix.directory }}/libs/" >> $GITHUB_ENV

# Sets GOOGLE_APPLICATION_CREDENTIALS in the environment, to be consumed by gcloud or client libraries
- name: Generate Google Cloud credential configuration
if: matrix.package == '@rust/chonky'
uses: google-github-actions/auth@6fc4af4b145ae7821d527454aa9bd537d1f2dc5f # v2.1.7
with:
project_id: ${{ secrets.GOOGLE_CLOUD_HASH_PROJECT_ID }}
service_account: ${{ secrets.GOOGLE_CLOUD_VERTEX_SERVICE_ACCOUNT }}
workload_identity_provider: ${{ secrets.GOOGLE_CLOUD_IDENTITY_PROVIDER }}

- name: Install Rust toolchain
if: always() && steps.tests.outputs.has-rust == 'true'
uses: ./.github/actions/install-rust-toolchain
Expand Down Expand Up @@ -178,6 +192,10 @@ jobs:
continue-on-error: ${{ steps.tests.outputs.allow-failure == 'true' }}
env:
TEST_COVERAGE: ${{ github.event_name != 'merge_group' }}
# Variables needed for chonky tests
GOOGLE_PROJECT_ID: ${{ secrets.GOOGLE_CLOUD_HASH_PROJECT_ID }}
GOOGLE_DEFAULT_CREDENTIALS: ${{ env.GOOGLE_DEFAULT_CREDENTIALS }} # set by google-github-actions/auth
HUGGING_FACE_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }}
run: |
turbo run test:unit --env-mode=loose --filter "${{ matrix.package }}"
echo "TRIMMED_PACKAGE_NAME=$(echo "${{ matrix.package }}" | sed 's|@||g' | sed 's|/|.|g')" >> $GITHUB_ENV
Expand Down Expand Up @@ -225,6 +243,11 @@ jobs:
fail-fast: false
if: needs.setup.outputs.integration-tests != '{"package":[],"include":[]}'
runs-on: ubuntu-24.04
permissions:
# Required to fetch an OIDC token, used to auth with Google Cloud Platform for @rust/chonky tests
id-token: "write"
# Maintain permission to read repo contents
contents: "read"
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand Down Expand Up @@ -293,6 +316,15 @@ jobs:
rm -rf $temp_dir
echo "PDFIUM_DYNAMIC_LIB_PATH=$(pwd)/${{ matrix.directory }}/libs/" >> $GITHUB_ENV

# Sets GOOGLE_APPLICATION_CREDENTIALS in the environment, to be consumed by gcloud or client libraries
- name: Generate Google Cloud credential configuration
if: matrix.package == '@rust/chonky'
uses: google-github-actions/auth@6fc4af4b145ae7821d527454aa9bd537d1f2dc5f # v2.1.7
with:
project_id: ${{ secrets.GOOGLE_CLOUD_HASH_PROJECT_ID }}
service_account: ${{ secrets.GOOGLE_CLOUD_VERTEX_SERVICE_ACCOUNT }}
workload_identity_provider: ${{ secrets.GOOGLE_CLOUD_IDENTITY_PROVIDER }}

- name: Install playwright
if: matrix.package == '@tests/hash-playwright'
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
Expand Down Expand Up @@ -350,6 +382,11 @@ jobs:

- name: Run tests
continue-on-error: ${{ steps.tests.outputs.allow-failure == 'true' }}
env:
# Variables needed for chonky tests
GOOGLE_PROJECT_ID: ${{ secrets.GOOGLE_CLOUD_HASH_PROJECT_ID }}
GOOGLE_DEFAULT_CREDENTIALS: ${{ env.GOOGLE_DEFAULT_CREDENTIALS }} # set by google-github-actions/auth
HUGGING_FACE_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }}
run: |
turbo run test:integration --env-mode=loose --filter "${{ matrix.package }}"
echo "TRIMMED_PACKAGE_NAME=$(echo "${{ matrix.package }}" | sed 's|@||g' | sed 's|/|.|g')" >> $GITHUB_ENV
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ blocks/**/.env
.env.local
.env.*.local

# Generated credentials from google-github-actions/auth
gha-creds-*.json

# macOS directory file
**/.DS_Store

Expand Down
3 changes: 3 additions & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ blocks/**/.env
.env.local
.env.*.local

# Generated credentials from google-github-actions/auth
gha-creds-*.json

# macOS directory file
**/.DS_Store

Expand Down
67 changes: 66 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ ariadne = { version = "=0.5.0", default-features = false }
aws-types = { version = "=1.3.3", default-features = false }
axum = { version = "0.7.5" }
axum-core = { version = "0.4.3" }
base64 = { version = "=0.22.1" }
bumpalo = { version = "=3.16.0", default-features = false }
bytes = { version = "1.6.0" }
clap_builder = { version = "=4.5.21", default-features = false, features = ["std"] }
Expand Down
10 changes: 9 additions & 1 deletion libs/chonky/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ edition.workspace = true
error-stack = { workspace = true, public = true }

# Public third-party dependencies
base64 = { workspace = true }
clap = { workspace = true, features = ["derive"] }
futures = { workspace = true, features = ["alloc"] }
image = { workspace = true, public = true, features = ["png", "bmp"] }
pdfium-render = { workspace = true, public = true }
num-traits = { workspace = true }
pdfium-render = { workspace = true, features = ["thread_safe"], public = true }
reqwest = { workspace = true, features = ["json"] }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
tokio = { workspace = true, features = ["macros", "rt-multi-thread", "fs"] }

# Private workspace dependencies

Expand Down
Loading
Loading