pablovela5620 commited on
Commit
1895a6b
1 Parent(s): 3cc3ef2

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +36 -5
app.py CHANGED
@@ -1,7 +1,38 @@
1
- import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ from pathlib import Path
3
 
4
+ PIXI_PATH = Path("/home/user/.pixi/bin/pixi")
5
+ PIXI_VERSION = "0.27.1"
6
 
7
+
8
+ def check_and_install_pixi() -> None:
9
+ try:
10
+ subprocess.check_call(f"{PIXI_PATH} --version", shell=True)
11
+ except subprocess.CalledProcessError:
12
+ print("pixi not found. Installing pixi...")
13
+ # Install pixi using the provided installation script
14
+ subprocess.check_call(
15
+ f"PIXI_VERSION=v{PIXI_VERSION} curl -fsSL https://pixi.sh/install.sh | bash",
16
+ shell=True,
17
+ )
18
+ subprocess.check_call(
19
+ f"{PIXI_PATH} self-update --version {PIXI_VERSION}", shell=True
20
+ )
21
+ subprocess.check_call(f"{PIXI_PATH} --version", shell=True)
22
+
23
+
24
+ def run_command(command: str) -> None:
25
+ try:
26
+ subprocess.check_call(command, shell=True)
27
+ except subprocess.CalledProcessError as e:
28
+ print(f"run command {command}. Error: {e}")
29
+
30
+
31
+ if __name__ == "__main__":
32
+ check_and_install_pixi()
33
+ # install lsof
34
+ run_command(command=f"{PIXI_PATH} global install lsof")
35
+ # kill anything running on port 7860
36
+ run_command(command=f"{PIXI_PATH.parent}/lsof -t -i:7860 | xargs -r kill")
37
+ # run spaces app
38
+ run_command(command=f"{PIXI_PATH} run -e spaces app")