Julian Bilcke commited on
Commit ·
617534e
1
Parent(s): 7c5128a
hacking our way in
Browse files
wgp.py
CHANGED
|
@@ -1,6 +1,16 @@
|
|
| 1 |
import os
|
| 2 |
import time
|
| 3 |
import sys
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
import threading
|
| 5 |
import argparse
|
| 6 |
from mmgp import offload, safetensors2, profile_type
|
|
|
|
| 1 |
import os
|
| 2 |
import time
|
| 3 |
import sys
|
| 4 |
+
import shlex
|
| 5 |
+
|
| 6 |
+
# Currently there is no HF space metadata param to pass CLI params through the README.md,
|
| 7 |
+
# to circumvent this we monkey patch to inject parameters from environment variable.
|
| 8 |
+
if 'APP_PARAMETERS' in os.environ:
|
| 9 |
+
# Parse the environment variable using shlex to handle quoted arguments properly
|
| 10 |
+
env_params = shlex.split(os.environ['APP_PARAMETERS'])
|
| 11 |
+
# Insert the parameters after the script name (sys.argv[0])
|
| 12 |
+
sys.argv = [sys.argv[0]] + env_params + sys.argv[1:]
|
| 13 |
+
|
| 14 |
import threading
|
| 15 |
import argparse
|
| 16 |
from mmgp import offload, safetensors2, profile_type
|