Skip to content

Commit

Permalink
Fix derived class handling
Browse files Browse the repository at this point in the history
  • Loading branch information
vshampor committed Apr 19, 2023
1 parent aa8e714 commit 30ab20a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
9 changes: 7 additions & 2 deletions docs/api/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ def collect_api_entities() -> List[str]:
if objects_module == modname:
if inspect.isclass(obj) or inspect.isfunction(obj):
if hasattr(obj, "_nncf_api_marker"):
print(f"\t{obj_name}")
api_fqns.append(f"{modname}.{obj_name}")
marked_object_name = obj._nncf_api_marker
# Check the actual name of the originally marked object
# so that the classes derived from base API classes don't
# all automatically end up in API
if marked_object_name == obj.__name__:
print(f"\t{obj_name}")
api_fqns.append(f"{modname}.{obj_name}")

print()
skipped_str = '\n'.join([f"{k}: {v}" for k, v in skipped_modules.items()])
Expand Down
4 changes: 3 additions & 1 deletion nncf/common/api_marker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ def __init__(self):
pass

def __call__(self, obj):
setattr(obj, api.API_MARKER_ATTR, True)
# The value of the marker will be useful in determining
# whether we are handling a base class or a derived one.
setattr(obj, api.API_MARKER_ATTR, obj.__name__)
return obj
1 change: 0 additions & 1 deletion nncf/common/quantization/structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from enum import Enum
from typing import Dict, List, Optional, Any

from nncf.common.api_marker import api
from nncf.common.graph import NNCFNode
from nncf.common.graph import NNCFNodeName
from nncf.config.schemata.defaults import QUANTIZATION_BITS
Expand Down
2 changes: 1 addition & 1 deletion nncf/torch/automl/environment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
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.
"""
"""

0 comments on commit 30ab20a

Please sign in to comment.