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

now pylzy does not abort workflow in case of grpc error[WIP] #1074

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions pylzy/lzy/api/v1/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
TypeVar, cast, Set, )

from ai.lzy.v1.whiteboard.whiteboard_pb2 import Whiteboard
from grpc.aio import AioRpcError

from lzy.api.v1.env import Env
from lzy.api.v1.provisioning import Provisioning
from lzy.api.v1.snapshot import Snapshot, DefaultSnapshot
Expand Down Expand Up @@ -41,15 +43,15 @@ def get_active(cls) -> Optional["LzyWorkflow"]:
return cls.instance

def __init__(
self,
name: str,
owner: "Lzy",
env: Env,
provisioning: Provisioning,
auto_py_env: PyEnv,
*,
eager: bool = False,
interactive: bool = True
self,
name: str,
owner: "Lzy",
env: Env,
provisioning: Provisioning,
auto_py_env: PyEnv,
*,
eager: bool = False,
interactive: bool = True
Comment on lines +46 to +54
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove tab here please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

):
if not is_name_valid(name):
raise ValueError(f"Invalid workflow name. Name can contain only {NAME_VALID_SYMBOLS}")
Expand Down Expand Up @@ -145,6 +147,8 @@ def __enter__(self) -> "LzyWorkflow":
self.__snapshot = DefaultSnapshot(self.owner.serializer_registry, storage_uri, self.owner.storage_client,
self.owner.storage_name)
return self
except AioRpcError as e:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

except AioRpcError:
    raise

raise e
except Exception as e:
try:
self.__abort()
Expand All @@ -167,6 +171,8 @@ def __exit__(self, exc_type, exc_val, exc_tb) -> None:
finally:
if exc_type is None:
self.__destroy()
elif exc_type is AioRpcError:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here may be UNAVAILABLE, so we must abort wf in this case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UNAVAILABLE is retryable error. Python lzy-client should repeat request in case. If after an amount of attempts lzy service is still unavailable so I believe that it is really UNAVAILABLE and an abort request is useless :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think isinstance(e, AioRpcError) would be more accurate here

raise exc_val
else:
try:
self.__abort()
Expand Down