Skip to content
Merged
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
14 changes: 6 additions & 8 deletions .github/workflows/python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,19 @@ jobs:
poetry install

- name: Run Black
run: poetry run poe black-check
run: poetry poe black-check

- name: Run Ruff
run: poetry run poe ruff-check
run: poetry poe ruff-check

- name: Run Mypy
run: poetry run poe mypy
run: poetry poe mypy

- name: Run Pytest
run: poetry run poe test
run: poetry poe test

- name: Install Extra Dependencies
run: |
poetry env use ${{ matrix.python-version }}
poetry install --all-extras
run: poetry install --all-extras

- name: Run Pytest on Extras
run: poetry run poe test
run: poetry poe test
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ Formatting, linting, type checking, and tests are defined as
[Poe](https://poethepoet.natn.io/) tasks in `pyproject.toml`.

```bash
poetry run poe {format,check,test,all}
poetry poe {format,check,test,all}
```

Code changes or additions should pass `poetry run poe all` before opening a PR.
Code changes or additions should pass `poetry poe all` before opening a PR.


### Tests
Expand All @@ -83,23 +83,23 @@ By default, only required unit tests are executed. Extra unit tests and integrat
tests are skipped.

```bash
poetry run poe {test,all}
poetry poe {test,all}
```

Extra unit tests are skipped when their dependencies are not installed. To execute extra
unit tests, install one or more extras and run the tests.

```bash
poetry install --all-extras
poetry run poe {test,all}
poetry poe {test,all}
```

Integration tests make API calls to an IPA environment and require a host and API token
to execute. These tests create datasets, setup workflows, and train models. **Expect
them to take tens of minutes to run.**

```bash
poetry run poe test-integration \
poetry poe test-integration \
--host try.indico.io \
--token indico_api_token.txt
```
Expand Down
2 changes: 1 addition & 1 deletion indico_toolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
"ToolkitStaggeredLoopError",
"ToolkitStatusError",
)
__version__ = "6.14.0"
__version__ = "6.14.1"
2 changes: 1 addition & 1 deletion indico_toolkit/etloutput/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import TYPE_CHECKING

from ..results import NULL_BOX, NULL_SPAN, Box, Span
from ..results.utilities import get, has
from ..results.utils import get, has
from .cell import Cell, CellType
from .errors import EtlOutputError, TableCellNotFoundError, TokenNotFoundError
from .etloutput import EtlOutput
Expand Down
2 changes: 1 addition & 1 deletion indico_toolkit/etloutput/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from enum import Enum

from ..results import NULL_SPAN, Box, Span
from ..results.utilities import get
from ..results.utils import get
from .range import Range


Expand Down
2 changes: 1 addition & 1 deletion indico_toolkit/etloutput/range.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass

from ..results.utilities import get
from ..results.utils import get


@dataclass(order=True, frozen=True)
Expand Down
2 changes: 1 addition & 1 deletion indico_toolkit/etloutput/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from operator import attrgetter

from ..results import Box
from ..results.utilities import get
from ..results.utils import get
from .cell import Cell


Expand Down
2 changes: 1 addition & 1 deletion indico_toolkit/etloutput/token.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dataclasses import dataclass

from ..results import Box, Span
from ..results.utilities import get
from ..results.utils import get


@dataclass(frozen=True)
Expand Down
2 changes: 1 addition & 1 deletion indico_toolkit/results/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)
from .result import Result
from .review import Review, ReviewType
from .utilities import get
from .utils import get

if TYPE_CHECKING:
from collections.abc import Awaitable, Callable
Expand Down
2 changes: 1 addition & 1 deletion indico_toolkit/results/document.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass

from .utilities import get
from .utils import get


@dataclass(frozen=True, order=True)
Expand Down
2 changes: 1 addition & 1 deletion indico_toolkit/results/model.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dataclasses import dataclass
from enum import Enum

from .utilities import get, has
from .utils import get, has


class ModelGroupType(Enum):
Expand Down
2 changes: 1 addition & 1 deletion indico_toolkit/results/normalization.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re
from typing import TYPE_CHECKING

from .utilities import get, has
from .utils import get, has

if TYPE_CHECKING:
from collections.abc import Iterator
Expand Down
2 changes: 1 addition & 1 deletion indico_toolkit/results/predictionlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Unbundling,
)
from .review import Review, ReviewType
from .utilities import nfilter
from .utils import nfilter

if TYPE_CHECKING:
from collections.abc import Callable, Collection, Container, Iterable
Expand Down
2 changes: 1 addition & 1 deletion indico_toolkit/results/predictions/box.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dataclasses import dataclass
from typing import TYPE_CHECKING

from ..utilities import get
from ..utils import get

if TYPE_CHECKING:
from typing import Final
Expand Down
2 changes: 1 addition & 1 deletion indico_toolkit/results/predictions/citation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dataclasses import dataclass
from typing import TYPE_CHECKING

from ..utilities import get
from ..utils import get
from .span import NULL_SPAN, Span

if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion indico_toolkit/results/predictions/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import TYPE_CHECKING

from ..review import Review
from ..utilities import get, omit
from ..utils import get, omit
from .prediction import Prediction

if TYPE_CHECKING:
Expand Down
14 changes: 9 additions & 5 deletions indico_toolkit/results/predictions/documentextraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import TYPE_CHECKING

from ..review import Review
from ..utilities import get, has, omit
from ..utils import get, has, omit
from .extraction import Extraction
from .group import Group
from .span import NULL_SPAN, Span
Expand Down Expand Up @@ -127,8 +127,10 @@ def to_v1_dict(self) -> "dict[str, Any]":
"end": self.span.end,
}

prediction["normalized"]["formatted"] = self.text
prediction["text"] = self.text # 6.10 sometimes reverts to raw text in review.
if self.text != get(prediction, str, "normalized", "formatted"):
prediction["normalized"]["formatted"] = self.text
prediction["normalized"]["text"] = self.text
prediction["text"] = self.text

if self.accepted:
prediction["accepted"] = True
Expand All @@ -149,8 +151,10 @@ def to_v3_dict(self) -> "dict[str, Any]":
"spans": [span.to_dict() for span in self.spans],
}

prediction["normalized"]["formatted"] = self.text
prediction["text"] = self.text # 6.10 sometimes reverts to raw text in review.
if self.text != get(prediction, str, "normalized", "formatted"):
prediction["normalized"]["formatted"] = self.text
prediction["normalized"]["text"] = self.text
prediction["text"] = self.text

if self.accepted:
prediction["accepted"] = True
Expand Down
27 changes: 16 additions & 11 deletions indico_toolkit/results/predictions/formextraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import TYPE_CHECKING

from ..review import Review
from ..utilities import get, has, omit
from ..utils import get, has, omit
from .box import Box
from .extraction import Extraction

Expand Down Expand Up @@ -97,18 +97,23 @@ def _to_dict(self) -> "dict[str, Any]":
}

if self.type == FormExtractionType.CHECKBOX:
prediction["normalized"]["structured"]["checked"] = self.checked
prediction["normalized"]["formatted"] = (
"Checked" if self.checked else "Unchecked"
)
prediction["normalized"]["structured"] = {"checked": self.checked}
text = "Checked" if self.checked else "Unchecked"
prediction["normalized"]["formatted"] = text
prediction["normalized"]["text"] = self.text
prediction["text"] = self.text
elif self.type == FormExtractionType.SIGNATURE:
prediction["normalized"]["structured"]["signed"] = self.signed
prediction["normalized"]["formatted"] = (
"Signed" if self.signed else "Unsigned"
)
prediction["normalized"]["structured"] = {"signed": self.signed}
text = "Signed" if self.signed else "Unsigned"
prediction["normalized"]["formatted"] = text
# Don't overwrite the text of the signature stored in these attributes.
# prediction["normalized"]["text"] = self.text
# prediction["text"] = self.text
elif self.type == FormExtractionType.TEXT:
prediction["normalized"]["formatted"] = self.text
prediction["text"] = self.text # 6.10 sometimes reverts to text in review.
if self.text != get(prediction, str, "normalized", "formatted"):
prediction["normalized"]["formatted"] = self.text
prediction["normalized"]["text"] = self.text
prediction["text"] = self.text

if self.accepted:
prediction["accepted"] = True
Expand Down
2 changes: 1 addition & 1 deletion indico_toolkit/results/predictions/group.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dataclasses import dataclass
from typing import TYPE_CHECKING

from ..utilities import get
from ..utils import get

if TYPE_CHECKING:
from typing import Any
Expand Down
2 changes: 1 addition & 1 deletion indico_toolkit/results/predictions/span.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dataclasses import dataclass
from typing import TYPE_CHECKING

from ..utilities import get
from ..utils import get

if TYPE_CHECKING:
from typing import Any, Final
Expand Down
2 changes: 1 addition & 1 deletion indico_toolkit/results/predictions/summarization.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import TYPE_CHECKING

from ..review import Review
from ..utilities import get, has, omit
from ..utils import get, has, omit
from .citation import NULL_CITATION, Citation
from .extraction import Extraction

Expand Down
2 changes: 1 addition & 1 deletion indico_toolkit/results/predictions/unbundling.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import TYPE_CHECKING

from ..review import Review
from ..utilities import get, omit
from ..utils import get, omit
from .prediction import Prediction

if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion indico_toolkit/results/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .predictionlist import PredictionList
from .predictions import Prediction
from .review import Review, ReviewType
from .utilities import get
from .utils import get

if TYPE_CHECKING:
from typing import Any
Expand Down
2 changes: 1 addition & 1 deletion indico_toolkit/results/review.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dataclasses import dataclass
from enum import Enum

from .utilities import get
from .utils import get


class ReviewType(Enum):
Expand Down
File renamed without changes.
Loading