Commit 0c258bac authored by Miquel Jubert Hermoso's avatar Miquel Jubert Hermoso Committed by Facebook GitHub Bot
Browse files

Move files from OSS option 1 to Option 2

Summary:
Pull Request resolved: https://github.com/facebookresearch/d2go/pull/224

*This diff is part of a stack which has the goal of "buckifying" D2 (https://github.com/facebookresearch/d2go/commit/87374efb134e539090e0b5c476809dc35bf6aedb)Go core and enabling autodeps and other tooling. The last diff in the stack introduces the TARGETS. The diffs earlier in the stack are resolving circular dependencies and other issues which prevent the buckification from occurring.*

This diffs moves a few files from using the pattern 1 of open source overriding to the pattern 2, using the decorators.

Reviewed By: wat3rBro

Differential Revision: D35928506

fbshipit-source-id: 2ec82809843c49558db7e38e1906810dfa3e07f3
parent 217bbabd
...@@ -2,11 +2,14 @@ ...@@ -2,11 +2,14 @@
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os import os
from typing import Dict, List from enum import Enum
from typing import Any, Dict, List
import pkg_resources import pkg_resources
from d2go.utils.oss_helper import fb_overwritable
@fb_overwritable()
def reroute_config_path(path: str) -> str: def reroute_config_path(path: str) -> str:
""" """
Supporting rerouting the config files for convenience: Supporting rerouting the config files for convenience:
...@@ -187,3 +190,15 @@ def get_diff_cfg(old_cfg, new_cfg): ...@@ -187,3 +190,15 @@ def get_diff_cfg(old_cfg, new_cfg):
out = new_cfg.__class__() out = new_cfg.__class__()
return get_diff_cfg_rec(old_cfg, new_cfg, out) return get_diff_cfg_rec(old_cfg, new_cfg, out)
def namedtuple_to_dict(obj: Any):
"""Convert NamedTuple or dataclass to dict so it can be used as config"""
res = {}
for k, v in obj.__dict__.items():
if isinstance(v, Enum):
# in case of enum, serialize the enum value
res[k] = v.value
else:
res[k] = v
return res
...@@ -12,8 +12,10 @@ from d2go.modeling.meta_arch.fcos import add_fcos_configs ...@@ -12,8 +12,10 @@ from d2go.modeling.meta_arch.fcos import add_fcos_configs
from d2go.modeling.model_freezing_utils import add_model_freezing_configs from d2go.modeling.model_freezing_utils import add_model_freezing_configs
from d2go.modeling.subclass import add_subclass_configs from d2go.modeling.subclass import add_subclass_configs
from d2go.quantization.modeling import add_quantization_default_configs from d2go.quantization.modeling import add_quantization_default_configs
from d2go.utils.oss_helper import fb_overwritable
@fb_overwritable()
def add_tensorboard_default_configs(_C): def add_tensorboard_default_configs(_C):
_C.TENSORBOARD = CN() _C.TENSORBOARD = CN()
# Output from dataloader will be written to tensorboard at this frequency # Output from dataloader will be written to tensorboard at this frequency
...@@ -28,12 +30,14 @@ def add_tensorboard_default_configs(_C): ...@@ -28,12 +30,14 @@ def add_tensorboard_default_configs(_C):
_C.register_deprecated_key("TENSORBOARD.LOG_DIR") _C.register_deprecated_key("TENSORBOARD.LOG_DIR")
@fb_overwritable()
def add_abnormal_checker_configs(_C): def add_abnormal_checker_configs(_C):
_C.ABNORMAL_CHECKER = CN() _C.ABNORMAL_CHECKER = CN()
# check and log the iteration with bad losses if enabled # check and log the iteration with bad losses if enabled
_C.ABNORMAL_CHECKER.ENABLED = False _C.ABNORMAL_CHECKER.ENABLED = False
@fb_overwritable()
def get_default_cfg(_C): def get_default_cfg(_C):
# _C.MODEL.FBNET... # _C.MODEL.FBNET...
add_fbnet_v2_default_configs(_C) add_fbnet_v2_default_configs(_C)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment