-
Notifications
You must be signed in to change notification settings - Fork 327
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
Support mutable tensor on oscar #2432
Conversation
Just merge the master branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments
mars/deploy/oscar/session.py
Outdated
@abstractmethod | ||
async def create_mutable_tensor(self, | ||
shape: tuple, | ||
dtype: str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type should be Union[np.dtype, str]
|
||
|
||
class MutableTensorActor(mo.Actor): | ||
def __init__(self, shape: tuple, dtype: str, chunk_size, worker_pools, name: str = None, default_value=0): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dtype
should be Union[np.dtype, str]
, and how about just getting all bands when needed?
mars/services/session/api/oscar.py
Outdated
@@ -109,6 +109,20 @@ async def destroy_remote_object(self, | |||
session = await self._get_session_ref(session_id) | |||
return await session.destroy_remote_object(name) | |||
|
|||
async def create_mutable_tensor(self, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend to add this API to mutable API instead of session API.
Besides, now, the data stored in worker is just a numpy ndarray, please use storage API to store data. And |
Signed-off-by: Tao He <[email protected]>
Signed-off-by: Tao He <[email protected]>
Signed-off-by: Tao He <[email protected]>
Signed-off-by: Tao He <[email protected]>
Signed-off-by: Tao He <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
mars/services/mutable/api/web.py
Outdated
res = await oscar_api.get_mutable_tensor(name) | ||
self.write(serialize_serializable(res)) | ||
|
||
@web_api('(?P<name>[^/]+)', method='delete') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use DELETE
method to handle seal
? Maybe POST
is better. I'm also wondering why this is not covered in tests. A parameterized test with different APIs may be applied.
mars/services/mutable/api/oscar.py
Outdated
if name is None: | ||
name = str(uuid.uuid1()) | ||
if name in self._mutable_objects: | ||
raise ValueError("Mutable tensor %s already exists!" % name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use f-string to format error messages.
mars/services/mutable/api/oscar.py
Outdated
self._session_id = session_id | ||
self._address = address | ||
self._cluster_api = cluster_api | ||
self._mutable_objects = dict() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it proper to reference mutable objects locally, or if we need to manage it at service side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a get_mutable_tensor
method on session.
We shouldn't record the state here, actually. I missed it in previous review.
from .service import MutableTensorActor | ||
|
||
|
||
class MutableTensor: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an object passed to clients, I recommend putting it in mars.services.mutable.core
.
mars/services/mutable/worker/core.py
Outdated
from ....typing import ChunkType | ||
|
||
|
||
class Chunk: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use more explicit class name, for inst., MutableTensorChunk
.
Signed-off-by: Tao He <[email protected]>
All concerns in previous review comments and in DingDing talks have been addressed. |
Signed-off-by: Tao He <[email protected]>
Signed-off-by: Tao He <[email protected]>
Signed-off-by: Tao He <[email protected]>
Signed-off-by: Tao He <[email protected]>
Signed-off-by: Tao He <[email protected]>
Signed-off-by: Tao He <[email protected]>
Signed-off-by: Tao He <[email protected]>
Signed-off-by: Tao He <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks, look forward to seeing more contributions from you. |
What do these changes do?
Related issue number
Fixes #2195