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

second but now tested Tasks generator with/without threads #291

Merged
merged 5 commits into from
Oct 22, 2020

Conversation

vincentsarago
Copy link
Member

re-do of #281

  1. tests were poorly written
  2. everything was fine when running with 1 thread because of a bug
  3. Generator lose its state at the first exception, meaning that we can't really go through all the stack of tasks, it's was just luck that we someone had a first COG returning (yield) before a task raise an exception.

cc @kylebarron @geospatial-jeff

@@ -73,7 +73,7 @@ def reader(asset: str, *args, **kwargs) -> Tuple[numpy.ndarray, numpy.ndarray]:
)

if not chunk_size:
chunk_size = threads or len(assets)
chunk_size = threads if threads > 1 else len(assets)
Copy link
Member Author

Choose a reason for hiding this comment

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

this explains why it was fine with threads=1, because we were processing chunks of one element.

@@ -222,18 +221,64 @@ def test_mosaic_tiler_Stdev():

def test_threads():
"""Test mosaic tiler."""
assets = [asset1, asset2, asset1, asset2, asset1, asset2]
assets = [asset2, asset1, asset1, asset2, asset1, asset2]
Copy link
Member Author

Choose a reason for hiding this comment

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

Simple but important changes, before we were just lucky because the tiler was first yielding result for asset1. This change was made during testing to validate the new implementation

rio_tiler/tasks.py Outdated Show resolved Hide resolved
@@ -44,15 +47,9 @@ def filter_tasks(
if not allowed_exceptions:
allowed_exceptions = ()

while True:
for (future, asset) in tasks:
Copy link
Member Author

Choose a reason for hiding this comment

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

because we don't need generators anymore we can switch back to simple Sequence

@vincentsarago vincentsarago merged commit 8d3ae24 into master Oct 22, 2020
@vincentsarago vincentsarago deleted the fixBadTasksGenerator branch October 22, 2020 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants