-
Notifications
You must be signed in to change notification settings - Fork 287
Labels
bugbugs in the librarybugs in the library
Description
Description
My setup mounts PYTHAINLP_DATA_DIR from a central server in read-only mode.
Expected results
If db.json existed and it is read-only, there should be no problem reading it.
Current results
TinyDB raised permission denied when db.json is read-only
Traceback (most recent call last):
File "[REDACTED]/train.py", line 142, in <module>
main(args)
File "[REDACTED]/train.py", line 83, in main
from featurizer import Featurizer
File "[REDACTED]/featurizer.py", line 1, in <module>
from pythainlp.tokenize import newmm
File "[REDACTED]/venv/lib/python3.9/site-packages/pythainlp/__init__.py", line 39, in <module>
from pythainlp.soundex import soundex
File "[REDACTED]/venv/lib/python3.9/site-packages/pythainlp/soundex/__init__.py", line 15, in <module>
from pythainlp.soundex.lk82 import lk82
File "[REDACTED]/venv/lib/python3.9/site-packages/pythainlp/soundex/lk82.py", line 10, in <module>
from pythainlp.util import remove_tonemark
File "[REDACTED]/venv/lib/python3.9/site-packages/pythainlp/util/__init__.py", line 68, in <module>
from pythainlp.util.keywords import find_keyword, rank
File "[REDACTED]/venv/lib/python3.9/site-packages/pythainlp/util/keywords.py", line 5, in <module>
from pythainlp.corpus import thai_stopwords
File "[REDACTED]/venv/lib/python3.9/site-packages/pythainlp/corpus/__init__.py", line 55, in <module>
TinyDB(_CORPUS_DB_PATH).close()
File "[REDACTED]/venv/lib/python3.9/site-packages/tinydb/database.py", line 94, in __init__
self._storage: Storage = storage(*args, **kwargs)
File "[REDACTED]/venv/lib/python3.9/site-packages/tinydb/storages.py", line 102, in __init__
touch(path, create_dirs=create_dirs)
File "[REDACTED]/venv/lib/python3.9/site-packages/tinydb/storages.py", line 31, in touch
with open(path, 'a'):
PermissionError: [Errno 13] Permission denied: './datadir/pythainlp-data/db.json'
Steps to reproduce
- change data dir permission to read-only
chmod 0444 /your/dir/here/* - import ulmfit preprocess.
- observe the error.
from pythainlp.ulmfit import preprocessContext
Your environment
- PyThaiNLP version: 3.0.0
- Python version: 3.9.10
- Operating system and version (distro, 32/64-bit): Linux gentoo-grill 5.16.4-gentoo
- More info (Docker, VM, etc.):
Possible solution
A little digging and I found that TinyDB my has option for access modes msiemens/tinydb#136 (comment)
Files
datadir's content:
pythainlp-data/
├── db.json
├── itos_lstm.pkl
└── thwiki_model_lstm.pth
db.json:
{"_default": {"1": {"name": "wiki_lm_lstm", "version": "0.32", "filename": "thwiki_model_lstm.pth"}, "2": {"name": "wiki_itos_lstm", "version": "0.32", "filename": "itos_lstm.pkl"}}}
Metadata
Metadata
Assignees
Labels
bugbugs in the librarybugs in the library