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

Features: Distributed computation #2

Open
arita37 opened this issue Nov 17, 2016 · 1 comment
Open

Features: Distributed computation #2

arita37 opened this issue Nov 17, 2016 · 1 comment
Labels

Comments

@arita37
Copy link

arita37 commented Nov 17, 2016

Hello,

Find your project interresting.
Just wondering if there is a way to generate many instances of a class: c1, c2,...cn (all having different parameters) and send them on the clusters and do individual compute ( c1.compute() ) and get back the results into in the local computer ?

Thanks

@mattja
Copy link
Owner

mattja commented Nov 22, 2016

Yes, you can use the __init__ function of your class to give different parameters to each instance.
For example, here giving each instance slightly different random values:

import distob
import numpy as np

class C(object):
    def __init__(self):
        self.a = np.random.normal(7.0, 2.0)

    def compute(self, x):
        return 100*x + self.a

N = 10
instances = [C() for i in range(N)]
instances = distob.scatter(instances)

results = distob.call_all(instances, 'compute', 1.0)
print(results)

The function calls to compute() will be executed in parallel on the cluster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants