Skip to content

Commit

Permalink
Remove create-platform-image command from indexify-cli (#1136)
Browse files Browse the repository at this point in the history
Co-authored-by: Julio Martinez <[email protected]>
  • Loading branch information
j3m7 and Julio Martinez authored Dec 21, 2024
1 parent ab93241 commit 15f6b4f
Showing 1 changed file with 0 additions and 66 deletions.
66 changes: 0 additions & 66 deletions python-sdk/indexify/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,72 +288,6 @@ def function_executor(
).run()


def _create_platform_image(image: Image, service_endpoint: str):
fd, context_file = tempfile.mkstemp()
image.build_context(context_file)
client = httpx

headers = {}
api_key = os.getenv("TENSORLAKE_API_KEY")
if api_key:
headers["Authorization"] = f"Bearer {api_key}"

image_hash = image.hash()

# Check if the image is built before pushing a new one
builds_response = client.get(
f"{service_endpoint}/builds",
params={
"image_name": image._image_name,
"image_hash": image_hash,
},
headers=headers,
)
builds_response.raise_for_status()
matching_builds = [Build.model_validate(b) for b in builds_response.json()]
if not matching_builds:
files = {"context": open(context_file, "rb")}

data = {"name": image._image_name, "hash": image_hash}

res = client.post(
f"{service_endpoint}/builds", data=data, files=files, headers=headers
)
res.raise_for_status()

build = Build.model_validate(res.json())
else:
build = matching_builds[0]

match build.status:
case "completed":
print(f"image {build.image_name}:{build.image_hash} is already built")
case "ready" | "building":
print(f"waiting for {build.image_name} image to build")
while build.status != "completed":
time.sleep(5)
res = client.get(
f"{service_endpoint}/builds/{build.id}", headers=headers
)
build = Build.model_validate(res.json())

case _:
raise ValueError(f"Unexpected build status {build.status}")

match build.result:
case "success":
build_duration = build.push_completed_at - build.started_at
print(
f"Building completed in {build_duration}; image is stored in {build.uri}"
)

case "failed":
print(f"Building failed, please see logs for details")

case _:
raise ValueError(f"Unexpected build result {build.status}")


def _create_image(image: Image, python_sdk_path):
console.print(
Text("Creating container for ", style="cyan"),
Expand Down

0 comments on commit 15f6b4f

Please sign in to comment.