gitarsenal-cli 1.1.14 → 1.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitarsenal-cli",
3
- "version": "1.1.14",
3
+ "version": "1.1.15",
4
4
  "description": "CLI tool for creating Modal sandboxes with GitHub repositories",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -118,17 +118,45 @@ def setup_modal_auth():
118
118
  os.environ["MODAL_TOKEN_ID"] = token
119
119
  os.environ["MODAL_TOKEN"] = token
120
120
 
121
- # Try to set the token using Modal CLI
121
+ # Try to set the token using Modal CLI by writing to a file
122
122
  try:
123
+ # Create a temporary token file
124
+ import tempfile
125
+ with tempfile.NamedTemporaryFile(mode='w', delete=False) as temp_file:
126
+ temp_file.write(token)
127
+ temp_file_path = temp_file.name
128
+
129
+ # Use the file with modal token set
123
130
  import subprocess
124
131
  result = subprocess.run(
125
- ["modal", "token", "set", token],
132
+ ["modal", "token", "set", "--from-file", temp_file_path],
126
133
  capture_output=True, text=True, check=False
127
134
  )
135
+
136
+ # Clean up the temporary file
137
+ import os
138
+ try:
139
+ os.unlink(temp_file_path)
140
+ except:
141
+ pass
142
+
128
143
  if result.returncode == 0:
129
144
  logger.info("Modal token set via CLI command")
130
145
  else:
131
146
  logger.warning(f"CLI token set returned: {result.stderr}")
147
+
148
+ # As a fallback, also create the token file in the expected location
149
+ try:
150
+ from pathlib import Path
151
+ modal_dir = Path.home() / ".modal"
152
+ modal_dir.mkdir(exist_ok=True)
153
+ token_file = modal_dir / "token.json"
154
+ with open(token_file, 'w') as f:
155
+ f.write(f'{{"token_id": "{token}", "token": "{token}"}}')
156
+ logger.info(f"Created Modal token file at {token_file}")
157
+ except Exception as file_err:
158
+ logger.warning(f"Failed to create Modal token file: {file_err}")
159
+
132
160
  except Exception as cli_err:
133
161
  logger.warning(f"Failed to set token via CLI: {cli_err}")
134
162
 
@@ -251,15 +279,41 @@ def create_ssh_container():
251
279
 
252
280
  # Try to set token via CLI as well
253
281
  try:
282
+ # Create a temporary token file
283
+ import tempfile
284
+ with tempfile.NamedTemporaryFile(mode='w', delete=False) as temp_file:
285
+ temp_file.write(MODAL_TOKEN)
286
+ temp_file_path = temp_file.name
287
+
288
+ # Use the file with modal token set
254
289
  import subprocess
255
290
  result = subprocess.run(
256
- ["modal", "token", "set", MODAL_TOKEN],
291
+ ["modal", "token", "set", "--from-file", temp_file_path],
257
292
  capture_output=True, text=True
258
293
  )
294
+
295
+ # Clean up the temporary file
296
+ try:
297
+ os.unlink(temp_file_path)
298
+ except:
299
+ pass
300
+
259
301
  if result.returncode == 0:
260
302
  logger.info("Successfully set token via Modal CLI")
261
303
  else:
262
304
  logger.warning(f"Modal CLI token set returned: {result.stderr}")
305
+
306
+ # As a fallback, also create the token file in the expected location
307
+ try:
308
+ from pathlib import Path
309
+ modal_dir = Path.home() / ".modal"
310
+ modal_dir.mkdir(exist_ok=True)
311
+ token_file = modal_dir / "token.json"
312
+ with open(token_file, 'w') as f:
313
+ f.write(f'{{"token_id": "{MODAL_TOKEN}", "token": "{MODAL_TOKEN}"}}')
314
+ logger.info(f"Created Modal token file at {token_file}")
315
+ except Exception as file_err:
316
+ logger.warning(f"Failed to create Modal token file: {file_err}")
263
317
  except Exception as e:
264
318
  logger.warning(f"Failed to set token via CLI: {e}")
265
319
 
@@ -302,12 +356,38 @@ def create_ssh_container():
302
356
 
303
357
  # Try to set token via CLI again in this thread
304
358
  try:
359
+ # Create a temporary token file
360
+ import tempfile
361
+ with tempfile.NamedTemporaryFile(mode='w', delete=False) as temp_file:
362
+ temp_file.write(MODAL_TOKEN)
363
+ temp_file_path = temp_file.name
364
+
365
+ # Use the file with modal token set
305
366
  import subprocess
306
367
  subprocess.run(
307
- ["modal", "token", "set", MODAL_TOKEN],
368
+ ["modal", "token", "set", "--from-file", temp_file_path],
308
369
  capture_output=True, text=True, check=False
309
370
  )
371
+
372
+ # Clean up the temporary file
373
+ try:
374
+ os.unlink(temp_file_path)
375
+ except:
376
+ pass
377
+
310
378
  logger.info("Set Modal token via CLI in thread")
379
+
380
+ # Also create the token file in the expected location
381
+ try:
382
+ from pathlib import Path
383
+ modal_dir = Path.home() / ".modal"
384
+ modal_dir.mkdir(exist_ok=True)
385
+ token_file = modal_dir / "token.json"
386
+ with open(token_file, 'w') as f:
387
+ f.write(f'{{"token_id": "{MODAL_TOKEN}", "token": "{MODAL_TOKEN}"}}')
388
+ logger.info(f"Created Modal token file at {token_file} in thread")
389
+ except Exception as file_err:
390
+ logger.warning(f"Failed to create Modal token file in thread: {file_err}")
311
391
  except Exception as e:
312
392
  logger.warning(f"Failed to set token via CLI in thread: {e}")
313
393
 
@@ -41,6 +41,18 @@ def setup_modal_token():
41
41
  os.environ["MODAL_TOKEN_ID"] = BUILT_IN_MODAL_TOKEN
42
42
  os.environ["MODAL_TOKEN"] = BUILT_IN_MODAL_TOKEN
43
43
  logger.info("Built-in Modal token set in environment")
44
+
45
+ # Also create the token file in the expected location
46
+ try:
47
+ modal_dir = Path.home() / ".modal"
48
+ modal_dir.mkdir(exist_ok=True)
49
+ token_file = modal_dir / "token.json"
50
+ with open(token_file, 'w') as f:
51
+ f.write(f'{{"token_id": "{BUILT_IN_MODAL_TOKEN}", "token": "{BUILT_IN_MODAL_TOKEN}"}}')
52
+ logger.info(f"Created Modal token file at {token_file}")
53
+ except Exception as e:
54
+ logger.warning(f"Failed to create Modal token file: {e}")
55
+
44
56
  return True
45
57
 
46
58
  def get_token_from_gitarsenal():
@@ -517,7 +517,7 @@ def create_modal_sandbox(gpu_type, repo_url=None, repo_name=None, setup_commands
517
517
  try:
518
518
  import subprocess
519
519
  token_result = subprocess.run(
520
- ["modal", "token", "set", modal_token],
520
+ ["modal", "token", "set", "--from-env"],
521
521
  capture_output=True, text=True
522
522
  )
523
523
  if token_result.returncode == 0:
@@ -2113,7 +2113,7 @@ def create_modal_ssh_container(gpu_type, repo_url=None, repo_name=None, setup_co
2113
2113
  import subprocess
2114
2114
  print(f"🔄 Setting token via Modal CLI (token length: {len(modal_token_id)})")
2115
2115
  result = subprocess.run(
2116
- ["modal", "token", "set", modal_token_id],
2116
+ ["modal", "token", "set", "--from-env"],
2117
2117
  capture_output=True, text=True
2118
2118
  )
2119
2119
  if result.returncode == 0: