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.
- package/package.json +1 -1
- package/python/MODAL_TOKEN_README.md +27 -14
- package/python/credentials_manager.py +0 -0
- package/python/fetch_modal_tokens.py +183 -0
- package/python/fix_modal_token.py +17 -7
- package/python/fix_modal_token_advanced.py +71 -72
- package/python/gitarsenal_proxy_client.py +0 -0
- package/python/modal_auth_patch.py +57 -30
- package/python/modal_proxy_service.py +108 -33
- package/python/modal_token_solution.py +84 -76
- package/python/test_modalSandboxScript.py +85 -31
- package/python/test_modal_auth.py +21 -9
@@ -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
|
-
#
|
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
|
17
|
-
print("🔄
|
18
|
-
import
|
19
|
-
|
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
|
54
|
+
print(f"⚠️ Error fetching Modal tokens: {e}")
|
22
55
|
|
23
|
-
#
|
56
|
+
# Apply the comprehensive Modal token solution as fallback
|
24
57
|
try:
|
25
|
-
# Import the
|
26
|
-
print("🔄
|
27
|
-
import
|
28
|
-
print("✅ Modal
|
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
|
66
|
+
print(f"⚠️ Error applying comprehensive Modal token solution: {e}")
|
31
67
|
|
32
|
-
# Fall back to
|
68
|
+
# Fall back to the authentication patch
|
33
69
|
try:
|
34
|
-
#
|
35
|
-
print("🔄 Falling back to
|
36
|
-
|
37
|
-
|
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
|
-
#
|
43
|
-
|
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
|
51
|
-
|
52
|
-
#
|
53
|
-
|
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
|
-
#
|
15
|
-
|
16
|
-
|
17
|
-
|
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"
|
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
|
-
#
|
40
|
+
# Use the correct format with token_id and token_secret
|
30
41
|
token_data = {
|
31
|
-
"token_id":
|
32
|
-
"
|
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 = {
|
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
|