# 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
  Args:
    parameters: ExecutableSpec constructor parameters except self.

  Returns:
    Python source code.
  """
  source = '    executor_spec: job_blocks.ExecutorSpec,\n'

  keyword_args_started = False
  for parameter in parameters:
    if (parameter.kind == inspect.Parameter.KEYWORD_ONLY and
        not keyword_args_started):
      keyword_args_started = True
      source += '    *,\n'

    parameter_source = _KNOWN_ARGS_DICT[parameter.name]
    if (parameter.default != inspect.Parameter.empty and
        '=' not in parameter_source):
      parameter_source += f' = {parameter.default!r}'

    source += f'    {parameter_source},\n'

  if not keyword_args_started:
    source += '    *,\n'

  source += '    args: Optional[job_blocks.UserArgs] = None,\n'
  source += '    env_vars: Mapping[str, str] = immutabledict.immutabledict(),\n'
  return source



# 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

  Args:
    parameters: ExecutableSpec constructor parameters except self.

  Returns:
    Python source code.
  """
  source = '    executor_spec: job_blocks.ExecutorSpec,\n'

  keyword_args_started = False
  for parameter in parameters:
    if (parameter.kind == inspect.Parameter.KEYWORD_ONLY and
        not keyword_args_started):
      keyword_args_started = True
      source += '    *,\n'

    parameter_source = _KNOWN_ARGS_DICT[parameter.name]
    if (parameter.default != inspect.Parameter.empty and
        '=' not in parameter_source):
      parameter_source += f' = {parameter.default!r}'

    source += f'    {parameter_source},\n'

  if not keyword_args_started:
    source += '    *,\n'

  source += '    args: Optional[job_blocks.UserArgs] = None,\n'
  source += '    env_vars: Mapping[str, str] = immutabledict.immutabledict(),\n'
  return source



def generate_factory_method(executable: Type[job_blocks.ExecutableSpec]) -> str: