Skip to content

Commit

Permalink
Update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
bnmoch3 committed Feb 27, 2024
1 parent 8e9c3a6 commit f674b81
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# This file is autogenerated by maturin v1.4.0
# To update, run
#
# maturin generate-ci github
#
name: CI

on:
push:
branches:
- main
- master
tags:
- "*"
- "v[0-9]+.[0-9]+.[0-9]+"
pull_request:
workflow_dispatch:

Expand All @@ -21,31 +27,13 @@ env:
RUSTFLAGS: "-Dwarnings"

jobs:
linux_tests:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64]
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Set up Rust
run: rustup show
- uses: mozilla-actions/sccache-action@v0.0.3
- run: python3 -m venv venv
- run: cargo fmt --all && cargo clippy --all-features
- run: maturin develop
- run: pytest

linux:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, x86, aarch64, armv7]
env:
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: 1
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand Down Expand Up @@ -126,12 +114,12 @@ jobs:

release:
name: Release
if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, windows, macos, sdist]
runs-on: ubuntu-latest
environment: pypi
if: "startsWith(github.ref, 'refs/tags/v')"
needs: [linux, windows, macos, sdist]
environment: release
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polars_fuzzy_match"
version = "0.1.0"
version = "0.1.2"
edition = "2021"

[lib]
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.SILENT:
.DEFAULT_GOAL:=dev

.PHONY: run build-dev clean format
.PHONY: run build-dev clean format lint
dev: build-dev
python examples/usage.py

Expand All @@ -13,6 +13,10 @@ build-dev: .build-dev

format:
ruff format polars_fuzzy_match/
cargo fmt --all

lint:
cargo clippy --all-features

clean:
rm .build-dev
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ requires-python = ">=3.10"
"Change Log" = "https://github.com/bnm3k/polars-fuzzy-match/releases"
"Issue Tracker" = "https://github.com/bnm3k/polars-fuzzy-match/issues"

[build-system]
requires = ["maturin>=1.0,<2.0", "polars>=0.20.6"]
build-backend = "maturin"

[tool.ruff]
line-length = 80
Expand Down
5 changes: 3 additions & 2 deletions src/fuzzy_match.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::unused_unit)]
use polars::prelude::*;
use pyo3_polars::derive::polars_expr;
use pyo3_polars::export::polars_core::utils::CustomIterTools;
Expand Down Expand Up @@ -50,7 +51,7 @@ pub enum PatternCaseMatching {
// exact match
#[polars_expr(output_type=UInt32)]
fn fuzzy_match_score(haystack: &[Series], kwargs: FuzzyMatchKwargs) -> PolarsResult<Series> {
let ca = (&haystack[0]).str()?;
let ca = haystack[0].str()?;

// config
let config = nucleo::Config::DEFAULT;
Expand All @@ -62,7 +63,7 @@ fn fuzzy_match_score(haystack: &[Series], kwargs: FuzzyMatchKwargs) -> PolarsRes
.map(|v: Option<&str>| {
if let Some(s) = v {
let haystack = Utf32Str::new(s, &mut buf);
pattern.score(haystack, &mut matcher).map(|v| v as u32)
pattern.score(haystack, &mut matcher)
} else {
None
}
Expand Down

0 comments on commit f674b81

Please sign in to comment.