-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Overview Add @colin-ho's shuffle testing PR to this repo; also add the ability to invoke it in CI runs. --------- Co-authored-by: Desmond Cheong <[email protected]>
- Loading branch information
1 parent
78c738f
commit c2abed8
Showing
6 changed files
with
412 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
Given a comma-separated string of environment variables, parse them into a dictionary. | ||
Example: | ||
env_str = "a=1,b=2" | ||
result = parse_env_var_str(env_str) | ||
# returns {"a":1,"b":2} | ||
""" | ||
|
||
import argparse | ||
import json | ||
|
||
|
||
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} | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--enable-ray-tracing", action="store_true") | ||
parser.add_argument("--env-vars", required=True) | ||
args = parser.parse_args() | ||
|
||
env_vars = parse_env_var_str(args.env_vars) | ||
if args.enable_ray_tracing: | ||
env_vars["DAFT_ENABLE_RAY_TRACING"] = "1" | ||
ray_env_vars = { | ||
"env_vars": env_vars, | ||
} | ||
print(json.dumps(ray_env_vars)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,30 @@ | ||
# /// script | ||
# requires-python = ">=3.12" | ||
# dependencies = [] | ||
# /// | ||
|
||
""" | ||
The `read` function below is sourced from: | ||
https://packaging.python.org/en/latest/specifications/inline-script-metadata/#inline-script-metadata | ||
""" | ||
|
||
import re | ||
|
||
import tomllib | ||
|
||
REGEX = r"(?m)^# /// (?P<type>[a-zA-Z0-9-]+)$\s(?P<content>(^#(| .*)$\s)+)^# ///$" | ||
|
||
|
||
def read(script: str) -> dict | None: | ||
name = "script" | ||
matches = list(filter(lambda m: m.group("type") == name, re.finditer(REGEX, script))) | ||
if len(matches) > 1: | ||
raise ValueError(f"Multiple {name} blocks found") | ||
elif len(matches) == 1: | ||
content = "".join( | ||
line[2:] if line.startswith("# ") else line[1:] | ||
for line in matches[0].group("content").splitlines(keepends=True) | ||
) | ||
return tomllib.loads(content) | ||
else: | ||
return None |
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
Oops, something went wrong.