Skip to content

Commit d384725

Browse files
committed
Add test and documentation
1 parent 562b89d commit d384725

File tree

4 files changed

+95
-16
lines changed

4 files changed

+95
-16
lines changed

README.md

+31-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,37 @@ Commands:
6464
To create an endpoint:
6565

6666
```
67-
hugie endpoint create examples/development.json
67+
Usage: hugie endpoint create [OPTIONS] [DATA]
68+
69+
Create an endpoint
70+
71+
Args: data (str): Path to JSON data to create the endpoint
72+
73+
Arguments:
74+
[DATA] Path JSON data to create the endpoint
75+
76+
Options:
77+
--account-id TEXT ID of the account (for private endpoints)
78+
--name TEXT Name of the endpoint [default: hf-endpoint]
79+
--type TEXT Type of endpoint, one of ['public', 'protected',
80+
'private']
81+
--accelerator TEXT Accelerator to use. One of ['CPU','GPU'] [default:
82+
cpu]
83+
--instance-type TEXT [default: c6i]
84+
--instance-size TEXT [default: small]
85+
--min-replica INTEGER Minimum number of replicas [default: 1]
86+
--max-replica INTEGER Maximum number of replicas [default: 1]
87+
--framework TEXT Framework to use [default: custom]
88+
--repository TEXT Name of the hf model repository [default: t5-small]
89+
--revision TEXT Revision of the hf model repository [default: main]
90+
--task TEXT Task of the model [default: text-generation]
91+
--image TEXT Image to use from huggingface or tgi [default:
92+
huggingface]
93+
--vendor TEXT Vendor to use. One of ['aws','gcp'] [default: aws]
94+
--region TEXT Vendor specific region, e.g. 'us-east-1' [default:
95+
us-east-1]
96+
--json Prints the full output in JSON.
97+
--help Show this message and exit.
6898
```
6999

70100
## List

docs/endpoint.md

+31-14
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,37 @@ hugie endpoint create examples/development.json
3030

3131
Command reference:
3232
```
33-
Usage: hugie endpoint create [OPTIONS] DATA
34-
35-
Create an endpoint
36-
Args: data (str): Path to JSON data to create the endpoint
37-
38-
╭─ Arguments ──────────────────────────────────────────────────────────────────╮
39-
│ * data TEXT Path JSON data to create the endpoint [default: None] │
40-
│ [required] │
41-
╰──────────────────────────────────────────────────────────────────────────────╯
42-
╭─ Options ────────────────────────────────────────────────────────────────────╮
43-
│ --json Prints the full output in JSON. │
44-
│ --help Show this message and exit. │
45-
╰──────────────────────────────────────────────────────────────────────────────╯
46-
33+
Usage: hugie endpoint create [OPTIONS] [DATA]
34+
35+
Create an endpoint
36+
37+
Args: data (str): Path to JSON data to create the endpoint
38+
39+
Arguments:
40+
[DATA] Path JSON data to create the endpoint
41+
42+
Options:
43+
--account-id TEXT ID of the account (for private endpoints)
44+
--name TEXT Name of the endpoint [default: hf-endpoint]
45+
--type TEXT Type of endpoint, one of ['public', 'protected',
46+
'private']
47+
--accelerator TEXT Accelerator to use. One of ['CPU','GPU'] [default:
48+
cpu]
49+
--instance-type TEXT [default: c6i]
50+
--instance-size TEXT [default: small]
51+
--min-replica INTEGER Minimum number of replicas [default: 1]
52+
--max-replica INTEGER Maximum number of replicas [default: 1]
53+
--framework TEXT Framework to use [default: custom]
54+
--repository TEXT Name of the hf model repository [default: t5-small]
55+
--revision TEXT Revision of the hf model repository [default: main]
56+
--task TEXT Task of the model [default: text-generation]
57+
--image TEXT Image to use from huggingface or tgi [default:
58+
huggingface]
59+
--vendor TEXT Vendor to use. One of ['aws','gcp'] [default: aws]
60+
--region TEXT Vendor specific region, e.g. 'us-east-1' [default:
61+
us-east-1]
62+
--json Prints the full output in JSON.
63+
--help Show this message and exit.
4764
```
4865

4966
## list/ls

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "hugie"
3-
version = "0.3.2"
3+
version = "0.4.0"
44
description = "CLI for managing Hugging Face Inference Endpoints"
55
authors = ["Matthew Upson <[email protected]>",
66
"Nick Sorros <[email protected]>"]

tests/test_endpoint.py

+32
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,38 @@ def raise_for_status():
7070
assert result.exit_code == 0
7171

7272

73+
def test_create_args(monkeypatch):
74+
class MockCreateResponse:
75+
def json():
76+
pass
77+
78+
def raise_for_status():
79+
pass
80+
81+
status_code = 200
82+
83+
monkeypatch.setattr("requests.post", lambda url, **kwargs: MockCreateResponse)
84+
result = runner.invoke(
85+
app,
86+
[
87+
"create",
88+
"--name",
89+
"test",
90+
"--instance-type",
91+
"local",
92+
"--instance-size",
93+
"medium",
94+
"--repository",
95+
"bert",
96+
"--task",
97+
"text-generation",
98+
"--accelerator",
99+
"gpu",
100+
],
101+
)
102+
assert result.exit_code == 0
103+
104+
73105
def test_update(monkeypatch, data_path):
74106
class MockUpdateResponse:
75107
def json():

0 commit comments

Comments
 (0)