You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/notes/installation.rst
+25-7Lines changed: 25 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,7 +89,8 @@ Key considerations
89
89
90
90
2. **Use a writable local directory**: The default data directory (``~/pythainlp-data``) may not be writable on executor nodes. Use a local directory like ``./pythainlp-data`` instead.
91
91
92
-
3. **Set ``PYTHAINLP_DATA_DIR`` before data access**: Always set the ``PYTHAINLP_DATA_DIR`` environment variable before the first call that reads or writes PyThaiNLP data on each worker.
92
+
3. **Set ``PYTHAINLP_DATA`` before data access**: Always set the ``PYTHAINLP_DATA`` environment variable before the first call that reads or writes PyThaiNLP data on each worker.
93
+
(``PYTHAINLP_DATA_DIR`` is also accepted for backward compatibility but is deprecated.)
93
94
94
95
Example usage with Apache Spark
95
96
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -104,7 +105,7 @@ Basic example using PySpark RDD::
@@ -141,13 +142,30 @@ Note that while the code itself is thread-safe, you still need to configure the
141
142
Runtime configurations
142
143
----------------------
143
144
144
-
.. envvar:: PYTHAINLP_DATA_DIR
145
+
.. envvar:: PYTHAINLP_DATA
145
146
146
147
Specifies the location where downloaded data and the corpus database are stored. If the directory does not exist, PyThaiNLP will create it.
147
148
148
149
By default this is a directory named ``pythainlp-data`` in the user's home directory.
149
150
150
-
Run ``thainlp data path`` at the command line to display the current `PYTHAINLP_DATA_DIR`.
151
+
Run ``thainlp data path`` at the command line to display the current data directory.
152
+
153
+
.. envvar:: PYTHAINLP_DATA_DIR
154
+
155
+
.. deprecated::
156
+
Use :envvar:`PYTHAINLP_DATA` instead. Setting ``PYTHAINLP_DATA_DIR`` triggers a
157
+
:class:`DeprecationWarning` at runtime. If both ``PYTHAINLP_DATA`` and ``PYTHAINLP_DATA_DIR``
158
+
are set simultaneously, PyThaiNLP raises :exc:`ValueError`.
159
+
160
+
.. envvar:: PYTHAINLP_OFFLINE
161
+
162
+
When set to a truthy value (``1``, ``true``, ``yes``, ``on``), PyThaiNLP operates in
163
+
*offline mode*: corpus downloads are disabled, and :func:`pythainlp.corpus.get_corpus_path`
164
+
raises :exc:`FileNotFoundError` for any corpus that is not already cached locally.
165
+
166
+
Use :func:`pythainlp.is_offline_mode` to check the current state programmatically.
167
+
168
+
This follows the same convention as ``HF_HUB_OFFLINE`` in `huggingface_hub`.
151
169
152
170
.. envvar:: PYTHAINLP_READ_MODE
153
171
@@ -158,11 +176,11 @@ Installation FAQ
158
176
159
177
Q: How do I set environment variables on each executor node in a distributed environment?
160
178
161
-
A: When using PyThaiNLP in distributed computing environments like Apache Spark, you need to set the ``PYTHAINLP_DATA_DIR`` environment variable inside the function that will be distributed to executor nodes. For example::
179
+
A: When using PyThaiNLP in distributed computing environments like Apache Spark, you need to set the ``PYTHAINLP_DATA`` environment variable inside the function that will be distributed to executor nodes. For example::
0 commit comments