Push a pure-python module to Dask workers

后端 未结 2 2018
南旧
南旧 2021-01-26 10:09

Is there an easy way in Dask to push a pure-python module to the workers?

I have many workers in a cluster and I want to distribute a local module that I have on my cl

相关标签:
2条回答
  • 2021-01-26 10:22

    Alternative if you wish to deploy a package to the workers after they have started you can do something similar to this using Client.run and Client.restart

    def deploy_env(packages):
        conda_prefix = pathlib.Path(sys.executable).parent.parent
        res = subprocess.check_output(['conda', 'install', '-p', conda_prefix] + packages)
        return res
    
    # Run the deploy command on all the workers
    result = client.run(deploy_env, packages)
    
    # Restart all the worker processes
    client.restart()
    

    After this the packages specified will be installed on all currently running workers.

    This approach will not work when adding additional workers to the scheduler.

    0 讨论(0)
  • 2021-01-26 10:36

    Yes, use the Client.upload_file method.

    client.upload_file('myfile.py')
    

    This method will distribute the file and, if the file ends in .py or .egg will also import and reload the module on each of the workers.

    0 讨论(0)
提交回复
热议问题