Skip to content

Commit 9f7a714

Browse files
authored
Rename env_name parameter in python client constructors (#2431)
1 parent 89ba2f4 commit 9f7a714

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

docs/clients/python.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
## client
2121

2222
```python
23-
client(env: Optional[str] = None) -> Client
23+
client(env_name: Optional[str] = None) -> Client
2424
```
2525

2626
Initialize a client based on the specified environment. If no environment is specified, it will attempt to use the default environment.
2727

2828
**Arguments**:
2929

30-
- `env` - Name of the environment to use.
30+
- `env_name` - Name of the environment to use.
3131

3232

3333
**Returns**:
@@ -37,14 +37,14 @@ Initialize a client based on the specified environment. If no environment is spe
3737
## new\_client
3838

3939
```python
40-
new_client(name: str, operator_endpoint: str) -> Client
40+
new_client(env_name: str, operator_endpoint: str) -> Client
4141
```
4242

4343
Create a new environment to connect to an existing cluster, and initialize a client to deploy and manage APIs on that cluster.
4444

4545
**Arguments**:
4646

47-
- `name` - Name of the environment to create.
47+
- `env_name` - Name of the environment to create.
4848
- `operator_endpoint` - The endpoint for the operator of your Cortex cluster. You can get this endpoint by running the CLI command `cortex cluster info`.
4949

5050

python/client/cortex/__init__.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,44 +25,46 @@
2525

2626

2727
@sentry_wrapper
28-
def client(env: Optional[str] = None) -> Client:
28+
def client(env_name: Optional[str] = None) -> Client:
2929
"""
3030
Initialize a client based on the specified environment. If no environment is specified, it will attempt to use the default environment.
3131
3232
Args:
33-
env: Name of the environment to use.
33+
env_name: Name of the environment to use.
3434
3535
Returns:
3636
Cortex client that can be used to deploy and manage APIs in the specified environment.
3737
"""
3838
environments = env_list()
3939

40-
if env is None:
40+
if env_name is None:
4141
if not environments.get("default_environment"):
4242
raise NotFound("no default environment configured")
43-
env = environments["default_environment"]
43+
env_name = environments["default_environment"]
4444

4545
found = False
4646
for environment in environments["environments"]:
47-
if environment["name"] == env:
47+
if environment["name"] == env_name:
4848
found = True
4949
break
5050
if not found:
51-
raise NotFound(f"can't find environment {env}, create one by calling `cortex.new_client()`")
51+
raise NotFound(
52+
f"can't find environment {env_name}, create one by calling `cortex.new_client()`"
53+
)
5254

5355
return Client(environment)
5456

5557

5658
@sentry_wrapper
5759
def new_client(
58-
name: str,
60+
env_name: str,
5961
operator_endpoint: str,
6062
) -> Client:
6163
"""
6264
Create a new environment to connect to an existing cluster, and initialize a client to deploy and manage APIs on that cluster.
6365
6466
Args:
65-
name: Name of the environment to create.
67+
env_name: Name of the environment to create.
6668
operator_endpoint: The endpoint for the operator of your Cortex cluster. You can get this endpoint by running the CLI command `cortex cluster info`.
6769
6870
Returns:
@@ -71,14 +73,14 @@ def new_client(
7173
cli_args = [
7274
"env",
7375
"configure",
74-
name,
76+
env_name,
7577
"--operator-endpoint",
7678
operator_endpoint,
7779
]
7880

7981
run_cli(cli_args, hide_output=True)
8082

81-
return client(name)
83+
return client(env_name)
8284

8385

8486
@sentry_wrapper

0 commit comments

Comments
 (0)