diff --git a/.github/workflows/ci_pipeline.yaml b/.github/workflows/ci_pipeline.yaml index 1c52c64df..2daa959a3 100644 --- a/.github/workflows/ci_pipeline.yaml +++ b/.github/workflows/ci_pipeline.yaml @@ -129,8 +129,7 @@ jobs: OS: ubuntu-latest PYTHON: 3.11 run: | - python .github/install_mindspore.py - pip install -r download.txt + pip install mindspore - name: Test with pytest run: | pytest -vs tests/transformers/models/${{ matrix.alpha }}*/test_modeling* diff --git a/.github/workflows/make_wheel_releases.yml b/.github/workflows/make_wheel_releases.yml index 554ce5017..76dd5354a 100644 --- a/.github/workflows/make_wheel_releases.yml +++ b/.github/workflows/make_wheel_releases.yml @@ -27,7 +27,7 @@ jobs: run: python -m build --wheel - name: Upload file - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: mindnlp-whl path: dist/* diff --git a/mindnlp/core/ops/array.py b/mindnlp/core/ops/array.py index 1cd14c2c6..1eb318aee 100644 --- a/mindnlp/core/ops/array.py +++ b/mindnlp/core/ops/array.py @@ -130,7 +130,7 @@ def narrow(input, dim, start, length): has_nonzero = hasattr(mindspore.mint, 'nonzero') def nonzero(input, *, as_tuple=False): if use_pyboost() and has_nonzero: - return mindspore.mint.nonzero(input, as_tuple) + return mindspore.mint.nonzero(input, as_tuple=as_tuple) _nonzero = _get_cache_prim(ops.NonZero)() out = _nonzero(input) if as_tuple: diff --git a/mindnlp/utils/download.py b/mindnlp/utils/download.py index 299f8d201..45ad56cc4 100644 --- a/mindnlp/utils/download.py +++ b/mindnlp/utils/download.py @@ -149,7 +149,7 @@ def threads_exclusive_http_get(url, storage_folder=None, md5sum=None, download_f if sys.platform != "win32": import fcntl # pylint: disable=import-error else: - import winfcntlock as fcntl # pylint: disable=import-error + from . import winfcntlock as fcntl # pylint: disable=import-error with open(lock_file_path, 'w') as lock_file: fd = lock_file.fileno() try: @@ -160,6 +160,11 @@ def threads_exclusive_http_get(url, storage_folder=None, md5sum=None, download_f raise exp finally: fcntl.flock(fd, fcntl.LOCK_UN) + lock_file.close() + try: + os.remove(lock_file_path) + except Exception as delete_exp: + logging.error(f"Failed to delete lock file: {delete_exp}") def http_get(url, path=None, md5sum=None, download_file_name=None, proxies=None, headers=None): diff --git a/mindnlp/utils/winfcntlock.py b/mindnlp/utils/winfcntlock.py index a3988e2c7..e6ab54d28 100644 --- a/mindnlp/utils/winfcntlock.py +++ b/mindnlp/utils/winfcntlock.py @@ -21,12 +21,13 @@ LOCK_EX = win32con.LOCKFILE_EXCLUSIVE_LOCK LOCK_SH = 0 # The default value LOCK_NB = win32con.LOCKFILE_FAIL_IMMEDIATELY +LOCK_UN = 0x08 __overlapped = pywintypes.OVERLAPPED() -def lock(file, flags): - hfile = win32file._get_osfhandle(file.fileno()) +def flock(file, flags): + hfile = win32file._get_osfhandle(file) win32file.LockFileEx(hfile, flags, 0, 0xffff0000, __overlapped) def unlock(file): - hfile = win32file._get_osfhandle(file.fileno()) + hfile = win32file._get_osfhandle(file) win32file.UnlockFileEx(hfile, 0, 0xffff0000, __overlapped)