From 49825c5eb8cd235ae8bc8c2149a23792c6deb6fd Mon Sep 17 00:00:00 2001 From: Alexandra Hobbs <ahobbs@contractor.usgs.gov> Date: Wed, 4 Dec 2024 12:43:30 -0700 Subject: [PATCH] made requested documentation changes --- README.md | 29 ++++++++++++++++++- docs/develop.md | 3 ++ docs/install.md | 2 +- docs/metadata_webservice.md | 56 +++++++++++++++++++++++++++++++++++-- 4 files changed, 86 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 436c92474..9de81eed3 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,34 @@ output_factory.write_file( ### Docker -Docker is the simplest install option. Find instructions [here](./localdev/local_development.md). +Docker is the simplest install option. + +1. Create and start a new container + + named `geomagio`, + listening on local port `8000`, + from the image `usgs/geomag-algorithms` on docker hub + + ``` + docker run -dit --name geomagio -p 8000:8000 usgs/geomag-algorithms + ``` + +2. Use the running container + +- Run the `geomag.py` command line interface: + + > To work with files outside the container, + > use a volume mount when starting the container + + ``` + docker exec -it geomagio geomag.py + ``` + +- Or, to run an interactive python prompt: + + ``` + docker exec -it geomagio python + ``` ## Algorithms diff --git a/docs/develop.md b/docs/develop.md index 932d5ed75..b9985919e 100644 --- a/docs/develop.md +++ b/docs/develop.md @@ -111,3 +111,6 @@ https://black.readthedocs.io/en/stable/the_black_code_style Resolve any rebase conflicts. If you have already pushed this branch to your fork, you *may* need to force push because branch history has changed. + +## Local Development +After you get everything installed, you can find further instructions on local development [here](../localdev/local_development.md). diff --git a/docs/install.md b/docs/install.md index 7e5e1fd7c..1bc684aaf 100644 --- a/docs/install.md +++ b/docs/install.md @@ -1,7 +1,7 @@ # Installation This document describes installation instructions for users. For those that wish to modify or develop custom code within **geomag-algorithms**, or prefer to install the Docker container, please see the following documents: > - [Develop](./develop.md) provides installation instruction for developers. -> - [Docker](../localdev/local_development.md) describes Docker container installation and usage. +> - [Docker](./install_docker.md) describes Docker container installation and usage. ## Requirements diff --git a/docs/metadata_webservice.md b/docs/metadata_webservice.md index 23600254e..9c0b5141b 100644 --- a/docs/metadata_webservice.md +++ b/docs/metadata_webservice.md @@ -1,5 +1,41 @@ # Running the Metadata Webservice Locally +## Run mysql in a container (for local development) + +``` +docker run --rm --name mysql-db -e MYSQL_ROOT_PASSWORD=password -p 3306:3306 mysql:5.7 +``` + +This exposes port 3306 so python can connect locally. When running the webservice in a container, container links should be used so the container can access the database container. + +## Set up schema in database + +> This is only needed the first time the database is created. Volume mounts can make this more persistent. + +``` +export DATABASE_URL=mysql://root:password@localhost/geomag_operations +``` + +### Create mysql database +``` +docker exec -it mysql-db mysql -uroot -ppassword +``` +> Inside mysql container: +``` +CREATE DATABASE geomag_operations; +exit +``` + +``` +poetry run python create_db.py +``` + +### Add some testing data (depends on DATABASE_URL environment set above). + +``` +poetry run python test_metadata.py +``` + ## Set up OpenID application in code.usgs.gov. - Under your account, go to settings @@ -16,5 +52,21 @@ Scopes: `openid`, `profile`, `email` -## Running with Docker -[local_development.md](../localdev/local_development.md) describes Docker container installation and usage. +## Start webservice + +- Export variables used for authentication: + +``` +export DATABASE_URL=mysql://root:password@localhost/geomag_operations +export OPENID_CLIENT_ID={Application ID} +export OPENID_CLIENT_SECRET={Secret} +export OPENID_METADATA_URL=https://code.usgs.gov/.well-known/openid-configuration +export SECRET_KEY=changeme +export SECRET_SALT=salt +``` + +- Run app + +``` +poetry run uvicorn geomagio.api:app +``` -- GitLab