-
Notifications
You must be signed in to change notification settings - Fork 296
ci: Add ability to array-ify args and run multiple jobs #3584
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
735b16c
Array-ify the run-cluster script
raunakab 05c51ab
Remove test file
raunakab a744cf2
Change to raising errors instead of performing assertions
raunakab 96ec531
Remove debug prints
raunakab 46ebcab
Add catalog generation from s3 instead of from local
raunakab b3da1a3
Remove data-gen
raunakab e936e9f
Remove extra variable
raunakab 5c14913
Change up catalog registration
raunakab b96aed2
Generate catalog off of s3 urls instead
raunakab dbe5f8c
Remove the removal of the daft dir
raunakab 54e2269
Add scale-factor argument
raunakab 8ed2077
Add default scale-factor size
raunakab 674ca8f
Remove duckdb dep
raunakab debb5b8
Add inline metadata to job_runner script
raunakab 92f227c
Edit description
raunakab 5b5a9f9
Remove trailing slash
raunakab ff89642
Merge branch 'main' into ci/run-cluster
raunakab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import argparse | ||
import asyncio | ||
import json | ||
from dataclasses import dataclass | ||
from datetime import datetime, timedelta | ||
from pathlib import Path | ||
from typing import Optional | ||
|
||
import duckdb | ||
from ray.job_submission import JobStatus, JobSubmissionClient | ||
|
||
|
||
def parse_env_var_str(env_var_str: str) -> dict: | ||
iter = map( | ||
lambda s: s.strip().split("="), | ||
filter(lambda s: s, env_var_str.split(",")), | ||
) | ||
return {k: v for k, v in iter} | ||
|
||
|
||
async def print_logs(logs): | ||
async for lines in logs: | ||
print(lines, end="") | ||
|
||
|
||
async def wait_on_job(logs, timeout_s): | ||
await asyncio.wait_for(print_logs(logs), timeout=timeout_s) | ||
|
||
|
||
def generate_data(): | ||
datadir = Path(__file__).parents[2] / "gendata" | ||
raunakab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
datadir.mkdir(parents=True, exist_ok=True) | ||
scale_factor = 0.01 | ||
raunakab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
db = duckdb.connect(database=datadir / "tpcds.db") | ||
db.sql(f"call dsdgen(sf = {scale_factor})") | ||
for item in db.sql("show tables").fetchall(): | ||
tbl = item[0] | ||
parquet_file = datadir / f"{tbl}.parquet" | ||
print(f"Exporting {tbl} to {parquet_file}") | ||
db.sql(f"COPY {tbl} TO '{parquet_file}'") | ||
raunakab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
@dataclass | ||
class Result: | ||
query: int | ||
duration: timedelta | ||
error_msg: Optional[str] | ||
|
||
|
||
def submit_job( | ||
working_dir: Path, | ||
entrypoint_script: str, | ||
entrypoint_args: str, | ||
env_vars: str, | ||
enable_ray_tracing: bool, | ||
): | ||
generate_data() | ||
|
||
env_vars_dict = parse_env_var_str(env_vars) | ||
if enable_ray_tracing: | ||
env_vars_dict["DAFT_ENABLE_RAY_TRACING"] = "1" | ||
|
||
client = JobSubmissionClient(address="http://localhost:8265") | ||
|
||
if entrypoint_args.startswith("[") and entrypoint_args.endswith("]"): | ||
# this is a json-encoded list of strings; parse accordingly | ||
list_of_entrypoint_args: list[str] = json.loads(entrypoint_args) | ||
else: | ||
list_of_entrypoint_args: list[str] = [entrypoint_args] | ||
|
||
results = [] | ||
|
||
for index, args in enumerate(list_of_entrypoint_args): | ||
entrypoint = f"DAFT_RUNNER=ray python {entrypoint_script} {args}" | ||
print(f"{entrypoint=}") | ||
start = datetime.now() | ||
job_id = client.submit_job( | ||
entrypoint=entrypoint, | ||
runtime_env={ | ||
"working_dir": working_dir, | ||
"env_vars": env_vars_dict, | ||
}, | ||
) | ||
|
||
asyncio.run(wait_on_job(client.tail_job_logs(job_id), timeout_s=60 * 30)) | ||
|
||
status = client.get_job_status(job_id) | ||
assert status.is_terminal(), "Job should have terminated" | ||
end = datetime.now() | ||
duration = end - start | ||
error_msg = None | ||
if status != JobStatus.SUCCEEDED: | ||
job_info = client.get_job_info(job_id) | ||
error_msg = job_info.message | ||
|
||
result = Result(query=index, duration=duration, error_msg=error_msg) | ||
results.append(result) | ||
|
||
print(f"{results=}") | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--working-dir", type=Path, required=True) | ||
parser.add_argument("--entrypoint-script", type=str, required=True) | ||
parser.add_argument("--entrypoint-args", type=str, required=True) | ||
parser.add_argument("--env-vars", type=str, required=True) | ||
parser.add_argument("--enable-ray-tracing", action="store_true") | ||
|
||
args = parser.parse_args() | ||
|
||
working_dir: Path = args.working_dir | ||
assert working_dir.exists() and working_dir.is_dir(), "The working dir must exist and be directory" | ||
entrypoint: Path = working_dir / args.entrypoint_script | ||
assert entrypoint.exists() and entrypoint.is_file(), "The entrypoint script must exist and be a file" | ||
raunakab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
submit_job( | ||
working_dir=working_dir, | ||
entrypoint_script=args.entrypoint_script, | ||
entrypoint_args=args.entrypoint_args, | ||
env_vars=args.env_vars, | ||
enable_ray_tracing=args.enable_ray_tracing, | ||
) |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import daft | ||
|
||
df = daft.from_pydict({"nums": [1, 2, 3]}) | ||
|
||
df.show() | ||
raunakab marked this conversation as resolved.
Show resolved
Hide resolved
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.