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

Less intrusive doc builds #1060

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d5fd824
Rather than mocking pandas, intercept parsing of EncoderDataFrame and…
dagardner-nv Jul 14, 2023
f496bda
Remove import of MutateOp, allowing the register_morpheus_extensions …
dagardner-nv Jul 14, 2023
87aa76f
Update import path for MutateOp
dagardner-nv Jul 14, 2023
b2dca87
Don't import register_morpheus_extensions and patch_numpy_dtype_regis…
dagardner-nv Jul 14, 2023
c2d9db5
Mock register_morpheus_extensions and patch_numpy_dtype_registry to p…
dagardner-nv Jul 14, 2023
e7c896e
Perform inspect.unwrap in a try block since auto-doc mocks will retur…
dagardner-nv Jul 17, 2023
1ffb42b
Remove hacky work-around
dagardner-nv Jul 17, 2023
402145d
Remove un-needed mock
dagardner-nv Jul 17, 2023
b8f8625
Hack to remove mocked transform method
dagardner-nv Jul 17, 2023
9bce794
cleanups
dagardner-nv Jul 17, 2023
c824f4b
Merge branch 'branch-23.11' into david-doc-builds-nvt-mock
dagardner-nv Jul 17, 2023
ae0ad29
Remove unused import, ignore error for bare except
dagardner-nv Jul 17, 2023
e12b2a9
Fix import paths
dagardner-nv Jul 17, 2023
1509e50
Merge branch 'branch-23.11' of github.com:nv-morpheus/Morpheus into d…
dagardner-nv Jul 21, 2023
808bfd0
Merge branch 'branch-23.11' of github.com:nv-morpheus/Morpheus into d…
dagardner-nv Jul 21, 2023
a9dcb02
Version fixes
dagardner-nv Jul 21, 2023
9639126
yapf formatting
dagardner-nv Jul 21, 2023
c53ff71
Merge branch 'branch-23.11' into david-doc-builds-nvt-mock
dagardner-nv Jul 26, 2023
1909c26
Merge branch 'branch-23.11' into david-doc-builds-nvt-mock
dagardner-nv Aug 4, 2023
e965840
Merge branch 'branch-23.11' into david-doc-builds-nvt-mock
dagardner-nv Aug 22, 2023
9f59b71
Merge branch 'branch-23.11' into david-doc-builds-nvt-mock
dagardner-nv Aug 23, 2023
152fee0
Merge branch 'david-doc-builds-nvt-mock' of github.com:dagardner-nv/M…
dagardner-nv Aug 23, 2023
83bc486
Scale back the more magical hacks in conf.py per PR feedback
dagardner-nv Aug 23, 2023
3edb003
pylint fixes
dagardner-nv Aug 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#

import importlib
import os
import sys
Expand Down Expand Up @@ -166,9 +166,8 @@
"cupy", # Avoid loading GPU libraries during the documentation build
"merlin",
"morpheus.cli.commands", # Dont document the CLI in Sphinx
"morpheus.utils.nvt.mutate.annotate",
"nvtabular",
"pandas", # Avoid documenting pandas for the purposes of the dfencoder.dataframe
"pandas",
"tensorrt",
"torch",
"tqdm",
Expand Down
6 changes: 5 additions & 1 deletion docs/source/sphinxext/github_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ def _linkcode_resolve(domain, info, package, url_fmt, revision):

# Unwrap the object to get the correct source
# file in case that is wrapped by a decorator
obj = inspect.unwrap(obj)
# Note: objects mocked by autodoc_mock_imports will raise an exception when we try to unwrap them
try:
obj = inspect.unwrap(obj)
except: # noqa: E722
return

fn: str = None
lineno: str = None
Expand Down
5 changes: 0 additions & 5 deletions morpheus/utils/nvt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,3 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from .extensions import register_morpheus_extensions
from .mutate import MutateOp

__all__ = ["MutateOp", "register_morpheus_extensions"]
23 changes: 23 additions & 0 deletions morpheus/utils/nvt/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import functools
import inspect
import os
import typing

import pandas as pd
Expand Down Expand Up @@ -98,3 +100,24 @@ def wrapper(*args, **kwargs) -> typing.Union[pd.DataFrame, cudf.DataFrame]:
return wrapper

return decorator


# Avoid using the annotate decorator in sphinx builds, instead define a simple pass-through decorator
if os.environ.get("MORPHEUS_IN_SPHINX_BUILD") is None:
from merlin.core.dispatch import annotate # pylint: disable=unused-import
else:

def annotate(*args, **kwargs): # pylint: disable=unused-argument
"""
`merlin.core.dispatch.annotate`
"""

def decorator(func):

@functools.wraps(func)
def wrappper(*args, **kwargs):
return func(*args, **kwargs)

return wrappper

return decorator
17 changes: 2 additions & 15 deletions morpheus/utils/nvt/mutate.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import functools
import os
import typing
from inspect import getsourcelines

Expand All @@ -24,18 +22,7 @@
from nvtabular.ops.operator import ColumnSelector
from nvtabular.ops.operator import Operator

# Avoid using the annotate decorator in sphinx builds, instead define a simple pass-through decorator
if os.environ.get("MORPHEUS_IN_SPHINX_BUILD") is None:
from merlin.core.dispatch import annotate # pylint: disable=ungrouped-imports
else:

def annotate(func, *args, **kwargs): # pylint: disable=unused-argument

@functools.wraps(func)
def decorator(func):
return func

return decorator
from morpheus.utils.nvt.decorators import annotate


class MutateOp(Operator):
Expand Down Expand Up @@ -108,7 +95,7 @@ def label(self):

try:
# otherwise get the lambda source code from the inspect module if possible
source = getsourcelines(self.f)[0][0]
source = getsourcelines(self.f)[0][0] # pylint: disable=no-member
lambdas = [op.strip() for op in source.split(">>") if "lambda " in op]
if len(lambdas) == 1 and lambdas[0].count("lambda") == 1:
return lambdas[0]
Expand Down
2 changes: 1 addition & 1 deletion morpheus/utils/nvt/schema_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
from morpheus.utils.column_info import StringCatColumn
from morpheus.utils.column_info import StringJoinColumn
from morpheus.utils.column_info import create_increment_col
from morpheus.utils.nvt import MutateOp
from morpheus.utils.nvt.decorators import sync_df_as_pandas
from morpheus.utils.nvt.mutate import MutateOp
from morpheus.utils.nvt.transforms import json_flatten


Expand Down
8 changes: 4 additions & 4 deletions morpheus/utils/schema_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@
import cudf

from morpheus.utils.column_info import DataFrameInputSchema
from morpheus.utils.nvt import register_morpheus_extensions
from morpheus.utils.nvt.patches import patch_numpy_dtype_registry
from morpheus.utils.nvt import patches
from morpheus.utils.nvt.extensions import morpheus_ext
from morpheus.utils.nvt.schema_converters import create_and_attach_nvt_workflow

if os.environ.get("MORPHEUS_IN_SPHINX_BUILD") is None:
# Apply patches to NVT
# TODO(Devin): Can be removed, once numpy mappings are updated in Merlin
# ========================================================================
patch_numpy_dtype_registry()
patches.patch_numpy_dtype_registry()
# ========================================================================

# Add morpheus conversion mappings
# ========================================================================
register_morpheus_extensions()
morpheus_ext.register_morpheus_extensions()
# =========================================================================

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/nvt/integration/test_mutate_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import cudf

from morpheus.utils.nvt import MutateOp
from morpheus.utils.nvt.mutate import MutateOp
from morpheus.utils.nvt.transforms import json_flatten


Expand Down
2 changes: 1 addition & 1 deletion tests/utils/nvt/test_mutate_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from merlin.schema import Schema
from nvtabular.ops.operator import ColumnSelector

from morpheus.utils.nvt import MutateOp
from morpheus.utils.nvt.mutate import MutateOp


@pytest.fixture(name="df")
Expand Down