Skip to content

Commit

Permalink
fixed <3.10 type hinting bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Filimoa committed Apr 8, 2024
1 parent 06509d1 commit 07b21ea
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 5 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Publish Python 🐍 distribution 📦 to PyPI

on: push

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/openparse
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
name: >-
Sign the Python 🐍 distribution 📦 with Sigstore
and upload them to GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest

permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes ""
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="openparse",
version="0.5.0",
version="0.5.1",
entry_points={
"console_scripts": [
"openparse-download= openparse.cli:download_unitable_weights",
Expand Down
8 changes: 4 additions & 4 deletions src/openparse/processing/semantic_transforms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Literal, Dict
from typing import List, Literal, Dict, Union

import numpy as np

Expand All @@ -11,7 +11,7 @@


def cosine_similarity(
a: np.ndarray | list[float], b: np.ndarray | list[float]
a: Union[np.ndarray, List[float]], b: Union[np.ndarray, List[float]]
) -> float:
return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))

Expand All @@ -36,7 +36,7 @@ def __init__(
self.batch_size = batch_size
self.client = self._create_client()

def embed_many(self, texts: list[str]) -> List[List[float]]:
def embed_many(self, texts: List[str]) -> List[List[float]]:
"""
Generate embeddings for a list of texts in batches.
Expand Down Expand Up @@ -111,7 +111,7 @@ def process(self, nodes: List[Node]) -> List[Node]:

return nodes

def _get_node_similarities(self, nodes: list[Node]) -> list[float]:
def _get_node_similarities(self, nodes: List[Node]) -> List[float]:
"""
Get the similarity of each node with the node that precedes it
"""
Expand Down

0 comments on commit 07b21ea

Please sign in to comment.