Skip to content

Commit d900748

Browse files
committed
Example for cloning an existing image
Signed-off-by: Jeev B <jeevb@users.noreply.github.com>
1 parent 07dc8c7 commit d900748

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import asyncio
2+
3+
import flyte
4+
from flyte import Image
5+
6+
# Start from an existing base image and clone it so the default configured builder picks it up.
7+
# The .clone() call assigns a name, which triggers a build.
8+
image = Image.from_base("ghcr.io/flyteorg/flyte:py3.12-v2.0.0b56").clone(
9+
name="my-flyte-image",
10+
)
11+
12+
env = flyte.TaskEnvironment(
13+
name="my-flyte-task",
14+
image=image,
15+
resources=flyte.Resources(cpu="500m", memory="512Mi"),
16+
)
17+
18+
19+
@env.task
20+
async def sleep_task(seconds: int = 10) -> str:
21+
print(f"Sleeping for {seconds} seconds...", flush=True)
22+
await asyncio.sleep(seconds)
23+
print("Done!", flush=True)
24+
return f"Slept for {seconds} seconds"
25+
26+
27+
if __name__ == "__main__":
28+
flyte.init_from_config()
29+
run = flyte.run(sleep_task, seconds=10)
30+
print(run.name)
31+
print(run.url)
32+
run.wait()

src/flyte/_internal/imagebuild/image_builder.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,6 @@ class ImageBuildEngine:
142142
@staticmethod
143143
@alru_cache
144144
async def image_exists(image: Image) -> Optional[str]:
145-
if image.base_image is not None and not image._layers:
146-
logger.debug(f"Image {image} has a base image: {image.base_image} and no layers. Skip existence check.")
147-
return image.uri
148145
assert image.name is not None, f"Image name is not set for {image}"
149146

150147
tag = image._final_tag

0 commit comments

Comments
 (0)