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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ Under the hood, the following happens when calling `PyTorchIEPipeline.from_pretr
</summary>

```python
from pytorch_ie.auto import AutoTaskModule, AutoModel
from pytorch_ie.core import AutoTaskModule, AutoModel
from pytorch_ie.pipeline import PyTorchIEPipeline

model_name_or_path = "pie/example-ner-spanclf-conll03"
Expand All @@ -375,8 +375,8 @@ ner_pipeline = PyTorchIEPipeline(model=ner_model, taskmodule=ner_taskmodule, dev
from dataclasses import dataclass

from pytorch_ie import PyTorchIEPipeline
from pytorch_ie.annotations import BinaryRelation, LabeledSpan
from pytorch_ie.core import AnnotationLayer, annotation_field
from pytorch_ie.annotations import BinaryRelation, LabeledSpan
from pytorch_ie.documents import TextDocument


Expand Down
4 changes: 2 additions & 2 deletions examples/predict/ner_span_classification.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from dataclasses import dataclass

from pie_core import AnnotationLayer, annotation_field
from pie_documents.annotations import LabeledSpan
from pie_documents.documents import TextDocument

from pytorch_ie import PyTorchIEPipeline
from pytorch_ie.annotations import LabeledSpan
from pytorch_ie.documents import TextDocument
from pytorch_ie.models import TransformerSpanClassificationModel
from pytorch_ie.taskmodules import TransformerSpanClassificationTaskModule

Expand Down
4 changes: 2 additions & 2 deletions examples/predict/re_generative.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from dataclasses import dataclass

from pie_core import AnnotationLayer, annotation_field
from pie_documents.annotations import BinaryRelation, LabeledSpan
from pie_documents.documents import TextDocument

from pytorch_ie import PyTorchIEPipeline
from pytorch_ie.annotations import BinaryRelation, LabeledSpan
from pytorch_ie.documents import TextDocument
from pytorch_ie.models import TransformerSeq2SeqModel
from pytorch_ie.taskmodules import TransformerSeq2SeqTaskModule

Expand Down
4 changes: 2 additions & 2 deletions examples/predict/re_text_classification.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from dataclasses import dataclass

from pie_core import AnnotationLayer, annotation_field
from pie_documents.annotations import BinaryRelation, LabeledSpan
from pie_documents.documents import TextDocument

from pytorch_ie import PyTorchIEPipeline
from pytorch_ie.annotations import BinaryRelation, LabeledSpan
from pytorch_ie.documents import TextDocument
from pytorch_ie.models import TransformerTextClassificationModel
from pytorch_ie.taskmodules import TransformerRETextClassificationTaskModule

Expand Down
2 changes: 1 addition & 1 deletion src/pytorch_ie/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# flake8: noqa

from pytorch_ie.auto import AutoModel, AutoTaskModule
from pytorch_ie.core import *
from pytorch_ie.datamodule import PieDataModule
from pytorch_ie.dataset import IterableTaskEncodingDataset, TaskEncodingDataset
from pytorch_ie.model import PyTorchIEModel
from pytorch_ie.pipeline import PyTorchIEPipeline
14 changes: 1 addition & 13 deletions src/pytorch_ie/annotations.py
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
# backward compatibility
from pie_documents.annotations import (
BinaryRelation,
Label,
LabeledMultiSpan,
LabeledSpan,
MultiLabel,
MultiLabeledBinaryRelation,
MultiLabeledSpan,
MultiSpan,
NaryRelation,
Span,
)
from pie_documents.annotations import *
2 changes: 0 additions & 2 deletions src/pytorch_ie/auto.py

This file was deleted.

36 changes: 1 addition & 35 deletions src/pytorch_ie/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,35 +1 @@
import sys

import pie_core
from pie_core import taskmodule
from pie_core.document import Annotation, AnnotationLayer, Document, annotation_field
from pie_core.metric import DocumentMetric
from pie_core.module_mixins import (
EnterDatasetDictMixin,
EnterDatasetMixin,
ExitDatasetDictMixin,
ExitDatasetMixin,
WithDocumentTypeMixin,
)
from pie_core.preparable import PreparableMixin
from pie_core.statistic import DocumentStatistic
from pie_core.taskencoding import TaskEncoding, TaskEncodingSequence
from pie_core.taskmodule import TaskModule

from pytorch_ie import model
from pytorch_ie.dataset import IterableTaskEncodingDataset, TaskEncodingDataset
from pytorch_ie.model import PyTorchIEModel

submodules = ["document", "taskmodule", "metric", "statistic"]
for sub in submodules:
module = getattr(pie_core, sub)
sys.modules[f"{__name__}.{sub}"] = module

sys.modules[f"{__name__}.model"] = model

taskmodule.TaskEncodingDataset = TaskEncodingDataset
taskmodule.IterableTaskEncodingDataset = IterableTaskEncodingDataset

# backwards compatibility
AnnotationList = AnnotationLayer
RequiresDocumentTypeMixin = WithDocumentTypeMixin
from pie_core import *
32 changes: 1 addition & 31 deletions src/pytorch_ie/documents.py
Original file line number Diff line number Diff line change
@@ -1,31 +1 @@
# backwards compatibility
from pie_documents.documents import (
DocumentWithLabel,
DocumentWithMultiLabel,
TextBasedDocument,
TextDocumentWithLabel,
TextDocumentWithLabeledMultiSpans,
TextDocumentWithLabeledMultiSpansAndBinaryRelations,
TextDocumentWithLabeledMultiSpansAndLabeledPartitions,
TextDocumentWithLabeledMultiSpansBinaryRelationsAndLabeledPartitions,
TextDocumentWithLabeledPartitions,
TextDocumentWithLabeledSpans,
TextDocumentWithLabeledSpansAndBinaryRelations,
TextDocumentWithLabeledSpansAndLabeledPartitions,
TextDocumentWithLabeledSpansAndSentences,
TextDocumentWithLabeledSpansBinaryRelationsAndLabeledPartitions,
TextDocumentWithMultiLabel,
TextDocumentWithSentences,
TextDocumentWithSpans,
TextDocumentWithSpansAndBinaryRelations,
TextDocumentWithSpansAndLabeledPartitions,
TextDocumentWithSpansBinaryRelationsAndLabeledPartitions,
TokenBasedDocument,
WithMetadata,
WithText,
WithTokens,
)
from typing_extensions import TypeAlias

# backwards compatibility
TextDocument: TypeAlias = TextBasedDocument
from pie_documents.documents import *
3 changes: 1 addition & 2 deletions src/pytorch_ie/metrics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# backwards compatibility
from pie_documents.metrics import ConfusionMatrix, F1Metric, SQuADF1
from pie_documents.metrics import *
2 changes: 1 addition & 1 deletion src/pytorch_ie/model.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any, Dict

import torch
from pie_core import Auto, Model
from pie_core import Model
from pytorch_lightning import LightningModule


Expand Down
14 changes: 7 additions & 7 deletions src/pytorch_ie/taskmodules/transformer_re_text_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
import numpy as np
import torch
from pie_core import AnnotationLayer, Document, TaskEncoding, TaskModule
from pie_documents.annotations import (
BinaryRelation,
LabeledSpan,
MultiLabeledBinaryRelation,
NaryRelation,
Span,
)
from pie_documents.documents import (
TextDocument,
TextDocumentWithLabeledSpansAndBinaryRelations,
Expand All @@ -35,13 +42,6 @@
from transformers.tokenization_utils_base import TruncationStrategy
from typing_extensions import TypeAlias

from pytorch_ie.annotations import (
BinaryRelation,
LabeledSpan,
MultiLabeledBinaryRelation,
NaryRelation,
Span,
)
from pytorch_ie.models.transformer_text_classification import ModelOutputType, ModelStepInputType
from pytorch_ie.taskmodules.interface import ChangesTokenizerVocabSize
from pytorch_ie.utils.span import get_token_slice, is_contained_in
Expand Down
7 changes: 0 additions & 7 deletions src/pytorch_ie/utils/hydra.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/pytorch_ie/utils/span.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
Tuple,
)

from pie_documents.annotations import LabeledSpan, Span

# backwards compatibility imports from pie_documents.utils.span
from pie_documents.utils.span import have_overlap as has_overlap
from pie_documents.utils.span import is_contained_in
from transformers import PreTrainedTokenizer

from pytorch_ie.annotations import LabeledSpan, Span

# TODO: most of this should be superseded by pie_documents.utils.sequence_tagging,
# remove respective content

Expand Down
4 changes: 2 additions & 2 deletions tests/pipeline/test_ner_span_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import pytest
from pie_core import AnnotationLayer, annotation_field
from pie_documents.annotations import LabeledSpan
from pie_documents.documents import TextDocument

from pytorch_ie import PyTorchIEPipeline
from pytorch_ie.annotations import LabeledSpan
from pytorch_ie.documents import TextDocument
from pytorch_ie.models import TransformerSpanClassificationModel
from pytorch_ie.taskmodules import TransformerSpanClassificationTaskModule

Expand Down
4 changes: 2 additions & 2 deletions tests/pipeline/test_re_generative.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import pytest
from pie_core import AnnotationLayer, annotation_field
from pie_documents.annotations import BinaryRelation, LabeledSpan
from pie_documents.documents import TextDocument

from pytorch_ie import PyTorchIEPipeline
from pytorch_ie.annotations import BinaryRelation, LabeledSpan
from pytorch_ie.documents import TextDocument
from pytorch_ie.models import TransformerSeq2SeqModel
from pytorch_ie.taskmodules import TransformerSeq2SeqTaskModule

Expand Down
4 changes: 2 additions & 2 deletions tests/pipeline/test_re_text_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import pytest
import torch
from pie_core import AnnotationLayer, annotation_field
from pie_documents.annotations import BinaryRelation, LabeledSpan
from pie_documents.documents import TextDocument

from pytorch_ie import PyTorchIEPipeline
from pytorch_ie.annotations import BinaryRelation, LabeledSpan
from pytorch_ie.documents import TextDocument
from pytorch_ie.models import TransformerTextClassificationModel
from pytorch_ie.taskmodules import TransformerRETextClassificationTaskModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

import pytest
import torch
from pie_core import AnnotationLayer, Document, annotation_field
from pie_documents.annotations import Label
from transformers import BatchEncoding

from pytorch_ie import AnnotationLayer, Document, annotation_field
from pytorch_ie.annotations import Label
from pytorch_ie.taskmodules import SimpleTransformerTextClassificationTaskModule
from tests import _config_to_str

Expand Down
6 changes: 3 additions & 3 deletions tests/taskmodules/test_transformer_seq2seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

import pytest
import torch
from pie_core import AnnotationLayer, annotation_field
from pie_documents.annotations import BinaryRelation, LabeledSpan
from pie_documents.documents import TextDocument
from transformers import BatchEncoding

from pytorch_ie import AnnotationLayer, annotation_field
from pytorch_ie.annotations import BinaryRelation, LabeledSpan
from pytorch_ie.documents import TextDocument
from pytorch_ie.taskmodules import TransformerSeq2SeqTaskModule


Expand Down
2 changes: 1 addition & 1 deletion tests/taskmodules/test_transformer_span_classification.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numpy
import pytest
import torch
from pie_core import TaskModule

from pytorch_ie import TaskModule
from pytorch_ie.taskmodules import TransformerSpanClassificationTaskModule


Expand Down
4 changes: 2 additions & 2 deletions tests/taskmodules/test_transformer_token_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import numpy as np
import pytest
import torch
from pie_core import AnnotationLayer, Document, annotation_field
from pie_documents.annotations import LabeledSpan, Span
from transformers import BatchEncoding

from pytorch_ie import AnnotationLayer, Document, annotation_field
from pytorch_ie.annotations import LabeledSpan, Span
from pytorch_ie.taskmodules import TransformerTokenClassificationTaskModule


Expand Down
15 changes: 11 additions & 4 deletions tests/test_auto.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
from dataclasses import dataclass

import pytest
from pie_core import AnnotationLayer, AutoAnnotationPipeline, Model, TaskModule, annotation_field
from pie_core import (
AnnotationLayer,
AutoAnnotationPipeline,
AutoModel,
AutoTaskModule,
Model,
TaskModule,
annotation_field,
)
from pie_documents.annotations import LabeledSpan
from pie_documents.documents import TextDocument

from pytorch_ie import PyTorchIEPipeline
from pytorch_ie.annotations import LabeledSpan
from pytorch_ie.auto import AutoModel, AutoTaskModule
from pytorch_ie.documents import TextDocument
from pytorch_ie.models import TransformerSpanClassificationModel
from pytorch_ie.taskmodules import TransformerSpanClassificationTaskModule

Expand Down
4 changes: 2 additions & 2 deletions tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import torch
import transformers
from pie_core import AnnotationLayer, annotation_field
from pie_documents.annotations import LabeledSpan
from pie_documents.documents import TextDocument
from transformers.modeling_outputs import BaseModelOutputWithPooling

import pytorch_ie.models.modules.mlp
from pytorch_ie import PyTorchIEPipeline
from pytorch_ie.annotations import LabeledSpan
from pytorch_ie.documents import TextDocument
from pytorch_ie.models.transformer_span_classification import TransformerSpanClassificationModel
from pytorch_ie.taskmodules.transformer_span_classification import (
TransformerSpanClassificationTaskModule,
Expand Down
5 changes: 3 additions & 2 deletions tests/utils/test_document.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pytorch_ie.annotations import LabeledSpan
from pytorch_ie.documents import TextDocumentWithLabeledSpans
from pie_documents.annotations import LabeledSpan
from pie_documents.documents import TextDocumentWithLabeledSpans

from pytorch_ie.utils.document import merge_annotations_from_documents


Expand Down