Skip to content

Commit adb997f

Browse files
Merge pull request #74 from Caltech-IPAC/FIREFLY-1705-confirm-access
FIREFLY-1705: Add a static method to determine firefly access & better error handling
2 parents 0164323 + 2b5dcb8 commit adb997f

File tree

4 files changed

+335
-10
lines changed

4 files changed

+335
-10
lines changed

examples/test-access.ipynb

Lines changed: 289 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,289 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "b89ca528-303e-45a8-abe9-7eb93b0b6825",
6+
"metadata": {},
7+
"source": [
8+
"# Test accessing different Firefly servers"
9+
]
10+
},
11+
{
12+
"cell_type": "code",
13+
"execution_count": 1,
14+
"id": "befc8619",
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"from firefly_client import FireflyClient\n",
19+
"import os"
20+
]
21+
},
22+
{
23+
"cell_type": "code",
24+
"execution_count": 2,
25+
"id": "cf4a4e98",
26+
"metadata": {},
27+
"outputs": [],
28+
"source": [
29+
"# Uncomment for debugging outputs\n",
30+
"# FireflyClient._debug= True"
31+
]
32+
},
33+
{
34+
"cell_type": "code",
35+
"execution_count": 3,
36+
"id": "38803c9f",
37+
"metadata": {},
38+
"outputs": [],
39+
"source": [
40+
"using_lab = False"
41+
]
42+
},
43+
{
44+
"cell_type": "markdown",
45+
"id": "6c665c34",
46+
"metadata": {},
47+
"source": [
48+
"## Firefly server URL setup"
49+
]
50+
},
51+
{
52+
"cell_type": "code",
53+
"execution_count": null,
54+
"id": "a4755749",
55+
"metadata": {},
56+
"outputs": [],
57+
"source": [
58+
"# Following only matters if using_lab=False. \n",
59+
"TEST_URL = {\n",
60+
" 'no-auth': 'https://irsa.ipac.caltech.edu/irsaviewer', # IRSAViewer\n",
61+
" 'invalid': 'https://irsa.ipac.caltech.edu/irsaviewerxx', # IRSAViewer with typo\n",
62+
" 'auth': 'https://data-int.lsst.cloud/portal/app/' # LSST Data Int Portal\n",
63+
"}\n",
64+
"\n",
65+
"url = TEST_URL['auth']"
66+
]
67+
},
68+
{
69+
"cell_type": "markdown",
70+
"id": "7bc7498e",
71+
"metadata": {},
72+
"source": [
73+
"> ***IMPORTANT: If `using_lab=True`, one of the above test urls must be set in environment before starting the JupyterLab.***\n",
74+
"\n",
75+
"This will work out of the box on a science platform like RSP notebook aspect, where both url (and token if needed) are set in the environment."
76+
]
77+
},
78+
{
79+
"cell_type": "code",
80+
"execution_count": null,
81+
"id": "d07c1bf2",
82+
"metadata": {},
83+
"outputs": [],
84+
"source": [
85+
"if using_lab: # since `url` is ignored in lab environment\n",
86+
" # url comes from jupyter-firefly-extensions (set as 'fireflyURLLab'), \n",
87+
" # which picks it from (in descending order of precedence):\n",
88+
" # - environment variable 'FIREFLY_URL' \n",
89+
" # - ~/.jupyter/jupyter_notebook_config.json\n",
90+
" # - ~/.jupyter/jupyter_notebook_config.py\n",
91+
" url = os.environ['fireflyURLLab']"
92+
]
93+
},
94+
{
95+
"cell_type": "markdown",
96+
"id": "b78e3342",
97+
"metadata": {},
98+
"source": [
99+
"## No token"
100+
]
101+
},
102+
{
103+
"cell_type": "code",
104+
"execution_count": 6,
105+
"id": "541d96b2",
106+
"metadata": {},
107+
"outputs": [
108+
{
109+
"data": {
110+
"text/plain": [
111+
"{'success': False, 'response': <Response [302]>}"
112+
]
113+
},
114+
"execution_count": 6,
115+
"metadata": {},
116+
"output_type": "execute_result"
117+
}
118+
],
119+
"source": [
120+
"FireflyClient.confirm_access(url)"
121+
]
122+
},
123+
{
124+
"cell_type": "code",
125+
"execution_count": 7,
126+
"id": "0f1916a8",
127+
"metadata": {},
128+
"outputs": [
129+
{
130+
"ename": "ValueError",
131+
"evalue": "Connection failed to URL https://data-int.lsst.cloud/portal/app/ with status: 302\nYou may want to check the URL with your web browser.\n\nCheck if the Firefly URL is correct, which is passed as a parameter.\n\nIf an authorization token is required to access the above URL, the `token` parameter must be passed.",
132+
"output_type": "error",
133+
"traceback": [
134+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
135+
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
136+
"Cell \u001b[0;32mIn[7], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m fc \u001b[38;5;241m=\u001b[39m FireflyClient\u001b[38;5;241m.\u001b[39mmake_lab_client() \u001b[38;5;28;01mif\u001b[39;00m using_lab \u001b[38;5;28;01melse\u001b[39;00m \u001b[43mFireflyClient\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmake_client\u001b[49m\u001b[43m(\u001b[49m\u001b[43murl\u001b[49m\u001b[43m)\u001b[49m\n",
137+
"File \u001b[0;32m~/dev/cm/firefly_client/firefly_client/firefly_client.py:216\u001b[0m, in \u001b[0;36mFireflyClient.make_client\u001b[0;34m(cls, url, html_file, launch_browser, channel_override, verbose, token, viewer_override)\u001b[0m\n\u001b[1;32m 168\u001b[0m \u001b[38;5;129m@classmethod\u001b[39m\n\u001b[1;32m 169\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mmake_client\u001b[39m(\u001b[38;5;28mcls\u001b[39m, url\u001b[38;5;241m=\u001b[39m_default_url, html_file\u001b[38;5;241m=\u001b[39m_def_html_file, launch_browser\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m,\n\u001b[1;32m 170\u001b[0m channel_override\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m, verbose\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m, token\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m, viewer_override\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m):\n\u001b[1;32m 171\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 172\u001b[0m \u001b[38;5;124;03m Factory method to create a Firefly client in a plain Python, IPython, or\u001b[39;00m\n\u001b[1;32m 173\u001b[0m \u001b[38;5;124;03m notebook session, and attempt to open a display. If a display cannot be\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 214\u001b[0m \u001b[38;5;124;03m A FireflyClient that works in the lab environment\u001b[39;00m\n\u001b[1;32m 215\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 216\u001b[0m fc \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mcls\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43murl\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mEnv\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mresolve_client_channel\u001b[49m\u001b[43m(\u001b[49m\u001b[43mchannel_override\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mhtml_file\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtoken\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mviewer_override\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 217\u001b[0m verbose \u001b[38;5;129;01mand\u001b[39;00m Env\u001b[38;5;241m.\u001b[39mshow_start_browser_tab_msg(fc\u001b[38;5;241m.\u001b[39mget_firefly_url())\n\u001b[1;32m 218\u001b[0m launch_browser \u001b[38;5;129;01mand\u001b[39;00m fc\u001b[38;5;241m.\u001b[39mlaunch_browser()\n",
138+
"File \u001b[0;32m~/dev/cm/firefly_client/firefly_client/firefly_client.py:261\u001b[0m, in \u001b[0;36mFireflyClient.__init__\u001b[0;34m(self, url, channel, html_file, token, viewer_override)\u001b[0m\n\u001b[1;32m 253\u001b[0m url_err_msg \u001b[38;5;241m=\u001b[39m Env\u001b[38;5;241m.\u001b[39mfailed_net_message(url, access[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mresponse\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39mstatus_code)\n\u001b[1;32m 254\u001b[0m token_err_msg \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 255\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mCheck if the passed `token` is valid and has the necessary \u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m 256\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mauthorization to access the above URL.\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 259\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mthe `token` parameter must be passed.\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m 260\u001b[0m )\n\u001b[0;32m--> 261\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00murl_err_msg\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00mtoken_err_msg\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 262\u001b[0m debug(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mnew instance: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00murl\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n",
139+
"\u001b[0;31mValueError\u001b[0m: Connection failed to URL https://data-int.lsst.cloud/portal/app/ with status: 302\nYou may want to check the URL with your web browser.\n\nCheck if the Firefly URL is correct, which is passed as a parameter.\n\nIf an authorization token is required to access the above URL, the `token` parameter must be passed."
140+
]
141+
}
142+
],
143+
"source": [
144+
"fc = FireflyClient.make_lab_client() if using_lab else FireflyClient.make_client(url)"
145+
]
146+
},
147+
{
148+
"cell_type": "markdown",
149+
"id": "e38321cb",
150+
"metadata": {},
151+
"source": [
152+
"## Invalid token"
153+
]
154+
},
155+
{
156+
"cell_type": "code",
157+
"execution_count": 8,
158+
"id": "aaa5ff12",
159+
"metadata": {},
160+
"outputs": [],
161+
"source": [
162+
"token = 'invalid_lsst_token'"
163+
]
164+
},
165+
{
166+
"cell_type": "code",
167+
"execution_count": 9,
168+
"id": "4483f122",
169+
"metadata": {},
170+
"outputs": [
171+
{
172+
"data": {
173+
"text/plain": [
174+
"{'success': False, 'response': <Response [302]>}"
175+
]
176+
},
177+
"execution_count": 9,
178+
"metadata": {},
179+
"output_type": "execute_result"
180+
}
181+
],
182+
"source": [
183+
"FireflyClient.confirm_access(url, token)"
184+
]
185+
},
186+
{
187+
"cell_type": "code",
188+
"execution_count": 10,
189+
"id": "1f42031c",
190+
"metadata": {},
191+
"outputs": [
192+
{
193+
"ename": "ValueError",
194+
"evalue": "Connection failed to URL https://data-int.lsst.cloud/portal/app/ with status: 302\nYou may want to check the URL with your web browser.\n\nCheck if the Firefly URL is correct, which is passed as a parameter.\n\nCheck if the passed `token` is valid and has the necessary authorization to access the above URL.",
195+
"output_type": "error",
196+
"traceback": [
197+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
198+
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
199+
"Cell \u001b[0;32mIn[10], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m fc \u001b[38;5;241m=\u001b[39m FireflyClient\u001b[38;5;241m.\u001b[39mmake_lab_client(token\u001b[38;5;241m=\u001b[39mtoken) \u001b[38;5;28;01mif\u001b[39;00m using_lab \u001b[38;5;28;01melse\u001b[39;00m \u001b[43mFireflyClient\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmake_client\u001b[49m\u001b[43m(\u001b[49m\u001b[43murl\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtoken\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtoken\u001b[49m\u001b[43m)\u001b[49m\n",
200+
"File \u001b[0;32m~/dev/cm/firefly_client/firefly_client/firefly_client.py:216\u001b[0m, in \u001b[0;36mFireflyClient.make_client\u001b[0;34m(cls, url, html_file, launch_browser, channel_override, verbose, token, viewer_override)\u001b[0m\n\u001b[1;32m 168\u001b[0m \u001b[38;5;129m@classmethod\u001b[39m\n\u001b[1;32m 169\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mmake_client\u001b[39m(\u001b[38;5;28mcls\u001b[39m, url\u001b[38;5;241m=\u001b[39m_default_url, html_file\u001b[38;5;241m=\u001b[39m_def_html_file, launch_browser\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m,\n\u001b[1;32m 170\u001b[0m channel_override\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m, verbose\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m, token\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m, viewer_override\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m):\n\u001b[1;32m 171\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 172\u001b[0m \u001b[38;5;124;03m Factory method to create a Firefly client in a plain Python, IPython, or\u001b[39;00m\n\u001b[1;32m 173\u001b[0m \u001b[38;5;124;03m notebook session, and attempt to open a display. If a display cannot be\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 214\u001b[0m \u001b[38;5;124;03m A FireflyClient that works in the lab environment\u001b[39;00m\n\u001b[1;32m 215\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 216\u001b[0m fc \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mcls\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43murl\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mEnv\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mresolve_client_channel\u001b[49m\u001b[43m(\u001b[49m\u001b[43mchannel_override\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mhtml_file\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtoken\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mviewer_override\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 217\u001b[0m verbose \u001b[38;5;129;01mand\u001b[39;00m Env\u001b[38;5;241m.\u001b[39mshow_start_browser_tab_msg(fc\u001b[38;5;241m.\u001b[39mget_firefly_url())\n\u001b[1;32m 218\u001b[0m launch_browser \u001b[38;5;129;01mand\u001b[39;00m fc\u001b[38;5;241m.\u001b[39mlaunch_browser()\n",
201+
"File \u001b[0;32m~/dev/cm/firefly_client/firefly_client/firefly_client.py:261\u001b[0m, in \u001b[0;36mFireflyClient.__init__\u001b[0;34m(self, url, channel, html_file, token, viewer_override)\u001b[0m\n\u001b[1;32m 253\u001b[0m url_err_msg \u001b[38;5;241m=\u001b[39m Env\u001b[38;5;241m.\u001b[39mfailed_net_message(url, access[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mresponse\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39mstatus_code)\n\u001b[1;32m 254\u001b[0m token_err_msg \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 255\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mCheck if the passed `token` is valid and has the necessary \u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m 256\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mauthorization to access the above URL.\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 259\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mthe `token` parameter must be passed.\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m 260\u001b[0m )\n\u001b[0;32m--> 261\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00murl_err_msg\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00mtoken_err_msg\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 262\u001b[0m debug(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mnew instance: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00murl\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n",
202+
"\u001b[0;31mValueError\u001b[0m: Connection failed to URL https://data-int.lsst.cloud/portal/app/ with status: 302\nYou may want to check the URL with your web browser.\n\nCheck if the Firefly URL is correct, which is passed as a parameter.\n\nCheck if the passed `token` is valid and has the necessary authorization to access the above URL."
203+
]
204+
}
205+
],
206+
"source": [
207+
"fc = FireflyClient.make_lab_client(token=token) if using_lab else FireflyClient.make_client(url, token=token)"
208+
]
209+
},
210+
{
211+
"cell_type": "markdown",
212+
"id": "0478d21a",
213+
"metadata": {},
214+
"source": [
215+
"## Valid token"
216+
]
217+
},
218+
{
219+
"cell_type": "code",
220+
"execution_count": null,
221+
"id": "f4e5d7ad",
222+
"metadata": {},
223+
"outputs": [],
224+
"source": [
225+
"token = os.environ['ACCESS_TOKEN'] # token must be set in environment don't hardcode it here"
226+
]
227+
},
228+
{
229+
"cell_type": "code",
230+
"execution_count": 13,
231+
"id": "d4e00c0f",
232+
"metadata": {},
233+
"outputs": [
234+
{
235+
"data": {
236+
"text/plain": [
237+
"{'success': True, 'response': <Response [200]>}"
238+
]
239+
},
240+
"execution_count": 13,
241+
"metadata": {},
242+
"output_type": "execute_result"
243+
}
244+
],
245+
"source": [
246+
"FireflyClient.confirm_access(url, token)"
247+
]
248+
},
249+
{
250+
"cell_type": "code",
251+
"execution_count": 14,
252+
"id": "69730712",
253+
"metadata": {},
254+
"outputs": [],
255+
"source": [
256+
"fc = FireflyClient.make_lab_client(token=token) if using_lab else FireflyClient.make_client(url, token=token)"
257+
]
258+
},
259+
{
260+
"cell_type": "code",
261+
"execution_count": null,
262+
"id": "85a3e941",
263+
"metadata": {},
264+
"outputs": [],
265+
"source": []
266+
}
267+
],
268+
"metadata": {
269+
"kernelspec": {
270+
"display_name": "ffpy",
271+
"language": "python",
272+
"name": "python3"
273+
},
274+
"language_info": {
275+
"codemirror_mode": {
276+
"name": "ipython",
277+
"version": 3
278+
},
279+
"file_extension": ".py",
280+
"mimetype": "text/x-python",
281+
"name": "python",
282+
"nbconvert_exporter": "python",
283+
"pygments_lexer": "ipython3",
284+
"version": "3.12.5"
285+
}
286+
},
287+
"nbformat": 4,
288+
"nbformat_minor": 5
289+
}

firefly_client/env.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,20 @@ def find_default_firefly_html(cls): return cls.firefly_html
9393

9494
@classmethod
9595
def failed_net_message(cls, location, status_code=-1):
96-
s_str = 'with status: %s' % status_code if (status_code > -1) else ''
97-
check = 'You may want to check the URL with your web browser.\n'
98-
err_message = 'Connection fail to URL %s %s\n%s' % (location, s_str, check)
99-
if cls.firefly_lab_extension and cls.firefly_url_lab:
100-
err_message += ('\nCheck the Firefly URL in ~/.jupyter/jupyter_notebook_config.py' +
101-
' or ~/.jupyter/jupyter_notebook_config.json')
102-
elif cls.firefly_url:
103-
err_message += 'Check setting of FIREFLY_URL environment variable: %s' % cls.firefly_url
96+
status_str = f'with status: {status_code}' if status_code > -1 else ''
97+
check_msg = 'You may want to check the URL with your web browser.\n'
98+
err_message = f'Connection failed to URL {location} {status_str}\n{check_msg}'
99+
100+
# url sources in order of precedence
101+
url_sources = []
102+
if cls.firefly_url: # any environment
103+
url_sources.append(f'environment variable "{ENV_FF_URL}"')
104+
if cls.firefly_lab_extension and cls.firefly_url_lab: # lab environment
105+
url_sources += [
106+
'~/.jupyter/jupyter_notebook_config.json',
107+
'~/.jupyter/jupyter_notebook_config.py',
108+
]
109+
url_sources_msg = f', or is set via {" or ".join(url_sources)}' if url_sources else ''
110+
err_message += (f'\nCheck if the Firefly URL is correct, which is '
111+
f'passed as a parameter{url_sources_msg}.')
104112
return err_message

firefly_client/fc_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ def ensure3(val, name):
6464
return ret
6565

6666

67-
# actions from Firefly
6867
ACTION_DICT = {
68+
# actions from Firefly JS
6969
'ShowFits': 'ImagePlotCntlr.PlotImage',
7070
'AddExtension': 'ExternalAccessCntlr/extensionAdd',
7171
'FetchTable': 'table.fetch',
@@ -95,6 +95,8 @@ def ensure3(val, name):
9595
'ShowHiPS': 'ImagePlotCntlr.PlotHiPS',
9696
'ShowImageOrHiPS': 'ImagePlotCntlr.plotHiPSOrImage',
9797
'ImagelineBasedFootprint': 'DrawLayerCntlr.ImageLineBasedFP.imagelineBasedFPCreate',
98+
99+
# actions from jupyter_firefly_extensions
98100
'StartLabWindow': 'StartLabWindow',
99101
'StartBrowserTab': 'StartBrowserTab'
100102
}

0 commit comments

Comments
 (0)