Skip to content

Commit

Permalink
Fix documentation build (#8308)
Browse files Browse the repository at this point in the history
* Fix docs build

Signed-off-by: Vladimir Bataev <[email protected]>

* Clean up

Signed-off-by: Vladimir Bataev <[email protected]>

* Fix mock imports

Signed-off-by: Vladimir Bataev <[email protected]>

* Add comment

Signed-off-by: Vladimir Bataev <[email protected]>

---------

Signed-off-by: Vladimir Bataev <[email protected]>
  • Loading branch information
artbataev authored Feb 1, 2024
1 parent f6e6485 commit a4f1f1c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 2 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
'PIL',
'boto3',
'taming',
'cytoolz', # for adapters
'megatron', # for nlp
]

_skipped_autodoc_mock_imports = ['wrapt', 'numpy']
Expand Down
2 changes: 1 addition & 1 deletion docs/update_docs_docker.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cd ../
docker run --rm -v $PWD:/workspace python:3.8 /bin/bash -c "cd /workspace && \
docker run --rm -v $PWD:/workspace python:3.10 /bin/bash -c "cd /workspace && \
pip install -r requirements/requirements_docs.txt && cd docs/ && rm -rf build && make clean && make html && make html"
echo "To start web server just run in docs directory:"
echo "python3 -m http.server 8000 --directory ./build/html/"
4 changes: 4 additions & 0 deletions nemo/core/neural_types/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ def fields(self):
return None

def compare(self, second) -> NeuralTypeComparisonResult:
if torch.jit.is_scripting():
# Neural types for TorchScript are suppressed
# This is a stub to make TorchScript happy
return NeuralTypeComparisonResult.SAME
# First, check general compatibility
first_t = type(self)
second_t = type(second)
Expand Down
18 changes: 15 additions & 3 deletions nemo/core/neural_types/neural_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,21 @@ def __str__(self):
else:
return f"axes: None; elements_type: {self.elements_type.__class__.__name__}"

def __init__(self, axes: Optional[Any] = None, elements_type: Optional[Any] = None, optional: bool = False):
"""
Args:
axes: a tuple of AxisTypes objects representing the semantics of what varying each axis means
elements_type: None or ElementType; we need Any annotation here to avoid problems with TorchScript (it is checked in _init_internal)
optional: If input to the port of this type can be optional (False by default).
"""
if not torch.jit.is_scripting():
self._init_internal(axes=axes, elements_type=elements_type, optional=optional)

@torch.jit.unused
def __init__(self, axes: Optional[Any] = None, elements_type: Optional[ElementType] = None, optional=False):
def _init_internal(
self, axes: Optional[Any] = None, elements_type: Optional[ElementType] = None, optional: bool = False
):
"""Internals of __init__, separated to make TorchScript and autodoc work"""
if elements_type is None:
elements_type = VoidType()
if not isinstance(elements_type, ElementType):
Expand All @@ -62,8 +75,7 @@ def __init__(self, axes: Optional[Any] = None, elements_type: Optional[ElementTy
)
self.elements_type = elements_type
if axes is not None:
if not torch.jit.is_scripting():
NeuralType.__check_sanity(axes)
NeuralType.__check_sanity(axes)
axes_list = []
for axis in axes:
if isinstance(axis, str):
Expand Down

0 comments on commit a4f1f1c

Please sign in to comment.