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

PermissionError in phold plot #36

Open
Ulthran opened this issue Apr 12, 2024 · 6 comments
Open

PermissionError in phold plot #36

Ulthran opened this issue Apr 12, 2024 · 6 comments

Comments

@Ulthran
Copy link

Ulthran commented Apr 12, 2024

  • phold version: 0.1.4
  • Python version: 3.10.14
  • Operating System: Windows (WSL2, Ubuntu)

Description

Trying to run phold plot and I'm getting this error:

2024-04-12 16:30:33.499 | INFO     | phold.utils.validation:instantiate_dirs:70 - Checking the output directory /home/ctbus/Penn/sunbeam/projects/virus/sunbeam_output/virus/phold/LONG_plot
2024-04-12 16:30:33.499 | INFO     | phold.utils.validation:instantiate_dirs:73 - Removing /home/ctbus/Penn/sunbeam/projects/virus/sunbeam_output/virus/phold/LONG_plot because --force was specified
Traceback (most recent call last):
  File "/home/ctbus/Penn/sunbeam/.snakemake/160f8892b5f849b64b315e3ee4674746_/bin/phold", line 10, in <module>
    sys.exit(main())
  File "/home/ctbus/Penn/sunbeam/.snakemake/160f8892b5f849b64b315e3ee4674746_/lib/python3.10/site-packages/phold/__init__.py", line 1355, in main
    main_cli()
  File "/home/ctbus/Penn/sunbeam/.snakemake/160f8892b5f849b64b315e3ee4674746_/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/ctbus/Penn/sunbeam/.snakemake/160f8892b5f849b64b315e3ee4674746_/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/ctbus/Penn/sunbeam/.snakemake/160f8892b5f849b64b315e3ee4674746_/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ctbus/Penn/sunbeam/.snakemake/160f8892b5f849b64b315e3ee4674746_/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ctbus/Penn/sunbeam/.snakemake/160f8892b5f849b64b315e3ee4674746_/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/ctbus/Penn/sunbeam/.snakemake/160f8892b5f849b64b315e3ee4674746_/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ctbus/Penn/sunbeam/.snakemake/160f8892b5f849b64b315e3ee4674746_/lib/python3.10/site-packages/phold/__init__.py", line 1236, in plot
    instantiate_dirs(output, force)
  File "/home/ctbus/Penn/sunbeam/.snakemake/160f8892b5f849b64b315e3ee4674746_/lib/python3.10/site-packages/phold/utils/validation.py", line 74, in instantiate_dirs
    shutil.rmtree(output_dir)
  File "/home/ctbus/Penn/sunbeam/.snakemake/160f8892b5f849b64b315e3ee4674746_/lib/python3.10/shutil.py", line 725, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/home/ctbus/Penn/sunbeam/.snakemake/160f8892b5f849b64b315e3ee4674746_/lib/python3.10/shutil.py", line 681, in _rmtree_safe_fd
    onerror(os.unlink, fullname, sys.exc_info())
  File "/home/ctbus/Penn/sunbeam/.snakemake/160f8892b5f849b64b315e3ee4674746_/lib/python3.10/shutil.py", line 679, in _rmtree_safe_fd
    os.unlink(entry.name, dir_fd=topfd)
PermissionError: [Errno 13] Permission denied: 'phold_plot_1712951468.829077.log'

I'm running this locally on a computer where I'm the only user. Permissions for the output of phold compare:

drwxr-xr-x 4 ctbus ctbus 4096 Apr 12 15:47 ./
drwxr-xr-x 8 ctbus ctbus 4096 Apr 12 16:29 ../
drwxr-xr-x 2 ctbus ctbus 4096 Apr 12 15:47 logs/
-rw-r--r-- 1 ctbus ctbus 6324 Apr 12 15:47 phold.gbk
-rw-r--r-- 1 ctbus ctbus  624 Apr 12 15:47 phold_3di.fasta
-rw-r--r-- 1 ctbus ctbus  624 Apr 12 15:47 phold_aa.fasta
-rw-r--r-- 1 ctbus ctbus 1945 Apr 12 15:47 phold_all_cds_functions.tsv
-rw-r--r-- 1 ctbus ctbus 9244 Apr 12 15:47 phold_compare_1712951223.3917286.log
-rw-r--r-- 1 ctbus ctbus 1596 Apr 12 15:47 phold_per_cds_predictions.tsv
drwxr-xr-x 2 ctbus ctbus 4096 Apr 12 15:47 sub_db_tophits/

What I Did

Ran install, predict, compare with minimal options, just specifying inputs, outputs, db path, and --force. Plot command:

phold plot -i {input.gbk} -o $(dirname {output.png}) --force

Getting this using a conda install and a docker install. I suspect it's just a matter of earlier steps writing with overly restrictive permissions for what plot is trying to do. Let me know if there's any more information/help I can give.

Thanks,
Charlie

@gbouras13
Copy link
Owner

Hi @Ulthran ,

Thanks for raising this. I am not sure myself what could be the issue - I don't think it has anything to do with the output for phold compare.

It looks like it can't force remove the output directory shutil.rmtree(output_dir) but weirdly throws an error to the log file... I am not really sure - maybe try without --force?

George

@Ulthran
Copy link
Author

Ulthran commented Apr 16, 2024

Thanks @gbouras13, without --force it's complaining about the directory existing:

2024-04-16 09:33:38.406 | INFO     | phold.utils.validation:instantiate_dirs:70 - Checking the output directory /home/ctbus/Penn/sunbeam/projects/virus/sunbeam_output/virus/phold/LONG_plot2
2024-04-16 09:33:38.406 | ERROR    | phold.utils.validation:instantiate_dirs:81 - Output directory already exists and force was not specified. Please specify -f or --force to overwrite the output directory

Unfortunately, that's because of snakemake making the output directory before running the command (which I don't think is behavior I can change). So I need to run with --force in this context.

@gbouras13
Copy link
Owner

@Ulthran I've run into that with snakemake before too :(

I'll implement phold into a snakemake pipeline when I get some time and see if I get the same error as well - otherwise, not quite sure how to go about fixing this!

George

@Ulthran
Copy link
Author

Ulthran commented Apr 22, 2024

Ok thanks George, this is at the end of our pipeline so it's not hugely important that it be automated. If you do come up with a fix though we'll be happy to implement it!

@gbouras13
Copy link
Owner

Hi @Ulthran ,

We have implemented phold in a snakemake pipeline (https://github.com/linsalrob/sphae) and don't have such an error - maybe have a look at the rules in sphae?

George

@Ulthran
Copy link
Author

Ulthran commented Aug 5, 2024

Thanks @gbouras13 , it's only happening for phold plot though. Do you get the same issue if you add a rule for that to sphae?

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