NLeSC / noodles

Computational workflow engine, making distributed computing in Python easy!
http://nlesc.github.io/noodles
Apache License 2.0
21 stars 7 forks source link

push_map.map deprecated Warning #80

Closed felipeZ closed 5 years ago

felipeZ commented 5 years ago

Running a workflow using the run_parallel function from from noodles.run.threading.sqlite3 import run_parallel, results in the following warning:

python3.6/site-packages/noodles/run/scheduler.py:155: DeprecationWarning: generator 'push_map.map' raised StopIteration
  sink.send(EndOfQueue)

A minimal examples, is provided below:

from noodles import (schedule_hint, serial)
from noodles.run.threading.sqlite3 import run_parallel
from noodles.serial import (Registry)

def run(wf, n_processes=1, cache='cache.db'):
    """
    Run locally using several threads.
    Caching can be turned off by specifying cache=None
    """
    return run_parallel(
        wf, n_threads=n_processes, registry=registry,
        db_file=cache, always_cache=False, echo_log=False)

def registry():
    """
    This function pass to the noodles infrascture all the information
    related to the Structure of the Package object that is schedule.
    This *Registry* class contains hints that help Noodles to encode
    and decode this Package object.
    """
    return Registry(parent=serial.base())

@schedule_hint()
def fun(x, y):
    return x ** 2 + y

@schedule_hint()
def fun2(x):
    return 2 * x + 3

def test():
    a = fun(3, 5)
    b = fun(2, a)

    c = fun2(b)

    return run(c)
felipeZ commented 5 years ago

The previous Warning is now an error in python 3.7. The following error is reported:

Traceback (most recent call last):
  File "miniconda3/envs/py37/lib/python3.7/site-packages/noodles/lib/streams.py", line 163, in map
    sink.send(self.f(x))
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "test.py", line 46, in <module>
    test()
  File "test.py", line 42, in test
    return run(c)
  File "test.py", line 13, in run
    db_file=cache, always_cache=False, echo_log=False)
  File "/home/felipe/miniconda3/envs/py37/lib/python3.7/site-packages/noodles/run/threading/sqlite3.py", line 108, in run_parallel
    result = scheduler.run(parallel_sqlite_worker, get_workflow(workflow))
  File "/home/felipe/miniconda3/envs/py37/lib/python3.7/site-packages/noodles/run/scheduler.py", line 155, in run
    sink.send(EndOfQueue)
RuntimeError: generator raised StopIteration
jhidding commented 5 years ago

This is fixed in master

felipeZ commented 5 years ago

fixed by https://github.com/NLeSC/noodles/commit/8444d16d10dffd9d8abbc7d55c067f1fddcffecf