gitarsenal-cli 1.1.19 → 1.1.21

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.
@@ -9,55 +9,109 @@ import getpass
9
9
  import requests
10
10
  import secrets
11
11
  import string
12
+ import argparse
12
13
  from pathlib import Path
13
14
 
14
- # Apply the comprehensive Modal token solution first
15
+ # Parse command-line arguments
16
+ parser = argparse.ArgumentParser(description='Launch a Modal sandbox')
17
+ parser.add_argument('--proxy-url', help='URL of the proxy server')
18
+ parser.add_argument('--proxy-api-key', help='API key for the proxy server')
19
+ parser.add_argument('--gpu', default='A10G', help='GPU type to use')
20
+ parser.add_argument('--repo-url', help='Repository URL')
21
+ parser.add_argument('--volume-name', help='Volume name')
22
+ parser.add_argument('--use-api', action='store_true', help='Use API to fetch setup commands')
23
+
24
+ # Parse only known args to avoid conflicts with other arguments
25
+ args, unknown = parser.parse_known_args()
26
+
27
+ # Set proxy URL and API key in environment variables if provided
28
+ if args.proxy_url:
29
+ os.environ["MODAL_PROXY_URL"] = args.proxy_url
30
+ print(f"✅ Set MODAL_PROXY_URL from command line: {args.proxy_url}")
31
+
32
+ if args.proxy_api_key:
33
+ os.environ["MODAL_PROXY_API_KEY"] = args.proxy_api_key
34
+ print(f"✅ Set MODAL_PROXY_API_KEY from command line")
35
+
36
+ # First, try to fetch tokens from the proxy server
15
37
  try:
16
- # Import the comprehensive solution module
17
- print("🔄 Applying comprehensive Modal token solution...")
18
- import modal_token_solution
19
- print("✅ Comprehensive Modal token solution applied")
38
+ # Import the fetch_modal_tokens module
39
+ print("🔄 Fetching Modal tokens from proxy server...")
40
+ from fetch_modal_tokens import get_tokens
41
+ token_id, token_secret = get_tokens()
42
+ print(f"✅ Modal tokens fetched successfully")
43
+
44
+ # Explicitly set the environment variables again to be sure
45
+ os.environ["MODAL_TOKEN_ID"] = token_id
46
+ os.environ["MODAL_TOKEN_SECRET"] = token_secret
47
+
48
+ # Also set the old environment variable for backward compatibility
49
+ os.environ["MODAL_TOKEN"] = token_id
50
+
51
+ # Set token variables for later use
52
+ token = token_id # For backward compatibility
20
53
  except Exception as e:
21
- print(f"⚠️ Error applying comprehensive Modal token solution: {e}")
54
+ print(f"⚠️ Error fetching Modal tokens: {e}")
22
55
 
23
- # Fall back to the authentication patch
56
+ # Apply the comprehensive Modal token solution as fallback
24
57
  try:
25
- # Import the patch module
26
- print("🔄 Falling back to Modal authentication patch...")
27
- import modal_auth_patch
28
- print("✅ Modal authentication patch applied")
58
+ # Import the comprehensive solution module
59
+ print("🔄 Applying comprehensive Modal token solution...")
60
+ import modal_token_solution
61
+ print("✅ Comprehensive Modal token solution applied")
62
+
63
+ # Set token variables for later use
64
+ token = modal_token_solution.TOKEN_ID # For backward compatibility
29
65
  except Exception as e:
30
- print(f"⚠️ Error applying Modal authentication patch: {e}")
66
+ print(f"⚠️ Error applying comprehensive Modal token solution: {e}")
31
67
 
32
- # Fall back to fix_modal_token.py
68
+ # Fall back to the authentication patch
33
69
  try:
34
- # Execute the fix_modal_token.py script
35
- print("🔄 Falling back to fix_modal_token.py...")
36
- result = subprocess.run(
37
- ["python", os.path.join(os.path.dirname(__file__), "fix_modal_token.py")],
38
- capture_output=True,
39
- text=True
40
- )
70
+ # Import the patch module
71
+ print("🔄 Falling back to Modal authentication patch...")
72
+ import modal_auth_patch
73
+ print(" Modal authentication patch applied")
41
74
 
42
- # Print the output
43
- print(result.stdout)
44
-
45
- if result.returncode != 0:
46
- print(f"⚠️ Warning: fix_modal_token.py exited with code {result.returncode}")
47
- if result.stderr:
48
- print(f"Error: {result.stderr}")
75
+ # Set token variables for later use
76
+ token = modal_auth_patch.TOKEN_ID # For backward compatibility
49
77
  except Exception as e:
50
- print(f"⚠️ Error running fix_modal_token.py: {e}")
51
-
52
- # Set token variable for later use
53
- token = "ak-eNMIXRdfbvpxIXcSHKPFQW"
78
+ print(f"⚠️ Error applying Modal authentication patch: {e}")
79
+
80
+ # Fall back to fix_modal_token.py
81
+ try:
82
+ # Execute the fix_modal_token.py script
83
+ print("🔄 Falling back to fix_modal_token.py...")
84
+ result = subprocess.run(
85
+ ["python", os.path.join(os.path.dirname(__file__), "fix_modal_token.py")],
86
+ capture_output=True,
87
+ text=True
88
+ )
89
+
90
+ # Print the output
91
+ print(result.stdout)
92
+
93
+ if result.returncode != 0:
94
+ print(f"⚠️ Warning: fix_modal_token.py exited with code {result.returncode}")
95
+ if result.stderr:
96
+ print(f"Error: {result.stderr}")
97
+
98
+ # Set token variables for later use
99
+ token = "ak-sLhYqCjkvixiYcb9LAuCHp" # Default token ID
100
+ except Exception as e:
101
+ print(f"⚠️ Error running fix_modal_token.py: {e}")
102
+
103
+ # Last resort: use hardcoded tokens
104
+ token = "ak-sLhYqCjkvixiYcb9LAuCHp" # Default token ID
54
105
 
55
106
  # Print debug info
56
107
  print(f"🔍 DEBUG: Checking environment variables")
57
108
  print(f"🔍 MODAL_TOKEN_ID exists: {'Yes' if os.environ.get('MODAL_TOKEN_ID') else 'No'}")
109
+ print(f"🔍 MODAL_TOKEN_SECRET exists: {'Yes' if os.environ.get('MODAL_TOKEN_SECRET') else 'No'}")
58
110
  print(f"🔍 MODAL_TOKEN exists: {'Yes' if os.environ.get('MODAL_TOKEN') else 'No'}")
59
111
  if os.environ.get('MODAL_TOKEN_ID'):
60
112
  print(f"🔍 MODAL_TOKEN_ID length: {len(os.environ.get('MODAL_TOKEN_ID'))}")
113
+ if os.environ.get('MODAL_TOKEN_SECRET'):
114
+ print(f"🔍 MODAL_TOKEN_SECRET length: {len(os.environ.get('MODAL_TOKEN_SECRET'))}")
61
115
  if os.environ.get('MODAL_TOKEN'):
62
116
  print(f"🔍 MODAL_TOKEN length: {len(os.environ.get('MODAL_TOKEN'))}")
63
117
  print(f"✅ Modal token setup completed")
@@ -11,25 +11,36 @@ import json
11
11
  from pathlib import Path
12
12
  import time
13
13
 
14
- # Set token directly in environment
15
- TOKEN = "ak-eNMIXRdfbvpxIXcSHKPFQW"
16
- os.environ["MODAL_TOKEN_ID"] = TOKEN
17
- os.environ["MODAL_TOKEN"] = TOKEN
14
+ # Try to get tokens from the proxy server
15
+ try:
16
+ # First, try to import the fetch_modal_tokens module
17
+ from fetch_modal_tokens import get_tokens
18
+ TOKEN_ID, TOKEN_SECRET = get_tokens()
19
+ print(f"✅ Using tokens from proxy server or defaults")
20
+ except ImportError:
21
+ # If the module is not available, use hardcoded tokens
22
+ TOKEN_ID = "ak-sLhYqCjkvixiYcb9LAuCHp"
23
+ TOKEN_SECRET = "as-fPzD0Zm0dl6IFAEkhaH9pq" # Real token secret from fr8mafia profile
24
+ print(f"⚠️ Using hardcoded tokens")
25
+
26
+ # Set tokens directly in environment
27
+ os.environ["MODAL_TOKEN_ID"] = TOKEN_ID
28
+ os.environ["MODAL_TOKEN_SECRET"] = TOKEN_SECRET
18
29
 
19
30
  # Print environment variables
20
31
  print(f"Environment variables:")
21
32
  print(f"MODAL_TOKEN_ID = {os.environ.get('MODAL_TOKEN_ID')}")
22
- print(f"MODAL_TOKEN = {os.environ.get('MODAL_TOKEN')}")
33
+ print(f"MODAL_TOKEN_SECRET = {os.environ.get('MODAL_TOKEN_SECRET')}")
23
34
 
24
35
  # Create token file
25
36
  modal_dir = Path.home() / ".modal"
26
37
  modal_dir.mkdir(exist_ok=True)
27
38
  token_file = modal_dir / "token.json"
28
39
  with open(token_file, 'w') as f:
29
- # Try different formats
40
+ # Use the correct format with token_id and token_secret
30
41
  token_data = {
31
- "token_id": TOKEN,
32
- "token": TOKEN
42
+ "token_id": TOKEN_ID,
43
+ "token_secret": TOKEN_SECRET
33
44
  }
34
45
  json.dump(token_data, f)
35
46
  print(f"Created token file at {token_file}")
@@ -38,7 +49,8 @@ print(f"Token file contents: {json.dumps(token_data)}")
38
49
  # Create .modalconfig file
39
50
  modalconfig_file = Path.home() / ".modalconfig"
40
51
  with open(modalconfig_file, 'w') as f:
41
- f.write(f"token_id = {TOKEN}\n")
52
+ f.write(f"token_id = {TOKEN_ID}\n")
53
+ f.write(f"token_secret = {TOKEN_SECRET}\n")
42
54
  print(f"Created .modalconfig file at {modalconfig_file}")
43
55
 
44
56
  # Try to import Modal