Skip to content

Commit 22df87c

Browse files
authored
Follow PEP 621 (#38)
* Follow PEP621 * Fix a bug in util.py * Remove unnecessary files * Fix CI * Apply black * Update pypi-publish.yml
1 parent fbbdd9c commit 22df87c

File tree

11 files changed

+50
-127
lines changed

11 files changed

+50
-127
lines changed

.github/workflows/ci.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ jobs:
1919
- name: Install dependencies
2020
run: |
2121
python -m pip install -U pip
22-
pip install -r requirements.txt
23-
- name: Lint with flake8
22+
python -m pip install -e ".[dev]"
23+
- name: Lint with ruff
2424
run: |
25-
flake8
25+
ruff check spacy_partial_tagger
26+
ruff check tests
2627
- name: Lint with black
2728
run: |
28-
black . --check
29-
- name: Lint with isort
30-
run: |
31-
isort -c .
29+
black . --check spacy_partial_tagger
30+
black . --check tests
3231
- name: Lint with mypy
3332
run: |
3433
mypy spacy_partial_tagger
34+
mypy tests
3535
- name: Run tests
3636
run: |
3737
pytest --cov=spacy_partial_tagger --cov-report=term-missing

.github/workflows/pypi-publish.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ jobs:
1616
- name: Install dependencies
1717
run: |
1818
python -m pip install --upgrade pip
19-
pip install poetry
19+
python -m pip install hatch build
2020
- name: Build a binary wheel and a source tarball
2121
run: |
22-
poetry build
22+
hatch version "${GITHUB_REF_NAME}"
23+
python -m build
2324
- name: Publish a Python distribution to PyPI
2425
uses: pypa/gh-action-pypi-publish@release/v1
2526
with:

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,6 @@ cython_debug/
160160

161161
.tool-versions
162162
poetry.lock
163+
.pdm-python
164+
pdm.toml
165+
pdm.lock

pyproject.toml

+35-34
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,60 @@
11
[build-system]
2-
requires = ["poetry-core>=1.0.0"]
3-
build-backend = "poetry.core.masonry.api"
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
44

55
[project]
66
name = "spacy-partial-tagger"
7-
requires-python = ">=3.8"
8-
9-
[tool.poetry]
10-
name = "spacy-partial-tagger"
11-
version = "0.15.2"
127
description = "Sequence Tagger for Partially Annotated Dataset in spaCy"
13-
authors = ["yasufumi <[email protected]>"]
14-
license = "MIT"
15-
readme = "README.md"
16-
repository = "https://github.com/tech-sketch/spacy-partial-tagger"
8+
requires-python = ">=3.8,<4.0"
9+
readme = {file = "README.md", content-type = "text/markdown"}
10+
license = {file = "LICENSE"}
11+
authors = [
12+
{name = "Yasufumi Taniguchi", email = "[email protected]"},
13+
]
1714
classifiers = [
1815
"Programming Language :: Python",
1916
"Programming Language :: Python :: 3.8",
2017
"Programming Language :: Python :: 3.9"
2118
]
19+
dependencies = [
20+
"thinc<9.0.0,>=8.0.15",
21+
"transformers[ja]<5.0.0,>=4.25.1",
22+
"torch<3.0.0,>=2.0.1",
23+
"spacy[transformers]<4.0.0,>=3.3.1",
24+
"spacy-alignments<1.0.0,>=0.8.5",
25+
"pytorch-partial-tagger<1.0.0,>=0.1.12",
26+
]
27+
dynamic = ["version"]
2228

23-
[tool.poetry.dependencies]
24-
python = "^3.8"
25-
thinc = "^8.0.15"
26-
transformers = {extras = ["ja"], version = "^4.25.1"}
27-
torch = "^2.0.1"
28-
spacy = {extras = ["transformers"], version = "^3.3.1"}
29-
spacy-alignments = "^0.8.5"
30-
pytorch-partial-tagger = "^0.1.12"
29+
[project.urls]
30+
Repository = "https://github.com/doccano/spacy-partial-tagger"
3131

32-
[tool.poetry.group.dev.dependencies]
33-
mypy = "^1.3.0"
34-
black = "^22.3.0"
35-
pytest = "^7.1.1"
36-
isort = "^5.10.1"
37-
flake8 = "^4.0.1"
38-
pytest-cov = "^3.0.0"
39-
ruff = "^0.0.270"
32+
[project.optional-dependencies]
33+
dev = [
34+
"mypy>=1.3.1",
35+
"black>=23.3.0",
36+
"pytest>=7.1.1",
37+
"isort>=5.10.1",
38+
"flake8>=4.0.1",
39+
"pytest-cov>=3.0.0",
40+
"ruff>=0.0.270",
41+
]
4042

41-
[tool.poetry.plugins.spacy_factories]
43+
[project.entry-points]
44+
[project.entry-points.spacy_factories]
4245
partial_ner = "spacy_partial_tagger.pipeline:make_partial_ner"
4346

44-
[tool.poetry.plugins.spacy_architectures]
47+
[project.entry-points.spacy_architectures]
4548
"spacy-partial-tagger.PartialTagger.v1" = "spacy_partial_tagger.tagger:build_partial_tagger_v1"
4649

50+
[tool.hatch.version]
51+
path = "spacy_partial_tagger/__about__.py"
52+
4753
[tool.mypy]
4854
ignore_missing_imports = true
4955
disallow_untyped_defs = true
5056
show_error_codes = true
5157

52-
[tool.isort]
53-
profile = "black"
54-
include_trailing_comma = true
55-
multi_line_output = 3
56-
5758
[tool.black]
5859
exclude = '''
5960
/(

requirements.txt

-74
This file was deleted.

setup.cfg

-5
This file was deleted.

spacy_partial_tagger/__about__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "0.15.2"

spacy_partial_tagger/pipeline.py

-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def set_annotations(
5151
docs: List[Doc],
5252
tag_indices: Floats2d,
5353
) -> None:
54-
5554
for doc, indices in zip(docs, tag_indices.tolist()):
5655
indices = [index for index in indices if index != self.padding_index]
5756
alignment = doc.user_data["alignment"]
@@ -157,7 +156,6 @@ def add_label(self, label: str) -> int:
157156
def from_bytes(
158157
self, bytes_data: bytes, *, exclude: tuple = ()
159158
) -> "PartialEntityRecognizer":
160-
161159
self._validate_serialization_attrs()
162160

163161
def load_model(b: bytes) -> None:

spacy_partial_tagger/tagger.py

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ def forward(
4242
X: List[Doc],
4343
is_train: bool,
4444
) -> Tuple[Tuple[Floats4d, Ints2d], Callable]:
45-
4645
tokenizer: BaseTokenizer = model.attrs["tokenizer"]
4746

4847
text_batch = tokenizer(tuple(doc.text for doc in X))

spacy_partial_tagger/tokenizer.py

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def __init__(
2020
tokenizer: _BertJapaneseTokenizer,
2121
tokenizer_args: Optional[dict] = None,
2222
):
23-
2423
self.__tokenizer = tokenizer
2524

2625
self.__tokenizer_args = tokenizer_args or {

spacy_partial_tagger/util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def get_alignments(
3030
tokens = tokenizer.word_tokenizer.tokenize(
3131
text, never_split=tokenizer.all_special_tokens
3232
)
33-
_, y2x = tokenizations.get_alignments(text, tokens)
33+
_, y2x = tokenizations.get_alignments(list(text), tokens)
3434
token2char = {i: (x[0], x[-1] + 1) for i, x in enumerate(y2x)}
3535

3636
pieces = [

0 commit comments

Comments
 (0)