Skip to content

Commit

Permalink
fix download image
Browse files Browse the repository at this point in the history
Signed-off-by: SdgJlbl <sarah.diot-girard@owkin.com>
  • Loading branch information
SdgJlbl committed Aug 16, 2023
1 parent 2785c44 commit 78685ff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions backend/substrapp/compute_tasks/image_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ def wait_for_image_built(function: orchestrator.Function, channel: str) -> None:
f"Initial function URI {function.function_address.uri}; "
f"modified URI{function.function_address.uri.replace('file', 'image')}"
)
# TODO remove hard-coded values
attempt = 0
max_attempts = 10
max_attempts = 60
while attempt < max_attempts:
try:
function_image_content = organization_client.get(
Expand All @@ -58,15 +59,20 @@ def wait_for_image_built(function: orchestrator.Function, channel: str) -> None:
url=function.function_address.uri.replace("file", "image"),
checksum=None,
)
break
except OrganizationHttpError:
attempt += 1
time.sleep(5)
else:
raise exceptions.PodTimeoutError(
f"Build for function {function.key} on backend {function.owner} didn't complete after 300 seconds"
)

os.makedirs(SUBTUPLE_TMP_DIR, exist_ok=True)
with TemporaryDirectory(dir=SUBTUPLE_TMP_DIR) as tmp_dir:
storage_path = pathlib.Path(tmp_dir) / f"{container_image_tag}.zip"
storage_path.write_bytes(function_image_content)
push_payload(storage_path, registry=REGISTRY, secure=False)
os.makedirs(SUBTUPLE_TMP_DIR, exist_ok=True)
with TemporaryDirectory(dir=SUBTUPLE_TMP_DIR) as tmp_dir:
storage_path = pathlib.Path(tmp_dir) / f"{container_image_tag}.zip"
storage_path.write_bytes(function_image_content)
push_payload(storage_path, registry=REGISTRY, secure=False)

#
# if exc.status_code == 404:
Expand Down
2 changes: 1 addition & 1 deletion backend/substrapp/events/reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def on_function_event(payload):
)

else:
logger.debug("Function not belonging to this organization, skipping building", asset_key=function.key)
logger.debug("Function not belonging to this organization, skipping building", asset_key=orc_function.key)


def on_model_event(payload):
Expand Down

0 comments on commit 78685ff

Please sign in to comment.