Spaces:
Configuration error
Configuration error
Commit
Β·
5a185d0
1
Parent(s):
5bcb90a
refactor π»
Browse files- backend/src/__init__.py +1 -0
- backend/src/resources/module.py +23 -22
backend/src/__init__.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import resource
|
| 2 |
import src.demo
|
| 3 |
import src.index
|
|
|
|
| 1 |
+
import examples
|
| 2 |
import resource
|
| 3 |
import src.demo
|
| 4 |
import src.index
|
backend/src/resources/module.py
CHANGED
|
@@ -36,12 +36,12 @@ def tabularGradio(funcs, names, name="Tabular Temp Name", **kwargs):
|
|
| 36 |
assert len(funcs) == len(names), f"{bcolor.BOLD}{bcolor.FAIL}π something went wrong!!! The function you appended dose not match the lenght of the names{bcolor.ENDC}"
|
| 37 |
# assert all([fn == "wrap" for fn in funcs]), f"{bcolor().BOLD}{bcolor().FAIL}not all of these are decorated with the right decorator{bcolor().ENDC}"
|
| 38 |
port= kwargs["port"] if "port" in kwargs else DOCKER_PORT.determinePort()
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
|
| 46 |
gr.TabbedInterface(funcs, names).launch(server_port=port,
|
| 47 |
server_name=f"{DOCKER_LOCAL_HOST}",
|
|
@@ -63,12 +63,12 @@ def tabularGradio(funcs, names, name="Tabular Temp Name", **kwargs):
|
|
| 63 |
ssl_certfile=kwargs['ssl_certfile'] if "ssl_certfile" in kwargs else None,
|
| 64 |
ssl_keyfile_password=kwargs['ssl_keyfile_password'] if "ssl_keyfile_password" in kwargs else None,
|
| 65 |
quiet=kwargs['quiet'] if "quiet" in kwargs else False)
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
|
| 73 |
return
|
| 74 |
|
|
@@ -181,12 +181,12 @@ def GradioModule(cls):
|
|
| 181 |
|
| 182 |
def run(self, **kwargs):
|
| 183 |
port= kwargs["port"] if "port" in kwargs else DOCKER_PORT.determinePort()
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
|
| 191 |
self.compile(live=kwargs[ 'live' ] if "live" in kwargs else False,
|
| 192 |
allow_flagging=kwargs[ 'allow_flagging' ] if "allow_flagging" in kwargs else None,
|
|
@@ -219,10 +219,11 @@ def GradioModule(cls):
|
|
| 219 |
ssl_certfile=kwargs['ssl_certfile'] if "ssl_certfile" in kwargs else None,
|
| 220 |
ssl_keyfile_password=kwargs['ssl_keyfile_password'] if "ssl_keyfile_password" in kwargs else None,
|
| 221 |
quiet=kwargs['quiet'] if "quiet" in kwargs else False)
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
|
|
|
| 226 |
return
|
| 227 |
|
| 228 |
return Decorator
|
|
|
|
| 36 |
assert len(funcs) == len(names), f"{bcolor.BOLD}{bcolor.FAIL}π something went wrong!!! The function you appended dose not match the lenght of the names{bcolor.ENDC}"
|
| 37 |
# assert all([fn == "wrap" for fn in funcs]), f"{bcolor().BOLD}{bcolor().FAIL}not all of these are decorated with the right decorator{bcolor().ENDC}"
|
| 38 |
port= kwargs["port"] if "port" in kwargs else DOCKER_PORT.determinePort()
|
| 39 |
+
if 'listen' in kwargs:
|
| 40 |
+
try:
|
| 41 |
+
requests.post(f"http://{DOCKER_LOCAL_HOST}:{ kwargs[ 'listen' ] }/api/append/port", json={"port" : port, "host" : f'http://localhost:{port}', "file" : 'Not Applicable', "name" : name, "kwargs" : kwargs})
|
| 42 |
+
except Exception as e:
|
| 43 |
+
print(f"**{bcolor.BOLD}{bcolor.FAIL}CONNECTION ERROR{bcolor.ENDC}** πThe listening api is either not up or you choose the wrong port.π \n {e}")
|
| 44 |
+
return
|
| 45 |
|
| 46 |
gr.TabbedInterface(funcs, names).launch(server_port=port,
|
| 47 |
server_name=f"{DOCKER_LOCAL_HOST}",
|
|
|
|
| 63 |
ssl_certfile=kwargs['ssl_certfile'] if "ssl_certfile" in kwargs else None,
|
| 64 |
ssl_keyfile_password=kwargs['ssl_keyfile_password'] if "ssl_keyfile_password" in kwargs else None,
|
| 65 |
quiet=kwargs['quiet'] if "quiet" in kwargs else False)
|
| 66 |
+
if 'listen' in kwargs:
|
| 67 |
+
try:
|
| 68 |
+
requests.post(f"http://{DOCKER_LOCAL_HOST}:{ kwargs[ 'listen' ] }/api/remove/port", json={"port" : port, "host" : f'http://localhost:{port}', "file" : 'Not Applicable', "name" : name, "kwargs" : kwargs})
|
| 69 |
+
except Exception as e:
|
| 70 |
+
|
| 71 |
+
print(f"**{bcolor.BOLD}{bcolor.FAIL}CONNECTION ERROR{bcolor.ENDC}** πThe api either lost connection or was turned off...π \n {e}")
|
| 72 |
|
| 73 |
return
|
| 74 |
|
|
|
|
| 181 |
|
| 182 |
def run(self, **kwargs):
|
| 183 |
port= kwargs["port"] if "port" in kwargs else DOCKER_PORT.determinePort()
|
| 184 |
+
if 'listen' in kwargs:
|
| 185 |
+
try:
|
| 186 |
+
requests.post(f"http://{DOCKER_LOCAL_HOST}:{ kwargs[ 'listen' ] }/api/append/port", json={"port" : port, "host" : f'http://localhost:{port}', "file" : getfile(self.cls.__class__), "name" : self.cls.__class__.__name__, "kwargs" : kwargs})
|
| 187 |
+
except Exception:
|
| 188 |
+
print(f"**{bcolor.BOLD}{bcolor.FAIL}CONNECTION ERROR{bcolor.ENDC}** πThe listening api is either not up or you choose the wrong port.π")
|
| 189 |
+
return
|
| 190 |
|
| 191 |
self.compile(live=kwargs[ 'live' ] if "live" in kwargs else False,
|
| 192 |
allow_flagging=kwargs[ 'allow_flagging' ] if "allow_flagging" in kwargs else None,
|
|
|
|
| 219 |
ssl_certfile=kwargs['ssl_certfile'] if "ssl_certfile" in kwargs else None,
|
| 220 |
ssl_keyfile_password=kwargs['ssl_keyfile_password'] if "ssl_keyfile_password" in kwargs else None,
|
| 221 |
quiet=kwargs['quiet'] if "quiet" in kwargs else False)
|
| 222 |
+
if 'listen' in kwargs:
|
| 223 |
+
try:
|
| 224 |
+
requests.post(f"http://{DOCKER_LOCAL_HOST}:{ kwargs[ 'listen' ] }/api/remove/port", json={"port" : port, "host" : f'http://localhost:{port}', "file" : getfile(self.cls.__class__), "name" : self.cls.__class__.__name__, "kwargs" : kwargs})
|
| 225 |
+
except Exception:
|
| 226 |
+
print(f"**{bcolor.BOLD}{bcolor.FAIL}CONNECTION ERROR{bcolor.ENDC}** πThe api either lost connection or was turned off...π")
|
| 227 |
return
|
| 228 |
|
| 229 |
return Decorator
|