Skip to content

Create //torchx/specs:lib_core #1048

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions torchx/cli/test/cmd_run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

from torchx.cli.argparse_util import ArgOnceAction, torchxconfig
from torchx.cli.cmd_run import _parse_component_name_and_args, CmdBuiltins, CmdRun
from torchx.runner.config import ENV_TORCHXCONFIG
from torchx.schedulers.local_scheduler import SignalException

from torchx.specs import AppDryRunInfo
Expand All @@ -40,11 +41,19 @@ def cwd(path: str) -> Generator[None, None, None]:
class CmdRunTest(unittest.TestCase):
def setUp(self) -> None:
self.tmpdir = Path(tempfile.mkdtemp())

# create empty .torchxconfig so that user .torchxconfig is not picked up
empty_config = self.tmpdir / ".torchxconfig"
empty_config.touch()
self.mock_env = patch.dict(os.environ, {ENV_TORCHXCONFIG: str(empty_config)})
self.mock_env.start()

self.parser = argparse.ArgumentParser()
self.cmd_run = CmdRun()
self.cmd_run.add_arguments(self.parser)

def tearDown(self) -> None:
self.mock_env.stop()
shutil.rmtree(self.tmpdir, ignore_errors=True)
ArgOnceAction.called_args = set()
torchxconfig.called_args = set()
Expand Down
15 changes: 10 additions & 5 deletions torchx/specs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
scheduler or pipeline adapter.
"""
import difflib
from typing import Callable, Dict, Optional
from typing import Callable, Dict, Mapping, Optional

from torchx.specs.api import (
ALL,
Expand Down Expand Up @@ -48,12 +48,17 @@
)
from torchx.specs.builders import make_app_handle, materialize_appdef, parse_mounts

from torchx.specs.named_resources_aws import NAMED_RESOURCES as AWS_NAMED_RESOURCES
from torchx.specs.named_resources_generic import (
NAMED_RESOURCES as GENERIC_NAMED_RESOURCES,
)
from torchx.util.entrypoints import load_group

from torchx.util.modules import import_attr

AWS_NAMED_RESOURCES: Mapping[str, Callable[[], Resource]] = import_attr(
"torchx.specs.named_resources_aws", "NAMED_RESOURCES", default={}
)
GENERIC_NAMED_RESOURCES: Mapping[str, Callable[[], Resource]] = import_attr(
"torchx.specs.named_resources_generic", "NAMED_RESOURCES", default={}
)

GiB: int = 1024


Expand Down
1 change: 0 additions & 1 deletion torchx/specs/finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from types import ModuleType
from typing import Any, Callable, Dict, Generator, List, Optional, Union

from torchx.specs import AppDef
from torchx.specs.file_linter import get_fn_docstring, TorchxFunctionValidator, validate
from torchx.util import entrypoints
from torchx.util.io import read_conf_file
Expand Down
Loading