Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
6 changes: 5 additions & 1 deletion .github/actions/project-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ inputs:
description: "Additional Rust target to install"
required: false
default: ""
python_version:
description: "Python version to use"
required: false
default: "3.13"

runs:
using: "composite"
Expand All @@ -23,7 +27,7 @@ runs:
# Python
- uses: actions/setup-python@v5
with:
python-version: "3.13"
python-version: ${{ inputs.python_version }}

# ----- OS-Specific System Dependencies -----

Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/ci-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: ci

on:
push:
branches: [main]
paths:
- encoderfile-py/**
pull_request:
paths:
- encoderfile-py/**
workflow_dispatch:

jobs:
test_python:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Project setup
uses: ./.github/actions/project-setup
with:
# use MSRV
python_version: "3.10"

- name: Install Maturin
run: |
cargo binstall maturin --force --disable-telemetry
ls -la /home/runner/.cargo/bin/

- name: Build rs (debug)
run: cargo build --locked

- name: Maturin develop
run: |
ls -la /home/runner/.cargo/bin/
just build-py

- name: Test
run: just test-py

- name: Stubtest
run: just stubtest
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ cython_debug/
.abstra/

# Visual Studio Code
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
# and can be added to the global gitignore or merged into this file. However, if you prefer,
# and can be added to the global gitignore or merged into this file. However, if you prefer,
# you could uncomment the following to ignore the entire vscode folder
# .vscode/

Expand Down
26 changes: 17 additions & 9 deletions Justfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export PATH := "/home/runner/.cargo/bin" + env_var("PATH")
# Setup
setup:
@echo "creating .venv"
Expand All @@ -18,11 +19,11 @@ check:
@cargo hack check --each-feature

coverage:
@cargo llvm-cov \
--workspace \
--all-features \
--lcov \
--output-path lcov.info
@cargo llvm-cov \
--workspace \
--all-features \
--lcov \
--output-path lcov.info

pre-commit:
@uv run --dev pre-commit run --all-files
Expand Down Expand Up @@ -51,6 +52,12 @@ lint-py:
# ruff check
@uv run ruff check

test-py:
@uv run \
--dev \
--directory encoderfile-py \
-m pytest

stubtest:
@uv run \
--dev \
Expand All @@ -71,19 +78,20 @@ generate-docs:
--all-features

licenses:
@echo "Generating licenses..."
@cargo about generate about.hbs > THIRDPARTY.md
@echo "Generating licenses..."
@cargo about generate about.hbs > THIRDPARTY.md

# Utilities

target_max_mb := "2000"

clean:
#!/usr/bin/env bash
if [ -d target ]; then
target_size_mb=$(du -sm target | cut -f1)
echo "target/ size: ${target_size_mb} MB"
if [ "${target_size_mb}" -gt "{{target_max_mb}}" ]; then
echo "target/ exceeds {{target_max_mb}} MB — running cargo clean..."
if [ "${target_size_mb}" -gt "{{ target_max_mb }}" ]; then
echo "target/ exceeds {{ target_max_mb }} MB — running cargo clean..."
cargo clean
else
echo "target/ size within limits — skipping clean."
Expand Down
3 changes: 2 additions & 1 deletion encoderfile-py/python/encoderfile/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from encoderfile import run_cli
import sys

from encoderfile import run_cli # type: ignore

if __name__ == "__main__":
args = ["encoderfile"] + sys.argv[1:]

Expand Down
6 changes: 3 additions & 3 deletions encoderfile-py/python/tests/assets/test_config.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
encoderfile:
name: my-model-2
path: models/token_classification
path: ../models/token_classification
model_type: token_classification
output_path: /tmp/test-model.encoderfile
base_binary_path: ./target/debug/encoderfile-runtime
base_binary_path: ../target/debug/encoderfile-runtime
transform: |
--- Applies a softmax across token classification logits.
--- Each token classification is normalized independently.
---
---
--- Args:
--- arr (Tensor): A tensor of shape [batch_size, n_tokens, n_labels].
--- The softmax is applied along the third axis (n_labels).
Expand Down
6 changes: 3 additions & 3 deletions encoderfile-py/python/tests/assets/test_config_lua.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
encoderfile:
name: my-model-2-lua
path: models/token_classification
path: ../models/token_classification
model_type: token_classification
output_path: /tmp/test-model-lua.encoderfile
base_binary_path: ./target/debug/encoderfile-runtime
base_binary_path: ../target/debug/encoderfile-runtime
lua_libs:
- table
- math
transform: |
--- Applies a softmax across token classification logits.
--- Each token classification is normalized independently.
---
---
--- Args:
--- arr (Tensor): A tensor of shape [batch_size, n_tokens, n_labels].
--- The softmax is applied along the third axis (n_labels).
Expand Down
Loading
Loading