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

Unexpected write permission required for general/last.pt? #23

Open
BioinfoTongLI opened this issue Dec 5, 2024 · 3 comments
Open

Unexpected write permission required for general/last.pt? #23

BioinfoTongLI opened this issue Dec 5, 2024 · 3 comments
Assignees

Comments

@BioinfoTongLI
Copy link

Describe the bug
spotiflow asks for writing permissions in the folder of pretrained models.
This is raising an issue when the pretrained models is downloaded into a container, where it's ready-only

exepcted behaviour
Spotiflow should just load the models from the directory and not try to write anything there(?)

To Reproduce
run a standard prediction with general model

Environment (please complete the following information):

  • Spotiflow version: 0.5.1
  • OS: linux
  • OS version: 22.04

Additional context
Add any other context about the problem here.

@AlbertDominguez AlbertDominguez self-assigned this Dec 9, 2024
@AlbertDominguez
Copy link
Collaborator

Hi @BioinfoTongLI,

I tried to replicate by using a read-only cache directory and having the model placed there beforehand but it seems to load normally. Could you paste here the relevant Dockerfile lines (e.g. copying the model to the dir)? Is the model unzipped by the dockerfile or it just transfers the zip?

@BioinfoTongLI
Copy link
Author

Hi @AlbertDominguez, sure! many thanks for your reply!
Here it is.
https://github.com/BioinfoTongLI/containers/blob/main/spotiflow/0.5.1-py11/Dockerfile
I've checked that indeed it loaded successfully with Docker. But not with singularity.

Here's the actually error mesage.

Python 3.11.10 | packaged by conda-forge | (main, Oct 16 2024, 01:27:36) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from spotiflow.model import Spotiflow
>>> from spotiflow.model import Spotiflow
>>> Spotiflow.from_pretrained('general')
INFO:spotiflow.model.spotiflow:Loading pretrained model: general
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/conda/lib/python3.11/site-packages/spotiflow/model/spotiflow.py", line 229, in from_pretrained
    pretrained_path = get_pretrained_model_path(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/spotiflow/model/pretrained.py", line 46, in get_pretrained_model_path
    get_file(
  File "/opt/conda/lib/python3.11/site-packages/spotiflow/utils/get_file.py", line 597, in get_file
    _extract_archive(fpath, datadir, archive_format)
  File "/opt/conda/lib/python3.11/site-packages/spotiflow/utils/get_file.py", line 158, in _extract_archive
    archive.extractall(path)
  File "/opt/conda/lib/python3.11/zipfile.py", line 1702, in extractall
    self._extract_member(zipinfo, path, pwd)
  File "/opt/conda/lib/python3.11/zipfile.py", line 1756, in _extract_member
    open(targetpath, "wb") as target:
    ^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 30] Read-only file system: '/models/general/last.pt'

I will try to find out if it's a singularity-specific issue.

@AlbertDominguez
Copy link
Collaborator

Hi @BioinfoTongLI ,

I think I found the culprit! We were automatically unzipping the model files (which are downloaded as a bundled zip file) each time, even if it had been unzipped before. I just pushed a fix so that unzipping happens only if the resulting folder does not exist yet, so nothing should be tried to be written. I unfortunately do not have a singularity setup, but could you try to install from the latest commit? If that works I'll release to PyPi with the fix.

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