-
Notifications
You must be signed in to change notification settings - Fork 54
CLI Layout and Create RayCluster function #227
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 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
cc1d341
Create: base and file layout for CLI
carsonmh 0949b39
Add: Create raycluster command for CLI
carsonmh a91511d
Refactor: refactor CLI using pre-commit
carsonmh d6f5944
Test: unit tests for create raycluster function in the CLI
carsonmh 7ca9a36
Update: update egg-info with more paths
carsonmh edbbd09
Change: change Framework Cluster to RayCluster
carsonmh ed9c3c8
merge: rebase with main
carsonmh 43959a3
Fix: unit tests
carsonmh a1b5763
Change: create cluster to define cluster in unit tests
carsonmh 318a1a5
Add: error handling for invalid command
carsonmh 85b42de
test: change tests so cli cluster definition has its own yaml file
carsonmh 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
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
Empty file.
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,12 @@ | ||
import ast | ||
import click | ||
|
||
|
||
class PythonLiteralOption(click.Option): | ||
def type_cast_value(self, ctx, value): | ||
try: | ||
if not value: | ||
return None | ||
return ast.literal_eval(value) | ||
except: | ||
raise click.BadParameter(value) |
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,36 @@ | ||
import click | ||
import sys | ||
import os | ||
|
||
cmd_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), "commands")) | ||
|
||
|
||
class CodeflareCLI(click.MultiCommand): | ||
def list_commands(self, ctx): | ||
rv = [] | ||
for filename in os.listdir(cmd_folder): | ||
if filename.endswith(".py") and filename != "__init__.py": | ||
rv.append(filename[:-3]) | ||
rv.sort() | ||
return rv | ||
|
||
def get_command(self, ctx, name): | ||
ns = {} | ||
fn = os.path.join(cmd_folder, name + ".py") | ||
try: | ||
with open(fn) as f: | ||
code = compile(f.read(), fn, "exec") | ||
eval(code, ns, ns) | ||
return ns["cli"] | ||
except FileNotFoundError: | ||
return | ||
|
||
|
||
@click.command(cls=CodeflareCLI) | ||
@click.pass_context | ||
def cli(ctx): | ||
pass | ||
|
||
|
||
if __name__ == "__main__": | ||
cli() |
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,36 @@ | ||
import click | ||
|
||
from codeflare_sdk.cluster.cluster import Cluster | ||
from codeflare_sdk.cluster.config import ClusterConfiguration | ||
from codeflare_sdk.cli.cli_utils import PythonLiteralOption | ||
|
||
|
||
@click.group() | ||
def cli(): | ||
"""Define a resource with parameter specifications""" | ||
pass | ||
|
||
|
||
@cli.command() | ||
@click.option("--name", type=str, required=True) | ||
@click.option("--namespace", "-n", type=str) | ||
@click.option("--head_info", cls=PythonLiteralOption, type=list) | ||
@click.option("--machine_types", cls=PythonLiteralOption, type=list) | ||
@click.option("--min_cpus", type=int) | ||
@click.option("--max_cpus", type=int) | ||
@click.option("--min_worker", type=int) | ||
@click.option("--max_worker", type=int) | ||
@click.option("--min_memory", type=int) | ||
@click.option("--max_memory", type=int) | ||
@click.option("--gpu", type=int) | ||
@click.option("--template", type=str) | ||
@click.option("--instascale", type=bool) | ||
@click.option("--envs", cls=PythonLiteralOption, type=dict) | ||
@click.option("--image", type=str) | ||
@click.option("--local_interactive", type=bool) | ||
@click.option("--image_pull_secrets", cls=PythonLiteralOption, type=list) | ||
def raycluster(**kwargs): | ||
"""Define a RayCluster with parameter specifications""" | ||
filtered_kwargs = {k: v for k, v in kwargs.items() if v is not None} | ||
clusterConfig = ClusterConfiguration(**filtered_kwargs) | ||
Cluster(clusterConfig) # Creates yaml file |
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
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.