Skip to content

Commit

Permalink
fix pytest error (#1885)
Browse files Browse the repository at this point in the history
  • Loading branch information
lvyufeng authored Dec 24, 2024
1 parent 46eaebe commit 58cea12
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 37 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci_pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip==24.0
Expand All @@ -40,7 +40,7 @@ jobs:
shell: bash
env:
OS: ubuntu-latest
PYTHON: 3.9
PYTHON: 3.11
run: |
python .github/install_mindspore.py
pip install -r download.txt
Expand All @@ -54,7 +54,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: [3.9]
python: [3.11]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip==24.0
Expand All @@ -127,7 +127,7 @@ jobs:
shell: bash
env:
OS: ubuntu-latest
PYTHON: 3.9
PYTHON: 3.11
run: |
python .github/install_mindspore.py
pip install -r download.txt
Expand All @@ -141,10 +141,10 @@ jobs:
if: github.event_name == 'push' && github.repository_owner == 'mindspore-lab'
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3.11
- uses: "lvyufeng/action-kaggle-gpu-test@latest"
with:
kaggle_username: "${{ secrets.KAGGLE_USERNAME }}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/doc_rst_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip==24.0
Expand Down
3 changes: 3 additions & 0 deletions mindnlp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
if SOC in ('ascend910', 'ascend310b'):
context.set_context(ascend_config={"precision_mode": "allow_mix_precision"})

if version.parse(mindspore.__version__) < version.parse('2.3.0'):
mindspore.mint = None

from mindspore import jit as ms_jit
from mindnlp import patch
from mindnlp import transformers
Expand Down
52 changes: 26 additions & 26 deletions mindnlp/sentence/sentence_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@
class SentenceTransformer(nn.Sequential):
def __init__(
self,
model_name_or_path: str | None = None,
modules: Iterable[nn.Module] | None = None,
prompts: dict[str, str] | None = None,
default_prompt_name: str | None = None,
similarity_fn_name: str | SimilarityFunction | None = None,
cache_folder: str | None = None,
model_name_or_path: str = None,
modules: Iterable[nn.Module] = None,
prompts: dict[str, str] = None,
default_prompt_name: str = None,
similarity_fn_name: str | SimilarityFunction = None,
cache_folder: str = None,
trust_remote_code: bool = False,
revision: str | None = None,
revision: str = None,
local_files_only: bool = False,
token: bool | str | None = None,
truncate_dim: int | None = None,
model_kwargs: dict[str, Any] | None = None,
tokenizer_kwargs: dict[str, Any] | None = None,
config_kwargs: dict[str, Any] | None = None,
token: bool | str = None,
truncate_dim: int = None,
model_kwargs: dict[str, Any] = None,
tokenizer_kwargs: dict[str, Any] = None,
config_kwargs: dict[str, Any] = None,
):
self.prompts = prompts or {}
self.default_prompt_name = default_prompt_name
Expand Down Expand Up @@ -193,8 +193,8 @@ def _load_module_class_from_ref(
class_ref: str,
model_name_or_path: str,
trust_remote_code: bool,
revision: str | None,
model_kwargs: dict[str, Any] | None,
revision: str,
model_kwargs: dict[str, Any],
) -> nn.Module:
# If the class is from sentence_transformers, we can directly import it,
# otherwise, we try to import it dynamically, and if that fails, we fall back to the default import
Expand All @@ -206,14 +206,14 @@ def _load_module_class_from_ref(
def _load_sbert_model(
self,
model_name_or_path: str,
token: bool | str | None,
cache_folder: str | None,
revision: str | None = None,
token: bool | str,
cache_folder: str,
revision: str = None,
trust_remote_code: bool = False,
local_files_only: bool = False,
model_kwargs: dict[str, Any] | None = None,
tokenizer_kwargs: dict[str, Any] | None = None,
config_kwargs: dict[str, Any] | None = None,
model_kwargs: dict[str, Any] = None,
tokenizer_kwargs: dict[str, Any] = None,
config_kwargs: dict[str, Any] = None,
) -> dict[str, nn.Module]:
"""
Loads a full SentenceTransformer model using the modules.json file.
Expand Down Expand Up @@ -385,14 +385,14 @@ def _load_sbert_model(
def _load_auto_model(
self,
model_name_or_path: str,
token: bool | str | None,
cache_folder: str | None,
revision: str | None = None,
token: bool | str,
cache_folder: str,
revision: str = None,
trust_remote_code: bool = False,
local_files_only: bool = False,
model_kwargs: dict[str, Any] | None = None,
tokenizer_kwargs: dict[str, Any] | None = None,
config_kwargs: dict[str, Any] | None = None,
model_kwargs: dict[str, Any] = None,
tokenizer_kwargs: dict[str, Any] = None,
config_kwargs: dict[str, Any] = None,
) -> list[nn.Module]:
"""
Creates a simple Transformer + Mean Pooling model and returns the modules
Expand Down
2 changes: 1 addition & 1 deletion tests/core/modules/loss/test_cmrc2018loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import mindspore
from ddt import ddt, data
from mindspore import Tensor
from mindnlp.core.modules import CMRC2018Loss
from mindnlp.common.modules import CMRC2018Loss
from ....common import MindNLPTestCase

@ddt
Expand Down
2 changes: 1 addition & 1 deletion tests/core/modules/loss/test_rdrop_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import mindspore
from ddt import ddt, data
from mindspore import Tensor
from mindnlp.core.modules import RDropLoss
from mindnlp.common.modules import RDropLoss
from ....common import MindNLPTestCase

@ddt
Expand Down
2 changes: 1 addition & 1 deletion tests/core/modules/test_crf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import mindspore
from mindnlp.core import nn, ops

from mindnlp.core.modules import CRF
from mindnlp.common.modules import CRF

RANDOM_SEED = 1478754

Expand Down

0 comments on commit 58cea12

Please sign in to comment.