From 0a69aac3bb87da88356a4340cbef48452577e954 Mon Sep 17 00:00:00 2001 From: RandomY-2 <69881587+RandomY-2@users.noreply.github.com> Date: Mon, 4 Oct 2021 14:36:12 -0700 Subject: [PATCH 1/2] simplify property field --- mars/services/task/supervisor/processor.py | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/mars/services/task/supervisor/processor.py b/mars/services/task/supervisor/processor.py index bbd1d4437c..65c7ca9231 100644 --- a/mars/services/task/supervisor/processor.py +++ b/mars/services/task/supervisor/processor.py @@ -599,27 +599,15 @@ def get_tileable_details(self): else: status = SubtaskStatus.running - # get properties for tileable - all_propertes = {} - for slot in tileable.__slots__: - all_propertes.update(getattr(tileable, slot, None)) - - # Only int/float/string type values for now - displayed_properties = dict() - for property_key, property_value in all_propertes.items(): - # Omit key property - if (property_key == 'key'): - continue - - if isinstance(property_value, int) or isinstance(property_value, float) \ - or isinstance(property_value, str): - displayed_properties[property_key] = property_value + props = {slot: getattr(tileable, slot, None) for slot in tileable.__slots__} + props = {k: v for k, v in props.get('_FIELD_VALUES').items() + if k != 'key' and isinstance(v, (int, float, str))} tileable_infos[tileable.key] = { 'progress': progress, 'subtaskCount': len(results), 'status': status.value, - 'properties': displayed_properties, + 'properties': props, } return tileable_infos From 205ef5836e9a9712c8f0355fc0e62a3e1fbf2f79 Mon Sep 17 00:00:00 2001 From: RandomY-2 <69881587+RandomY-2@users.noreply.github.com> Date: Mon, 4 Oct 2021 17:15:11 -0700 Subject: [PATCH 2/2] change test; --- mars/services/task/supervisor/processor.py | 2 +- mars/services/task/tests/test_service.py | 21 --------------------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/mars/services/task/supervisor/processor.py b/mars/services/task/supervisor/processor.py index 65c7ca9231..c8afcf2bb9 100644 --- a/mars/services/task/supervisor/processor.py +++ b/mars/services/task/supervisor/processor.py @@ -601,7 +601,7 @@ def get_tileable_details(self): props = {slot: getattr(tileable, slot, None) for slot in tileable.__slots__} props = {k: v for k, v in props.get('_FIELD_VALUES').items() - if k != 'key' and isinstance(v, (int, float, str))} + if k != 'key' and isinstance(v, (int, float, str))} tileable_infos[tileable.key] = { 'progress': progress, diff --git a/mars/services/task/tests/test_service.py b/mars/services/task/tests/test_service.py index 4c33659865..1182a7cb37 100644 --- a/mars/services/task/tests/test_service.py +++ b/mars/services/task/tests/test_service.py @@ -384,27 +384,6 @@ def _get_fields(details, field, wrapper=None): details = await task_api.get_tileable_details(task_id) assert details[r7.key]['status'] == SubtaskStatus.errored.value - def a(): - return md.DataFrame([[1, 2], [3, 4]]) - - def b(): - return md.DataFrame([[1, 2, 3, 4], [4, 3, 2, 1]]) - - def c(a, b): - return a.sum() * a.product() * b.sum() * a.sum() / a.sum() * b.product() / a.product() - - ra = mr.spawn(a) - rb = mr.spawn(b) - rc = mr.spawn(c, args=(ra, rb)) - - graph = TileableGraph([rc.data]) - next(TileableGraphBuilder(graph).build()) - - task_id = await task_api.submit_tileable_graph(graph, fuse_enabled=False) - - await asyncio.sleep(1) - details = await task_api.get_tileable_details(task_id) - def is_valid_type(value): return isinstance(value, int) or isinstance(value, float) or isinstance(value, str)