Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-13768 Fix firefly_client uploads to work with server on https #10

Merged
merged 5 commits into from
Mar 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
77 changes: 8 additions & 69 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ The next lines will set up the display, using a public Firefly server.
import lsst.afw.display as afw_display
afw_display.setDefaultBackend('lsst.display.firefly')
display1 = afw_display.getDisplay(frame=1,
host='lsst-demo.ncsa.illinois.edu', port=80,
host='https://lsst-demo.ncsa.illinois.edu',
name='mychannel')

Open a browser window to
Expand Down Expand Up @@ -118,13 +118,13 @@ the :meth:`getDisplay` method from `lsst.afw.display`:

import lsst.afw.display as afw_display
afw_display.setDefaultBackend('lsst.display.firefly')
display1 = afw_display.getDisplay(frame=1, host='localhost', port=8080,
display1 = afw_display.getDisplay(frame=1, host='http://localhost:8080',
basedir='firefly', name='afw')

The parameters shown above (besides ``frame``) are the defaults and will
apply when running a Firefly server locally with default settings.

If a Firefly server has been provided to you, set ``host``, ``port``, and
If a Firefly server has been provided to you, set ``host`` and
``basedir`` according to the information provided. You should set ``name``
to a unique string to avoid another user from writing to your display.

Expand All @@ -147,7 +147,7 @@ opens the browser window, if your Python session is on your local machine.
When running a remote Python session, or one inside a container, you will
need to
open a browser window or tab on your local machine yourself. For example,
for ``host=lsst-dev``, ``port=8085``, ``basedir=firefly``, ``name=mine``,
for ``host=http://lsst-dev:8085``, ``basedir=firefly``, ``name=mine``,
use the url ``http://lsst-dev:8085/firefly?__wsch=mine``.


Expand Down Expand Up @@ -211,71 +211,10 @@ The :meth:`display1.dot` method will overlay a symbol at a point.
Installing lsst.display.firefly
===============================

Since `display_firefly` is not yet included in the `lsst_distrib` set of stack
packages, this section outlines several installation scenarios.

.. _lsst-display_firefly-eups-distrib-install:

Installing with eups distrib install
------------------------------------

To check for published distributions of `display_firefly`, use

.. code-block:: shell
:name: eups-distrib-list

eups distrib list display_firefly -s https://sw.lsstcorp.org/eupspkg

This command will return the published versions of `display_firefly`, with
the third item displayed as the EUPS version. Provide that version to
`eups distrib install display_firefly`, e.g.:

.. code-block:: shell
:name: eups-distrib-install

eups distrib install display_firefly master-g83bca5e38c+1

The version may not be compatible with the version of the stack you are
using. This will be fixed when `display_firefly` is included in the
`lsst_distrib` distribution.


Developer installation from source code
---------------------------------------

Install using lsstsw
^^^^^^^^^^^^^^^^^^^^

If using `lsstsw` to develop with the stack, rebuild the package:

.. code-block:: shell
:name: rebuild-firefly

rebuild display_firefly

Note the build number NNNN that is output by the rebuild process, then:

.. code-block:: shell
:name: tag-clone

eups tags --clone bNNNN current

Install using Github and scons
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Set up the stack with `lsst_distrib` or an obs package such as `obs_sdss`.

Clone and install `display_firefly`:

.. code-block:: shell
:name: git-display-ff

git clone https://github.com/lsst/display_firefly
cd display_firefly
setup -j -r . -t $USER
scons

Install the dependency `firefly_client` with `pip install firefly_client`.
Now that `display_firefly` is included in the `lsst_distrib` set of stack
packages, the `setup lsst_distrib` command will set up this package and
its dependecies. See methods for installing `lsst_distrib` at
`pipelines.lsst.io <https://pipelines.lsst.io>`_.

.. _lsst-display-firefly-servers:

Expand Down
18 changes: 10 additions & 8 deletions python/lsst/display/firefly/firefly.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from past.builtins import long

import tempfile
from urllib.parse import urlparse

import lsst.afw.display.interface as interface
import lsst.afw.display.virtualDevice as virtualDevice
Expand All @@ -52,8 +53,8 @@ def __init__(self, str):


def firefly_version():
"""Return the version of firefly in use, as a string"""
raise NotImplementedError("firefly_version")
"""Return the version of firefly_client in use, as a string"""
return(firefly_client.__version__)

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Expand All @@ -78,7 +79,7 @@ def __handleCallbacks(event):
if data.get('type') == "POINT":
lsst.log.debug("Event Received: %s" % data.get('id'))

def __init__(self, display, verbose=False, host="localhost", port=8080,
def __init__(self, display, verbose=False, host="http://localhost:8080",
name="afw", basedir="firefly", *args, **kwargs):
virtualDevice.DisplayImpl.__init__(self, display, verbose)

Expand All @@ -88,18 +89,19 @@ def __init__(self, display, verbose=False, host="localhost", port=8080,
global _fireflyClient
if not _fireflyClient:
try:
_fireflyClient = firefly_client.FireflyClient("%s:%d" % (host, port),
_fireflyClient = firefly_client.FireflyClient(host,
channel=name, basedir=basedir, **kwargs)
except Exception as e:
raise RuntimeError("Unable to connect websocket %s:%d: %s" % (host, port, e))
if (host == "localhost"):
raise RuntimeError("Unable to connect websocket %s: %s" % (host, e))
parsed_host = urlparse(host)
if (parsed_host.hostname == "localhost"):
_fireflyClient.launch_browser()
try:
_fireflyClient.add_listener(self.__handleCallbacks)
except Exception as e:
raise RuntimeError("Cannot add listener. Browser must be connected" +
"to %s:%d/%s/;wsch=%s: %s" %
(host, port, basedir, name, e))
"to %s: %s" %
(_fireflyClient.get_firefly_url(), e))

self._isBuffered = False
self._regions = []
Expand Down