Skip to content
Snippets Groups Projects
Commit 1383b7ca authored by Jeremy M Fee's avatar Jeremy M Fee
Browse files

Add pip, links to develop and docker to install. Update docker docs

parent d9ba7268
No related branches found
No related tags found
No related merge requests found
...@@ -39,11 +39,12 @@ RUN useradd \ ...@@ -39,11 +39,12 @@ RUN useradd \
-r \ -r \
-s /sbin/nologin \ -s /sbin/nologin \
geomag_user \ geomag_user \
&& mkdir -p /home/geomag_user/notebooks \ && mkdir -p /data \
&& chown -R geomag_user:geomag_user /home/geomag_user && chown -R geomag_user:geomag_user /data
USER geomag_user USER geomag_user
WORKDIR /geomag-algorithms WORKDIR /data
EXPOSE 8000 EXPOSE 8000
# entrypoint needs double quotes # entrypoint needs double quotes
ENTRYPOINT [ "/geomag-algorithms/docker-entrypoint.sh" ] ENTRYPOINT [ "/geomag-algorithms/docker-entrypoint.sh" ]
#! /bin/bash #! /bin/bash
# run jupyter in the background, and forward SIGTERM manually.
# "exec" seems like a much simpler solution for this,
# however, jupyter kernels die noisy deaths when using exec.
# _term () {
# echo 'Caught SIGTERM'
# kill -TERM "$child"
#}
#trap _term SIGTERM
# add geomagio to notebook path # add geomagio to notebook path
export PYTHONPATH=/geomag-algorithms export PYTHONPATH=/geomag-algorithms
# run jupyter notebook server # run jupyter notebook server
exec jupyter notebook \ exec jupyter notebook \
--ip='*' \ --ip='*' \
--notebook-dir=/home/geomag_user/notebooks \ --notebook-dir=/data \
--no-browser \ --no-browser \
--port=8000 --port=8000
#child=$!
#wait "$child"
Installation # Installation
============
> - [Develop](./develop.md) describes how to install locally.
> - [Docker](./install_docker.md) describes container usage.
## Requirements:
1) Install Python and dependencies (obspy and pycurl) - Python 3.6 or newer
- ObsPy 1.2.1 or newer
Using Anaconda is recommended ( https://conda.io/miniconda.html ). ## Procedure:
conda env create -f geomagenv.yml 1. Install Python and dependencies
source activate geomagenv
or - Option 1: Anaconda/Miniconda (https://conda.io/miniconda.html):
conda create --name=geomagenv --channel conda-forge python=3 obspy pycurl conda create --name=geomagenv --channel conda-forge python=3 obspy pycurl
source activate geomagenv source activate geomagenv
2) Install **geomagio** - Option 2: Pip
pip install git+https://github.com/usgs/geomag-algorithms.git > `pyenv` can install specific/multiple versions of python
>
> - https://github.com/pyenv/pyenv
> - https://github.com/pyenv-win/pyenv-win
# create virtual environment (optional)
python -m venv path/to/geomagenv
source path/to/geomagenv/bin/activate
# install dependencies
pip install numpy
pip install obspy
2. Install **geomagio**
pip install git+https://github.com/usgs/geomag-algorithms.git
3) Use **geomagio** 3. Use **geomagio**
- Use the main script, `geomag.py -h` - Use the main script, `geomag.py -h`
- In python scripts, `import geomagio` - In python scripts, `import geomagio`
......
## Docker ## Docker
https://www.docker.com/ https://www.docker.com/
Docker containers bundle all dependencies needed to use geomag-algorithms. Docker containers bundle all dependencies needed to use geomag-algorithms.
The container includes a Jupyter Notebook server for interactive development. The container includes a Jupyter Notebook server for interactive development.
> Docker images are built using the `Dockerfile` at the root of this project. ### Run docker container
> This page provides one example of how to run a container. See https://docs.docker.com/engine/reference/run/ for detailed `docker run` documentation.
### Create a new docker container The following command creates and starts a container in the background.
The following command creates and starts a container. docker run -rm -it --name geomagio -p 8000:8000 -v $(pwd)/data:/data usgs/geomag-algorithms
```
docker run -d --name geomagio -p 8000:80 usgs/geomag-algorithms
```
- `-d` runs container in the background - `-rm` runs a temporary container
- `-it` makes the container interactive (so you can stop it with `ctrl+c`)
- `-name geomagio` assigns the name `geomagio` - `-name geomagio` assigns the name `geomagio`
- `-p 8000:80` forwards system port `8000` to container port `80` - `-p 8000:8000` forwards system port `8000` to container port `8000`
- `-v $(pwd)/data:/data` mounts a local data directory (./data) into the container so notebooks are saved
- `usgs/geomag-algorithms:latest` refers to the - `usgs/geomag-algorithms:latest` refers to the
latest version of the geomag-algorithms docker image latest version of the geomag-algorithms docker image
> Notebooks are stored in the container in the directory
> `/home/geomag_user/notebooks`
### Use the container ### Use the container
- Start a stopped container:
```
docker start geomagio
```
- Run an interactive python prompt - Run an interactive python prompt
```
docker exec -it geomagio python
``` docker exec -it geomagio python
- Use the Jupyter Notebook server - Use the Jupyter Notebook server
```
open http://localhost:8000/ Check the output for a URL like this, that can be opened in a web browser: `http://127.0.0.1:8000/?token=...`
```
- Use the `geomag.py` command line interface - Use the `geomag.py` command line interface
```
docker exec -it geomagio geomag.py \ docker exec -it geomagio geomag.py \
--inchannels H E Z F \ --inchannels H E Z F \
--input edge \ --input edge \
--interval minute \ --interval minute \
--observatory BOU \ --observatory BOU \
--output iaga2002 \ --output iaga2002 \
--output-stdout \ --output-stdout \
--starttime 2016-07-04T00:00:00Z \ --starttime 2016-07-04T00:00:00Z \
--endtime 2016-07-04T23:59:00Z --endtime 2016-07-04T23:59:00Z
```
- Stop a running container: - Stop a running container:
```
docker stop geomagio Press `Ctrl+C` and follow prompts to stop the container.
```
### Build container
Docker images are built using the `Dockerfile` at the root of this project.
docker build -t usgs/geomag-algorithms:TAG .
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment