latch_cli package#



latch_cli.click_utils module#

class latch_cli.click_utils.EnumChoice(choices: Type[Enum], case_sensitive: bool = True)[source]#

Bases: Choice

convert(value: Any, param: Parameter | None, ctx: Context | None) Any[source]#

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail() with a descriptive message.

  • value – The value to convert.

  • param – The parameter that is using this type to convert its value. May be None.

  • ctx – The current context that arrived at this value. May be None.

class latch_cli.click_utils.ColoredHelpFormatter(indent_increment: int = 2, width: int | None = None, max_width: int | None = None)[source]#

Bases: HelpFormatter

write_usage(prog: str, args: str = '', prefix: str | None = None) None[source]#

Writes a usage line into the buffer.

  • prog – the program name.

  • args – whitespace separated list of arguments.

  • prefix – The prefix for the first line. Defaults to "Usage: ".

write_heading(heading: str)[source]#

Writes a heading into the buffer.

write_dl(rows: Sequence[Tuple[str, str]], col_max: int = 30, col_spacing: int = 2) None[source]#

Writes a definition list into the buffer. This is how options and commands are usually formatted.

  • rows – a list of two item tuples for the terms and values.

  • col_max – the maximum width of the first column.

  • col_spacing – the number of spaces between the first and second column.

class latch_cli.click_utils.LatchCommand(name: str | None, context_settings: MutableMapping[str, Any] | None = None, callback: Callable[[...], Any] | None = None, params: List[Parameter] | None = None, help: str | None = None, epilog: str | None = None, short_help: str | None = None, options_metavar: str | None = '[OPTIONS]', add_help_option: bool = True, no_args_is_help: bool = False, hidden: bool = False, deprecated: bool = False)[source]#

Bases: Command

format_epilog(ctx: Context, formatter: HelpFormatter) None[source]#

Writes the epilog into the formatter if it exists.

class latch_cli.click_utils.LatchGroup(name: str | None = None, commands: MutableMapping[str, Command] | Sequence[Command] | None = None, **attrs: Any)[source]#

Bases: LatchCommand, Group

latch_cli.click_utils.colored_exception_show(self, file: IO | None = None) None[source]#
latch_cli.click_utils.colored_usage_error_show(self, file: IO | None = None) None[source]#
latch_cli.click_utils.bold(s: str) str[source]#
class latch_cli.click_utils.AnsiCodes[source]#

Bases: object

bold = '\x1b[1m'#
reset = '\x1b[22m'#
underline = '\x1b[4m'#
no_underline = '\x1b[24m'#
url_href = '\x1b]8;;'#
url_name = '\x1b\\'#
url_end = '\x1b]8;;\x1b\\'#

latch_cli.constants module#

class latch_cli.constants.Units(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: int, Enum

KiB = 1024#
kB = 1000#
MiB = 1048576#
MB = 1000000#
GiB = 1073741824#
GB = 1000000000#
TiB = 1099511627776#
TB = 1000000000000#

alias of Units

class latch_cli.constants.LatchConstants(base_image: str = '', file_max_size: int = 4194304, file_chunk_size: int = 268435456, pkg_name: str = 'latch', pkg_config: str = '.latch/config', jump_host: str = '', jump_user: str = 'jumpuser', centromere_poll_timeout: int = 18000, centromere_keepalive_interval: int = 30)[source]#

Bases: object

base_image: str = ''#
file_max_size: int = 4194304#
file_chunk_size: int = 268435456#
maximum_upload_parts = 10000#
maximum_upload_size = 5497558138880#
pkg_name: str = 'latch'#
pkg_config: str = '.latch/config'#
ignore_regex = re.compile('(\\.git|\\.latch_report\\.tar\\.gz|traceback\\.txt|metadata\\.json)$')#
jump_host: str = ''#
jump_user: str = 'jumpuser'#
centromere_poll_timeout: int = 18000#
centromere_keepalive_interval: int = 30#
class latch_cli.constants.OAuth2Constants(client_id: str = 'jzFBOhIbfp4EPRYZ8wmx4YyvL27LFDeB', authz_server_host: str = '', redirect_url: str = '')[source]#

Bases: object

client_id: str = 'jzFBOhIbfp4EPRYZ8wmx4YyvL27LFDeB'#

Identifies the authentication server in 0Auth2.0 flow

authz_server_host: str = ''#

Host of the authentication server used in 0Auth2.0 flow.

redirect_url: str = ''#

Redirect URL registered with authentication server.

latch_cli.main module#

Entrypoints to service functions through a latch_cli.

latch_cli.main.requires_login(f: Callable[[P], T]) Callable[[P], T][source]#

latch_cli.menus module#

latch_cli.menus.buffered_print() Tuple[Callable, Callable][source]#
latch_cli.menus.clear(k: int)[source]#

Clear k lines below the cursor, returning the cursor to its original position

latch_cli.menus.draw_box(ul_corner_pos: Tuple[int, int], height: int, width: int, color: str | None = None)[source]#
latch_cli.menus.move_cursor(pos: Tuple[int, int])[source]#

Move the cursor to a given (x, y) coordinate

latch_cli.menus.move_cursor_up(n: int)[source]#
latch_cli.menus.line_up(n: int)[source]#

Moves to the start of the destination line

latch_cli.menus.move_cursor_down(n: int)[source]#
latch_cli.menus.line_down(n: int)[source]#

Moves to the start of the destination line

latch_cli.menus.move_cursor_right(n: int)[source]#
latch_cli.menus.move_cursor_left(n: int)[source]#
latch_cli.menus.current_cursor_position() Tuple[int, int][source]#
latch_cli.menus.draw_vertical_line(height: int, up: bool = False, make_corner: bool = False, color: str | None = None)[source]#

Draws a vertical line with given height, going upwards if up is True and downwards otherwise.

latch_cli.menus.draw_horizontal_line(width: int, left: bool = False, make_corner: bool = False, color: str | None = None)[source]#

Draws a horizontal line with given width, going to the left if left is True and to the right otherwise.

latch_cli.menus.read_next_byte() bytes[source]#
latch_cli.menus.read_bytes(num_bytes: int) bytes[source]#
latch_cli.menus.select_tui(title: str, options: List[str], clear_terminal: bool = True)[source]#

Renders a terminal UI that allows users to select one of the options listed in options

  • title – The title of the selection window.

  • options – A list of names for each of the options.

  • clear_terminal – Whether or not to clear the entire terminal window before displaying - default False

latch_cli.tinyrequests module#

class latch_cli.tinyrequests.TinyResponse(resp: HTTPResponse, url: str, *, stream: bool = False)[source]#

Bases: object

property headers#
property status_code#
property content#
iter_content(chunk_size: int | None = 1)[source]#
property url#
latch_cli.tinyrequests.request(method: str, url: str, *, headers: Dict[str, str] = {}, data: bytes | None = None, json: Any | None = None, stream: bool = False)[source]#
latch_cli.tinyrequests.get(url: str, *, headers: Dict[str, str] = {}, data: bytes | None = None, json: Any | None = None, stream: bool = False)[source]#
latch_cli.tinyrequests.put(url: str, *, headers: Dict[str, str] = {}, data: bytes | None = None, json: Any | None = None, stream: bool = False)[source]# str, *, headers: Dict[str, str] = {}, data: bytes | None = None, json: Any | None = None, stream: bool = False)[source]#

latch_cli.workflow_config module#

class latch_cli.workflow_config.BaseImageOptions(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: str, Enum

default = 'default'#
cuda = 'cuda'#
opencl = 'opencl'#
class latch_cli.workflow_config.LatchWorkflowConfig(latch_version: str, base_image: str, date: str)[source]#

Bases: object

Configuration for a Latch workflow.

latch_version: str#

Version of the Latch SDK used to initialize the workflow

base_image: str#

Exact version of the included workflow base image

date: str#

Timestamp of the latch init call

latch_cli.workflow_config.create_and_write_config(pkg_root: Path, base_image_type: BaseImageOptions = BaseImageOptions.default)[source]#

Module contents#