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

Include tileable property in detail api #2493

Merged
merged 14 commits into from
Oct 6, 2021
6 changes: 6 additions & 0 deletions mars/services/task/supervisor/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,11 +599,17 @@ def get_tileable_details(self):
else:
status = SubtaskStatus.running

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': props,
}

return tileable_infos

def get_tileable_subtasks(self, tileable_id: str, with_input_output: bool):
Expand Down
14 changes: 14 additions & 0 deletions mars/services/task/tests/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,20 @@ 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 is_valid_type(value):
return isinstance(value, int) or isinstance(value, float) or isinstance(value, str)
Copy link
Member

@wjsi wjsi Oct 5, 2021

Choose a reason for hiding this comment

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

Multiple isinstances can be simplified with a single call on tuple of types, for inst., isinstance(value, (int, float, str)). Hence this utility function may not be needed.


contain_id_property = False
for tileable in details.keys():
for property_key, property_value in details.get(tileable).get('properties').items():
assert property_key != 'key'
assert is_valid_type(property_value)

if property_key == 'id':
contain_id_property = True

assert contain_id_property == True


@pytest.mark.asyncio
@pytest.mark.parametrize('with_input_output', [False, True])
Expand Down