move configs into fairseq dir (#1403)

Summary:
this way they get shipped together with fairseq package

Pull Request resolved: https://github.com/fairinternal/fairseq-py/pull/1403

Reviewed By: myleott

Differential Revision: D24803076

Pulled By: alexeib

fbshipit-source-id: a9aa6e47a8ef26fae4d54691f1616a721b8f6112
This commit is contained in:
alexeib 2020-11-06 22:51:29 -08:00 committed by Facebook GitHub Bot
parent b7a2e00958
commit 09a5d864fc
13 changed files with 4 additions and 8 deletions

View File

@ -290,9 +290,6 @@ def convert_namespace_to_omegaconf(args: Namespace) -> DictConfig:
# configs will be in fairseq/config after installation
config_path = os.path.join("..", "config")
if not os.path.exists(config_path):
# in case of "--editable" installs we need to go one dir up
config_path = os.path.join("..", "..", "config")
with initialize(config_path=config_path):
composed_cfg = compose("config", overrides=overrides, strict=False)

View File

@ -6,6 +6,7 @@
import hydra
from omegaconf import OmegaConf
import os
from fairseq.dataclass.initialize import hydra_init
from fairseq_cli.train import main as pre_main
@ -19,7 +20,7 @@ import torch
logger = logging.getLogger(__name__)
@hydra.main(config_path="../config", config_name="config")
@hydra.main(config_path=os.path.join("..", "fairseq", "config"), config_name="config")
def hydra_main(cfg: FairseqConfig) -> None:
cfg = OmegaConf.create(OmegaConf.to_container(cfg, resolve=True, enum_to_str=True))

View File

@ -222,15 +222,13 @@ def get_files(path, relative_to="fairseq"):
try:
# symlink config and examples into fairseq package so package_data accepts them
# symlink examples into fairseq package so package_data accepts them
if "build_ext" not in sys.argv[1:]:
os.symlink(os.path.join("..", "config"), "fairseq/config")
os.symlink(os.path.join("..", "examples"), "fairseq/examples")
package_data = {
"fairseq": get_files("fairseq/config") + get_files("fairseq/examples"),
"fairseq": get_files("fairseq/examples"),
}
do_setup(package_data)
finally:
if "build_ext" not in sys.argv[1:]:
os.unlink("fairseq/config")
os.unlink("fairseq/examples")