-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add hugie config modify
sub-command (resolves #41)
#47
Changes from 7 commits
3ed0a5d
31bd8dc
987be9e
94e09f3
ecab6d8
3b3ab00
5a74d6a
667d83a
b4f6346
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
# Venv, direnv | ||
.env | ||
.envrc | ||
.venv/ | ||
|
||
# Python cache, eggs | ||
*egg-info/ | ||
*__pycache__/ | ||
dist/ | ||
*egg-info/ | ||
build | ||
dist/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Config | ||
|
||
This page details the usage of the config command | ||
|
||
``` | ||
Usage: hugie config [OPTIONS] COMMAND [ARGS]... | ||
|
||
╭─ Options ────────────────────────────────────────────────────────────────────╮ | ||
│ --help Show this message and exit. │ | ||
╰──────────────────────────────────────────────────────────────────────────────╯ | ||
╭─ Commands ───────────────────────────────────────────────────────────────────╮ | ||
│ modify Modify an existing endpoint config file │ | ||
╰──────────────────────────────────────────────────────────────────────────────╯ | ||
``` | ||
|
||
## Modify | ||
|
||
Modify an existing config file. | ||
|
||
Command referene: | ||
``` | ||
Usage: hugie config modify [OPTIONS] PATH | ||
|
||
Modify an existing endpoint config file | ||
|
||
╭─ Arguments ──────────────────────────────────────────────────────────────────╮ | ||
│ * path TEXT [default: None] [required] │ | ||
╰──────────────────────────────────────────────────────────────────────────────╯ | ||
╭─ Options ────────────────────────────────────────────────────────────────────╮ | ||
│ --accountid TEXT ID of the account (for private endpoints) │ | ||
│ [default: None] │ | ||
│ --name TEXT Name of the endpoint [default: None] │ | ||
│ --type TEXT Type of endpoint, one of ['public', │ | ||
│ 'protected', 'private'] │ | ||
│ [default: None] │ | ||
│ --accelerator TEXT Accelerator to use. One of ['CPU','GPU'] │ | ||
│ [default: None] │ | ||
│ --instancetype TEXT [default: None] │ | ||
│ --instancesize TEXT [default: None] │ | ||
│ --minreplica INTEGER Minimum number of replicas [default: None] │ | ||
│ --maxreplica INTEGER Maximum number of replicas [default: None] │ | ||
│ --framework TEXT Framework to use [default: huggingface] │ | ||
│ --image TEXT Image to use when deploying model endppint. │ | ||
│ Must be string representing a valid JSON, │ | ||
│ e.g. '{'huggingface': {}}' │ | ||
│ [default: None] │ | ||
│ --repository TEXT Name of the hf model repository │ | ||
│ [default: None] │ | ||
│ --revision TEXT Revision of the hf model repository │ | ||
│ [default: None] │ | ||
│ --task TEXT Task of the model [default: None] │ | ||
│ --vendor TEXT Vendor to use. One of ['aws','gcp'] │ | ||
│ [default: None] │ | ||
│ --region TEXT Vendor specific region, e.g. 'us-east-1' │ | ||
│ [default: None] │ | ||
│ --overwrite -o Overwrite inpiut file with updated config │ | ||
│ --help Show this message and exit. │ | ||
╰──────────────────────────────────────────────────────────────────────────────╯ | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import typer | ||
|
||
from hugie.endpoint import app as endpoint_app | ||
from hugie.config import app as config_app | ||
|
||
app = typer.Typer() | ||
|
||
app.add_typer(endpoint_app, name="endpoint") | ||
app.add_typer(config_app, name="config") | ||
|
||
if __name__ == "__main__": | ||
app() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import srsly | ||
import typer | ||
|
||
from hugie.models import InferenceEndpointConfig | ||
|
||
app = typer.Typer() | ||
|
||
|
||
@app.command() | ||
def modify( | ||
path: str, | ||
accountId: str = typer.Option( | ||
None, help="ID of the account (for private endpoints)" | ||
), | ||
name: str = typer.Option(None, help="Name of the endpoint"), | ||
type: str = typer.Option( | ||
None, help="Type of endpoint, one of ['public', 'protected', 'private']" | ||
), | ||
accelerator: str = typer.Option( | ||
"None", help="Accelerator to use. One of ['CPU','GPU']" | ||
), | ||
instanceType: str = typer.Option(None), | ||
instanceSize: str = typer.Option(None), | ||
minReplica: int = typer.Option(None, help="Minimum number of replicas"), | ||
maxReplica: int = typer.Option(None, help="Maximum number of replicas"), | ||
framework: str = typer.Option("huggingface", help="Framework to use"), | ||
image: str = typer.Option( | ||
None, | ||
help="Image to use when deploying model endppint. Must be string representing a valid JSON, e.g. '{'huggingface': {}}'", | ||
), | ||
repository: str = typer.Option(None, help="Name of the hf model repository"), | ||
revision: str = typer.Option(None, help="Revision of the hf model repository"), | ||
task: str = typer.Option(None, help="Task of the model"), | ||
vendor: str = typer.Option(None, help="Vendor to use. One of ['aws','gcp']"), | ||
region: str = typer.Option(None, help="Vendor specific region, e.g. 'us-east-1'"), | ||
overwrite: bool = typer.Option( | ||
False, "--overwrite", "-o", help="Overwrite inpiut file with updated config" | ||
), | ||
): | ||
""" | ||
Modify an existing endpoint config file | ||
""" | ||
|
||
config = InferenceEndpointConfig.from_json(path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does it work with a path that does not exist? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it should fail. I will add tests and error handling for this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Error handling already covered by Noe that I was also considering adding a |
||
|
||
# Standard configs | ||
|
||
if name: | ||
config.name = name | ||
|
||
if type: | ||
config.type = type | ||
|
||
if accountId: | ||
config.accountId = accountId | ||
|
||
# Model config | ||
|
||
if repository: | ||
config.model.repository = repository | ||
|
||
if revision: | ||
config.model.revision = revision | ||
|
||
if framework: | ||
config.model.framework = framework | ||
|
||
if task: | ||
config.model.task = task | ||
|
||
if image: | ||
config.model.image = image | ||
|
||
# Compute config | ||
|
||
if instanceSize: | ||
config.compute.instanceSize = instanceSize | ||
|
||
if accelerator: | ||
config.compute.accelerator = accelerator | ||
|
||
if instanceType: | ||
config.compute.instanceType = instanceType | ||
|
||
# Scaling config | ||
|
||
if minReplica: | ||
config.scaling.minReplica = minReplica | ||
|
||
if maxReplica: | ||
config.scaling.maxReplica = maxReplica | ||
|
||
# Provider config | ||
|
||
if vendor: | ||
config.provider.vendor = vendor | ||
|
||
if region: | ||
config.provider.region = region | ||
|
||
if overwrite: | ||
try: | ||
srsly.write_json(path, config.dict()) | ||
typer.secho(f"Updated config at {path}", fg=typer.colors.GREEN) | ||
except Exception: | ||
typer.secho(f"Failed to update config at {path}", fg=typer.colors.RED) | ||
|
||
else: | ||
typer.secho(srsly.json_dumps(config.dict()), fg=typer.colors.YELLOW) | ||
|
||
|
||
if __name__ == "__main__": | ||
app() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this contain
config
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's a separate sub command, so it should be in docs/config