Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry on server unavailable #1085

Merged
merged 10 commits into from
Nov 14, 2023
Prev Previous commit
Next Next commit
fix typechecker
YevheniiSemendiak committed Nov 10, 2023

Verified

This commit was signed with the committer’s verified signature. The key has expired.
addaleax Anna Henningsen
commit a09ae2098261c5d85c34d629f827e46734c5b26c
50 changes: 27 additions & 23 deletions src/neuro_flow/expr.py
Original file line number Diff line number Diff line change
@@ -1386,33 +1386,37 @@ async def eval(self, root: RootABC) -> URL:
return ret


class ImageRefExprMixin:
async def eval(self, root: RootABC) -> Optional[str]:
ret = await super().eval(root)
project_ctx = None
if ret and ret.startswith("image:"):
try:
# Hack to get flow's project ctx -> project_name
project_ctx = root.lookup("project")
except LookupError:
pass
if ret and project_ctx:
async with root.client() as cl:
uri = cl.parse.str_to_uri(
ret,
project_name=project_ctx.project_name, # type: ignore
short=True,
)
ret = str(uri)
return ret
async def project_image_ref(img_ref: str, root: RootABC) -> str:
project_ctx = None
if img_ref.startswith("image:"):
try:
# Hack to get flow's project ctx -> project_name
project_ctx = root.lookup("project")
except LookupError:
pass
if project_ctx:
async with root.client() as cl:
uri = cl.parse.str_to_uri(
img_ref,
project_name=project_ctx.project_name, # type: ignore
short=True,
)
img_ref = str(uri)
return img_ref


class OptImageRefStrExpr(ImageRefExprMixin, OptStrExpr):
pass
class OptImageRefStrExpr(OptStrExpr):
async def eval(self, root: RootABC) -> Optional[str]:
img_ref = await super().eval(root)
if img_ref is not None:
return await project_image_ref(img_ref, root)
return None


class ImageRefStrExpr(ImageRefExprMixin, StrExpr):
pass
class ImageRefStrExpr(StrExpr):
async def eval(self, root: RootABC) -> str:
img_ref = await super().eval(root)
return await project_image_ref(img_ref, root)


class OptURIExpr(URIExprMixin, Expr[URL]):