Skip to content

Commit

Permalink
DOCS-modin-project#7144: Add information about logging from user defi…
Browse files Browse the repository at this point in the history
…ned function (modin-project#7155)

Co-authored-by: Iaroslav Igoshev <[email protected]>
Signed-off-by: arunjose696 <[email protected]>
  • Loading branch information
arunjose696 and YarShev authored Apr 10, 2024
1 parent 4ad1807 commit 717a328
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions docs/usage_guide/advanced_usage/modin_logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,42 @@ Disable Modin logging like so:
LogMode.disable()
# User code goes here
Debugging from user defined functions:

.. warning::
When attempting to use Modin logging in user defined functions that execute in workers for logging lower-level operators
as in example below, multiple log directories ``.modin/logs/job_**`` would be created for each worker executing the UDF.

.. code-block:: python
import modin.pandas as pd
def udf(x):
from modin.config import LogMode
LogMode.enable()
return x + 1
modin_df = pd.DataFrame([0, 1, 2, 3])
print(modin_df.map(udf))
So the **recommended** approach would be to use a different logger as in the below snipet
to log from user defined functions that execute on workers.
Below is an an example to log from UDF. For this the logger config has to be specified inside the UDF that would execute on a remote worker.

.. code-block:: python
import logging
import modin.pandas as pd
def udf(x):
logging.basicConfig(filename='modin_udf.log', level=logging.INFO)
logging.info("This log message will be written to modin_udf.log ")
# User code goes here
return x + 1
modin_df = pd.DataFrame([0, 1, 2, 3])
print(modin_df.map(udf))

0 comments on commit 717a328

Please sign in to comment.