-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make distributed execution work (#33)
* Make distributed execution work * fix tips.py * fixes; incorporate changes from #32
- Loading branch information
1 parent
8ce17e2
commit 9fcf28e
Showing
12 changed files
with
183 additions
and
169 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
import os | ||
|
||
import ray | ||
from raysql.context import RaySqlContext | ||
from raysql.worker import Worker | ||
|
||
# Start our cluster | ||
ray.init() | ||
from raysql import RaySqlContext, ResultSet | ||
|
||
# create some remote Workers | ||
workers = [Worker.remote() for i in range(2)] | ||
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) | ||
|
||
# create a remote context and register a table | ||
ctx = RaySqlContext.remote(workers) | ||
ray.get(ctx.register_csv.remote('tips', 'tips.csv', True)) | ||
# Start a local cluster | ||
ray.init(resources={"worker": 1}) | ||
|
||
# Parquet is also supported | ||
# ctx.register_parquet('tips', 'tips.parquet') | ||
# Create a context and register a table | ||
ctx = RaySqlContext(2, use_ray_shuffle=True) | ||
# Register either a CSV or Parquet file | ||
# ctx.register_csv("tips", f"{SCRIPT_DIR}/tips.csv", True) | ||
ctx.register_parquet("tips", f"{SCRIPT_DIR}/tips.parquet") | ||
|
||
result_set = ray.get(ctx.sql.remote('select sex, smoker, avg(tip/total_bill) as tip_pct from tips group by sex, smoker')) | ||
print(result_set) | ||
result_set = ctx.sql( | ||
"select sex, smoker, avg(tip/total_bill) as tip_pct from tips group by sex, smoker" | ||
) | ||
print("Result:") | ||
print(ResultSet(result_set)) |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import ray | ||
|
||
|
||
def node_aff(node_id: ray.NodeID, *, soft: bool = False) -> dict: | ||
return { | ||
"scheduling_strategy": ray.util.scheduling_strategies.NodeAffinitySchedulingStrategy( | ||
node_id=node_id, | ||
soft=soft, | ||
) | ||
} | ||
|
||
|
||
def current_node_aff() -> dict: | ||
return node_aff(ray.get_runtime_context().get_node_id()) |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
black | ||
flake8 | ||
isort | ||
maturin | ||
maturin[patchelf] | ||
mypy | ||
numpy | ||
pyarrow | ||
pytest | ||
ray==2.3.0 | ||
toml | ||
importlib_metadata; python_version < "3.8" |
Oops, something went wrong.