Skip to content

Commit

Permalink
Trying to improve code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
vcfgv committed Aug 25, 2021
1 parent 494d143 commit db74157
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions mars/deploy/oscar/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ async def fetch(self, *tileables, **kwargs) -> list:
result = []
for tileable, fetch_infos in zip(tileables, fetch_infos_list):
index_to_data = [(fetch_info.chunk.index, fetch_info.data)
for fetch_info in fetch_infos]
for fetch_info in fetch_infos]
merged = merge_chunks(index_to_data)
if hasattr(tileable, 'order') and tileable.ndim > 0:
module = get_array_module(merged)
Expand All @@ -890,7 +890,7 @@ async def fetch_infos(self, *tileables, filters, **kwargs) -> list:
filters = available_fields
else:
for filter_name in filters:
if filter_name not in available_fields:
if filter_name not in available_fields: # pragma: no cover
raise TypeError(f'`fetch_infos` got unexpected '
f'filter name: {filter_name}')
filters = set(filters)
Expand Down
12 changes: 10 additions & 2 deletions mars/deploy/oscar/tests/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import mars.remote as mr
from mars.config import option_context
from mars.deploy.oscar.session import get_default_async_session, \
get_default_session, new_session, execute, fetch, stop_server, \
get_default_session, new_session, execute, fetch, fetch_infos,stop_server, \
AsyncSession, _IsolatedWebSession
from mars.deploy.oscar.local import new_cluster
from mars.deploy.oscar.service import load_config
Expand Down Expand Up @@ -181,14 +181,21 @@ async def test_fetch_infos(create_cluster):
df = md.DataFrame(raw_df, chunk_size=10)
df.execute()
fetched_infos = df.fetch_infos()
print(fetched_infos)

assert 'object_id' in fetched_infos
assert 'level' in fetched_infos
assert 'memory_size' in fetched_infos
assert 'store_size' in fetched_infos
assert 'band' in fetched_infos

results_infos = mr.ExecutableTuple([df, df]).execute()._fetch_infos()
assert len(results_infos) == 2
assert 'object_id' in results_infos[0]
assert 'level' in results_infos[0]
assert 'memory_size' in results_infos[0]
assert 'store_size' in results_infos[0]
assert 'band' in results_infos[0]


def _my_func():
print('output from function')
Expand Down Expand Up @@ -302,6 +309,7 @@ def test_no_default_session():
execute(b, show_progress=False)

np.testing.assert_array_equal(fetch(b), raw + 1)
fetch_infos(b, filters=None)
assert get_default_async_session() is not None
stop_server()
assert get_default_async_session() is None
Expand Down
6 changes: 6 additions & 0 deletions mars/deploy/oscar/tests/test_ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ async def test_execute_describe(ray_large_cluster, create_cluster):
await test_local.test_execute_describe(create_cluster)


@require_ray
@pytest.mark.asyncio
async def test_fetch_infos(ray_large_cluster, create_cluster):
await test_local.test_fetch_infos(create_cluster)


@require_ray
@pytest.mark.asyncio
def test_sync_execute(ray_large_cluster, create_cluster):
Expand Down

0 comments on commit db74157

Please sign in to comment.