Skip to content

Commit e77c647

Browse files
committed
fix: resolve all E501 line-too-long issues in vmm-cli.py
1 parent b6f9d85 commit e77c647

1 file changed

Lines changed: 26 additions & 14 deletions

File tree

vmm/src/vmm-cli.py

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,20 @@ def encrypt_env(envs, hex_public_key: str) -> str:
3939
4040
This function does the following:
4141
1. Converts the given environment variables to JSON bytes.
42-
2. Removes a leading "0x" from the provided public key (if present) and converts it to bytes.
42+
2. Removes a leading "0x" from the provided public key
43+
(if present) and converts it to bytes.
4344
3. Generates an ephemeral X25519 key pair.
44-
4. Computes a shared secret using this ephemeral private key and the remote public key.
45+
4. Computes a shared secret using this ephemeral private
46+
key and the remote public key.
4547
5. Uses the shared key directly as the 32-byte key for AES-GCM.
46-
6. Encrypts the JSON string with AES-GCM using a randomly generated IV.
47-
7. Concatenates the ephemeral public key, IV, and ciphertext and returns it as a hex string.
48+
6. Encrypts the JSON string with AES-GCM using a random IV.
49+
7. Concatenates the ephemeral public key, IV, and ciphertext
50+
and returns it as a hex string.
4851
4952
Args:
50-
envs: The environment variables to encrypt. This can be any JSON-serializable data structure.
51-
hex_public_key: The remote encryption public key in hexadecimal format.
53+
envs: The environment variables to encrypt. This can be
54+
any JSON-serializable data structure.
55+
hex_public_key: The remote encryption public key in hex.
5256
5357
Returns:
5458
A hexadecimal string that is the concatenation of:
@@ -372,7 +376,8 @@ def resize_vm(
372376

373377
if len(params) == 1:
374378
raise Exception(
375-
"at least one parameter must be specified for resize: --vcpu, --memory, --disk, or --image"
379+
"at least one parameter must be specified for resize:"
380+
" --vcpu, --memory, --disk, or --image"
376381
)
377382

378383
self.rpc_call("ResizeVm", params)
@@ -849,7 +854,7 @@ def update_vm(
849854
port_mappings = [parse_port_mapping(port) for port in ports]
850855
updates.append("port mappings")
851856
else:
852-
# ports is an empty list - shouldn't happen with mutually exclusive group
857+
# ports is empty - shouldn't happen with exclusive group
853858
port_mappings = []
854859
updates.append("port mappings (none)")
855860
upgrade_params["update_ports"] = True
@@ -870,7 +875,7 @@ def update_vm(
870875
}
871876
updates.append(f"GPUs ({len(gpu_slots)} devices)")
872877
else:
873-
# gpu_slots is an empty list ([] not None) - shouldn't happen with mutually exclusive group
878+
# gpu_slots is empty - shouldn't happen with exclusive group
874879
gpu_config = {"attach_mode": "listed", "gpus": []}
875880
updates.append("GPUs (none)")
876881
upgrade_params["gpus"] = gpu_config
@@ -1052,8 +1057,15 @@ def verify_signature(public_key: bytes, signature: bytes, app_id: str) -> Option
10521057
The compressed public key if valid, None otherwise
10531058
10541059
Examples:
1055-
>>> public_key = bytes.fromhex('e33a1832c6562067ff8f844a61e51ad051f1180b66ec2551fb0251735f3ee90a')
1056-
>>> signature = bytes.fromhex('8542c49081fbf4e03f62034f13fbf70630bdf256a53032e38465a27c36fd6bed7a5e7111652004aef37f7fd92fbfc1285212c4ae6a6154203a48f5e16cad2cef00')
1060+
>>> pk_hex = 'e33a1832c6562067ff8f844a61e51ad051f1180b66ec2551fb0251735f3ee90a'
1061+
>>> public_key = bytes.fromhex(pk_hex)
1062+
>>> sig_hex = (
1063+
... '8542c49081fbf4e03f62034f13fbf70630bdf256'
1064+
... 'a53032e38465a27c36fd6bed7a5e7111652004ae'
1065+
... 'f37f7fd92fbfc1285212c4ae6a6154203a48f5e1'
1066+
... '6cad2cef00'
1067+
... )
1068+
>>> signature = bytes.fromhex(sig_hex)
10571069
>>> app_id = '00' * 20
10581070
>>> compressed_pubkey = verify_signature(public_key, signature, app_id)
10591071
>>> print(compressed_pubkey)
@@ -1141,7 +1153,7 @@ def main():
11411153
parser.add_argument(
11421154
"--auth-password",
11431155
default=os.environ.get("DSTACK_VMM_AUTH_PASSWORD"),
1144-
help="Basic auth password (can also be set via DSTACK_VMM_AUTH_PASSWORD env var)",
1156+
help="Basic auth password (env: DSTACK_VMM_AUTH_PASSWORD)",
11451157
)
11461158

11471159
subparsers = parser.add_subparsers(dest="command", help="Commands")
@@ -1387,7 +1399,7 @@ def main():
13871399
action="append",
13881400
type=str,
13891401
required=True,
1390-
help="Port mapping in format: protocol[:address]:from:to (can be used multiple times)",
1402+
help="Port mapping: protocol[:address]:from:to (repeatable)",
13911403
)
13921404

13931405
# Update (all-in-one) command
@@ -1421,7 +1433,7 @@ def main():
14211433
"--port",
14221434
action="append",
14231435
type=str,
1424-
help="Port mapping in format: protocol[:address]:from:to (can be used multiple times)",
1436+
help="Port mapping: protocol[:address]:from:to (repeatable)",
14251437
)
14261438
port_group.add_argument(
14271439
"--no-ports",

0 commit comments

Comments
 (0)