Skip to content

Commit

Permalink
Merge branch 'master' into bug-fix-3552-document-embeddings-with-cls-…
Browse files Browse the repository at this point in the history
…pooling
  • Loading branch information
fkdosilovic authored Nov 16, 2024
2 parents 3c36200 + 7eb8533 commit a4709ae
Show file tree
Hide file tree
Showing 83 changed files with 1,092 additions and 1,120 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
FLAIR_CACHE_ROOT: ./cache/flair
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
- name: Set up Python 3.9
id: setup-python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.9
- name: Install Torch cpu
run: pip install torch --index-url https://download.pytorch.org/whl/cpu
- name: Install Flair dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: Build the docs using Sphinx and push to gh-pages
runs-on: ubuntu-latest
env:
python-version: 3.8
python-version: 3.9
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ the code should hopefully be easy.

### Setup

Flair requires python-3.8 or higher. To make sure your code also runs on the oldest supported
python version, it is recommended to use python-3.8.x for flair development.
Flair requires python-3.9 or higher. To make sure your code also runs on the oldest supported
python version, it is recommended to use python-3.9.x for flair development.

Create a python environment of your preference and run:
```bash
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ In your favorite virtual environment, simply do:
pip install flair
```

Flair requires Python 3.8+.
Flair requires Python 3.9+.

### Example 1: Tag Entities in Text

Expand Down
4 changes: 2 additions & 2 deletions docs/contributing/local_development.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ the code should hopefully be easy.

## Setup

Flair requires python-3.8 or higher. To make sure our code also runs on the oldest supported
python version, it is recommended to use python-3.8.x for flair development.
Flair requires python-3.9 or higher. To make sure our code also runs on the oldest supported
python version, it is recommended to use python-3.9.x for flair development.

Create a python environment of your preference and run:
```bash
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ In your favorite virtual environment, simply do:
pip install flair
```

Flair requires Python 3.8+.
Flair requires Python 3.9+.

## Example 1: Tag Entities in Text

Expand Down
11 changes: 6 additions & 5 deletions flair/class_utils.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import importlib
import inspect
from collections.abc import Iterable
from types import ModuleType
from typing import Any, Iterable, List, Optional, Type, TypeVar, Union, overload
from typing import Any, Optional, TypeVar, Union, overload

T = TypeVar("T")


def get_non_abstract_subclasses(cls: Type[T]) -> Iterable[Type[T]]:
def get_non_abstract_subclasses(cls: type[T]) -> Iterable[type[T]]:
for subclass in cls.__subclasses__():
yield from get_non_abstract_subclasses(subclass)
if inspect.isabstract(subclass):
continue
yield subclass


def get_state_subclass_by_name(cls: Type[T], cls_name: Optional[str]) -> Type[T]:
def get_state_subclass_by_name(cls: type[T], cls_name: Optional[str]) -> type[T]:
for sub_cls in get_non_abstract_subclasses(cls):
if sub_cls.__name__ == cls_name:
return sub_cls
Expand All @@ -26,12 +27,12 @@ def lazy_import(group: str, module: str, first_symbol: None) -> ModuleType: ...


@overload
def lazy_import(group: str, module: str, first_symbol: str, *symbols: str) -> List[Any]: ...
def lazy_import(group: str, module: str, first_symbol: str, *symbols: str) -> list[Any]: ...


def lazy_import(
group: str, module: str, first_symbol: Optional[str] = None, *symbols: str
) -> Union[List[Any], ModuleType]:
) -> Union[list[Any], ModuleType]:
try:
imported_module = importlib.import_module(module)
except ImportError:
Expand Down
Loading

0 comments on commit a4709ae

Please sign in to comment.