Showing
1 changed file
with
55 additions
and
1 deletions
... | @@ -77,6 +77,8 @@ | ... | @@ -77,6 +77,8 @@ |
77 | "DIFF_MODEL='1--gcVVix92_Fp75A-mWH0pJS0ahlni5m'\n", | 77 | "DIFF_MODEL='1--gcVVix92_Fp75A-mWH0pJS0ahlni5m'\n", |
78 | "\n", | 78 | "\n", |
79 | "!pip install gdown \\\n", | 79 | "!pip install gdown \\\n", |
80 | + " && mkdir -p weight/added \\\n", | ||
81 | + " && mkdir -p weight/diff \\\n", | ||
80 | " && gdown \"https://drive.google.com/uc?id=$ADD_MODEL\" -O weight/added/pytorch_model.bin \\\n", | 82 | " && gdown \"https://drive.google.com/uc?id=$ADD_MODEL\" -O weight/added/pytorch_model.bin \\\n", |
81 | " && gdown \"https://drive.google.com/uc?id=$DIFF_MODEL\" -O weight/diff/pytorch_model.bin" | 83 | " && gdown \"https://drive.google.com/uc?id=$DIFF_MODEL\" -O weight/diff/pytorch_model.bin" |
82 | ], | 84 | ], |
... | @@ -185,8 +187,60 @@ | ... | @@ -185,8 +187,60 @@ |
185 | "with open('ngrok.conf', 'w') as f:\n", | 187 | "with open('ngrok.conf', 'w') as f:\n", |
186 | " f.write(config)" | 188 | " f.write(config)" |
187 | ], | 189 | ], |
190 | + "execution_count": 1, | ||
191 | + "outputs": [ | ||
192 | + { | ||
193 | + "output_type": "error", | ||
194 | + "ename": "NameError", | ||
195 | + "evalue": "name 'authtoken' is not defined", | ||
196 | + "traceback": [ | ||
197 | + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", | ||
198 | + "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", | ||
199 | + "\u001b[1;32m<ipython-input-1-7305b3f78ded>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[0mconfig\u001b[0m \u001b[1;33m=\u001b[0m\u001b[0;31m\\\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2\u001b[0m f\"\"\"\n\u001b[1;32m----> 3\u001b[1;33m \u001b[0mauthtoken\u001b[0m\u001b[1;33m:\u001b[0m \u001b[1;33m{\u001b[0m\u001b[0mauthtoken\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 4\u001b[0m \u001b[0mregion\u001b[0m\u001b[1;33m:\u001b[0m \u001b[1;33m{\u001b[0m\u001b[0mregion\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[0mconsole_ui\u001b[0m\u001b[1;33m:\u001b[0m \u001b[1;32mFalse\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | ||
200 | + "\u001b[1;31mNameError\u001b[0m: name 'authtoken' is not defined" | ||
201 | + ] | ||
202 | + } | ||
203 | + ] | ||
204 | + }, | ||
205 | + { | ||
206 | + "cell_type": "code", | ||
188 | "execution_count": null, | 207 | "execution_count": null, |
189 | - "outputs": [] | 208 | + "metadata": {}, |
209 | + "outputs": [], | ||
210 | + "source": [ | ||
211 | + "from subprocess import Popen, PIPE\n", | ||
212 | + "import shlex\n", | ||
213 | + "import json\n", | ||
214 | + "import time\n", | ||
215 | + "\n", | ||
216 | + "\n", | ||
217 | + "def run_with_pipe(command):\n", | ||
218 | + " commands = list(map(shlex.split,command.split(\"|\")))\n", | ||
219 | + " ps = Popen(commands[0], stdout=PIPE, stderr=PIPE)\n", | ||
220 | + " for command in commands[1:]:\n", | ||
221 | + " ps = Popen(command, stdin=ps.stdout, stdout=PIPE, stderr=PIPE)\n", | ||
222 | + " return ps.stdout.readlines()\n", | ||
223 | + "\n", | ||
224 | + "\n", | ||
225 | + "def get_tunnel_adresses():\n", | ||
226 | + " info = run_with_pipe(\"curl http://localhost:4040/api/tunnels\")\n", | ||
227 | + " assert info\n", | ||
228 | + "\n", | ||
229 | + " info = json.loads(info[0])\n", | ||
230 | + " for tunnel in info['tunnels']:\n", | ||
231 | + " url = tunnel['public_url']\n", | ||
232 | + " port = url.split(':')[-1]\n", | ||
233 | + " local_port = tunnel['config']['addr'].split(':')[-1]\n", | ||
234 | + " print(f'{url} -> {local_port} [{tunnel[\"name\"]}]')\n", | ||
235 | + " if tunnel['name'] == 'input':\n", | ||
236 | + " in_addr = url\n", | ||
237 | + " elif tunnel['name'] == 'output':\n", | ||
238 | + " out_addr = url\n", | ||
239 | + " else:\n", | ||
240 | + " print(f'unknown tunnel: {tunnel[\"name\"]}')\n", | ||
241 | + "\n", | ||
242 | + " return in_addr, out_addr" | ||
243 | + ] | ||
190 | }, | 244 | }, |
191 | { | 245 | { |
192 | "cell_type": "code", | 246 | "cell_type": "code", | ... | ... |
-
Please register or login to post a comment