Skip to content

Commit

Permalink
[fix] Add hydra plugin as a file in the module
Browse files Browse the repository at this point in the history
  • Loading branch information
tamohannes committed Jun 27, 2024
1 parent e28c210 commit a077242
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 21 deletions.
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
entry_points={
"console_scripts": [
"urartu=urartu.__init__:main",
],
"hydra.plugins": [
"urartu_plugin = urartu.hydra_plugins.urartu_plugin.urartu_plugin:UrartuPlugin",
],
]
},
)
2 changes: 1 addition & 1 deletion urartu/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.9
2.0.10
31 changes: 15 additions & 16 deletions urartu/commands/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@

from aim import Run
from hydra import compose, initialize

from hydra.core.plugins import Plugins
from .command import Command

logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
)

from ..utils.launcher import launch, launch_on_slurm
from ..utils.slurm import is_submitit_available
from ..utils.registry import Registry
from ..utils.hydra_plugin import UrartuPlugin

logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")


def register_my_plugin() -> None:
Plugins.instance().register(UrartuPlugin)


register_my_plugin()


@Command.register("launch")
Expand All @@ -22,9 +27,7 @@ class Launch(Command):
Launches an action from a specific module
"""

def add_subparser(
self, parser: argparse._SubParsersAction
) -> argparse.ArgumentParser:
def add_subparser(self, parser: argparse._SubParsersAction) -> argparse.ArgumentParser:
description = """urartu: launcher"""
subparser = parser.add_parser(
self.name,
Expand All @@ -33,9 +36,7 @@ def add_subparser(
)

subparser.add_argument("--name", type=str, help="name of the project/module")
subparser.add_argument(
"module_args", nargs=argparse.REMAINDER, help="module arguments"
)
subparser.add_argument("module_args", nargs=argparse.REMAINDER, help="module arguments")

subparser.set_defaults(fire=self._launch)

Expand All @@ -44,7 +45,7 @@ def add_subparser(
def _launch(self, args: argparse.Namespace):
module_name = re.sub(r"[^A-Za-z0-9]+", "", args.name)
module_path = Registry.get_module_path_by_name(module_name)

with initialize(version_base=None, config_path="../config"):
cfg = compose(config_name="main", overrides=args.module_args)

Expand All @@ -55,9 +56,7 @@ def _launch(self, args: argparse.Namespace):
aim_run.set("cfg", cfg, strict=False)

if cfg.slurm.use_slurm:
assert (
is_submitit_available()
), "Please 'pip install submitit' to schedule jobs on SLURM"
assert is_submitit_available(), "Please 'pip install submitit' to schedule jobs on SLURM"

launch_on_slurm(
module=module_path,
Expand Down
Empty file removed urartu/hydra_plugins/__init__.py
Empty file.
Empty file.
File renamed without changes.

0 comments on commit a077242

Please sign in to comment.