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

Docker into develop #950

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ignore:
- "pocs/utils/data.py"
- "pocs/camera/canon_gphoto2.py"
- "pocs/camera/sbig.py"
- "pocs/camera/sbigudrv.py"
Expand Down
2 changes: 0 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ concurrency =
source =
peas
pocs
omit =
pocs/utils/data.py
parallel = True

[report]
Expand Down
27 changes: 27 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
docs/*
.git/*

# PANOPTES specific files
conf_files/*_local.yaml
examples/notebooks/*.fits
examples/notebooks/*.jpeg

# Development support
sftp-config.json

# emacs backups
*~
\#*\#

# TeX products
*.aux
*.log
*.pdf
*.toc

# Compiled files
*.py[co]
*.a
*.o
*.so
__pycache__
100 changes: 12 additions & 88 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,94 +1,18 @@
dist: xenial
sudo: required
language: python
services:
- mongodb
python:
- "3.6"
env:
- PANDIR=$HOME POCS=$TRAVIS_BUILD_DIR PANUSER=$USER ARDUINO_VERSION=1.8.1
- "3.7"
services:
- docker
before_install:
- mkdir -p $PANDIR/logs
- mkdir -p $PANDIR/astrometry/data
- ln -s $POCS $PANDIR/POCS
- pip install -U pip
- pip install coveralls

# Install arudino files
- cd $PANDIR
- export DISPLAY=:1.0
- export
- wget http://downloads.arduino.cc/arduino-${ARDUINO_VERSION}-linux64.tar.xz
- tar xf arduino-${ARDUINO_VERSION}-linux64.tar.xz
- sudo mv arduino-${ARDUINO_VERSION} /usr/local/share/arduino
- sudo ln -s /usr/local/share/arduino/arduino /usr/local/bin/arduino

# Install miniconda
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PANDIR/astrometry/bin:$PATH"
- hash -r

- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda info -a # Useful for debugging any issues with conda
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION
- source activate test-environment
- conda install numpy scipy

# Install astrometry.net
- wget https://github.com/dstndstn/astrometry.net/releases/download/0.78/astrometry.net-0.78.tar.gz
- tar zxvf astrometry.net-0.78.tar.gz && cd astrometry.net-0.78
- make && make py && make install INSTALL_DIR=$PANDIR/astrometry
- echo 'add_path $PANDIR/astrometry/data' | sudo tee --append $PANDIR/astrometry/etc/astrometry.cfg
addons:
apt:
packages:
- gphoto2
- libcairo2-dev
- libnetpbm10-dev
- netpbm
- libpng12-dev
- libjpeg-dev
- python-numpy
- python-pyfits
- python-dev
- zlib1g-dev
- libbz2-dev
- swig
- libcfitsio-bin
- libcfitsio-dev
install:
- cd $PANDIR
# install POCS and requirements
- cd $POCS
- pip install -r requirements.txt
- pip install -r docs/requirements.txt
- pip install -e .
# Force creation of config file.
- python -c "import astroplan"
# Custom IERS urls in config file.
- |
echo "\

[utils.iers.iers]
iers_auto_url = https://storage.googleapis.com/panoptes-resources/iers/ser7.dat
iers_auto_url_mirror = https://storage.googleapis.com/panoptes-resources/iers/ser7.dat
" >> $HOME/.astropy/config/astropy.cfg
# Download IERS and astroetry.net files.
- python pocs/utils/data.py --folder $PANDIR/astrometry/data
- ci_env=`bash <(curl -s https://codecov.io/env)`
- docker pull gcr.io/panoptes-exp/pocs:amd64
install: true
script:
- export BOARD="arduino:avr:micro"
- arduino --verify --board $BOARD resources/arduino_files/camera_board/camera_board.ino
- arduino --verify --board $BOARD resources/arduino_files/power_board/power_board.ino
- arduino --verify --board $BOARD resources/arduino_files/telemetry_board/telemetry_board.ino
- export PYTHONPATH="$PYTHONPATH:$POCS/scripts/coverage"
- export COVERAGE_PROCESS_START=.coveragerc
- coverage run $(which pytest) -v --test-databases all
- coverage combine
cache:
pip: true
directories:
- $PANDIR/astrometry/
after_success:
- bash <(curl -s https://codecov.io/bash)
- docker run -it
$ci_env
-e LOCAL_USER_ID=0
-v $TRAVIS_BUILD_DIR:/var/panoptes/POCS
gcr.io/panoptes-exp/pocs
scripts/testing/run-tests.sh
36 changes: 18 additions & 18 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Please see the
[code of conduct](https://github.com/panoptes/POCS/blob/develop/CODE_OF_CONDUCT.md)
[code of conduct](https://github.com/panoptes/POCS/blob/develop/CODE_OF_CONDUCT.md)
for our playground rules and follow them during all your contributions.

# Getting Started
Expand All @@ -25,35 +25,35 @@ for more info._
please create one specifying the need.
* Process
- Create a fork of the repository and use a topic branch within your fork to make changes.
- All of our repositories have a default branch of `develop` when you first clone them, but
- All of our repositories have a default branch of `develop` when you first clone them, but
your work should be in a separate branch.
- Create a branch with a descriptive name, e.g.:
- `git checkout -b new-camera-simulator`
- `git checkout -b issue-28`
- Ensure that your code meets this project's standards (see Testing and Code Formatting below).
- Run `python setup.py test` from the `$POCS` directory before pushing to github
- Squash your commits so they only reflect meaningful changes.
- Submit a pull request to the repository, be sure to reference the issue number it
- Submit a pull request to the repository, be sure to reference the issue number it
addresses.


# Setting up Local Environment
- Follow instructions in the [README](https://github.com/panoptes/POCS/blob/develop/README.md)
as well as the [Coding in PANOPTES](https://github.com/panoptes/POCS/wiki/Coding-in-PANOPTES)
- Follow instructions in the [README](https://github.com/panoptes/POCS/blob/develop/README.md)
as well as the [Coding in PANOPTES](https://github.com/panoptes/POCS/wiki/Coding-in-PANOPTES)
document.


# Testing
- All changes should have corresponding tests and existing tests should pass after
- All changes should have corresponding tests and existing tests should pass after
your changes.
- For more on testing see the
- For more on testing see the
[Coding in PANOPTES](https://github.com/panoptes/POCS/wiki/Coding-in-PANOPTES) page.

# Code Formatting

- All Python should use [PEP 8 Standards](https://www.python.org/dev/peps/pep-0008/)
- Line length is set at 100 characters instead of 80.
- It is recommended to have your editor auto-format code whenever you save a file
- It is recommended to have your editor auto-format code whenever you save a file
rather than attempt to go back and change an entire file all at once.
- You can also use
[yapf (Yet Another Python Formatter)](https://github.com/google/yapf)
Expand All @@ -66,7 +66,7 @@ for more info._
```
- Do not leave in commented-out code or unnecessary whitespace.
- Variable/function/class and file names should be meaningful and descriptive.
- File names should be lower case and underscored, not contain spaces. For example, `my_file.py`
- File names should be lower case and underscored, not contain spaces. For example, `my_file.py`
instead of `My File.py`.
- Define any project specific terminology or abbreviations you use in the file you use them.
- Use root-relative imports (i.e. relative to the POCS directory). This means that rather
Expand All @@ -78,7 +78,7 @@ instead of `My File.py`.
Import from the top-down instead:
```python
from pocs.base import PanBase
from pocs.utils import current_time
from panoptes.utils import current_time
```
The same applies to code inside of `peas`.
- Test imports are slightly different because `pocs/tests` and `peas/tests` are not Python
Expand All @@ -90,23 +90,23 @@ instead of `My File.py`.

Use appropriate logging:
- Log level:
- DEBUG (i.e. `self.logger.debug()`) should attempt to capture all run-time
- DEBUG (i.e. `self.logger.debug()`) should attempt to capture all run-time
information.
- INFO (i.e. `self.logger.info()`) should be used sparingly and meant to convey
- INFO (i.e. `self.logger.info()`) should be used sparingly and meant to convey
information to a person actively watching a running unit.
- WARNING (i.e. `self.logger.warning()`) should alert when something does not
go as expected but operation of unit can continue.
- ERROR (i.e. `self.logger.error()`) should be used at critical levels when
- ERROR (i.e. `self.logger.error()`) should be used at critical levels when
operation cannot continue.
- The logger supports variable information without the use of the `format` method.
- There is a `say` method available on the main `POCS` class that is meant to be
used in friendly manner to convey information to a user. This should be used only
for personable output and is typically displayed in the "chat box"of the PAWS
used in friendly manner to convey information to a user. This should be used only
for personable output and is typically displayed in the "chat box"of the PAWS
website. These messages are also sent to the INFO level logger.

#### Logging examples:

_Note: These are meant to illustrate the logging calls and are not necessarily indicative of real
_Note: These are meant to illustrate the logging calls and are not necessarily indicative of real
operation_

```
Expand All @@ -131,14 +131,14 @@ self.logger.error('Unable to connect to AAG Cloud Sensor, cannot continue')
#### Viewing log files

- You typically want to follow an active log file by using `tail -F` on the command line.
- The [`grc`](https://github.com/garabik/grc) (generic colouriser) can be used with
- The [`grc`](https://github.com/garabik/grc) (generic colouriser) can be used with
`tail` to get pretty log files.

```
(panoptes-env) $ grc tail -F $PANDIR/logs/pocs_shell.log
```

The following screenshot shows commands entered into a `jupyter-console` in the top
The following screenshot shows commands entered into a `jupyter-console` in the top
panel and the log file in the bottom panel.

<p align="center">
Expand Down
51 changes: 0 additions & 51 deletions Dockerfile

This file was deleted.

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ are some helper scripts to make this easier (from [here](https://cloud.google.co

```
gcloud components install docker-credential-gcr
docker-credential-gcr configure-docker
docker-credential-gcr gcr-login
gcloud auth configure-docker
```

#### Pull POCS container
Expand Down
11 changes: 11 additions & 0 deletions bin/peas-shell
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash -ie

USER_ID=$(id -u)
DOCKER_NAME="peas-shell"

if [ ! "$(docker ps -q -f name=${DOCKER_NAME})" ]; then
echo "${DOCKER_NAME} not running. Start services with scripts/pocs-docker.sh"
else
docker exec --user "${USER_ID}" -it peas-shell /bin/zsh -ic "python ${POCS}/scripts/${DOCKER_NAME}.py"
fi

44 changes: 44 additions & 0 deletions bin/pocs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash -ie

usage() {
echo -n "##################################################
# Start POCS via Docker.
#
##################################################

$ $(basename $0) [COMMAND]

Options:
COMMAND These options are passed at the end of the docker-compose command.
To start all service simply pass 'up'.

Examples:

# Start all services in the foreground.
$POCS/scripts/pocs-docker.sh up

# Start config-server and messaging-hub serivces in the background.
$POCS/scripts/pocs-docker.sh up --no-deps -d config-server messaging-hub

# Read the logs from the config-server
$POCS/scripts/pocs-docker.sh logs config-server

# Run the software tests (no hardware)
$POCS/scripts/pocs-docker.sh up
"
}

START=${1:-help}
if [ "${START}" = 'help' ] || [ "${START}" = '-h' ] || [ "${START}" = '--help' ]; then
usage
exit 1
fi

cd "$PANDIR"
docker-compose \
--project-directory "${PANDIR}" \
-f panoptes-utils/docker/docker-compose.yaml \
-f PAWS/docker/docker-compose.yaml \
-f POCS/docker/docker-compose.yaml \
-p panoptes "$@"

Loading