# Path: xmanager/xm/executables.py
# def name_from_path(path: str) -> str:
#   def __attrs_post_init__(self):
#   def name(self) -> str:
#   def name(self) -> str:
#   def name(self) -> str:
#   def name(self) -> str:
#   def name(self) -> str:
#   def name(self) -> str:
# class ModuleName(NamedTuple):
# class CommandList(NamedTuple):
# class Dockerfile(job_blocks.ExecutableSpec):
# class PythonContainer(job_blocks.ExecutableSpec):
# class BinaryDependency(abc.ABC):
# class Container(job_blocks.ExecutableSpec):
# class Binary(job_blocks.ExecutableSpec):
# class BazelContainer(job_blocks.ExecutableSpec):
# class BazelBinary(job_blocks.ExecutableSpec):
# 
# Path: xmanager/xm/job_blocks.py
# class SequentialArgs:
#   class _RegularItem:
#   class _KeywordItem:
# class ExecutableSpec(abc.ABC):
# class Executable(abc.ABC):
# class ExecutorSpec(abc.ABC):
# class Executor(abc.ABC):
# class Packageable:
# class Constraint(abc.ABC):
# class Job:
# class JobGroup:
#   def __init__(self) -> None:
#   def _ingest_regular_item(self, value: Any) -> None:
#   def _ingest_keyword_item(self, name: str, value: Any) -> None:
#   def _merge_from(self, args: 'SequentialArgs') -> None:
#     def import_regular_item(item: SequentialArgs._RegularItem):
#     def import_keyword_item(item: SequentialArgs._KeywordItem):
#   def from_collection(collection: Optional[UserArgs]) -> 'SequentialArgs':
#     def check_for_string(args: str) -> None:
#     def import_sequential_args(args: SequentialArgs) -> None:
#     def import_mapping(collection: Mapping[Any, Any]) -> None:
#     def import_sequence(collection: Sequence[Any]) -> None:
#   def to_list(
#       self,
#       escaper: Callable[[Any], str],
#       kwargs_joiner: Callable[[str, str], str] = utils.trivial_kwargs_joiner
#   ) -> List[str]:
#     def export_regular_item(item: SequentialArgs._RegularItem) -> str:
#     def export_keyword_item(item: SequentialArgs._KeywordItem) -> str:
#   def to_dict(self, kwargs_only: bool = False) -> Dict[str, Any]:
#     def export_regular_item(
#         item: SequentialArgs._RegularItem) -> Tuple[str, Any]:
#     def export_keyword_item(
#         item: SequentialArgs._KeywordItem) -> Tuple[str, Any]:
#   def __eq__(self, other) -> bool:
#   def __repr__(self) -> str:
# def merge_args(*operands: Union[SequentialArgs, UserArgs]) -> SequentialArgs:
#   def name(self) -> str:
#   def Spec(cls) -> ExecutorSpec:  # pylint: disable=invalid-name
#   def __init__(self,
#                *,
#                constraints: Optional[Sequence[Constraint]] = None,
#                **jobs: JobType) -> None:


import inspect
import re
import inflection
from typing import List, Sequence, Type
from absl import app
from xmanager.xm import executables
from xmanager.xm import job_blocks
# Partially due to deducing shorter module names (job_blocks rather than
# xmanager.xm.job_blocks). But mostly because type annotations for attr.s
# constructor show field types rather than what converters accept.
# So here we just list how each parameter should be defined.
_KNOWN_ARGS = (
    'base_image: Optional[str] = None',
    'bazel_args: Collection[str] = ()',
    'docker_instructions: Optional[List[str]] = None',
    'dockerfile: Optional[str] = None',
    'entrypoint: Union[executables.ModuleName, executables.CommandList]',
    'dependencies: Collection[executables.BinaryDependency] = ()',
    'image_path: str',
    'label: str',
    'path: str',
    'use_deep_module: bool',
)
_KNOWN_ARGS_DICT = {arg.split(':')[0]: arg for arg in _KNOWN_ARGS}

_ATTRIBUTES_SECTION_HEADER = '  Attributes:'
_ARGS_DOCSTRING = """  Args:
    executor_spec: Where the binary should be launched. Instructs for which
      platform it should be packaged."""
_DOCSTRING_SUFFIX = """
    args: Command line arguments to pass. This can be dict, list or
      xm.SequentialArgs. Dicts are most convenient for keyword flags.
      {'batch_size': 16} is passed as --batch_size=16. If positional arguments
      are needed one can use a list or xm.SequentialArgs.
    env_vars: Environment variables to be set.

  Returns:

# Path: xmanager/xm/executables.py
# def name_from_path(path: str) -> str:
#   def __attrs_post_init__(self):
#   def name(self) -> str:
#   def name(self) -> str:
#   def name(self) -> str:
#   def name(self) -> str:
#   def name(self) -> str:
#   def name(self) -> str:
# class ModuleName(NamedTuple):
# class CommandList(NamedTuple):
# class Dockerfile(job_blocks.ExecutableSpec):
# class PythonContainer(job_blocks.ExecutableSpec):
# class BinaryDependency(abc.ABC):
# class Container(job_blocks.ExecutableSpec):
# class Binary(job_blocks.ExecutableSpec):
# class BazelContainer(job_blocks.ExecutableSpec):
# class BazelBinary(job_blocks.ExecutableSpec):
# 
# Path: xmanager/xm/job_blocks.py
# class SequentialArgs:
#   class _RegularItem:
#   class _KeywordItem:
# class ExecutableSpec(abc.ABC):
# class Executable(abc.ABC):
# class ExecutorSpec(abc.ABC):
# class Executor(abc.ABC):
# class Packageable:
# class Constraint(abc.ABC):
# class Job:
# class JobGroup:
#   def __init__(self) -> None:
#   def _ingest_regular_item(self, value: Any) -> None:
#   def _ingest_keyword_item(self, name: str, value: Any) -> None:
#   def _merge_from(self, args: 'SequentialArgs') -> None:
#     def import_regular_item(item: SequentialArgs._RegularItem):
#     def import_keyword_item(item: SequentialArgs._KeywordItem):
#   def from_collection(collection: Optional[UserArgs]) -> 'SequentialArgs':
#     def check_for_string(args: str) -> None:
#     def import_sequential_args(args: SequentialArgs) -> None:
#     def import_mapping(collection: Mapping[Any, Any]) -> None:
#     def import_sequence(collection: Sequence[Any]) -> None:
#   def to_list(
#       self,
#       escaper: Callable[[Any], str],
#       kwargs_joiner: Callable[[str, str], str] = utils.trivial_kwargs_joiner
#   ) -> List[str]:
#     def export_regular_item(item: SequentialArgs._RegularItem) -> str:
#     def export_keyword_item(item: SequentialArgs._KeywordItem) -> str:
#   def to_dict(self, kwargs_only: bool = False) -> Dict[str, Any]:
#     def export_regular_item(
#         item: SequentialArgs._RegularItem) -> Tuple[str, Any]:
#     def export_keyword_item(
#         item: SequentialArgs._KeywordItem) -> Tuple[str, Any]:
#   def __eq__(self, other) -> bool:
#   def __repr__(self) -> str:
# def merge_args(*operands: Union[SequentialArgs, UserArgs]) -> SequentialArgs:
#   def name(self) -> str:
#   def Spec(cls) -> ExecutorSpec:  # pylint: disable=invalid-name
#   def __init__(self,
#                *,
#                constraints: Optional[Sequence[Constraint]] = None,
#                **jobs: JobType) -> None:


# Path: xmanager/xm/packagables_generator.py
import inspect
import re
import inflection
from typing import List, Sequence, Type
from absl import app
from xmanager.xm import executables
from xmanager.xm import job_blocks

# Partially due to deducing shorter module names (job_blocks rather than
# xmanager.xm.job_blocks). But mostly because type annotations for attr.s
# constructor show field types rather than what converters accept.
# So here we just list how each parameter should be defined.
_KNOWN_ARGS = (
    'base_image: Optional[str] = None',
    'bazel_args: Collection[str] = ()',
    'docker_instructions: Optional[List[str]] = None',
    'dockerfile: Optional[str] = None',
    'entrypoint: Union[executables.ModuleName, executables.CommandList]',
    'dependencies: Collection[executables.BinaryDependency] = ()',
    'image_path: str',
    'label: str',
    'path: str',
    'use_deep_module: bool',
)
_KNOWN_ARGS_DICT = {arg.split(':')[0]: arg for arg in _KNOWN_ARGS}

_ATTRIBUTES_SECTION_HEADER = '  Attributes:'
_ARGS_DOCSTRING = """  Args:
    executor_spec: Where the binary should be launched. Instructs for which
      platform it should be packaged."""
_DOCSTRING_SUFFIX = """
    args: Command line arguments to pass. This can be dict, list or
      xm.SequentialArgs. Dicts are most convenient for keyword flags.
      {'batch_size': 16} is passed as --batch_size=16. If positional arguments
      are needed one can use a list or xm.SequentialArgs.
    env_vars: Environment variables to be set.

  Returns:

    A packageable object which can be turned into an executable with