Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
geomag-algorithms
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ghsc
National Geomagnetism Program
geomag-algorithms
Commits
1383b7ca
Commit
1383b7ca
authored
5 years ago
by
Jeremy M Fee
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Dockerfile
+4
-3
4 additions, 3 deletions
Dockerfile
docker-entrypoint.sh
+1
-14
1 addition, 14 deletions
docker-entrypoint.sh
docs/install.md
+28
-12
28 additions, 12 deletions
docs/install.md
docs/install_docker.md
+32
-37
32 additions, 37 deletions
docs/install_docker.md
with
65 additions
and
66 deletions
Dockerfile
+
4
−
3
View file @
1383b7ca
...
@@ -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" ]
This diff is collapsed.
Click to expand it.
docker-entrypoint.sh
+
1
−
14
View file @
1383b7ca
#! /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"
This diff is collapsed.
Click to expand it.
docs/install.md
+
28
−
12
View file @
1383b7ca
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`
...
...
This diff is collapsed.
Click to expand it.
docs/install_docker.md
+
32
−
37
View file @
1383b7ca
## 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.
### C
reate a
new docker container
The following command c
reate
s
a
nd 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 .
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment