0

いくつかの分散ベンチマークを実行するために、並列 python を使用しようとしています (基本的に、中央サーバーから一連のマシンでいくつかのコードを調整して実行します)。機能を別のパッケージに移動するまで、私が持っていたコードは完全に正常に機能していました。それ以来、私は取得し続けImportError: No module named some.module.pp_testます。

私の質問は実際には 2 つあります。誰かが でこの問題に遭遇したppことがありますか?もしそうなら、どうすれば解決できますか? dill( )を使用してみimport dillましたが、役に立ちませんでした。また、追加のインフラストラクチャを必要としない、parallelpython の適切な代替品はありますか?

私が得る正確なエラーは次のとおりです。

RUNNING TEST
Waiting for hosts to finish booting....A fatal error has occured during the function execution
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/ppworker.py", line 86, in run
    __args = pickle.loads(__sargs)
ImportError: No module named some.module.pp_test
Caught exception in the run phase 'NoneType' object is not iterable
Traceback (most recent call last):
  File "test.py", line 5, in <module>
    p.ping_pong()
  File "/home/ubuntu/workspace/pp-test/some/module/pp_test.py", line 5, in ping_pong
    a_test.run()
  File "/home/ubuntu/workspace/pp-test/some/module/pp_test.py", line 27, in run
    pong, hostname = ping()
TypeError: 'NoneType' object is not iterable

コードは次のように構成されています。

pp-test/
       test.py
       some/
            __init__.py
            module/
                   __init__.py
                   pp_test.py

は次のtest.pyように実装されます。

from some.module.pp_test import MWE

p = MWE()
p.ping_pong()

ながらpp_test.py:

class MWE():
  def ping_pong(self):
    print "RUNNING TEST "
    a_test = PPTester()
    a_test.run()

import pp
import time
from sys import stdout, exit

class PPTester(object):
  def run(self):
    try:
        ppservers = ('10.10.10.10', )
        time.sleep(5)
        job_server = pp.Server(0, ppservers=ppservers)
        stdout.write("Waiting for hosts to finish booting...")
        while len(job_server.get_active_nodes()) - 1 < len(ppservers):
            stdout.write(".")
            stdout.flush()
            time.sleep(1)

        ppmodules = ()
        pings = [(server, job_server.submit(self.run_pong, modules=ppmodules)) for server in ppservers]
        for server, ping in pings:
            pong, hostname = ping()
            print "Host ", hostname, " is alive!"

        print "All servers booted up, starting benchmarks..."
        job_server.print_stats()
    except Exception as e:
        print "Caught exception in the run phase", e
        raise
    pass

  def run_pong(self):
    import subprocess
    p = subprocess.Popen("hostname", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
    (output, err) = p.communicate()
    p_status = p.wait()

    return "pong ", output
4

1 に答える 1

0

dillpython オブジェクトをシリアル化しないppため、そのままでは機能しません --オブジェクトのソース コードを抽出します (標準の python ライブラリのモジュールのように)。ppppinspect

ppを使用できるようにするにはdill(実際dill.sourceにはinspectによって拡張されます)、呼び出されdillた のフォークを使用する必要があります。としてインストールされます(つまり、 でインポートされます) が、ソース インスペクションがはるかに強力であるため、ほとんどの python オブジェクトを自動的に「シリアル化」し、それらの依存関係を自動的に追跡できます。ppppftppftppimport ppppft

ppftここにアクセスしてください: https://github.com/uqfoundation

ppftpipインストール可能で、python3.xと互換性があります。

于 2015-02-03T18:16:33.510 に答える