メインコンテンツまでスキップ
バージョン: v2602

intelligence.zenith_tune.command

OptionFormat Objects​

class OptionFormat(Enum)

Enum for different option formats.

EQUALS​

Example: --key=value

SPACE​

Example: --key value

KEYVALUE​

Example: --env KEY1=value1 KEY2=value2

FLAG​

Example: --verbose

Option Objects​

@dataclass
class Option()

Represents a command-line option.

OptionHandler Objects​

class OptionHandler(ABC)

Abstract base class for option handlers.

can_handle​

@abstractmethod
def can_handle(option: Option) -> bool

Check if this handler can handle the given option.

append​

@abstractmethod
def append(args: List[str], option: Option) -> List[str]

Append an option to the argument list.

update​

@abstractmethod
def update(args: List[str], option: Option) -> List[str]

Update an option in the argument list.

remove​

@abstractmethod
def remove(args: List[str], key: str) -> List[str]

Remove an option from the argument list.

CommandBuilder Objects​

class CommandBuilder()

Improved command builder with better separation of concerns.

update​

def update(option: str) -> "CommandBuilder"

Update an option.

append​

def append(option: str) -> "CommandBuilder"

Append an option (allows duplicates).

remove​

def remove(option: str) -> "CommandBuilder"

Remove an option.

get_command​

def get_command() -> str

Get the command string.

staging_directory​

def staging_directory(old_path: str,
new_path: str,
copy_files: bool = False) -> "CommandBuilder"

Replace directory paths in command and optionally copy directory for distributed training.

Arguments:

  • old_path - Path to replace in the command
  • new_path - New path to use in the command
  • copy_files - Whether to actually copy the directory (default: False)

Returns:

CommandBuilder instance for method chaining

Raises:

  • FileNotFoundError - If old_path doesn't exist and copy_files is True
  • NotADirectoryError - If old_path is not a directory and copy_files is True
  • OSError - If copying fails

EqualsHandler Objects​

class EqualsHandler(OptionHandler)

Handler for --key=value format.

SpaceHandler Objects​

class SpaceHandler(OptionHandler)

Handler for --key value format.

FlagHandler Objects​

class FlagHandler(OptionHandler)

Handler for --flag format.

KeyValueHandler Objects​

class KeyValueHandler(OptionHandler)

Handler for --key key1=value1 key2=value2 format.