Skip to content

Commit 055760c

Browse files
kiukchungfacebook-github-bot
authored andcommitted
Create //torchx/specs:lib_core (#1048)
Summary: IMPORTANT: If you believe you are broken by this diff due to autodeps/codemod having removed a dep to `//torchx/specs:api` in favor of `//torchx/specs:lib_core` then try adding a manual (`# manual`) dep to `//torchx/specs/fb:api_extended` to fix forward. **Example:** ``` python_library|binary( name = "my-lib-or-bin", srcs = [...], deps = [ "//torchx/specs:lib_core", # <-- added by autodeps codemod "//torchx/specs/fb:api_extended", # manual <-- manually add api_extended ... ] ) ``` Milestone 1.1 of torchx-lite (see [doc](https://fburl.com/gdoc/4wxcoaoa) for details) Creates `//torchx/specs:lib_core` with only the source files of `torchx.specs` module and a minimal set of dependencies for a proper closure of this module. For BC, we keep `//torchx/specs:lib` and `//torchx/specs:api` as is by adding the existing bundled deps as `manual` so that autodeps doesn't remove them on future codemods. Switches over to `//torchx/specs:lib_core` for TorchX internal targets (e.g. within `//torchx/...`). Differential Revision: D73195094
1 parent 3cb18e3 commit 055760c

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

torchx/specs/__init__.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
scheduler or pipeline adapter.
1414
"""
1515
import difflib
16-
from typing import Callable, Dict, Optional
16+
from typing import Callable, Dict, Mapping, Optional
1717

1818
from torchx.specs.api import (
1919
ALL,
@@ -48,12 +48,17 @@
4848
)
4949
from torchx.specs.builders import make_app_handle, materialize_appdef, parse_mounts
5050

51-
from torchx.specs.named_resources_aws import NAMED_RESOURCES as AWS_NAMED_RESOURCES
52-
from torchx.specs.named_resources_generic import (
53-
NAMED_RESOURCES as GENERIC_NAMED_RESOURCES,
54-
)
5551
from torchx.util.entrypoints import load_group
5652

53+
from torchx.util.modules import import_attr
54+
55+
AWS_NAMED_RESOURCES: Mapping[str, Callable[[], Resource]] = import_attr(
56+
"torchx.specs.named_resources_aws", "NAMED_RESOURCES", default={}
57+
)
58+
GENERIC_NAMED_RESOURCES: Mapping[str, Callable[[], Resource]] = import_attr(
59+
"torchx.specs.named_resources_generic", "NAMED_RESOURCES", default={}
60+
)
61+
5762
GiB: int = 1024
5863

5964

torchx/specs/finder.py

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from types import ModuleType
1919
from typing import Any, Callable, Dict, Generator, List, Optional, Union
2020

21-
from torchx.specs import AppDef
2221
from torchx.specs.file_linter import get_fn_docstring, TorchxFunctionValidator, validate
2322
from torchx.util import entrypoints
2423
from torchx.util.io import read_conf_file

0 commit comments

Comments
 (0)