Skip to content

Commit

Permalink
Merge pull request #45 from Caltech-IPAC/firefly-730-websocket
Browse files Browse the repository at this point in the history
Firefly-730: improve websocket communication
  • Loading branch information
robyww authored Mar 18, 2021
2 parents 9edab06 + 844a803 commit 3835093
Show file tree
Hide file tree
Showing 8 changed files with 223 additions and 253 deletions.
8 changes: 8 additions & 0 deletions doc/new-release-procedure.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,11 @@
1. `twine upload --repository-url https://test.pypi.org/legacy/ dist/*`
1. `pip uninstall firefly_client`
1. `pip install --verbose --index-url https://testpypi.python.org/pypi firefly_client`

### Conda and conda-forge

Anytime the version tag is updated conda-forge it set up to do a pull and add `firefly_client` to its distribution.

See the following sites:
- https://github.com/conda-forge/firefly-client-feedstock/
- https://anaconda.org/conda-forge/firefly-client
360 changes: 175 additions & 185 deletions firefly_client/firefly_client.py

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# Documentation dependencies
documenteer[pipelines]>=0.5.0,<0.6.0

requests~=2.22.0
setuptools~=41.0.1
websocket-client~=0.58.0
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

setup(
name='firefly_client',
version='2.5.0',
version='2.6.0',
description='Python API for Firefly',
author='IPAC LSST SUIT',
license='BSD',
url='http://github.com/Caltech-IPAC/firefly_client',
packages=['firefly_client'],
install_requires=['ws4py', 'future', 'requests'],
install_requires=['websocket-client', 'requests'],
classifiers=[
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
Expand Down
5 changes: 4 additions & 1 deletion test/test-5-instances-3-channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ def listener4(ev):
fc3_c1 = FireflyClient.make_client(host, channel_override=channel1, launch_browser=False)
fc1_c2 = FireflyClient.make_client(host, channel_override=channel2, launch_browser=True)
fc1_c2.add_extension(ext_type='POINT', title='a point')
fc1_c3 = FireflyClient.make_client(host, channel_override=channel3, launch_browser=False)
fc1_c3 = FireflyClient.make_client(host, channel_override=channel3, launch_browser=True)
print(f'>>>>>> channel: {channel1}, firefly url: {fc1_c1.get_firefly_url()}')
print(f'>>>>>> channel: {channel2}, firefly url: {fc1_c2.get_firefly_url()}')
print(f'>>>>>> channel: {channel3}, firefly url: {fc1_c3.get_firefly_url()}')
# adding stuff but there is not listener
fc1_c3.show_fits(url="http://web.ipac.caltech.edu.s3-us-west-2.amazonaws.com/staff/roby/demo/wise-00.fits")
fc1_c3.add_extension(ext_type='POINT', title='a point no CB')

# ------------ add listeners
fc1_c1.add_listener(listener1) # one web socket should be made for first 3 (channel1)
Expand Down
22 changes: 12 additions & 10 deletions test/test-simple-callback-in-lab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
"outputs": [],
"source": [
"# This test can be modified to make multiple firefly_clients to prove there is only 1 per channel\n",
"\n",
"# some host\n",
"lsst_demo_host = 'https://lsst-demo.ncsa.illinois.edu/firefly'\n",
"local_host = 'http://127.0.0.1:8080/firefly'\n",
"irsa = 'http://irsa.ipac.caltech.edu'\n",
"irsa = 'https://irsa.ipac.caltech.edu/irsaviewer'\n",
"fd = 'https://fireflydev.ipac.caltech.edu/firefly'\n",
"host = local_host\n",
"#host = fd\n",
"\n",
"host = irsa\n",
"channel1 = 'channel-test-1'\n",
"FireflyClient._debug = True\n",
"fc1_c1 = FireflyClient.make_client(host, channel_override=channel1, launch_browser=False)\n",
"fc1_c1.get_firefly_url()"
"FireflyClient._debug = False\n",
"fc = FireflyClient.make_client(host, channel_override=channel1, launch_browser=False)\n",
"fc.get_firefly_url()"
]
},
{
Expand All @@ -45,9 +47,9 @@
"source": [
"# Extensions can be made but there is not web socket connections until a listener is added\n",
"\n",
"fc1_c1.add_extension(ext_type='LINE_SELECT', title='a line')\n",
"fc1_c1.add_extension(ext_type='AREA_SELECT', title='a area')\n",
"fc1_c1.add_extension(ext_type='POINT', title='a point')"
"fc.add_extension(ext_type='LINE_SELECT', title='a line')\n",
"fc.add_extension(ext_type='AREA_SELECT', title='a area')\n",
"fc.add_extension(ext_type='POINT', title='a point')"
]
},
{
Expand Down Expand Up @@ -78,7 +80,7 @@
"\n",
"\n",
" \n",
"fc1_c1.add_listener(listener1)"
"fc.add_listener(listener1)"
]
},
{
Expand Down
36 changes: 18 additions & 18 deletions test/test-simple-callback-response.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
import json
from firefly_client import FireflyClient

lsst_demo_host = 'https://lsst-demo.ncsa.illinois.edu/firefly'
local_host = 'http://127.0.0.1:8080/firefly'
fd = 'https://fireflydev.ipac.caltech.edu/firefly'
irsa_host = 'https://irsa.ipac.caltech.edu/irsaviewer'
data_lsst_host = 'https://data.lsst.cloud/portal/app/'
host = irsa_host
channel1 = 'channel-test-1'

FireflyClient._debug = True
token = None
fc = FireflyClient.make_client(host, channel_override=channel1, launch_browser=True, token=token)
print(fc.get_firefly_url())


def example_listener(ev):
if False:
Expand All @@ -21,21 +33,9 @@ def example_listener(ev):
print(' world points: %s to %s' % (data['wpt0'], data['wpt1']))


lsst_demo_host = 'https://lsst-demo.ncsa.illinois.edu/firefly'
local_host = 'http://127.0.0.1:8080/firefly'
fd = 'https://fireflydev.ipac.caltech.edu/firefly'
irsa_host = 'https://irsa.ipac.caltech.edu/irsaviewer'
# host = local_host
# host = lsst_demo_host
host = irsa_host
channel1 = 'channel-test-1'

FireflyClient._debug = True
fc1_c1 = FireflyClient.make_client(host, channel_override=channel1, launch_browser=True)
print(fc1_c1.get_firefly_url())
fc1_c1.add_extension(ext_type='POINT', title='Output Selected Point')
fc1_c1.add_extension(ext_type='LINE_SELECT', title='Output Selected line')
fc1_c1.add_extension(ext_type='AREA_SELECT', title='Output Selected Area')
fc.add_extension(ext_type='POINT', title='Output Selected Point')
fc.add_extension(ext_type='LINE_SELECT', title='Output Selected line')
fc.add_extension(ext_type='AREA_SELECT', title='Output Selected Area')
# ------------ add listener and wait
fc1_c1.add_listener(example_listener)
fc1_c1.wait_for_events()
fc.add_listener(example_listener)
fc.wait_for_events()
37 changes: 0 additions & 37 deletions tests/test_import.py

This file was deleted.

0 comments on commit 3835093

Please sign in to comment.