From 6852be54bb9abd96e266684f912f60f0736e01f9 Mon Sep 17 00:00:00 2001 From: Thomas Petit-Jean Date: Wed, 16 Oct 2024 09:10:20 +0200 Subject: [PATCH] fix CI --- .github/workflows/documentation.yml | 2 +- .github/workflows/release.yml | 8 ++++---- .github/workflows/test-build.yml | 4 ++-- .github/workflows/tests.yml | 8 ++++---- edsnlp/pipes/ner/behaviors/alcohol/alcohol.py | 6 +++--- edsnlp/pipes/qualifiers/base.py | 4 ++-- edsnlp/pipes/qualifiers/family/family.py | 4 ++-- edsnlp/pipes/qualifiers/history/history.py | 4 ++-- edsnlp/pipes/qualifiers/hypothesis/hypothesis.py | 4 ++-- edsnlp/pipes/qualifiers/negation/negation.py | 4 ++-- .../qualifiers/reported_speech/reported_speech.py | 4 ++-- tests/pipelines/ner/disorders/alcohol.py | 12 ++++++++++++ 12 files changed, 38 insertions(+), 26 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 06aac1ac1..d182c0ae0 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -13,7 +13,7 @@ env: jobs: Documentation: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 65de04d5a..b6b9198d0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-22.04, windows-latest, macos-latest] steps: - uses: actions/checkout@v4 @@ -42,7 +42,7 @@ jobs: build_sdist: name: Build source distribution - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 @@ -58,7 +58,7 @@ jobs: name: Upload to PyPI needs: [build_wheels, build_sdist] - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/download-artifact@v4 @@ -76,7 +76,7 @@ jobs: # repository_url: https://test.pypi.org/legacy/ Documentation: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index 0b849728b..ac64a28b3 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -17,7 +17,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-22.04, windows-latest, macos-latest] steps: - uses: actions/checkout@v2 @@ -30,7 +30,7 @@ jobs: build_sdist: name: Build source distribution - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 728547434..f55139d32 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: linting: name: Linting if: github.event_name == 'pull_request' - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 with: @@ -32,7 +32,7 @@ jobs: pytest: name: Pytest - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: fail-fast: true matrix: @@ -120,7 +120,7 @@ jobs: documentation: name: Documentation - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 @@ -150,7 +150,7 @@ jobs: simple-installation: name: Simple installation - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: fail-fast: true matrix: diff --git a/edsnlp/pipes/ner/behaviors/alcohol/alcohol.py b/edsnlp/pipes/ner/behaviors/alcohol/alcohol.py index ca543fa6e..c1bbc9177 100644 --- a/edsnlp/pipes/ner/behaviors/alcohol/alcohol.py +++ b/edsnlp/pipes/ner/behaviors/alcohol/alcohol.py @@ -118,8 +118,8 @@ def process(self, doc: Doc) -> List[Span]: stopped = self.negation.process(span) if not any(stopped_token.negation for stopped_token in stopped.tokens): span._.status = 2 - - if "zero_after" in span._.assigned.keys(): - span._.negation = True + else: + if "zero_after" in span._.assigned.keys(): + span._.negation = True yield span diff --git a/edsnlp/pipes/qualifiers/base.py b/edsnlp/pipes/qualifiers/base.py index 2db014310..0b41fac9e 100644 --- a/edsnlp/pipes/qualifiers/base.py +++ b/edsnlp/pipes/qualifiers/base.py @@ -175,8 +175,8 @@ def get_matches(self, doc: Doc) -> List[Span]: def ensure_doc(self, doc: Union[Doc, Span]) -> Doc: return doc if not hasattr(doc, "as_doc") else doc.as_doc() - def process(self, doc: Doc) -> BaseQualifierResults: - doc = self.ensure_doc(doc) # pragma: no cover + def process(self, doc_like: Union[Doc, Span]) -> BaseQualifierResults: + doc_like = self.ensure_doc(doc_like) # pragma: no cover raise NotImplementedError def __call__(self, doc: Doc) -> Doc: diff --git a/edsnlp/pipes/qualifiers/family/family.py b/edsnlp/pipes/qualifiers/family/family.py index 541dac37d..12943d9eb 100644 --- a/edsnlp/pipes/qualifiers/family/family.py +++ b/edsnlp/pipes/qualifiers/family/family.py @@ -187,8 +187,8 @@ def set_extensions(self) -> None: if not Doc.has_extension("family"): Doc.set_extension("family", default=[]) - def process(self, doc: Doc) -> FamilyResults: - doc = self.ensure_doc(doc) + def process(self, doc_like: Union[Doc, Span]) -> FamilyResults: + doc = self.ensure_doc(doc_like) matches = self.get_matches(doc) terminations = [m for m in matches if m.label_ == "termination"] diff --git a/edsnlp/pipes/qualifiers/history/history.py b/edsnlp/pipes/qualifiers/history/history.py index 033877b7b..ab5469c95 100644 --- a/edsnlp/pipes/qualifiers/history/history.py +++ b/edsnlp/pipes/qualifiers/history/history.py @@ -326,8 +326,8 @@ def set_extensions(self) -> None: getter=deprecated_getter_factory("antecedent_cues", "history_cues"), ) - def process(self, doc: Doc) -> HistoryResults: - doc = self.ensure_doc(doc) + def process(self, doc_like: Union[Doc, Span]) -> HistoryResults: + doc = self.ensure_doc(doc_like) note_datetime = None if doc._.note_datetime is not None: try: diff --git a/edsnlp/pipes/qualifiers/hypothesis/hypothesis.py b/edsnlp/pipes/qualifiers/hypothesis/hypothesis.py index 8a75a5a2c..68ed1d1d1 100644 --- a/edsnlp/pipes/qualifiers/hypothesis/hypothesis.py +++ b/edsnlp/pipes/qualifiers/hypothesis/hypothesis.py @@ -262,8 +262,8 @@ def load_verbs( list_hypo_verbs_following, ) - def process(self, doc: Doc) -> HypothesisResults: - doc = self.ensure_doc(doc) + def process(self, doc_like: Union[Doc, Span]) -> HypothesisResults: + doc = self.ensure_doc(doc_like) matches = self.get_matches(doc) terminations = [m for m in matches if m.label_ == "termination"] diff --git a/edsnlp/pipes/qualifiers/negation/negation.py b/edsnlp/pipes/qualifiers/negation/negation.py index 083bf9e0d..ea4a4fc40 100644 --- a/edsnlp/pipes/qualifiers/negation/negation.py +++ b/edsnlp/pipes/qualifiers/negation/negation.py @@ -295,8 +295,8 @@ def __call__(self, doc: Doc) -> Doc: token._.negation = True return doc - def process(self, doc: Doc) -> NegationResults: - doc = self.ensure_doc(doc) + def process(self, doc_like: Union[Doc, Span]) -> NegationResults: + doc = self.ensure_doc(doc_like) matches = self.get_matches(doc) terminations = [m for m in matches if m.label_ == "termination"] diff --git a/edsnlp/pipes/qualifiers/reported_speech/reported_speech.py b/edsnlp/pipes/qualifiers/reported_speech/reported_speech.py index 55f0d5ca9..759eb7091 100644 --- a/edsnlp/pipes/qualifiers/reported_speech/reported_speech.py +++ b/edsnlp/pipes/qualifiers/reported_speech/reported_speech.py @@ -226,8 +226,8 @@ def load_verbs(self, verbs: List[str]) -> List[str]: return list_rep_verbs - def process(self, doc: Doc) -> ReportedSpeechResults: - doc = self.ensure_doc(doc) + def process(self, doc_like: Union[Doc, Span]) -> ReportedSpeechResults: + doc = self.ensure_doc(doc_like) matches = self.get_matches(doc) matches += list(self.regex_matcher(doc, as_spans=True)) diff --git a/tests/pipelines/ner/disorders/alcohol.py b/tests/pipelines/ner/disorders/alcohol.py index 2c6858f5e..f9fb65234 100644 --- a/tests/pipelines/ner/disorders/alcohol.py +++ b/tests/pipelines/ner/disorders/alcohol.py @@ -10,6 +10,9 @@ True, True, True, + True, + True, + False, ], detailled_status=[ None, @@ -22,6 +25,9 @@ "ABSTINENCE", None, None, + "ABSTINENCE", + None, + None, ], negation=[ None, @@ -34,6 +40,9 @@ None, True, False, + False, + False, + None, ], assign=None, texts=[ @@ -47,5 +56,8 @@ "Le patient est en cours de sevrage éthylotabagique", "Patient alcoolique: non.", "On a un alcoolique non sevré depuis 10 ans.", + "Alcoolisme sevré", + "Alcoolisme non sevré", + "Dosage vitamines 25-OH", ], )