Skip to content

[py310+] custom components binary operator not supported in file linting #826

Open
@ryxli

Description

@ryxli

🐛 Bug

custom components using binop instead of Optional result in validation error.

custom schedulers work as intended as there is no validation

Module (check all that applies):

  • [x ] torchx.spec
  • torchx.component
  • torchx.apps
  • torchx.runtime
  • torchx.cli
  • torchx.schedulers
  • torchx.pipelines
  • torchx.aws
  • torchx.examples
  • other

torchx.specs.file_linter

To Reproduce

Steps to reproduce the behavior:

  1. with python 3.10+ create and register any custom component, and use binopt instead of typing.Optional
  2. example client: Any | None = None, instead of client: Optional[Any] = None
  File "lib/python3.10/site-packages/torchx/specs/file_linter.py", line 144, in _validate_arg_def
    if complex_type_def.value.id == "Optional":
AttributeError: 'BinOp' object has no attribute 'value'

Expected behavior

have an edge case for 3.10 where this does not cause component validation to fail

Environment

  • torchx version (e.g. 0.1.0rc1): 0.6.0
  • Python version: 3.10
  • OS (e.g., Linux):
  • How you installed torchx (conda, pip, source, docker):
  • Docker image and tag (if using docker):
  • Git commit (if installed from source):
  • Execution environment (on-prem, AWS, GCP, Azure etc):
  • Any other relevant information:

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions