Last active
April 17, 2020 18:00
-
-
Save bllchmbrs/60b62279477ee741de32e263b9c7ac67 to your computer and use it in GitHub Desktop.
Running your First Distributed Python Application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ray | |
import time | |
from datetime import datetime as dt | |
@ray.remote | |
def adder(input_value): | |
time.sleep(1) | |
return input_value+1 | |
if __name__ == '__main__': | |
ray.init() | |
values = range(10) | |
start = dt.now() | |
new_values = [adder.remote(x) for x in values] | |
return_value = ray.get(new_values) | |
end = dt.now() | |
print("Return Value: {}".format(return_value)) | |
print("Elapsed Time: {}".format((end-start).total_seconds())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment