forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[workflow] Workflow queue (ray-project#24697)
* implement workflow queue
- Loading branch information
Showing
10 changed files
with
481 additions
and
129 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,24 @@ | |
import requests | ||
|
||
|
||
def fibonacci(n): | ||
assert n > 0 | ||
a, b = 0, 1 | ||
for _ in range(n - 1): | ||
a, b = b, a + b | ||
return b | ||
|
||
|
||
@ray.remote | ||
def compute_large_fib(M: int, n: int = 1, fib: int = 1): | ||
next_fib = requests.post( | ||
"https://nemo.api.stdlib.com/[email protected]/", data={"nth": n} | ||
).json() | ||
try: | ||
next_fib = requests.post( | ||
"https://nemo.api.stdlib.com/[email protected]/", data={"nth": n} | ||
).json() | ||
assert isinstance(next_fib, int) | ||
except AssertionError: | ||
# TODO(suquark): The web service would fail sometimes. This is a workaround. | ||
next_fib = fibonacci(n) | ||
if next_fib > M: | ||
return fib | ||
else: | ||
|
Oops, something went wrong.