IBM/simulai

Sphinx Build Successful but with 146 Warnings

TarikKaanKoc opened this issue · 7 comments

I have successfully built my Sphinx documentation but I am getting 146 warnings. Is there a way to automatically fix these warnings?

I have tried using the "nitpick mode" but I am getting an error that says "nitpick mode" is not available through the constructor name or entry point. I am not sure what is causing this issue and I would appreciate any help in resolving it.

Additionally, is there a way to automatically fix these warnings in the future?

Thank you. @snitramodranoel @Joao-L-S-Almeida

Hi, @TarikKaanKoc
Maybe the warnings you are receiving are like these ones:

/home/docs/checkouts/readthedocs.org/user_builds/simulai-toolkit/checkouts/latest/simulai/parallel.py:23: UserWarning: Trying to import MPI in /home/docs/checkouts/readthedocs.org/user_builds/simulai-toolkit/checkouts/latest/simulai/parallel.py.
  warnings.warn(f'Trying to import MPI in {__file__}.')
/home/docs/checkouts/readthedocs.org/user_builds/simulai-toolkit/checkouts/latest/simulai/parallel.py:24: UserWarning: mpi4py is not installed. If you want to execute MPI jobs, we recommend you install it.
  warnings.warn('mpi4py is not installed. If you want to execute MPI jobs, we recommend you install it.')
/home/docs/checkouts/readthedocs.org/user_builds/simulai-toolkit/checkouts/latest/simulai/regression/_opinf.py:33: UserWarning: Trying to import MPI in /home/docs/checkouts/readthedocs.org/user_builds/simulai-toolkit/checkouts/latest/simulai/regression/_opinf.py.
  warnings.warn(f'Trying to import MPI in {__file__}.')
/home/docs/checkouts/readthedocs.org/user_builds/simulai-toolkit/checkouts/latest/simulai/regression/_opinf.py:34: UserWarning: mpi4py is not installed. If you want to execute MPI jobs, we recommend you install it.
  warnings.warn('mpi4py is not installed. If you want to execute MPI jobs, we recommend you install it.')
/home/docs/checkouts/readthedocs.org/user_builds/simulai-toolkit/checkouts/latest/simulai/sampling/_hamiltonian_sampling.py:7: UserWarning: Hamilatonian sampling is in EXPERIMENTAL stage.
  warnings.warn("Hamilatonian sampling is in EXPERIMENTAL stage.")
/home/docs/checkouts/readthedocs.org/user_builds/simulai-toolkit/checkouts/latest/simulai/batching.py:docstring of simulai.batching.indices_batchdomain_constructor:4: CRITICAL: Unexpected section title.

The major part is related to MPI. The dependency mpi4py is just required for executing MPI jobs, so you have the option of not necessarily installing it, however, the warning is displayed when the importing of these modules is done, even when no MPI task is really being executed. It must not interfere in the general working, but we should move move these warnings for a more silent place, for example, inside the init methods, in this way the warnings are displayed just when the classes are instantiated.

@Joao-L-S-Almeida

How about this:

try:
    import mpi4py
    from mpi4py import MPI
except ImportError:
    print("mpi4py library not found. Skipping MPI operations.")
    mpi4py = None
    MPI = None

if mpi4py is not None:
    # MPI operations here
else:
    # Non-MPI operations here

@Joao-L-S-Almeida

How about this:

try:
    import mpi4py
    from mpi4py import MPI
except ImportError:
    print("mpi4py library not found. Skipping MPI operations.")
    mpi4py = None
    MPI = None

if mpi4py is not None:
    # MPI operations here
else:
    # Non-MPI operations here

unfortunately it didn't work

@Joao-L-S-Almeida

### Do you think this will work for us?

import warnings

    def __init__(self):
        try:
            from mpi4py import MPI
            self.MPI_AVAILABILITY = True
        except ImportError:
            self.MPI_AVAILABILITY = False
            warnings.warn(f'Trying to import MPI in {__file__}.')
            warnings.warn('mpi4py is not installed. If you want to execute MPI jobs, we recommend you install it.')

@Joao-L-S-Almeida

### Do you think this will work for us?

import warnings

    def __init__(self):
        try:
            from mpi4py import MPI
            self.MPI_AVAILABILITY = True
        except ImportError:
            self.MPI_AVAILABILITY = False
            warnings.warn(f'Trying to import MPI in {__file__}.')
            warnings.warn('mpi4py is not installed. If you want to execute MPI jobs, we recommend you install it.')

The problem it is mpi4py is used by the orthers methods. It should be visible as global inside the class OpInf. Maybe we can transform it in an attribute.

I'll try to move them and repeat the MPI tests in our cluster.

docs: fix mpi4py errors during documentation generation

  • added 'autodoc_mock_imports' configuration to mock the import of 'mpi4py'
  • verified that documentation is generated without errors related to 'mpi4py'

@Joao-L-S-Almeida #71