Skip to content

(torchx/specs) Support builtin list[str] and dict[str, str] runopts opt_type #1090

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
Jul 17, 2025

Conversation

kiukchung
Copy link
Contributor

Summary:
For python-3.9+ support scheduler runopt types to be specified using the built-in generic types (e.g. list[str] over typing.List[str]).

Basically lets scheduler implementations to declare their runopts (cfg) as:

def _run_opts(self) -> runopts:
  opts = runopts()
  opts.add("regions", type_=list[str], help="a list opt", default=[])
  opts.add("envs", type_=dict[str, str], help="a dict opt", default=[])

versus having to do:

from typing import List, Dict
def _run_opts(self) -> runopts:
  opts = runopts()
  opts.add("regions", type_=List[str], help="a list opt", default=[])
  opts.add("envs", type_=Dict[str, str], help="a dict opt", default=[])

Differential Revision: D78444106

…pt_type

Summary:
For python-3.9+ support scheduler runopt types to be specified using the built-in generic types (e.g. `list[str]` over `typing.List[str]`).

Basically lets scheduler implementations to declare their runopts (cfg) as:

```
def _run_opts(self) -> runopts:
  opts = runopts()
  opts.add("regions", type_=list[str], help="a list opt", default=[])
  opts.add("envs", type_=dict[str, str], help="a dict opt", default=[])
```

versus having to do:


```
from typing import List, Dict
def _run_opts(self) -> runopts:
  opts = runopts()
  opts.add("regions", type_=List[str], help="a list opt", default=[])
  opts.add("envs", type_=Dict[str, str], help="a dict opt", default=[])
```

Differential Revision: D78444106
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 16, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78444106

Copy link
Contributor

@andywag andywag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@facebook-github-bot facebook-github-bot merged commit 4adf7f6 into main Jul 17, 2025
24 of 26 checks passed
@facebook-github-bot facebook-github-bot deleted the export-D78444106 branch July 17, 2025 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants