latch_cli.utils package#

Submodules#

latch_cli.utils.ldata module#

latch_cli.utils.path module#

latch_cli.utils.path.is_remote_path(path: str) bool[source]#
latch_cli.utils.path.append_scheme(path: str, *, assume_remote: bool = False) str[source]#
latch_cli.utils.path.append_domain(path: str) str[source]#
latch_cli.utils.path.strip_domain(path: str) str[source]#
latch_cli.utils.path.is_account_relative(path: str) bool[source]#
latch_cli.utils.path.normalize_path(path: str, *, assume_remote: bool = False) str[source]#
latch_cli.utils.path.get_path_error(path: str, message: str, acc_id: str) str[source]#
latch_cli.utils.path.get_name_from_path(path: str)[source]#

Module contents#

Utility functions for services.

latch_cli.utils.urljoins(*args: str, dir: bool = False) str[source]#

Construct a URL by appending paths

Paths are always joined, with extra /`s added if missing. Does not allow overriding basenames as opposed to normal `urljoin. Whether the final path ends in a / is still significant and will be preserved in the output

>>> urljoin("latch:///directory/", "another_directory")
latch:///directory/another_directory
>>> # No slash means "another_directory" is treated as a filename
>>> urljoin(urljoin("latch:///directory/", "another_directory"), "file")
latch:///directory/file
>>> # Unintentionally overrode the filename
>>> urljoins("latch:///directory/", "another_directory", "file")
latch:///directory/another_directory/file
>>> # Joined paths as expected
Parameters:
  • args – Paths to join

  • dir – If true, ensure the output ends with a /

exception latch_cli.utils.AuthenticationError[source]#

Bases: RuntimeError

latch_cli.utils.get_auth_header() str[source]#
latch_cli.utils.sub_from_jwt(token: str) str[source]#

Extract a user sub (UUID) from a JWT minted by auth0.

Parameters:

token – JWT

Returns:

The user sub contained within the JWT.

latch_cli.utils.with_si_suffix(num, suffix='B', styled=False)[source]#
latch_cli.utils.human_readable_time(t_seconds: float) str[source]#
latch_cli.utils.hash_directory(dir_path: Path) str[source]#
latch_cli.utils.generate_temporary_ssh_credentials(ssh_key_path: Path, *, add_to_agent: bool = True) str[source]#
latch_cli.utils.get_local_package_version() str[source]#
latch_cli.utils.get_latest_package_version_request() str[source]#
latch_cli.utils.get_latest_package_version() str[source]#
class latch_cli.utils.TemporarySSHCredentials(ssh_key_path: Path)[source]#

Bases: object

generate()[source]#
cleanup()[source]#
property public_key#
property private_key#
class latch_cli.utils.WorkflowType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: Enum

latchbiosdk = 'latchbiosdk'#
snakemake = 'snakemake'#
latch_cli.utils.identifier_suffix_from_str(x: str) str[source]#
latch_cli.utils.identifier_from_str(x: str) str[source]#
latch_cli.utils.get_parameter_json_value(v)[source]#
latch_cli.utils.check_exists_and_rename(old: Path, new: Path)[source]#
latch_cli.utils.best_effort_display_name(x: str) str[source]#