gitarsenal-cli 1.1.17 → 1.1.18

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.17",
3
+ "version": "1.1.18",
4
4
  "description": "CLI tool for creating Modal sandboxes with GitHub repositories",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -296,9 +296,23 @@ def create_ssh_container():
296
296
  f.write(f'{{"token_id": "{MODAL_TOKEN}", "token": "{MODAL_TOKEN}"}}')
297
297
  logger.info(f"Created Modal token file at {token_file}")
298
298
 
299
- # Try to verify the token is working
299
+ # Set up token using multiple approaches
300
+ # 1. Create .modalconfig file as an alternative method
301
+ modalconfig_file = Path.home() / ".modalconfig"
302
+ with open(modalconfig_file, 'w') as f:
303
+ f.write(f"token_id = {token}\n")
304
+ logger.info(f"Created .modalconfig file at {modalconfig_file}")
305
+
306
+ # 2. Import modal and set token directly
300
307
  import modal
301
- # Just importing modal is enough to verify the token file is working
308
+
309
+ # 3. Try to directly configure Modal
310
+ try:
311
+ import modal.config
312
+ modal.config._auth_config.token_id = token
313
+ logger.info("Explicitly set token in Modal config")
314
+ except Exception as e:
315
+ logger.warning(f"Error setting token in Modal config: {e}")
302
316
  # No need to clean up any temporary files
303
317
 
304
318
  if result.returncode == 0:
@@ -367,10 +381,25 @@ def create_ssh_container():
367
381
  f.write(f'{{"token_id": "{MODAL_TOKEN}", "token": "{MODAL_TOKEN}"}}')
368
382
  logger.info(f"Created Modal token file at {token_file} in thread")
369
383
 
370
- # Try to verify the token is working
384
+ # Set up token using multiple approaches
385
+ # 1. Create .modalconfig file as an alternative method
386
+ modalconfig_file = Path.home() / ".modalconfig"
387
+ with open(modalconfig_file, 'w') as f:
388
+ f.write(f"token_id = {MODAL_TOKEN}\n")
389
+ logger.info(f"Created .modalconfig file at {modalconfig_file} in thread")
390
+
391
+ # 2. Import modal and set token directly
371
392
  import modal
372
- # Just importing modal is enough to verify the token file is working
373
- logger.info("Modal token verified in thread")
393
+
394
+ # 3. Try to directly configure Modal
395
+ try:
396
+ import modal.config
397
+ modal.config._auth_config.token_id = MODAL_TOKEN
398
+ logger.info("Explicitly set token in Modal config in thread")
399
+ except Exception as e:
400
+ logger.warning(f"Error setting token in Modal config in thread: {e}")
401
+
402
+ logger.info("Modal token setup completed in thread")
374
403
  except Exception as e:
375
404
  logger.warning(f"Failed to set token via CLI in thread: {e}")
376
405
 
@@ -40,12 +40,27 @@ try:
40
40
  if os.environ.get('MODAL_TOKEN'):
41
41
  print(f"🔍 MODAL_TOKEN length: {len(os.environ.get('MODAL_TOKEN'))}")
42
42
  print(f"✅ Modal token found (length: {len(token)})")
43
+
44
+ # Create a .modalconfig file as an alternative method
45
+ modalconfig_file = Path.home() / ".modalconfig"
46
+ with open(modalconfig_file, 'w') as f:
47
+ f.write(f"token_id = {token}\n")
48
+ print(f"✅ Created .modalconfig file at {modalconfig_file}")
43
49
  except Exception as e:
44
50
  print(f"⚠️ Error setting up Modal token: {e}")
45
51
 
46
52
  # Import modal after token setup
47
53
  import modal
48
54
 
55
+ # Explicitly set the token in Modal's config
56
+ try:
57
+ # Try to directly configure Modal with the token
58
+ import modal.config
59
+ modal.config._auth_config.token_id = token
60
+ print(f"✅ Explicitly set token in Modal config")
61
+ except Exception as e:
62
+ print(f"⚠️ Error setting token in Modal config: {e}")
63
+
49
64
  def handle_interactive_input(prompt, is_password=False):
50
65
  """Handle interactive input from the user with optional password masking"""
51
66
  print("\n" + "="*60)
@@ -2132,8 +2147,9 @@ def create_modal_ssh_container(gpu_type, repo_url=None, repo_name=None, setup_co
2132
2147
  if modal_token_id:
2133
2148
  print(f"✅ Modal token found (length: {len(modal_token_id)})")
2134
2149
 
2135
- # Create token file directly instead of using CLI
2150
+ # Set up Modal token using multiple approaches
2136
2151
  try:
2152
+ # 1. Create token file
2137
2153
  from pathlib import Path
2138
2154
  modal_dir = Path.home() / ".modal"
2139
2155
  modal_dir.mkdir(exist_ok=True)
@@ -2142,10 +2158,25 @@ def create_modal_ssh_container(gpu_type, repo_url=None, repo_name=None, setup_co
2142
2158
  print(f"🔄 Creating Modal token file (token length: {len(modal_token_id)})")
2143
2159
  with open(token_file, 'w') as f:
2144
2160
  f.write(f'{{"token_id": "{modal_token_id}", "token": "{modal_token_id}"}}')
2145
-
2146
2161
  print(f"✅ Modal token file created at {token_file}")
2162
+
2163
+ # 2. Create .modalconfig file
2164
+ modalconfig_file = Path.home() / ".modalconfig"
2165
+ with open(modalconfig_file, 'w') as f:
2166
+ f.write(f"token_id = {modal_token_id}\n")
2167
+ print(f"✅ Created .modalconfig file at {modalconfig_file}")
2168
+
2169
+ # 3. Try to directly configure Modal
2170
+ import modal.config
2171
+ modal.config._auth_config.token_id = modal_token_id
2172
+ print(f"✅ Explicitly set token in Modal config")
2173
+
2174
+ # 4. Set environment variables again to be sure
2175
+ os.environ["MODAL_TOKEN_ID"] = modal_token_id
2176
+ os.environ["MODAL_TOKEN"] = modal_token_id
2177
+ print(f"✅ Reset environment variables with token")
2147
2178
  except Exception as e:
2148
- print(f"⚠️ Error creating token file: {e}")
2179
+ print(f"⚠️ Error setting up Modal token: {e}")
2149
2180
  else:
2150
2181
  print("❌ No Modal token found in environment variables")
2151
2182
  # Try to get from file as a last resort