Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sporadic permission error on Windows when running preranked analysis #180

Closed
dmitriikamaevqia opened this issue Dec 13, 2022 · 2 comments
Closed

Comments

@dmitriikamaevqia
Copy link

Preranked analysis on Windows sometimes causes this error. My guess is you are trying to cleanup tmp directory while logger is sill writing into it

`C:\Users\abc\AppData\Local\Temp\ipykernel_4536\399291494.py:1: DeprecationWarning: processes is deprecated; use threads
preranked_result = gp.prerank(rnk=significant_genes,
2022-12-12 15:06:11,853 Duplicated values found in preranked stats: 34.79% of genes
The order of those genes will be arbitrary, which may produce unexpected results.


PermissionError Traceback (most recent call last)
File ~\AppData\Local\Programs\Python\Python39\lib\shutil.py:627, in _rmtree_unsafe(path, onerror)
626 try:
--> 627 os.unlink(fullname)
628 except OSError:

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\Users\abc\AppData\Local\Temp\tmpgamkfkhl\gseapy.prerank.log'

During handling of the above exception, another exception occurred:

PermissionError Traceback (most recent call last)
File ~\AppData\Local\Programs\Python\Python39\lib\tempfile.py:805, in TemporaryDirectory._rmtree..onerror(func, path, exc_info)
804 try:
--> 805 _os.unlink(path)
806 # PermissionError is raised on FreeBSD for directories

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\Users\abc\AppData\Local\Temp\tmpgamkfkhl\gseapy.prerank.log'

During handling of the above exception, another exception occurred:

NotADirectoryError Traceback (most recent call last)
Input In [10], in <cell line: 1>()
----> 1 preranked_result = gp.prerank(rnk=significant_genes,
2 gene_sets=gene_sets.copy(),
3 min_size=10,
4 max_size=10000,
5 processes=4,
6 no_plot=True)
7 gsea_df = preranked_result.res2d
8 gsea_df['Term'] = gsea_df.index

File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\gseapy_init_.py:356, in prerank(rnk, gene_sets, outdir, pheno_pos, pheno_neg, min_size, max_size, permutation_num, weighted_score_type, ascending, threads, figsize, format, graph_num, no_plot, seed, verbose, *arg, **kwarg)
336 threads = kwarg["processes"]
337 pre = Prerank(
338 rnk,
339 gene_sets,
(...)
354 verbose,
355 )
--> 356 pre.run()
357 return pre

File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\gseapy\gsea.py:464, in Prerank.run(self)
462 self._logger.info("Congratulations. GSEApy runs successfully................\n")
463 if self._outdir is None:
--> 464 self._tmpdir.cleanup()
466 return

File ~\AppData\Local\Programs\Python\Python39\lib\tempfile.py:834, in TemporaryDirectory.cleanup(self)
832 def cleanup(self):
833 if self._finalizer.detach():
--> 834 self._rmtree(self.name)

File ~\AppData\Local\Programs\Python\Python39\lib\tempfile.py:816, in TemporaryDirectory._rmtree(cls, name)
813 else:
814 raise
--> 816 _shutil.rmtree(name, onerror=onerror)

File ~\AppData\Local\Programs\Python\Python39\lib\shutil.py:759, in rmtree(path, ignore_errors, onerror)
757 # can't continue even if onerror hook returns
758 return
--> 759 return _rmtree_unsafe(path, onerror)

File ~\AppData\Local\Programs\Python\Python39\lib\shutil.py:629, in _rmtree_unsafe(path, onerror)
627 os.unlink(fullname)
628 except OSError:
--> 629 onerror(os.unlink, fullname, sys.exc_info())
630 try:
631 os.rmdir(path)

File ~\AppData\Local\Programs\Python\Python39\lib\tempfile.py:808, in TemporaryDirectory._rmtree..onerror(func, path, exc_info)
806 # PermissionError is raised on FreeBSD for directories
807 except (IsADirectoryError, PermissionError):
--> 808 cls._rmtree(path)
809 except FileNotFoundError:
810 pass

File ~\AppData\Local\Programs\Python\Python39\lib\tempfile.py:816, in TemporaryDirectory._rmtree(cls, name)
813 else:
814 raise
--> 816 _shutil.rmtree(name, onerror=onerror)

File ~\AppData\Local\Programs\Python\Python39\lib\shutil.py:759, in rmtree(path, ignore_errors, onerror)
757 # can't continue even if onerror hook returns
758 return
--> 759 return _rmtree_unsafe(path, onerror)

File ~\AppData\Local\Programs\Python\Python39\lib\shutil.py:610, in _rmtree_unsafe(path, onerror)
608 entries = list(scandir_it)
609 except OSError:
--> 610 onerror(os.scandir, path, sys.exc_info())
611 entries = []
612 for entry in entries:

File ~\AppData\Local\Programs\Python\Python39\lib\shutil.py:607, in _rmtree_unsafe(path, onerror)
605 def _rmtree_unsafe(path, onerror):
606 try:
--> 607 with os.scandir(path) as scandir_it:
608 entries = list(scandir_it)
609 except OSError:

NotADirectoryError: [WinError 267] The directory name is invalid: 'C:\Users\abc\AppData\Local\Temp\tmpgamkfkhl\gseapy.prerank.log'`

@zqfang
Copy link
Owner

zqfang commented Dec 15, 2022

That's weird. I'll check it.

zqfang pushed a commit that referenced this issue Dec 16, 2022
zqfang pushed a commit that referenced this issue Dec 18, 2022
@zqfang
Copy link
Owner

zqfang commented Dec 20, 2022

Fixed in new release v1.0.3

@zqfang zqfang closed this as completed Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants