PANOPTES Utilities

PyPI version Build Status codecov Documentation Status

Utility functions for use within the PANOPTES ecosystem and for general astronomical processing.

This library defines a number of modules that contain useful functions as well as a few services.

Getting

See Docker for ways to run panoptes-utils services without installing to your host computer.

pip

To install type:

pip install panoptes-utils

Docker

Docker containers are available for running the panoptes-utils module and associated services, which also serve as the base container for all other PANOPTES related containers.

See the Docker page for details.

Using

Modules

The modules can be used as helper utilities anywhere you would like.

Services

The services can be run either from a Docker image or from the installed script, as described below.

Config Server

A simple config param server. Runs as a Flask microservice that delivers JSON documents in response to requests for config key items.

Can be run from the installed script (defaults to http://localhost:6563/get-config):

$ panoptes-config-server -h
usage: panoptes-config-server [-h] [--host HOST] [--port PORT] [--public] [--config-file CONFIG_FILE] [--no-save] [--ignore-local] [--debug]

Start the config server for PANOPTES

optional arguments:
  -h, --help            show this help message and exit
  --host HOST           Host name, defaults to local interface.
  --port PORT           Local port, default 6563
  --public              If server should be public, default False. Note: inside a docker container set this to True to expose to host.
  --config-file CONFIG_FILE
                        Config file, default $PANDIR/conf_files/pocs.yaml
  --no-save             Prevent auto saving of any new values.
  --ignore-local        Ignore the local config files, default False. Mostly for testing.
  --debug               Debug

Or inside a python process:

>>> from panoptes.utils.config.server import config_server
>>> from panoptes.utils.config import client

>>> server_process=config_server()

>>> client.get_config('location.horizon')
30.0

>>> server_process.terminate()  # Or just exit notebook/console

For more details and usage examples, see the Config Server.

Development

Environment

Most users of panoptes-utils who need the full environment will also want the fulle POCS Environment.

Logging

The panoptes-utils module uses loguru for logging, which also serves as the basis for the POCS logger (see Logger).

To access the logs for the module, you can import directly from the logger module, i.e., from panoptes.utils.logger import logger. This is a simple wrapper around luguru with no extra configuration:

>>> from panoptes.utils import CountdownTimer
>>> # No logs by default
>>> t0 = CountdownTimer(5)
>>> t0.sleep()
False

>>> # Enable the logs
>>> from panoptes.utils.logger import logger
>>> logger.enable('panoptes')

>>> t1 = CountdownTimer(5)
2020-03-04 06:42:50 | DEBUG | panoptes.utils.time:restart:162 - Restarting Timer (blocking) 5.00/5.00
>>> t1.sleep()
2020-03-04 06:42:53 | DEBUG | panoptes.utils.time:sleep:183 - Sleeping for 2.43 seconds
False

Indices and tables