Skip to content

Commit acb04e3

Browse files
committed
del image option
Signed-off-by: Ayush Kamat <[email protected]>
1 parent ea7c1c6 commit acb04e3

File tree

2 files changed

+9
-47
lines changed

2 files changed

+9
-47
lines changed

src/latch_cli/main.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,6 @@ def generate_metadata(
413413
type=bool,
414414
help="Skip the confirmation dialog.",
415415
)
416-
@click.option("--image", "-i", type=str, help="Image to use for develop session.")
417416
@click.option(
418417
"--wf-version",
419418
"-v",
@@ -453,7 +452,6 @@ def generate_metadata(
453452
def local_development(
454453
pkg_root: Path,
455454
yes: bool,
456-
image: Optional[str],
457455
wf_version: Optional[str],
458456
disable_sync: bool,
459457
snakemake: bool,
@@ -482,7 +480,6 @@ def local_development(
482480
pkg_root.resolve(),
483481
skip_confirm_dialog=yes,
484482
size=instance_size,
485-
image=image,
486483
wf_version=wf_version,
487484
disable_sync=disable_sync,
488485
)

src/latch_cli/services/k8s/develop.py

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@
22

33
import asyncio
44
import json
5-
import re
65
import subprocess # noqa: S404
76
import sys
8-
from dataclasses import dataclass
97
from enum import Enum
10-
from textwrap import dedent
118
from typing import TYPE_CHECKING
129
from urllib.parse import urljoin, urlparse
1310

1411
import click
1512
import gql
1613
import websockets.client as websockets
17-
from typing_extensions import Self
1814

1915
from latch.utils import current_workspace
2016
from latch_sdk_config.latch import NUCLEUS_URL
@@ -54,24 +50,6 @@ class InstanceSize(str, Enum):
5450
# g6e_48xlarge_task = "g6e_48xlarge_task"
5551

5652

57-
@dataclass
58-
class ImageInfo:
59-
image: str
60-
version: str
61-
62-
__expr = re.compile(
63-
r"^(?:812206152185.dkr.ecr.us-west-2.amazonaws.com/)?(?P<image>[^:]+):(?P<version>[^:]+)"
64-
)
65-
66-
@classmethod
67-
def from_str(cls, image_str: str) -> Self:
68-
match = cls.__expr.match(image_str)
69-
if match is None:
70-
raise ValueError(f"invalid image name: {image_str}")
71-
72-
return cls(match["image"], match["version"])
73-
74-
7553
def workflow_name(pkg_root: Path) -> str:
7654
name_path = pkg_root / latch_constants.pkg_workflow_name
7755
if not name_path.exists():
@@ -84,7 +62,7 @@ def workflow_name(pkg_root: Path) -> str:
8462
return name_path.read_text().strip()
8563

8664

87-
def get_image_name(pkg_root: Path) -> str:
65+
def get_image(pkg_root: Path) -> str:
8866
ws_id = current_workspace()
8967
wf_name = workflow_name(pkg_root)
9068

@@ -99,7 +77,7 @@ def get_image_name(pkg_root: Path) -> str:
9977
return f"{prefix}_{suffix}"
10078

10179

102-
def get_image_info(pkg_root: Path) -> ImageInfo:
80+
def get_latest_registered_version(pkg_root: Path) -> str:
10381
ws_id = current_workspace()
10482

10583
wf_name = workflow_name(pkg_root)
@@ -127,9 +105,7 @@ def get_image_info(pkg_root: Path) -> ImageInfo:
127105
)
128106
raise click.exceptions.Exit(1)
129107

130-
latest_version = res["nodes"][0]["version"]
131-
132-
return ImageInfo(get_image_name(pkg_root), latest_version)
108+
return res["nodes"][0]["version"]
133109

134110

135111
async def rsync(pkg_root: Path, ip: str):
@@ -151,7 +127,6 @@ async def rsync(pkg_root: Path, ip: str):
151127
stderr=subprocess.DEVNULL,
152128
)
153129

154-
# todo(ayush): use inotify or something instead of running on a fixed interval
155130
await asyncio.sleep(0.5)
156131

157132

@@ -264,7 +239,6 @@ def local_development(
264239
*,
265240
size: InstanceSize,
266241
skip_confirm_dialog: bool,
267-
image: str | None,
268242
wf_version: str | None,
269243
disable_sync: bool,
270244
):
@@ -283,15 +257,13 @@ def local_development(
283257
)
284258
raise click.exceptions.Exit(1) from e
285259

286-
if image is not None:
287-
image_info = ImageInfo.from_str(image)
288-
elif wf_version is not None:
289-
image_info = ImageInfo(get_image_name(pkg_root), wf_version)
290-
else:
291-
image_info = get_image_info(pkg_root)
260+
image = get_image(pkg_root)
261+
if wf_version is None:
262+
wf_version = get_latest_registered_version(pkg_root)
292263

293264
click.secho("Initiating local development session", fg="blue")
294-
click.echo(click.style("Selected image: ", fg="blue") + image_info.image)
265+
click.echo(click.style("Selected image: ", fg="blue") + image)
266+
click.echo(click.style("Selected version: ", fg="blue") + wf_version)
295267
click.echo(click.style("Selected instance size: ", fg="blue") + size)
296268

297269
if skip_confirm_dialog:
@@ -307,12 +279,5 @@ def local_development(
307279
)
308280

309281
asyncio.run(
310-
session(
311-
pkg_root,
312-
image_info.image,
313-
image_info.version,
314-
ssh.public_key,
315-
size,
316-
disable_sync,
317-
)
282+
session(pkg_root, image, wf_version, ssh.public_key, size, disable_sync)
318283
)

0 commit comments

Comments
 (0)